diff options
| author | 2017-08-19 23:43:01 -0600 | |
|---|---|---|
| committer | 2017-08-19 23:43:01 -0600 | |
| commit | bbfa9d0635ce4b9226bed02ea1b6e8ddbb7e8a56 (patch) | |
| tree | 5bfecf66096077d72346da902a9646314cb60631 /src/core/frontend/emu_window.h | |
| parent | Merge pull request #2871 from wwylele/sw-spotlight (diff) | |
| parent | HID: fix a comment and a warning (diff) | |
| download | yuzu-bbfa9d0635ce4b9226bed02ea1b6e8ddbb7e8a56.tar.gz yuzu-bbfa9d0635ce4b9226bed02ea1b6e8ddbb7e8a56.tar.xz yuzu-bbfa9d0635ce4b9226bed02ea1b6e8ddbb7e8a56.zip | |
Merge pull request #2861 from wwylele/motion-refactor
Refactor MotionEmu into a InputDevice
Diffstat (limited to 'src/core/frontend/emu_window.h')
| -rw-r--r-- | src/core/frontend/emu_window.h | 83 |
1 files changed, 0 insertions, 83 deletions
diff --git a/src/core/frontend/emu_window.h b/src/core/frontend/emu_window.h index 9414123a4..7bdee251c 100644 --- a/src/core/frontend/emu_window.h +++ b/src/core/frontend/emu_window.h | |||
| @@ -69,27 +69,6 @@ public: | |||
| 69 | void TouchMoved(unsigned framebuffer_x, unsigned framebuffer_y); | 69 | void TouchMoved(unsigned framebuffer_x, unsigned framebuffer_y); |
| 70 | 70 | ||
| 71 | /** | 71 | /** |
| 72 | * Signal accelerometer state has changed. | ||
| 73 | * @param x X-axis accelerometer value | ||
| 74 | * @param y Y-axis accelerometer value | ||
| 75 | * @param z Z-axis accelerometer value | ||
| 76 | * @note all values are in unit of g (gravitational acceleration). | ||
| 77 | * e.g. x = 1.0 means 9.8m/s^2 in x direction. | ||
| 78 | * @see GetAccelerometerState for axis explanation. | ||
| 79 | */ | ||
| 80 | void AccelerometerChanged(float x, float y, float z); | ||
| 81 | |||
| 82 | /** | ||
| 83 | * Signal gyroscope state has changed. | ||
| 84 | * @param x X-axis accelerometer value | ||
| 85 | * @param y Y-axis accelerometer value | ||
| 86 | * @param z Z-axis accelerometer value | ||
| 87 | * @note all values are in deg/sec. | ||
| 88 | * @see GetGyroscopeState for axis explanation. | ||
| 89 | */ | ||
| 90 | void GyroscopeChanged(float x, float y, float z); | ||
| 91 | |||
| 92 | /** | ||
| 93 | * Gets the current touch screen state (touch X/Y coordinates and whether or not it is pressed). | 72 | * Gets the current touch screen state (touch X/Y coordinates and whether or not it is pressed). |
| 94 | * @note This should be called by the core emu thread to get a state set by the window thread. | 73 | * @note This should be called by the core emu thread to get a state set by the window thread. |
| 95 | * @todo Fix this function to be thread-safe. | 74 | * @todo Fix this function to be thread-safe. |
| @@ -101,52 +80,6 @@ public: | |||
| 101 | } | 80 | } |
| 102 | 81 | ||
| 103 | /** | 82 | /** |
| 104 | * Gets the current accelerometer state (acceleration along each three axis). | ||
| 105 | * Axis explained: | ||
| 106 | * +x is the same direction as LEFT on D-pad. | ||
| 107 | * +y is normal to the touch screen, pointing outward. | ||
| 108 | * +z is the same direction as UP on D-pad. | ||
| 109 | * Units: | ||
| 110 | * 1 unit of return value = 1/512 g (measured by hw test), | ||
| 111 | * where g is the gravitational acceleration (9.8 m/sec2). | ||
| 112 | * @note This should be called by the core emu thread to get a state set by the window thread. | ||
| 113 | * @return std::tuple of (x, y, z) | ||
| 114 | */ | ||
| 115 | std::tuple<s16, s16, s16> GetAccelerometerState() { | ||
| 116 | std::lock_guard<std::mutex> lock(accel_mutex); | ||
| 117 | return std::make_tuple(accel_x, accel_y, accel_z); | ||
| 118 | } | ||
| 119 | |||
| 120 | /** | ||
| 121 | * Gets the current gyroscope state (angular rates about each three axis). | ||
| 122 | * Axis explained: | ||
| 123 | * +x is the same direction as LEFT on D-pad. | ||
| 124 | * +y is normal to the touch screen, pointing outward. | ||
| 125 | * +z is the same direction as UP on D-pad. | ||
| 126 | * Orientation is determined by right-hand rule. | ||
| 127 | * Units: | ||
| 128 | * 1 unit of return value = (1/coef) deg/sec, | ||
| 129 | * where coef is the return value of GetGyroscopeRawToDpsCoefficient(). | ||
| 130 | * @note This should be called by the core emu thread to get a state set by the window thread. | ||
| 131 | * @return std::tuple of (x, y, z) | ||
| 132 | */ | ||
| 133 | std::tuple<s16, s16, s16> GetGyroscopeState() { | ||
| 134 | std::lock_guard<std::mutex> lock(gyro_mutex); | ||
| 135 | return std::make_tuple(gyro_x, gyro_y, gyro_z); | ||
| 136 | } | ||
| 137 | |||
| 138 | /** | ||
| 139 | * Gets the coefficient for units conversion of gyroscope state. | ||
| 140 | * The conversion formula is r = coefficient * v, | ||
| 141 | * where v is angular rate in deg/sec, | ||
| 142 | * and r is the gyroscope state. | ||
| 143 | * @return float-type coefficient | ||
| 144 | */ | ||
| 145 | f32 GetGyroscopeRawToDpsCoefficient() const { | ||
| 146 | return 14.375f; // taken from hw test, and gyroscope's document | ||
| 147 | } | ||
| 148 | |||
| 149 | /** | ||
| 150 | * Returns currently active configuration. | 83 | * Returns currently active configuration. |
| 151 | * @note Accesses to the returned object need not be consistent because it may be modified in | 84 | * @note Accesses to the returned object need not be consistent because it may be modified in |
| 152 | * another thread | 85 | * another thread |
| @@ -187,12 +120,6 @@ protected: | |||
| 187 | touch_x = 0; | 120 | touch_x = 0; |
| 188 | touch_y = 0; | 121 | touch_y = 0; |
| 189 | touch_pressed = false; | 122 | touch_pressed = false; |
| 190 | accel_x = 0; | ||
| 191 | accel_y = -512; | ||
| 192 | accel_z = 0; | ||
| 193 | gyro_x = 0; | ||
| 194 | gyro_y = 0; | ||
| 195 | gyro_z = 0; | ||
| 196 | } | 123 | } |
| 197 | virtual ~EmuWindow() {} | 124 | virtual ~EmuWindow() {} |
| 198 | 125 | ||
| @@ -255,16 +182,6 @@ private: | |||
| 255 | u16 touch_x; ///< Touchpad X-position in native 3DS pixel coordinates (0-320) | 182 | u16 touch_x; ///< Touchpad X-position in native 3DS pixel coordinates (0-320) |
| 256 | u16 touch_y; ///< Touchpad Y-position in native 3DS pixel coordinates (0-240) | 183 | u16 touch_y; ///< Touchpad Y-position in native 3DS pixel coordinates (0-240) |
| 257 | 184 | ||
| 258 | std::mutex accel_mutex; | ||
| 259 | s16 accel_x; ///< Accelerometer X-axis value in native 3DS units | ||
| 260 | s16 accel_y; ///< Accelerometer Y-axis value in native 3DS units | ||
| 261 | s16 accel_z; ///< Accelerometer Z-axis value in native 3DS units | ||
| 262 | |||
| 263 | std::mutex gyro_mutex; | ||
| 264 | s16 gyro_x; ///< Gyroscope X-axis value in native 3DS units | ||
| 265 | s16 gyro_y; ///< Gyroscope Y-axis value in native 3DS units | ||
| 266 | s16 gyro_z; ///< Gyroscope Z-axis value in native 3DS units | ||
| 267 | |||
| 268 | /** | 185 | /** |
| 269 | * Clip the provided coordinates to be inside the touchscreen area. | 186 | * Clip the provided coordinates to be inside the touchscreen area. |
| 270 | */ | 187 | */ |