This is an attempt at emulating the MIDI devices used by the games in the list below. With the recent inclusion of the actual Keyboardmania USB keyboard support, and the fact that Drummania is already playable with a gamepad, I feel less resistance to offering up this PR because it has some restrictions.
This code expects MIDI devices as input devices instead of normal gamepads. All supported games are already playable through gamepads as of #60, and introducing outside converters (MIDI -> keyboard press, etc) has some overhead which isn't desirable for music games. As such, this PR is Windows only due to its use of Win32 MIDI APIs. I have no experience with MIDI on nix and don't have a suitable environment to develop a replacement MIDI input system for nix, so there is a noop stub in place for non-Win32.
Some expected issues:
I use a FIFO queue for MIDI events. It's not the most elegant solution and in itself could potentially process MIDI commands slower than required, but it's not possible to send a lots of MIDI events to the game without flooding the game's buffers. When the game's buffers are flooded it will drop commands (usually KEY OFF commands) and starts to act really poorly to the point that it's unplayable.
MIDI drum kits vary in a lot of ways depending on how the manufacturer implemented things. For example, some hi hats may have multiple trigger zones each with their own MIDI command, and some kits may not send KEY OFF commands at all. It would require a decently complex device configuration screen which would allow binding multiple MIDI events to a single event as well as some other hacks to offer a robust enough configuration that supports every MIDI drum kit. This PR doesn't attempt to offer that.
As such, even though the Yamaha UX16 MIDI adapter is emulated, it's best to consider the supported MIDI drum kits to be the same as whatever the actual game supports.
I left a TODO comment in the actual code, but the PC-300 MIDI Keyboard descriptor is faked based on reverse engineering the game's code to figure out what it's checking for. Ideally someone who has access to a PC-300 keyboard should eventually replace the config descriptor with a real one.
NOTE: MIDI drum kits typically use MIDI channel 10 and GFDM expects events on MIDI channel 10. The input MIDI device must be sending events on channel 10 for it to be recognized in-game.
GUITARFREAKS 4thMIX & drummania 3rdMIX (first GFDM game to support MIDI devices)
This is an attempt at emulating the MIDI devices used by the games in the list below. With the recent inclusion of the actual Keyboardmania USB keyboard support, and the fact that Drummania is already playable with a gamepad, I feel less resistance to offering up this PR because it has some restrictions.
This code expects MIDI devices as input devices instead of normal gamepads. All supported games are already playable through gamepads as of #60, and introducing outside converters (MIDI -> keyboard press, etc) has some overhead which isn't desirable for music games. As such, this PR is Windows only due to its use of Win32 MIDI APIs. I have no experience with MIDI on nix and don't have a suitable environment to develop a replacement MIDI input system for nix, so there is a noop stub in place for non-Win32.
Some expected issues:
Demo: https://streamable.com/tl5l4s
Tested/Supported games
Roland PC-300 MIDI Keyboard
Yamaha UX16 USB-MIDI Interface
NOTE: MIDI drum kits typically use MIDI channel 10 and GFDM expects events on MIDI channel 10. The input MIDI device must be sending events on channel 10 for it to be recognized in-game.