2D Run-and-gun shooter inspired by One Man's Doomsday, Counter-Strike, and Metal Slug.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

46 lines
1.2 KiB

  1. #include "IZ_input.h"
  2. void IZ_InputHandleSDLEvents(IZ_InputState* state, SDL_Event e) {
  3. IZ_JoystickHandleEvents(&state->joystick_state, &state->action, e);
  4. IZ_KeyboardHandleEvents(&state->keyboard_state, &state->action, e);
  5. }
  6. void IZ_InputHandlePortMIDIEvents(IZ_InputState* state, PmEvent e) {
  7. IZ_MIDIInputHandleEvents(&state->midi_input_state, &state->action, e);
  8. }
  9. IZ_ProcedureResult IZ_InputInitialize(IZ_InputState* state, const char* config_path, u8 argc, const char* argv[]) {
  10. *state = (IZ_InputState) {
  11. .action = {},
  12. .joystick_state = {},
  13. .midi_input_state = {},
  14. .keyboard_state = {},
  15. };
  16. IZ_ProcedureResult result = 0;
  17. if (IZ_JoystickInitialize(&state->joystick_state, config_path, argc, argv)) {
  18. result |= 1;
  19. }
  20. if (IZ_KeyboardInitialize(&state->keyboard_state, config_path, argc, argv)) {
  21. result |= 2;
  22. }
  23. if (IZ_MIDIInputInitialize(&state->midi_input_state, config_path, argc, argv)) {
  24. result |= 4;
  25. }
  26. u8 player_index;
  27. for (player_index = 0; player_index < IZ_PLAYERS; player_index += 1) {
  28. state->action[player_index] = 0;
  29. }
  30. return -result;
  31. }
  32. void IZ_InputTeardown(IZ_InputState* state) {
  33. IZ_JoystickTeardown(&state->joystick_state);
  34. IZ_MIDIInputTeardown(&state->midi_input_state);
  35. }