demo/02-woodeneye-008/woodeneye-008: ignore gamepad stick deadzones.

This prevents an idle gamepad from overriding mouse input.
This commit is contained in:
Ryan C. Gordon 2025-11-08 14:09:45 -05:00
parent 3e2ff3f105
commit 90874fabcd
No known key found for this signature in database
GPG key ID: FA148B892AB48044

View file

@ -122,8 +122,10 @@ static void updatePlayerGamepad(Player *player)
if (player->gamepad) {
const int rightx = (int)SDL_GetGamepadAxis(player->gamepad, SDL_GAMEPAD_AXIS_RIGHTX);
const int righty = (int)SDL_GetGamepadAxis(player->gamepad, SDL_GAMEPAD_AXIS_RIGHTY);
player->yaw -= rightx * 0x00000800;
player->pitch = SDL_max(-0x40000000, SDL_min(0x40000000, player->pitch - righty * 0x00000800));
if ((SDL_abs(rightx) > 0x1000) || (SDL_abs(righty) > 0x1000)) { /* ignore if stick is near center, since it might be noise and the user is actually using the mouse, etc. */
player->yaw -= rightx * 0x00000800;
player->pitch = SDL_max(-0x40000000, SDL_min(0x40000000, player->pitch - righty * 0x00000800));
}
}
}