Skip to content

Touch controls for every console when touch is the only input; Jedi Knight gets move / look sticks with per-game sensitivity - #46

Merged
finger563 merged 3 commits into
mainfrom
feat/jk-touch-controls
Nov 28, 2026
Merged

finger563 merged 3 commits into
mainfrom
feat/jk-touch-controls

Conversation

@finger563

@finger563 finger563 commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

With no USB gamepad or keyboard connected, every game now draws its touch controls on the screen. They sit in the side bars when those are wide enough, and over the picture otherwise, including with the Fill video setting.

  • Each console's own pad, named as on the console (main/touch_gamepads.hpp):

    • B / A on the NES and Game Boy, plus L / R on the GBA;
    • A / B / X / Y and L / R on the SNES;
    • 1 / 2 on the Master System and Game Gear, and A / B / C on the Genesis;
    • the PlayStation shapes and L1 / R1 / L2 / R2 in MGS and TPM;
    • FIRE / RUN / USE / WPN and MAP / MENU in Doom, and the MSX and PICO-8 keys.

    A pause button replaces the invisible hot corner, and a finger can slide between face buttons.

  • Jedi Knight's own layout: floating move and look sticks; FIRE / ALT / JUMP / DUCK / ACT / ITEM; weapon and Force power buttons; a pause button. The move stick reaches the engine as joystick axes, so a light push walks and a full push runs.

  • Per-game touch sensitivity: JK's pause menu has Move sensitivity and Look sensitivity rows (25–300 %, 100 by default). They are stored per ROM in settings V2, which migrates the V1 file.

  • Touch stays a pointer where a game needs one: ScummVM always, Dark Forces in its menus, and JK in its menus and cutscenes.

  • Drawing without flicker on the single-buffered panel, where each pixel is written once a frame:

    • Side bars are drawn straight into the frame buffer, only when they change.
    • Over the picture at a scale below 2 (JK at 1.5×), the controls are blended into the staging tiles before the PPA.
    • Otherwise they are drawn at full resolution in cells in the tile buffer's internal RAM: PPA scale, CPU blend, PPA copy to the frame buffer.
    • A layout whose full-resolution overlay drops frames falls back to blending before the scaling. Today that's GBA in Fill.

Also:

  • Brightness drift fix: brightness and volume are saved rounded. The brightness is read back from the backlight's PWM duty, a hair under what was set, and truncating it lost 1 % every time a game quit.
  • tools/overlay_image.py skips fmt's dragonbox tables: their 64 / 128-bit constants can equal an overlay function's address.

Submodule PRs, both merged: esp-cpp/OpenJKDF2#9 (the stick's axes) and esp-cpp/TheForceEngine#4 (Dark Forces' menus vs missions). It was stacked on #44, which is merged; main is merged in.

Settings note: older firmware can't read the V2 settings file. Flashing an older build resets settings to defaults on its next save.

Testing (Tab5, touch only, muted)

Video task time a frame, with presented fps:

Game Video setting Video task fps
GBA Fit 15.1 ms 59.6, no drops
Genesis Fit 15.9 ms 59.5
SNES Fit 10.9 ms 35, as before
Doom 13.3 ms
NES (controls in the bars) Fit 8.8 ms 29.5, as before
NES Fill ~22 ms ~30
GBA Fill (after the fallback) 11.7 ms
  • GBA Fill crash: two crashes during development were fixed by taking the box from the PPA's placement. A 40 s Fill soak afterwards had no panic.
  • Jedi Knight: the sticks, buttons and pause button work. The sensitivity rows change and save the values (set 105, read back, restored to 100). Brightness held at 39 across two game launches.
  • ScummVM (Star Trek) and Dark Forces' intro and menus: no overlay, and touch works as the mouse.
  • Not tested:
    • Dark Forces' overlay during a mission;
    • MSX, PICO-8, SMS / GG and Game Boy, by eye;
    • each face button press on every console (only the d-pad was pressed on the device).
  • Builds: this tree builds clean, without the test hooks used on the device.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY

finger563 and others added 2 commits November 28, 2026 10:14
… the PC's 256

A metadata entry that points at a jkmots.cd (or *.jkm) marker is now a Jedi
Knight game whose install is a Mysteries of the Sith one: the cart passes
Config.mots, and jk_esp_engine_args() adds -motsCompat to the engine's
command line, so OpenJKDF2 runs in its MotS mode (.goo resources, MotS's
COG verbs, Force powers, HUD and saves). The engine side is
esp-cpp/OpenJKDF2#8 (this bumps components/jk/OpenJKDF2 to 28d67c2e): the
command line's flags reset at each launch, SMUSH (.san) cutscenes, and
three crashes the campaign found.

JK_SITHAI_MAX_ACTORS defaults to 256, the PC engine's size, up from 128: MotS's
Hutt palace (s2l1_palace) has 164 AI things. 672 bytes an entry, allocated
only while JK runs (445 KB of session arrays, was 361 KB).

README: the jkmots/ install (from the CD's GAMEDATA, JKMSNDLO.GOO from its
MININSTALL), its marker, and the games table.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
…night gets move / look sticks with per-game sensitivity

With no USB gamepad or keyboard connected, every game now draws its touch
controls on the screen. They sit in the side bars when those are wide enough,
and over the picture otherwise, including with the Fill video setting.

- Each console's own pad (main/touch_gamepads.hpp, a VirtualGamepad):
  - B / A on the NES and Game Boy, plus L / R on the GBA;
  - A / B / X / Y and L / R on the SNES;
  - 1 / 2 on the Master System and Game Gear, and A / B / C on the Genesis;
  - the PlayStation shapes and L1 / R1 / L2 / R2 in MGS and TPM;
  - FIRE / RUN / USE / WPN in Doom, and the MSX and PICO-8 keys.
  The pause button replaces the hot corner, and a finger can slide between
  face buttons.
- Jedi Knight's own layout (TouchControls, CUSTOM mode):
  - floating move and look sticks;
  - FIRE / ALT / JUMP / DUCK / ACT / ITEM;
  - weapon and Force power buttons;
  - a pause button.
  The move stick reaches the engine as joystick axes (jk_esp_input_t.stick_x
  / stick_y), so it walks or runs by how far it is pushed.
- Per-game touch sensitivity: JK's pause menu has Move / Look sensitivity
  rows (25-300 %). They are stored per ROM in settings V2 (Settings::touch_move
  / touch_look), which migrates a V1 file.
- Touch is the pointer where a game needs one: ScummVM always, Dark Forces in
  its menus, and JK in its menus and cutscenes (TouchControls::Mode::POINTER).
- Drawing without flicker on the single-buffered panel: each panel pixel is
  written once a frame.
  - Side bars are drawn straight into the frame buffer, only when what they
    show changes.
  - Over the picture, with a scale below 2 (JK at 1.5x), the controls are
    blended into the staging tiles before the PPA scales them.
  - Otherwise they are drawn at full resolution, in cells in the tile
    buffer's internal RAM: PPA scale, CPU blend, PPA copy to the frame buffer.
  - Measured in Fit: GBA 59.6 fps and Genesis 59.5 fps with no dropped frames.
  - A layout whose full-resolution overlay drops frames (GBA in Fill) falls
    back to blending before the scaling.
  - Layout::box_x0 / box_y0 come from the PPA's placement. An odd-width
    picture (GBA Fill, 1275 px) otherwise put the box one row off, past the
    cell buffer.
- main.cpp: volume and brightness are saved rounded. The brightness is read
  back from the backlight's PWM duty, a hair under what was set, and
  truncating it lost 1 % each time a game quit.
- tools/overlay_image.py skips fmt's dragonbox tables (64 / 128-bit powers of
  ten, half of which can equal an overlay function's address).
- Submodules:
  - OpenJKDF2 feat/esp32-touch-sticks: the stick's axes and binds;
  - TheForceEngine feat/touch-gamepad-in-missions: Dark Forces' POINTER /
    GAMEPAD switch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
Base automatically changed from feat/jk-mots to main November 28, 2026 22:11
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
@finger563
finger563 merged commit d0f808b into main Nov 28, 2026
2 checks passed
@finger563
finger563 deleted the feat/jk-touch-controls branch November 28, 2026 22:46
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