From 0c99d5eb2f3b21c0f9930a0696bfc241cf08da62 Mon Sep 17 00:00:00 2001 From: William Emfinger Date: Tue, 24 Nov 2026 18:41:30 -0700 Subject: [PATCH] Jedi Knight: a gamepad jump is as high as a keyboard one; face buttons do one thing each The USB gamepad's face buttons reached JK twice: as the keys of the gamepad layout (A activate, B jump, X crouch, Y use item) and as joystick buttons, which JK's default joystick binds map to fire, crouch, activate and jump. So B jumped crouched, which the engine launches at 0.7x the speed (measured: rise 0.095 against 0.1149 for the keyboard's X). A also fired, X also activated and Y also jumped. jk_esp_read_input now also gives the engine joy_buttons, the buttons without the USB gamepad's a/b/x/y, and the engine uses it in play (esp-cpp/OpenJKDF2 esp32/gamepad-face-buttons). JK's menus still get every button, so B is still Back there. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY --- components/jk/OpenJKDF2 | 2 +- components/jk/include/jk_esp.h | 3 +++ components/jk/src/jk.cpp | 10 +++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/components/jk/OpenJKDF2 b/components/jk/OpenJKDF2 index ea0c9c1..fc4edad 160000 --- a/components/jk/OpenJKDF2 +++ b/components/jk/OpenJKDF2 @@ -1 +1 @@ -Subproject commit ea0c9c18c96edceb626bbc2f21e7b4917780ac57 +Subproject commit fc4edad3915758736766782d55da6b7345c4b555 diff --git a/components/jk/include/jk_esp.h b/components/jk/include/jk_esp.h index 0957c1a..4a1cd0f 100644 --- a/components/jk/include/jk_esp.h +++ b/components/jk/include/jk_esp.h @@ -12,6 +12,9 @@ extern "C" { typedef struct { uint16_t buttons; // GamepadState::buttons bit layout (a,b,x,y,select,start,up,down,left,right) + // the same for the engine's joystick binds in play: without the USB gamepad's + // a/b/x/y, which arrive as keys (see jk_esp_read_input) + uint16_t joy_buttons; int16_t touch_x; // logical (landscape) touch position, -1 if none int16_t touch_y; uint8_t touch_down; diff --git a/components/jk/src/jk.cpp b/components/jk/src/jk.cpp index 7d3e96c..54ea7b0 100644 --- a/components/jk/src/jk.cpp +++ b/components/jk/src/jk.cpp @@ -319,7 +319,15 @@ void jk_esp_read_input(jk_esp_input_t *out) { // touch + USB gamepad; not gamepad_state(), whose keyboard-as-gamepad keys // (W = R, S = Y ...) would reach the engine's joystick binds on top of the // keys themselves - out->buttons = static_cast(emu.touch_gamepad_state().buttons | emu.usb_gamepad_state().buttons); + const uint16_t touch_buttons = emu.touch_gamepad_state().buttons; + const uint16_t usb_buttons = emu.usb_gamepad_state().buttons; + out->buttons = static_cast(touch_buttons | usb_buttons); + // In play the USB gamepad's A/B/X/Y arrive as keys (below), so the engine's + // joystick binds get them from the touch pad only. Both at once doubled each + // action: B jumped and (B2 = duck) crouched, so its jump was lower; A also + // fired, X also activated, Y also jumped. JK's menus still read all of them + // (B = back), see stdControl_ReadControls. + out->joy_buttons = static_cast(touch_buttons | (usb_buttons & ~0x000Fu)); auto touch = emu.touchpad_data(); out->touch_down = touch.num_touch_points > 0; out->touch_x = out->touch_down ? touch.x : -1;