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.
 
 
 
 
 
 

104 lines
1.7 KiB

  1. #ifndef IZ_MIDI_H
  2. #define IZ_MIDI_H
  3. #include <SDL_stdinc.h>
  4. #include <string.h>
  5. #ifndef PORTMIDI_INCLUDED
  6. #define PORTMIDI_INCLUDED
  7. #include <portmidi.h>
  8. #endif
  9. #include <minIni.h>
  10. #include "IZ_action.h"
  11. #include "../util/IZ_midi.h"
  12. #define MIDI_EVENT_BUFFER_SIZE 1024
  13. typedef u8 IZ_MIDINote;
  14. static const u8 IZ_MIDI_NOTE_ON = 0x90u;
  15. static const u8 IZ_MIDI_NOTE_OFF = 0x80u;
  16. typedef struct {
  17. PmDeviceID device_id;
  18. u8 channel;
  19. IZ_MIDINote control_mapping[CONTROLS];
  20. } IZ_MIDIInputConfig;
  21. typedef struct {
  22. IZ_MIDIInputConfig config;
  23. const PmDeviceInfo* device_info;
  24. PmStream* stream;
  25. PmEvent event_buffer[MIDI_EVENT_BUFFER_SIZE];
  26. i32 midi_events_count;
  27. } IZ_MIDIInputState;
  28. static const IZ_MIDIInputState IZ_MIDI_INPUT_DEFAULT_STATE[IZ_PLAYERS] = {
  29. {
  30. .config = {
  31. .control_mapping = {
  32. 70,
  33. 72,
  34. 71,
  35. 69,
  36. 65,
  37. 64,
  38. 48,
  39. 49,
  40. 50,
  41. 51,
  42. 52,
  43. 53,
  44. 54,
  45. 55,
  46. 56,
  47. 57,
  48. },
  49. .device_id = 0,
  50. .channel = 0,
  51. },
  52. .event_buffer = {},
  53. .stream = NULL,
  54. .device_info = NULL,
  55. },
  56. {
  57. .config = {
  58. .control_mapping = {
  59. 70,
  60. 72,
  61. 71,
  62. 69,
  63. 65,
  64. 64,
  65. 48,
  66. 49,
  67. 50,
  68. 51,
  69. 52,
  70. 53,
  71. 54,
  72. 55,
  73. 56,
  74. 57,
  75. },
  76. .device_id = 1,
  77. .channel = 1,
  78. },
  79. .event_buffer = {},
  80. .stream = NULL,
  81. .device_info = NULL,
  82. },
  83. };
  84. IZ_ProcedureResult IZ_MIDIInputSaveConfig(IZ_MIDIInputState(*)[IZ_PLAYERS], const char*);
  85. void IZ_MIDIInputHandleEvents(IZ_MIDIInputState(*)[IZ_PLAYERS], IZ_Action(*)[IZ_PLAYERS], PmEvent);
  86. IZ_ProcedureResult IZ_MIDIInputInitialize(IZ_MIDIInputState(*)[IZ_PLAYERS], const char*, u8, const char**);
  87. void IZ_MIDIInputTeardown(IZ_MIDIInputState(*)[IZ_PLAYERS]);
  88. #endif