Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run-native under Linux: lots of buttons don’t work, and some undocumented ones do #620

Open
Hawk777 opened this issue Mar 7, 2023 · 1 comment
Labels
good first issue Good for newcomers

Comments

@Hawk777
Copy link

Hawk777 commented Mar 7, 2023

According to the documentation, there should be a full set of keys for the first three players on a single keyboard. However, using w4 run-native on Linux, key input seems to violate the documentation in the following ways:

  • Dot and comma don’t do anything (they should be player 1 X and Z).
  • None of the numpad keys, which are supposed to be for player 3, do anything.
  • W, Y, J, and V, despite not being documented as doing anything, are player 1 Z.
  • K, C, and spacebar, despite not being documented as doing anything, are player 1 X.

Also, according to this page, there should be a bunch of hotkeys that do things in the emulator. None of them appear to do anything.

This is all tested with version 2.5.4, which was the version I got by downloading the Linux ZIP file here. I’m using an ordinary QWERTY keyboard (albeit one with NKRO), and Xorg.

@aduros
Copy link
Owner

aduros commented Mar 9, 2023

Hi, thanks for flagging this!

  • Dot and comma don’t do anything (they should be player 1 X and Z).
  • None of the numpad keys, which are supposed to be for player 3, do anything.

The native runtime doesn't currently listen to keys for players 3 and 4, but it should be easy to add.

  • W, Y, J, and V, despite not being documented as doing anything, are player 1 Z.
  • K, C, and spacebar, despite not being documented as doing anything, are player 1 X.

Some of these undocumented keys are actually to support Dvorak and German keyboards, as it looks like minifb has a limitation of not being able to map to a physical key location.

If you'd like to help with a PR, the source is here:

// Keyboard handling
const uint8_t* keyBuffer = mfb_get_key_buffer(window);
// Player 1
uint8_t gamepad = 0;
if (keyBuffer[KB_KEY_X] || keyBuffer[KB_KEY_V] || keyBuffer[KB_KEY_K] || keyBuffer[KB_KEY_SPACE]) {
gamepad |= W4_BUTTON_X;
}
if (keyBuffer[KB_KEY_Z] || keyBuffer[KB_KEY_C] || keyBuffer[KB_KEY_Y] || keyBuffer[KB_KEY_W] || keyBuffer[KB_KEY_J]) {
gamepad |= W4_BUTTON_Z;
}
if (keyBuffer[KB_KEY_LEFT]) {
gamepad |= W4_BUTTON_LEFT;
}
if (keyBuffer[KB_KEY_RIGHT]) {
gamepad |= W4_BUTTON_RIGHT;
}
if (keyBuffer[KB_KEY_UP]) {
gamepad |= W4_BUTTON_UP;
}
if (keyBuffer[KB_KEY_DOWN]) {
gamepad |= W4_BUTTON_DOWN;
}
w4_runtimeSetGamepad(0, gamepad);
// Player 2
gamepad = 0;
if (keyBuffer[KB_KEY_LEFT_SHIFT] || keyBuffer[KB_KEY_TAB]) {
gamepad |= W4_BUTTON_X;
}
if (keyBuffer[KB_KEY_A] || keyBuffer[KB_KEY_Q]) {
gamepad |= W4_BUTTON_Z;
}
if (keyBuffer[KB_KEY_S]) {
gamepad |= W4_BUTTON_LEFT;
}
if (keyBuffer[KB_KEY_F]) {
gamepad |= W4_BUTTON_RIGHT;
}
if (keyBuffer[KB_KEY_E]) {
gamepad |= W4_BUTTON_UP;
}
if (keyBuffer[KB_KEY_D]) {
gamepad |= W4_BUTTON_DOWN;
}
w4_runtimeSetGamepad(1, gamepad);

@aduros aduros added the good first issue Good for newcomers label Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants