libretro / vice-libretro

Versatile Commodore 8-bit Emulator
GNU General Public License v2.0
40 stars 70 forks source link

Linux/Wayland: Enter key not processed #300

Closed ntninja closed 3 years ago

ntninja commented 3 years ago

Steps to reproduce:

  1. Ensure that you are using a Linux Desktop system running a Wayland compositor (legacy X11 desktop session are not affected by this apparently)
  2. Download and install latest RetroArch release (Flatpak) from the website as per the official instructions
  3. Launch RetroArch
  4. Main MenuOnline UpdatesCore Downloader → Install Commodore – C64/C128 (Vice …)
  5. Main MenuLoad CoreCommodore – C64/C128 (Vice …)
  6. Main MenuStart Core
  7. Try pressing the enter key on the keyboard (it does not matter whether you toggle Focus Game on or off by the way)

Expected result: Cursor in line editor of emulated C64/C128 should move one line down.

Actual result: Nothing happens.

Other observations:

sonninnos commented 3 years ago

Can you also test standalone VICE? And how about every other key, are they correct? And is it only with the keyboard, as in does Enter work via the virtual keyboard and the RetroPad mapper?

Maybe it is for some reason sending numpad Enter, key 271 instead of 13.. It is unused in C64 and VIC-20 currently, but I guess I could add that to press Return too. Frodo seems to be doing that as well, which likely explains why it works there.

It is - at least for testing purposes - possible to create user defined keymaps under system/vice/, in this case system/vice/C64/.

Copy sdl_pos.vkm and/or sdl_sym.vkm from https://github.com/libretro/vice-libretro/tree/master/vice/data/C64 and edit this row: 13 0 1 8

Or rather add: 271 0 1 8

And of course change the keyboard keymap core option accordingly.

sonninnos commented 3 years ago

It also appears that there has been a related fix done to RetroArch just a month ago, which means it is not in the flatpak install. Could you try building the nightly?

ntninja commented 3 years ago

Thanks for your reply! So far I checked these things in RetroArch master with the most recent Nightly vice-libretro core from the buiild system:

And how about every other key, are they correct?

I have checked them all and from the main keyboard area (^ to R_Control), the following keys appear to be “dead” / doing nothing: Enter, Y (would be Z on English keyboard), X, A, S, Q, W.

Some these were apparently assigned to the Port 1 Controls in the main settings, but changing the device type from RetroPad to None had no effect.

When the device is set to RetroPad mode then S will cause a space to be entered. Which apparently corresponds to X-Button (Up).

(In Frodo all the before-mentioned keys work fine, except that A also opens some kind of overly keyboard that doesn't actually work – or at least I found no way to confirm the current key selection.)

Does Enter work via the virtual keyboard?

If by that you mean the overlay that pops up when pressing the key named “Select” (defaulting to R_Shift) with the Port 1 Controls set to RetroPad, then yes. All the keys displayed in that overlay work without issue.

[…] and the RetroPad mapper?

I'm sorry, I'm afraid I don't know what the RetroPad mapper exactly is and how I configure it to enter an Enter key. Please elaborate on how to do this.

Mapping enter to R2 fixes the enter key, but it's a bit of a hack.

Copy sdl_pos.vkm and/or sdl_sym.vkm from https://github.com/libretro/vice-libretro/tree/master/vice/data/C64 and […]

After discovering what a “Keymap core option” refers to, I tested this and it changed nothing. I also remapped another key to make sure loading the file actually does anything.

On that page I did discover though, that enabling “Input > Keyboard Pass-through” does fix the issue!

Can you also test standalone VICE?

VICE 3.4 as packaged by Debian has none of these issues and renders to Wayland using GTK3 and GTKGL.

ntninja commented 3 years ago

Current workaround (for others possibly stumbling on this):

  1. Open Quick Menu (F1)
  2. Scroll down to and open ControlsPort 1 Controls and set Device type to Disabled
  3. Go back (backspace) to Quick Menu and open Options and enable Input > Keyboard Pass-through
  4. Leave the Quick Menu and enable Game Focus (Scroll-Lock – binding can be changed in main menu → SettingsInputHotkeysGame Focus (Toggle) [6th entry from the bottom] if you don't have that key)
  5. Unobstructed keyboard input for the C64 emulator
  6. (Game Focus needs to be disabled before one can enter the Quick Menu again)
sonninnos commented 3 years ago

I have checked them all and from the main keyboard area (^ to R_Control), the following keys appear to be “dead” / doing nothing: Enter, Y (would be Z on English keyboard), X, A,S,Q,W`.

Some these were apparently assigned to the Port 1 Controls in the main settings, but changing the device type from RetroPad to None had no effect.

It does have the same effect here as enabling "Game Focus". Open up the statusbar with F12 and observe the joystick port indicators when pressing cursor keys for example.

(In Frodo all the before-mentioned keys work fine, except that A also opens some kind of overly keyboard that doesn't actually work – or at least I found no way to confirm the current key selection.)

And Frodo will then also have problems with games that do not like keyboard being pressed at the same time when joystick is used.

[…] and the RetroPad mapper?

~I'm sorry, I'm afraid I don't know what the RetroPad mapper exactly is and how I configure it to enter an Enter key. Please elaborate on how to do this.~

Mapping enter to R2 fixes the enter key, but it's a bit of a hack.

They are listed under core options. They are meant for making a more convenient controller than just a single button joystick. As in any button can press any key on the keyboard. Many games use Space and Enter, etc.

The port device type can also be switched to "Keyboard", which allows mapping D-Pad to any keyboard key too, useful for pinball games, as in not when combining joystick with keyboard.

On that page I did discover though, that enabling “Input > Keyboard Pass-through” does fix the issue!

That option is what makes it possible to not press keyboard keys and RetroPad buttons at the same time when using the keyboard as RetroPad.

The most blaring symptom of that is what happens when joystick on port 2 is pressed up at the same time as keyboard cursor up is pressed (which is really shift+down, because there is no cursor up key). It issues "LOAD" command, and it happens on a real C64 too. Which by default happens simply by pressing cursor up at the READY prompt.


So the whole issue is that by default RetroPad Start is keyboard Enter. And by default RetroPad Start does nothing, because it is not mapped. So the keyboard itself is fine. I guess I could and should add a check in that keyboard pass-through to let it go through if the button in question is not mapped.

I don't use the default keyboard mappings myself, so therefore it took a while to realize this, sorry.

And you don't need all of those steps in the workaround, just one of them. The simplest being the frontend "Game Focus" toggle, because it disables all RetroPad and frontend hotkey mappings, which allows using the keyboard properly. There are plenty of keys in RetroArch besides RetroPad keys which will make typing a nightmare. Enabling the pass-through is the worst option, which you will realize sooner or later, if you use keyboard as the joystick. Z is by default the fire button, so you will be hitting keyboard Z while firing, etc.

ntninja commented 3 years ago

I have checked them all and from the main keyboard area (^ to R_Control), the following keys appear to be “dead” / doing nothing: Enter, Y (would be Z on English keyboard), X, A, S, Q, W.

Some these were apparently assigned to the Port 1 Controls in the main settings, but changing the device type from RetroPad to None had no effect.

It does have the same effect here as enabling "Game Focus". Open up the statusbar with F12 and observe the joystick port indicators when pressing cursor keys for example.

Weirdly enough I can fully reproduce this for the arrow keys:

This is the case in both X11 and Wayland.

However, when having say S assigned to the X-button enabling/disabling Game Focus does nothing on Wayland. It does however switch between RetroPad and direct input on X11.

So apparently this issue is limited to only certain types of keys?

So the whole issue is that by default RetroPad Start is keyboard Enter. And by default RetroPad Start does nothing, because it is not mapped. So the keyboard itself is fine. I guess I could and should add a check in that keyboard pass-through to let it go through if the button in question is not mapped.

I don't use the default keyboard mappings myself, so therefore it took a while to realize this, sorry.

While I wholeheartly agree that it is weird to not be able to press enter in a line editor – and it sure was confusing for me at first – I believe that we have a separate issue to the one I initially reported here. Also, just because the enter key would then work without entering Game Focus, there are a lot of other direct-keyboard-unfriendly defaults in RetroArch such as H being Reset (very fun when the first word one instinctively tries to type is help – I'm a C64 noob and now I know that there is no such thing as help there :stuck_out_tongue_closed_eyes:).

To make the initial keyboard experience more friendly with the C64 prompt and text-based games either the initial RetroArch keybindings would have to be radically different, or Game Focus or the Hotkey button would have to be enabled by default. AFAICT the only thing to be done within this core is adding some noob documentation.

That said, from the above it is clear that the Linux/Wayland issue is unfortunately not resolved by this.

And you don't need all of those steps in the workaround, just one of them. The simplest being the frontend "Game Focus" toggle, because it disables all RetroPad and frontend hotkey mappings, which allows using the keyboard properly. There are plenty of keys in RetroArch besides RetroPad keys which will make typing a nightmare. Enabling the pass-through is the worst option, which you will realize sooner or later, if you use keyboard as the joystick. Z is by default the fire button, so you will be hitting keyboard Z while firing, etc.

It's true that pass-through isn't that great, it started to suck for me the moment I had to perform the first disk switch :upside_down_face:

The workaround I posted above however works even in the face of the Enter/S issues on Wayland documented above. But yes, I just remapped all RetroArch keybindings to F-, numpad- and command-block-keys now and it's much better my previous solution.

ntninja commented 3 years ago

Something I can do to help debug this? Trying some custom build? A guide for testing RetroArch on Wayland in VM?

sonninnos commented 3 years ago

It seems then that the Game Focus issue is a frontend issue and there is nothing to be done in this core.

Except that smallish change to the keyboard pass-through option I suggested, which may be a worthless effort anyway since there are still plenty of keys that cause issues without enabling Game Focus.

Indeed I have planned to add "Start in Game Focus" option to RetroArch sooner or later. And yep, RetroArch was not designed from the get-go to accommodate computers with keyboards, but it is what it is..

Edit: Nah, the change will cause other problems and would need much more effort to circumvent them, which makes the payoff ratio not good at all.

ntninja commented 3 years ago

It seems then that the Game Focus issue is a frontend issue and there is nothing to be done in this core.

Unproven, but likely true yes.

I found this issue, but it doesn't describe the issue at hand (Game Focus toggle does work, but only applies partially on Wayland, rather than not at all): https://github.com/libretro/RetroArch/issues/6993 . Issue tracker looks like it needs some person to do some full-time triage for a few weeks. :unamused:

I may try to debug this from the libretro side, but no promise.

Indeed I have planned to add "Start in Game Focus" option to RetroArch sooner or later. And yep, RetroArch was not designed from the get-go to accommodate computers with keyboards, but it is what it is..

That would be https://github.com/libretro/RetroArch/issues/6132 . From the way things appear to me the best solution would be to simply add a piece of visible UI that should whether Game Focus is currently enabled or not, plus some first-time info popup that tells people about its existence on devices with connected keyboards.

A preset for full-width PC keyboards that leaves the input section of the keyboard free would also be very helpful.

Except that smallish change to the keyboard pass-through option I suggested, which may be a worthless effort anyway since there are still plenty of keys that cause issues without enabling Game Focus.

Yeah, don't even bother with the current preset…