Renders on PSP again

This commit is contained in:
2025-09-12 00:25:17 -05:00
parent 964a9f64f2
commit 46a94ecacd
17 changed files with 105 additions and 31 deletions

View File

@@ -14,6 +14,23 @@ inputbuttondata_t INPUT_BUTTON_DATA[] = {
#if INPUT_SDL2 == 1
#if INPUT_GAMEPAD == 1
#if PSP
{ .name = "triangle", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_Y } },
{ .name = "cross", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_A } },
{ .name = "circle", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_B } },
{ .name = "square", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_X } },
{ .name = "start", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_START } },
{ .name = "select", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_BACK } },
{ .name = "up", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_DPAD_UP } },
{ .name = "down", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_DPAD_DOWN } },
{ .name = "left", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_DPAD_LEFT } },
{ .name = "right", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_DPAD_RIGHT } },
{ .name = "l", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_LEFTSHOULDER } },
{ .name = "r", { .type = INPUT_BUTTON_TYPE_GAMEPAD, .gpButton = SDL_CONTROLLER_BUTTON_RIGHTSHOULDER } },
{ .name = "lstick_positive_x", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTX, .positive = true } } },
{ .name = "lstick_negative_x", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTX, .positive = false } } },
{ .name = "lstick_positive_y", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTY, .positive = true } } },
{ .name = "lstick_negative_y", { .type = INPUT_BUTTON_TYPE_GAMEPAD_AXIS, .gpAxis = { .axis = SDL_CONTROLLER_AXIS_LEFTY, .positive = false } } },
#else
#endif
#endif
@@ -145,11 +162,12 @@ inputbuttondata_t INPUT_BUTTON_DATA[] = {
inputbutton_t inputButtonGetByName(const char_t *name) {
assertNotNull(name, "name must not be NULL");
uint32_t len = sizeof(INPUT_BUTTON_DATA) / sizeof(inputbuttondata_t);
for(uint32_t i = 0; i < len; i++) {
if(stringCompareInsensitive(INPUT_BUTTON_DATA[i].name, name) != 0) continue;
return INPUT_BUTTON_DATA[i].button;
inputbuttondata_t *data = INPUT_BUTTON_DATA;
while(data->name != NULL) {
if(stringCompareInsensitive(data->name, name) == 0) {
return data->button;
}
data++;
}
return (inputbutton_t){ .type = INPUT_BUTTON_TYPE_NONE };
@@ -170,12 +188,23 @@ float_t inputButtonGetValue(const inputbutton_t button) {
#if INPUT_GAMEPAD == 1
case INPUT_BUTTON_TYPE_GAMEPAD: {
#if INPUT_SDL2 == 1
if(SDL_GameControllerGetButton(
SDL_GameControllerFromInstanceID(0), button.gpButton
)) return 1.0f;
if(SDL_GameControllerGetButton(INPUT.controller, button.gpButton)) {
return 1.0f;
}
#endif
return 0.0f;
}
case INPUT_BUTTON_TYPE_GAMEPAD_AXIS: {
#if INPUT_SDL2 == 1
Sint16 axis = SDL_GameControllerGetAxis(INPUT.controller, button.gpAxis.axis);
if(!button.gpAxis.positive) axis = -axis;
float_t value = (float_t)axis / 32767.0f;
// Deadzone
if(value < INPUT.deadzone) return 0.0f;
return value;
#endif
}
#endif
default: {