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.
 
 
 
 
 
 

98 lines
1.6 KiB

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