Added (incomplete) motion controls emulation support. #6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds a new keyboard shortcut (unbound by default) that when pressed toggles the emulator to interpret the analog sticks as combined gyro and accelerometer inputs. Roughly speaking:
Left stick horizontal: Like rocking the controller side to side (stick right -> controller tilted right).
Left stick vertical: Like rocking the controller forward and back (stick up -> controller tilted forward [or pitched down])
Right stick horizontal: Like rotating the controller around an axis parallel to the analog sticks (i.e. changes the yaw) (stick right -> controller rotates North to East)
Right stick vertical: No function
It's difficult to control and really not practical for any action gameplay, but it's workable for puzzles, and if you don't have a controller with motion sensors it's better than nothing. I managed to use this to solve a couple shrines in BotW.
TODO:
Notes:
If someone else wants to tackle the input translation, after some experimentation I figured out that the Switch's coordinate system is right-handed, with X to the right, Y forward, and Z up (relative to the controller when it's lying flat on the floor). When the controller is at rest, the accelerometer vector is the direction of gravity ((0, 0, -1) seems to work for a neutral position). The gyroscope values are angular velocities, and since the coordinate system rotates with the controller, specifying these values is usually simple. Note that in my experimentation, it seems gyroscope changes without accelerometer changes are often ignored; ideally moving any stick in any single axis should change both gyroscope and accelerometer in an integrated fashion. Finally, I'm not sure about the units. I think the accelerometer may be in g (1 = 9.8 m/s^2). The gyroscope could be in deg/s, but not sure.