Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/jk/OpenJKDF2
3 changes: 3 additions & 0 deletions components/jk/include/jk_esp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 9 additions & 1 deletion components/jk/src/jk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint16_t>(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<uint16_t>(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<uint16_t>(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;
Expand Down
Loading