|
- #include "IZ_input.h"
-
- void IZ_InputHandleSDLEvents(IZ_InputState* state, SDL_Event e) {
- IZ_JoystickHandleEvents(&state->joystick_state, &state->action, e);
- IZ_KeyboardHandleEvents(&state->keyboard_state, &state->action, e);
- }
-
- void IZ_InputHandlePortMIDIEvents(IZ_InputState* state, PmEvent e) {
- IZ_MIDIInputHandleEvents(&state->midi_input_state, &state->action, e);
- }
-
- IZ_ProcedureResult IZ_InputInitialize(IZ_InputState* state, const char* config_path, u8 argc, const char* argv[]) {
- *state = (IZ_InputState) {
- .action = {},
- .joystick_state = {},
- .midi_input_state = {},
- .keyboard_state = {},
- };
-
- IZ_ProcedureResult result = 0;
-
- if (IZ_JoystickInitialize(&state->joystick_state, config_path, argc, argv) < 0) {
- result |= 1;
- }
-
- if (IZ_KeyboardInitialize(&state->keyboard_state, config_path, argc, argv) < 0) {
- result |= 2;
- }
-
- if (IZ_MIDIInputInitialize(&state->midi_input_state, config_path, argc, argv) < 0) {
- result |= 4;
- }
-
- u8 player_index;
- for (player_index = 0; player_index < IZ_PLAYERS; player_index += 1) {
- state->action[player_index] = 0;
- }
-
- return -result;
- }
-
- void IZ_InputTeardown(IZ_InputState* state) {
- IZ_JoystickTeardown(&state->joystick_state);
- IZ_MIDIInputTeardown(&state->midi_input_state);
- }
|