diff --git a/Backends/System/FreeBSD/Sources/kinc/backend/input/gamepad.cpp b/Backends/System/FreeBSD/Sources/kinc/backend/input/gamepad.cpp index 31c27275f..3bb01ec41 100644 --- a/Backends/System/FreeBSD/Sources/kinc/backend/input/gamepad.cpp +++ b/Backends/System/FreeBSD/Sources/kinc/backend/input/gamepad.cpp @@ -118,11 +118,11 @@ const char *kinc_gamepad_vendor(int gamepad) { } const char *kinc_gamepad_product_name(int gamepad) { - return gamepads[gamepad].name; + return gamepad >= 0 && gamepad < KINC_GAMEPAD_MAX_COUNT ? gamepads[gamepad].name : ""; } bool kinc_gamepad_connected(int gamepad) { - return gamepads[gamepad].connected; + return gamepad >= 0 && gamepad < KINC_GAMEPAD_MAX_COUNT && gamepads[gamepad].connected; } void kinc_gamepad_rumble(int gamepad, float left, float right) {} \ No newline at end of file diff --git a/Backends/System/Linux/Sources/kinc/backend/gamepad.c.h b/Backends/System/Linux/Sources/kinc/backend/gamepad.c.h index 03d671133..74b3dde94 100644 --- a/Backends/System/Linux/Sources/kinc/backend/gamepad.c.h +++ b/Backends/System/Linux/Sources/kinc/backend/gamepad.c.h @@ -188,11 +188,11 @@ const char *kinc_gamepad_vendor(int gamepad) { } const char *kinc_gamepad_product_name(int gamepad) { - return gamepads[gamepad].name; + return gamepad >= 0 && gamepad < KINC_GAMEPAD_MAX_COUNT ? gamepads[gamepad].name : ""; } bool kinc_gamepad_connected(int gamepad) { - return gamepads[gamepad].connected; + return gamepad >= 0 && gamepad < KINC_GAMEPAD_MAX_COUNT && gamepads[gamepad].connected; } void kinc_gamepad_rumble(int gamepad, float left, float right) {}