From cbcb9b02b0fb46d042b1f197a4a32b7d9080c311 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sun, 15 Dec 2019 23:22:53 +1000 Subject: [PATCH] AnalogController: Rumble support --- src/core/analog_controller.cpp | 69 ++++++++++++++++++++++++++++++---- src/core/analog_controller.h | 11 +++++- src/core/controller.cpp | 10 +++++ src/core/controller.h | 6 +++ 4 files changed, 88 insertions(+), 8 deletions(-) diff --git a/src/core/analog_controller.cpp b/src/core/analog_controller.cpp index c631f4148..7663f32b0 100644 --- a/src/core/analog_controller.cpp +++ b/src/core/analog_controller.cpp @@ -18,6 +18,7 @@ ControllerType AnalogController::GetType() const void AnalogController::Reset() { m_analog_mode = false; + m_rumble_unlocked = false; m_configuration_mode = false; m_command_param = 0; } @@ -28,9 +29,19 @@ bool AnalogController::DoState(StateWrapper& sw) return false; sw.Do(&m_analog_mode); + sw.Do(&m_rumble_unlocked); sw.Do(&m_configuration_mode); sw.Do(&m_command_param); sw.Do(&m_state); + + MotorState motor_state = m_motor_state; + sw.Do(&motor_state); + + if (sw.IsReading()) + { + for (u8 i = 0; i < NUM_MOTORS; i++) + SetMotorState(i, motor_state[i]); + } return true; } @@ -58,8 +69,6 @@ void AnalogController::SetAxisState(s32 axis_code, float value) void AnalogController::SetAxisState(Axis axis, u8 value) { m_axis_state[static_cast(axis)] = value; - - // TODO: Map to buttons in digital mode } void AnalogController::SetButtonState(Button button, bool pressed) @@ -78,6 +87,17 @@ void AnalogController::SetButtonState(s32 button_code, bool pressed) SetButtonState(static_cast