blob: 0572e0e85380659ac35c9cad3919fae39f8ee49a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#ifndef PW_PLAYER_H
#define PW_PLAYER_H
#include <SDL3/SDL_events.h>
#include <SDL3/SDL_gamepad.h>
#include <SDL3/SDL_joystick.h>
#define PW_PLAYERS_MAX 8
/**
* PICO-8 players.
*/
struct pw_players {
SDL_Gamepad *gamepads[PW_PLAYERS_MAX];
};
/**
* Allocates and initializes the PICO-8 player state.
*/
struct pw_players *pw_players_init(void);
/**
* Cleanup and free the PICO-8 input state.
*/
void pw_players_free(struct pw_players *players);
/**
* Handles an SDL events for updating connected players.
*/
bool pw_players_event(struct pw_players *players, SDL_Event *event);
/**
* The connection status of each player, as a convenience returns the
* number of connected players.
*/
size_t pw_players_status(struct pw_players *players,
bool connected[static PW_PLAYERS_MAX]);
/**
* Finds the player associated with a gamepad. Returns `PW_PLAYERS_MAX` if not
* found.
*/
size_t pw_player_find(struct pw_players *players, SDL_JoystickID gamepad);
#endif
|