mupen64plus-ui-python icon indicating copy to clipboard operation
mupen64plus-ui-python copied to clipboard

Input doesn't distinguish between right and left ctrl/shift

Open zeta12ti opened this issue 7 years ago • 4 comments
trafficstars

When hitting either right or left ctrl (or shift), the game takes the input to be left ctrl (or shift) regardless. This is a problem since Mupen64Plus uses right ctrl and right shift to reduce the amount that the arrow keys move the controls (c.f. this guide). If both keys are taken to be the left keys, there's no way to modulate the controls.

It looks like the culprit is Qt's handling of the situation. As you can see in keymap.py, Qt only has Key_Control and Key_Shift, with no way to distinguish right and left. The only solution appears to be using QKeyEvent::nativeScanCode, rather than the built-in codes.

zeta12ti avatar Sep 08 '18 13:09 zeta12ti

I don't remember exactly, but I think there were some issues with QKeyEvent::nativeScanCode, I did tried to add left/right modifiers and failed. Anyway, whole input system should be revisited to remove hard coded stuff and allow different input plugins for configuration, like other plugins do, see https://github.com/mupen64plus/mupen64plus-ui-python/issues/123 . Not sure when will I find time, I am quite busy, any help is welcomed.

gen2brain avatar Sep 08 '18 14:09 gen2brain

After getting familiar with the code, I think you're right. It would be nice to be able to directly reroute inputs to whatever plugin handles them (I guess using QT's nativeEvent handler so that the raw input is passed).

I made a quick patch here that fixes this issue for Posix systems. I tested it out and the right ctrl and shift do exactly what I want. I'm sure it can be easily adapted to Windows and iOS (but not more than one at once) using their virtualkeys or scancodes (Windows uses these codes. I think iOS is less uniform, but there's this).

zeta12ti avatar Sep 09 '18 12:09 zeta12ti

I was about to post the same issue. The same happens to me.

This issue should be given more attention because we are missing an important feature of mupen64plus which allows us to make smaller moves with the analog stick (e.g. for aiming accurately in a game). The feature is described in https://mupen64plus.org/wiki/index.php/KeyboardSetup like this:

When using the keyboard, the analog stick is normally moved by its full range when you press an arrow key. Sometimes you may need to make smaller moves. In this case, you can move the analog stick more gently by holding down the Right Control key (for -50%) or Right Shift key (-25%), or both (-75%).

I've even tried to unset shift and control keys in the configuration (so they are no assigned to any button) but no difference in the movement in the game.

I will try the @zeta12ti's patch but still people with other OS will be missing that feature.

raafaar avatar Sep 28 '22 19:09 raafaar

Thank you @zeta12ti. Your patch works for me. It should be merged into master.

raafaar avatar Oct 04 '22 15:10 raafaar