diff options
| author | JosJuice <josjuice@gmail.com> | 2019-11-20 19:40:47 +0100 |
|---|---|---|
| committer | JosJuice <josjuice@gmail.com> | 2019-11-20 20:13:36 +0100 |
| commit | c8b8a60033bb35917c10eeb5c4043ee428ae61a6 (patch) | |
| tree | 5fd72d47a96fa11554b02a5c86d7602d20be4d1a /Source/Core | |
| parent | 4d838212e2622f623a7f864163396a6a9634e47f (diff) | |
Android: Let WiimoteEmu know whether we have accelerometer/gyroscope
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/InputCommon/ControllerInterface/Android/Android.cpp | 47 | ||||
| -rw-r--r-- | Source/Core/InputCommon/ControllerInterface/Android/Android.h | 2 |
2 files changed, 37 insertions, 12 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/Android/Android.cpp b/Source/Core/InputCommon/ControllerInterface/Android/Android.cpp index 78fc029374..21537cba15 100644 --- a/Source/Core/InputCommon/ControllerInterface/Android/Android.cpp +++ b/Source/Core/InputCommon/ControllerInterface/Android/Android.cpp @@ -10,6 +10,21 @@ namespace ciface::Android { +static bool s_accelerometer_enabled = false; +static bool s_gyroscope_enabled = false; + +void SetMotionSensorsEnabled(bool accelerometer_enabled, bool gyroscope_enabled) +{ + const bool any_changes = + s_accelerometer_enabled != accelerometer_enabled || s_gyroscope_enabled != gyroscope_enabled; + + s_accelerometer_enabled = accelerometer_enabled; + s_gyroscope_enabled = gyroscope_enabled; + + if (any_changes) + g_controller_interface.RefreshDevices(); +} + void PopulateDevices() { for (int i = 0; i < 8; ++i) @@ -186,18 +201,26 @@ Touchscreen::Touchscreen(int padID) : _padID(padID) AddInput(new Axis(_padID, ButtonManager::TURNTABLE_EFFECT_DIAL)); // Wiimote IMU - AddInput(new Axis(_padID, ButtonManager::WIIMOTE_ACCEL_LEFT)); - AddInput(new Axis(_padID, ButtonManager::WIIMOTE_ACCEL_RIGHT)); - AddInput(new Axis(_padID, ButtonManager::WIIMOTE_ACCEL_FORWARD)); - AddInput(new Axis(_padID, ButtonManager::WIIMOTE_ACCEL_BACKWARD)); - AddInput(new Axis(_padID, ButtonManager::WIIMOTE_ACCEL_UP)); - AddInput(new Axis(_padID, ButtonManager::WIIMOTE_ACCEL_DOWN)); - AddInput(new Axis(_padID, ButtonManager::WIIMOTE_GYRO_PITCH_UP)); - AddInput(new Axis(_padID, ButtonManager::WIIMOTE_GYRO_PITCH_DOWN)); - AddInput(new Axis(_padID, ButtonManager::WIIMOTE_GYRO_ROLL_LEFT)); - AddInput(new Axis(_padID, ButtonManager::WIIMOTE_GYRO_ROLL_RIGHT)); - AddInput(new Axis(_padID, ButtonManager::WIIMOTE_GYRO_YAW_LEFT)); - AddInput(new Axis(_padID, ButtonManager::WIIMOTE_GYRO_YAW_RIGHT)); + // Only add inputs if we actually can receive data from the relevant sensor. + // Whether inputs exist affects what WiimoteEmu gets when calling ControlReference::BoundCount. + if (s_accelerometer_enabled) + { + AddInput(new Axis(_padID, ButtonManager::WIIMOTE_ACCEL_LEFT)); + AddInput(new Axis(_padID, ButtonManager::WIIMOTE_ACCEL_RIGHT)); + AddInput(new Axis(_padID, ButtonManager::WIIMOTE_ACCEL_FORWARD)); + AddInput(new Axis(_padID, ButtonManager::WIIMOTE_ACCEL_BACKWARD)); + AddInput(new Axis(_padID, ButtonManager::WIIMOTE_ACCEL_UP)); + AddInput(new Axis(_padID, ButtonManager::WIIMOTE_ACCEL_DOWN)); + } + if (s_gyroscope_enabled) + { + AddInput(new Axis(_padID, ButtonManager::WIIMOTE_GYRO_PITCH_UP)); + AddInput(new Axis(_padID, ButtonManager::WIIMOTE_GYRO_PITCH_DOWN)); + AddInput(new Axis(_padID, ButtonManager::WIIMOTE_GYRO_ROLL_LEFT)); + AddInput(new Axis(_padID, ButtonManager::WIIMOTE_GYRO_ROLL_RIGHT)); + AddInput(new Axis(_padID, ButtonManager::WIIMOTE_GYRO_YAW_LEFT)); + AddInput(new Axis(_padID, ButtonManager::WIIMOTE_GYRO_YAW_RIGHT)); + } // Rumble AddOutput(new Motor(_padID, ButtonManager::RUMBLE)); diff --git a/Source/Core/InputCommon/ControllerInterface/Android/Android.h b/Source/Core/InputCommon/ControllerInterface/Android/Android.h index 82a1a47954..c9e7ddc0a9 100644 --- a/Source/Core/InputCommon/ControllerInterface/Android/Android.h +++ b/Source/Core/InputCommon/ControllerInterface/Android/Android.h @@ -9,6 +9,8 @@ namespace ciface::Android { +void SetMotionSensorsEnabled(bool accelerometer_enabled, bool gyroscope_enabled); + void PopulateDevices(); class Touchscreen : public Core::Device |
