diff options
| author | Nicholas Rodrigues Lordello <[email protected]> | 2026-10-24 10:48:45 +0200 |
|---|---|---|
| committer | Nicholas Rodrigues Lordello <[email protected]> | 2026-10-24 10:48:45 +0200 |
| commit | 02da08e9d84371c558da6347210c00e3966f2dc5 (patch) | |
| tree | 2f755363d363888ffd17e870060c4049195e24a3 /src/game.c | |
| parent | 1c4eada99c6f98eae40c676d261c8d4fc1de6079 (diff) | |
Improve Gamepad Handling
There were a few cases where we would have stale input information
becaues the `pw_input` only receives events while the game is
running. This fixes that by:
- Reseting the player count on game start
- Clearing button states for disconnected players
- Improve handling of the POOM player 2 support in case a second
player connects
Diffstat (limited to 'src/game.c')
| -rw-r--r-- | src/game.c | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -72,16 +72,20 @@ void pw_game_free(struct pw_game *game) { SDL_free(game); } -bool pw_game_start(struct pw_game *game, struct pw_cart_data *cartdat) { +bool pw_game_start(struct pw_game *game, struct pw_players *players, + struct pw_cart_data *cartdat) { if (!game) { - SDL_InvalidParamError("game"); - return false; + return SDL_InvalidParamError("game"); + } + if (!players) { + return SDL_InvalidParamError("players"); } if (!cartdat) { - SDL_InvalidParamError("cartdat"); - return false; + return SDL_InvalidParamError("cartdat"); } + pw_input_reset(game->input, players); + if (game->cartdat) { pw_cart_data_free(game->cartdat); } @@ -134,8 +138,7 @@ bool pw_game_start(struct pw_game *game, struct pw_cart_data *cartdat) { bool pw_game_event(struct pw_game *game, struct pw_players *players, SDL_Event *event) { if (!game) { - SDL_InvalidParamError("game"); - return false; + return SDL_InvalidParamError("game"); } return pw_input_event(game->input, players, event); |
