Observing Gamepad State (PadOverlay)¶
The SDL3 build of the engine includes a debug overlay that shows the gamepad state ( on/off for 16 buttons and analog values for 6 axes ) in real time in the upper-left corner of the screen. It is useful when checking controller behavior on actual hardware ( for example, the Switch ).
For the detailed display specification and internals, see the guides in src/core:
Example display¶
+--------------------------------+
| Pad: Xbox Series X Controller |
| [A ][B ][X ][Y ] |
| [L1][R1][L2][R2] |
| [BK][ST][LS][RS] |
| [Lf][Up][Rt][Dn] |
| LX +0.45 LY -0.32 |
| RX +0.00 RY +0.00 |
| LT +0.00 RT +0.80 |
+--------------------------------+
- Header: SDL gamepad name (
(none)when nothing is connected ) - Cells: green while pressed, dark gray otherwise
- Axes: stick axes range
-1.00 〜 +1.00, trigger axes0.00 〜 +1.00
The WINVER build has no gamepad abstraction API, so when shown through the OGLDrawDevice path, every button is off and every axis reads +0.00.
Enabling the overlay¶
- From startup:
-padoverlay=1 - Toggle at run time: System.setPadOverlay
- From the REPL:
.padoverlay [on|off]
It works independently of -memoverlay=1
( upper-right corner ), and both can be shown at the same time.
Reading axes directly from TJS2¶
The overlay is for observation; to read analog axis values from a script, use System.getPadAxis.
var v = System.getPadAxis(0, System.padAxisLeftX);
// v は -1.0 〜 +1.0 の実数 (未接続/無効値で 0.0)
Six axis ID constants are provided, such as System.padAxisLeftX.
Use System.rumblePad / System.stopRumblePad for vibration. To check the number of connected gamepads or whether one is present, use System.getJoypadCount / System.hasJoypad.