mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-19 12:35:52 -04:00
Merge pull request #1152 from headshot2017/switch
add left analog stick movement for Switch
This commit is contained in:
commit
34d2e868fc
@ -120,7 +120,17 @@ static void HandleButtons(u64 mods) {
|
||||
Input_SetNonRepeatable(CCPAD_DOWN, mods & HidNpadButton_Down);
|
||||
}
|
||||
|
||||
static void ProcessJoystickInput(HidAnalogStickState* pos) {
|
||||
static void ProcessJoystickInput_L(HidAnalogStickState* pos) {
|
||||
// May not be exactly 0 on actual hardware
|
||||
if (Math_AbsI(pos->x) <= 16) pos->x = 0;
|
||||
if (Math_AbsI(pos->y) <= 16) pos->y = 0;
|
||||
|
||||
Input.JoystickMovement = (pos->x != 0 || pos->y != 0);
|
||||
if (!Input.JoystickMovement) return;
|
||||
Input.JoystickAngle = Math_Atan2(pos->x, -pos->y);
|
||||
}
|
||||
|
||||
static void ProcessJoystickInput_R(HidAnalogStickState* pos) {
|
||||
// May not be exactly 0 on actual hardware
|
||||
if (Math_AbsI(pos->x) <= 16) pos->x = 0;
|
||||
if (Math_AbsI(pos->y) <= 16) pos->y = 0;
|
||||
@ -166,8 +176,8 @@ void Window_ProcessEvents(double delta) {
|
||||
// Read the sticks' position
|
||||
HidAnalogStickState analog_stick_l = padGetStickPos(&pad, 0);
|
||||
HidAnalogStickState analog_stick_r = padGetStickPos(&pad, 1);
|
||||
ProcessJoystickInput(&analog_stick_l);
|
||||
ProcessJoystickInput(&analog_stick_r);
|
||||
ProcessJoystickInput_L(&analog_stick_l);
|
||||
ProcessJoystickInput_R(&analog_stick_r);
|
||||
|
||||
ProcessTouchInput();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user