laamaa / m8c

Cross-platform M8 tracker headless client
Other
380 stars 81 forks source link

Added config and handling for special game controller buttons to quit and reset display. #77

Closed smootalicious closed 2 years ago

smootalicious commented 2 years ago

On a game controller, using the M8 defined buttons can cause conflicts with defined M8 functionality, or simply fail to quit in the case of no attached keyboard to execute a quit. I added special game controller configs to quit and reset the display using any of the unused/unmapped to M8 buttons in combination with the defined "Select" button. The defaults are quit = select + SDL_CONTROLLER_BUTTON_RIGHTSTICK and reset display = select + SDL_CONTROLLER_BUTTON_LEFTSTICK.

smootalicious commented 2 years ago

I ended up reverting the removal of the original key combo for reset display since it may be (and probably is) used by users of the M8.

smootalicious commented 2 years ago

Added the game controller definitions from @jasonporrit's scripts (https://github.com/laamaa/m8c/pull/77/commits/de383da3999938633f3c28c50d5b9793dbb03b30)

smootalicious commented 2 years ago

Initialize the game controllers if they are plugged in before m8c starts. Read the database BEFORE trying to read the game controller - Basically, reading the database has to happen before assigning the joystick or it doesn't register as a gamepad. Check for the user's game controller db if found in their config dir, or fall back to the one included in the m8c directory.

(https://github.com/laamaa/m8c/pull/77/commits/f7cf5e28c1d666609cc01445ce5433d18e5fa207) f7cf5e2

smootalicious commented 2 years ago

Changed strategy to use SDL functions only and removed stat.h strategy because it is not cross-platform.

(https://github.com/laamaa/m8c/pull/77/commits/a839ff9f9e8c02f42e49d3c6a7c32e20c38d0c4c)

Ideally what should happen here is : try to get the gamecontroller db from the user pref directory; If it doesn't exist, then create it from the included one, and then try to open it. If that fails, then read the included db file. I haven't implemented this, but it seems like the right way..

smootalicious commented 2 years ago

RE: device disconnect detection. For some reason, the Effects Help screen causes the m8 (or headless) to send zero bytes and appear disconnected. One workaround by setting wait_for_device in the config file = true, but I had to reset the zero byte counter in the device disconnect code block, otherwise the zero counter would cause a display reset repeatedly with no delay. The other was to add a longer disconnect timeout, which I defaulted to 15 seconds and made configurable.

smootalicious commented 2 years ago

I'm really sorry if I am overwhelming you with changes.

smootalicious commented 2 years ago

Maybe adding a config parameter for the zero byte timeout is overkill, but the changes to reset the zero byte counter while the user has a button pressed does keep the m8c from shutting down on the Effects Help screen.

laamaa commented 2 years ago

Sorry for the delay with checking this - work, family and weekly beats have taken all my time lately :) I read through the PR and the changes make sense to me. I'll give it a little test and merge if it works ok for me!

laamaa commented 2 years ago

Looks like the fx palette reset still happens when using M8 hw buttons for navigation. It probably needs a better check for timeout than the current 0byte system, this is probably best addressed in a separate issue...

I didn't have a gamepad to test the quit buttons with but I'll assume it works :)

smootalicious commented 2 years ago

Sorry, I'm still awaiting my hardware M8 in the next shipment, so I couldn't test the zerobyte behavior with one. :(

laamaa commented 2 years ago

No worries :) The HW unit sends packets that contain the keypress+ID of the current view. That could be used with the current solution but it's probably a better idea to find some other way.

smootalicious commented 2 years ago

I found some other way - see new PR with just a tiny change I believe should work in all cases due to the port reset behavior on entering the loop when port==null.