mirror of
https://github.com/Ryujinx/SDL.git
synced 2025-01-03 20:35:33 +00:00
SDL_mfijoystick.m: remove VLA, so that projects can be built with error on vla
This commit is contained in:
parent
64a5e7be98
commit
192cdf3d04
|
@ -956,6 +956,7 @@ IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (controller.extendedGamepad) {
|
if (controller.extendedGamepad) {
|
||||||
|
SDL_bool isstack;
|
||||||
GCExtendedGamepad *gamepad = controller.extendedGamepad;
|
GCExtendedGamepad *gamepad = controller.extendedGamepad;
|
||||||
|
|
||||||
/* Axis order matches the XInput Windows mappings. */
|
/* Axis order matches the XInput Windows mappings. */
|
||||||
|
@ -969,9 +970,14 @@ IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Button order matches the XInput Windows mappings. */
|
/* Button order matches the XInput Windows mappings. */
|
||||||
Uint8 buttons[joystick->nbuttons];
|
Uint8 *buttons = SDL_small_alloc(Uint8, joystick->nbuttons, &isstack);
|
||||||
int button_count = 0;
|
int button_count = 0;
|
||||||
|
|
||||||
|
if (buttons == NULL) {
|
||||||
|
SDL_OutOfMemory();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* These buttons are part of the original MFi spec */
|
/* These buttons are part of the original MFi spec */
|
||||||
buttons[button_count++] = gamepad.buttonA.isPressed;
|
buttons[button_count++] = gamepad.buttonA.isPressed;
|
||||||
buttons[button_count++] = gamepad.buttonB.isPressed;
|
buttons[button_count++] = gamepad.buttonB.isPressed;
|
||||||
|
@ -1088,12 +1094,20 @@ IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
|
||||||
}
|
}
|
||||||
#endif /* ENABLE_MFI_SENSORS */
|
#endif /* ENABLE_MFI_SENSORS */
|
||||||
|
|
||||||
|
SDL_small_free(buttons, isstack);
|
||||||
} else if (controller.gamepad) {
|
} else if (controller.gamepad) {
|
||||||
|
SDL_bool isstack;
|
||||||
GCGamepad *gamepad = controller.gamepad;
|
GCGamepad *gamepad = controller.gamepad;
|
||||||
|
|
||||||
/* Button order matches the XInput Windows mappings. */
|
/* Button order matches the XInput Windows mappings. */
|
||||||
Uint8 buttons[joystick->nbuttons];
|
Uint8 *buttons = SDL_small_alloc(Uint8, joystick->nbuttons, &isstack);
|
||||||
int button_count = 0;
|
int button_count = 0;
|
||||||
|
|
||||||
|
if (buttons == NULL) {
|
||||||
|
SDL_OutOfMemory();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
buttons[button_count++] = gamepad.buttonA.isPressed;
|
buttons[button_count++] = gamepad.buttonA.isPressed;
|
||||||
buttons[button_count++] = gamepad.buttonB.isPressed;
|
buttons[button_count++] = gamepad.buttonB.isPressed;
|
||||||
buttons[button_count++] = gamepad.buttonX.isPressed;
|
buttons[button_count++] = gamepad.buttonX.isPressed;
|
||||||
|
@ -1108,6 +1122,8 @@ IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
|
||||||
for (i = 0; i < button_count; i++) {
|
for (i = 0; i < button_count; i++) {
|
||||||
SDL_PrivateJoystickButton(joystick, i, buttons[i]);
|
SDL_PrivateJoystickButton(joystick, i, buttons[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDL_small_free(buttons, isstack);
|
||||||
}
|
}
|
||||||
#if TARGET_OS_TV
|
#if TARGET_OS_TV
|
||||||
else if (controller.microGamepad) {
|
else if (controller.microGamepad) {
|
||||||
|
|
Loading…
Reference in a new issue