From f713ca675055fa522bf44e2d326eb3e7941ec381 Mon Sep 17 00:00:00 2001 From: dbalatoni13 <40299962+dbalatoni13@users.noreply.github.com> Date: Thu, 3 Apr 2025 23:59:14 +0200 Subject: [PATCH] Implement PADControlMotor --- lib/input.cpp | 50 +++++++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/lib/input.cpp b/lib/input.cpp index 286b074..7703a75 100644 --- a/lib/input.cpp +++ b/lib/input.cpp @@ -460,31 +460,35 @@ uint32_t PADRead(PADStatus* status) { return rumbleSupport; } +void PADControlMotor(int32_t chan, uint32_t command) { + auto controller = aurora::input::get_controller_for_player(chan); + auto instance = aurora::input::get_instance_for_player(chan); + if (controller == nullptr) { + return; + } + + if (controller->m_isGameCube) { + if (command == PAD_MOTOR_STOP) { + aurora::input::controller_rumble(instance, 0, 1, 0); + } else if (command == PAD_MOTOR_RUMBLE) { + aurora::input::controller_rumble(instance, 1, 1, 0); + } else if (command == PAD_MOTOR_STOP_HARD) { + aurora::input::controller_rumble(instance, 0, 0, 0); + } + } else { + if (command == PAD_MOTOR_STOP) { + aurora::input::controller_rumble(instance, 0, 0, 1); + } else if (command == PAD_MOTOR_RUMBLE) { + aurora::input::controller_rumble(instance, 32767, 32767, 0); + } else if (command == PAD_MOTOR_STOP_HARD) { + aurora::input::controller_rumble(instance, 0, 0, 0); + } + } +} + void PADControlAllMotors(const uint32_t* commands) { for (uint32_t i = 0; i < 4; ++i) { - auto controller = aurora::input::get_controller_for_player(i); - auto instance = aurora::input::get_instance_for_player(i); - if (controller == nullptr) { - continue; - } - - if (controller->m_isGameCube) { - if (commands[i] == PAD_MOTOR_STOP) { - aurora::input::controller_rumble(instance, 0, 1, 0); - } else if (commands[i] == PAD_MOTOR_RUMBLE) { - aurora::input::controller_rumble(instance, 1, 1, 0); - } else if (commands[i] == PAD_MOTOR_STOP_HARD) { - aurora::input::controller_rumble(instance, 0, 0, 0); - } - } else { - if (commands[i] == PAD_MOTOR_STOP) { - aurora::input::controller_rumble(instance, 0, 0, 1); - } else if (commands[i] == PAD_MOTOR_RUMBLE) { - aurora::input::controller_rumble(instance, 32767, 32767, 0); - } else if (commands[i] == PAD_MOTOR_STOP_HARD) { - aurora::input::controller_rumble(instance, 0, 0, 0); - } - } + PADControlMotor(i, commands[i]); } }