Skip to content

ESP32: a gamepad jump is as high as a keyboard one; face buttons do one thing each - #6

Merged
finger563 merged 1 commit into
esp32p4from
esp32/gamepad-face-buttons
Nov 25, 2026
Merged

finger563 merged 1 commit into
esp32p4from
esp32/gamepad-face-buttons

Conversation

@finger563

@finger563 finger563 commented Nov 25, 2026 •

Copy link
Copy Markdown

A gamepad jump went lower than a keyboard jump

tab5-emu sends the USB gamepad's face buttons to JK as the keys of its gamepad layout (A = space, B = x, X = c, Y = enter: activate, jump, crouch, use item). It also sent them through jk_esp_input_t.buttons as joystick buttons B1–B4. The homebrew default joystick binds (sithControl_MapDefaultsJoystick) map those to fire, duck, activate and jump, and on homebrew the profile's binds are reset to the defaults (jkPlayer.c, after sithControl_ReadConf). So each button did two things:

USB button as a key also, as a joystick button
A activate fire
B jump duck: the jump left crouched
X crouch activate
Y use item jump

sithControl_PlayerMovement reads DUCK before JUMP in the same frame, and sithPlayerActions_JumpWithVel gives a crouching jump 0.7× the speed.

Fix: in play, stdControl_ReadControls takes the joystick buttons from the new jk_esp_input_t.joy_buttons, which leaves out the USB gamepad's a/b/x/y; the touch pad's buttons still go through. While one of JK's menus is open (jkGuiRend_ESP32_MenuActive, new), it still takes every button: the menus use B1 as enter, B2 as back and B3 as the default button, and the binding screens read them too. The Select + X noclip combo is checked on the unmasked buttons, so it still works from either pad.

Testing (Tab5, with esp-cpp/tab5-emu#41)

A temporary test hook injected each press through the host's real input path (jk_esp_read_input), held it 300 ms on flat ground in level 1, and logged how far the player rose.

Press Before After
Keyboard X rise 0.1149 (×3) 0.1149 (×3)
USB pad B 0.0946–0.0952, crouched (×3) 0.1149, not crouched (×3)
USB pad Y 0.1149 (jumped) 0 (use item only)
Pad START, then pad B 6 s later START opens the in-game menu; B closes it (Back)

The diagnosis was checked by two skeptics, who confirmed the mechanism. They also pointed out that the menus need the joystick buttons, which is why the mask applies in play only.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY

…ne thing each

tab5-emu sends the USB gamepad's face buttons to JK as keys (A = space,
B = x, X = c, Y = enter: activate, jump, crouch, use item) and, through
jk_esp_input_t.buttons, also as joystick buttons B1-B4, which the homebrew
default binds map to fire, duck, activate and jump (profile binds are reset
to those defaults on homebrew). So each button did two things. B jumped and
ducked in the same frame, and sithPlayerActions_JumpWithVel gives a crouching
jump 0.7x the speed: measured on the device, the player rose 0.095 against
0.1149 for the keyboard's X. A also fired, X also activated, and Y also
jumped.

In play, stdControl_ReadControls now takes the joystick buttons from
jk_esp_input_t.joy_buttons, which leaves out the USB gamepad's a/b/x/y; the
touch pad's buttons still go through. While one of JK's menus is open
(jkGuiRend_ESP32_MenuActive), it still takes all of them: the menus use B1 as
enter, B2 as back and B3 as the default button, and the binding screens read
them too. The Select + X noclip combo still works from either pad.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant