Browse Source

Fix MIDI value parsing

Ensure note names are normalized (i.e. converted to lowercase) properly
before parsing.
master
TheoryOfNekomata 1 year ago
parent
commit
fa55ceaa97
4 changed files with 10 additions and 6 deletions
  1. +2
    -2
      docs/reference/files/config-game.ini
  2. +1
    -1
      src/packages/game/input/IZ_joystick.c
  3. +1
    -1
      src/packages/game/input/IZ_midi.c
  4. +6
    -2
      src/packages/game/util/IZ_midi.c

+ 2
- 2
docs/reference/files/config-game.ini View File

@@ -5,7 +5,7 @@ MaxFps=30
[Joystick.0]
DeviceID=0
AxisThreshold=8000
GUID=00000000-0000-0000-0000-000000000000
GUID=00000000000000000000000000000000
[Joystick.0.ControlMapping]
Affirm=11
Negate=10
@@ -65,7 +65,7 @@ Username=Player 1
[Joystick.1]
DeviceID=1
AxisThreshold=8000
GUID=00000000-0000-0000-0000-000000000000
GUID=00000000000000000000000000000000
[Joystick.1.ControlMapping]
Affirm=11
Negate=10


+ 1
- 1
src/packages/game/input/IZ_joystick.c View File

@@ -302,7 +302,7 @@ IZ_ProcedureResult IZ_JoystickInitialize(IZ_JoystickState(* state)[IZ_PLAYERS],
memcpy(&(*state)[player_index].config.guid, &joystick_guid, sizeof(SDL_GUID));
//(*state)[player_index].config.guid = joystick_guid;

printf("initialize event from guid: ");
printf("[INPUT:JOYSTICK] Initialize event from GUID: ");
for (u8 zz = 0; zz < 16; zz += 1) {
printf("%02x", (*state)[player_index].config.guid.data[zz]);
}


+ 1
- 1
src/packages/game/input/IZ_midi.c View File

@@ -157,7 +157,7 @@ IZ_ProcedureResult IZ_MIDIInputInitialize(IZ_MIDIInputState(* state)[IZ_PLAYERS]
u8 input_midi_devices_count = 0;
u8 device_index;
for (device_index = 0; device_index < midi_devices_count; device_index += 1) {
if (!Pm_GetDeviceInfo(device_index)->output) {
if (!Pm_GetDeviceInfo(device_index)->input) {
continue;
}



+ 6
- 2
src/packages/game/util/IZ_midi.c View File

@@ -26,8 +26,12 @@ char* IZ_MIDIGetNoteName(u8 midi_note) {
u8 IZ_MIDIGetNoteFromName(const char* name) {
char name_copy[8];
memcpy(name_copy, name, 8);
#ifdef WIN32
#ifdef IZ_WIN32
_strlwr_s(name_copy, 8);
#elif defined IZ_WIN64
_strlwr_s(name_copy, 8);
#else
_strlwr(name_copy);
#endif

u8 octave;
@@ -41,7 +45,7 @@ u8 IZ_MIDIGetNoteFromName(const char* name) {
return (octave * 12) + pitch_index;
}
}
return 255u;
return 255u; // invalid note value
}

u8 pitch_class;


Loading…
Cancel
Save