2D Run-and-gun shooter inspired by One Man's Doomsday, Counter-Strike, and Metal Slug.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

53 linhas
1.5 KiB

  1. #include "IZ_input.h"
  2. void IZ_InputHandleSDLEvents(IZ_InputState* state, SDL_Event e) {
  3. IZ_GameControllerHandleEvents(&state->game_controller_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. IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "input", "Setting up...");
  11. *state = (IZ_InputState) {
  12. .action = {},
  13. .game_controller_state = {},
  14. .midi_input_state = {},
  15. .keyboard_state = {},
  16. };
  17. IZ_ProcedureResult result = 0;
  18. if (IZ_GameControllerInitialize(&state->game_controller_state, config_path, argc, argv) < 0) {
  19. result |= 1;
  20. }
  21. if (IZ_KeyboardInitialize(&state->keyboard_state, config_path, argc, argv) < 0) {
  22. result |= 2;
  23. }
  24. if (IZ_MIDIInputInitialize(&state->midi_input_state, config_path, argc, argv) < 0) {
  25. result |= 4;
  26. }
  27. u8 player_index;
  28. for (player_index = 0; player_index < IZ_PLAYERS; player_index += 1) {
  29. state->action[player_index] = 0;
  30. }
  31. IZ_ProcedureResult final_result = -result;
  32. IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "input", "Setup complete. Result: %d", final_result);
  33. return final_result;
  34. }
  35. void IZ_InputTeardown(IZ_InputState* state) {
  36. IZ_LogInfo(IZ_LOG_CATEGORY_GLOBAL, "input", "Shutting down...");
  37. IZ_GameControllerTeardown(&state->game_controller_state);
  38. IZ_MIDIInputTeardown(&state->midi_input_state);
  39. }