Commit Graph
19 Commits
Author SHA1 Message Date
LibretroAdmin 87cfa110a1 input: an input driver's state call is not told the keyboard is held
Every input driver's state call took a flag, keyboard_mapping_blocked:
whether the keys are kept from the binds. It mattered when drivers
answered the binds themselves. The frontend answers them now, from the
keys it asks a driver for once a poll, and applies the flag itself; a
driver's state call answers the keyboard, the mouse and the pointer,
and none of the twenty-three read the flag. (udev passed it to its
touch code, which did not read it either.)

The parameter goes: from the interface, the twenty-three drivers, the
frontend's own stand-in driver and its nine calls. The frontend's own
functions keep theirs - that is where it is used.

Measured against this same master built without it, the frame's input
work over 300 frames (X11): 3,690,770 instructions to 3,690,476 with
no controller, 4,354,940 to 4,354,646 with one. An argument a call.

Checked: the frontend harness passes every lane; the X11 keyboard
session logs the same as before, and the hotkey and quit-combination
sessions what master's binary logged; the raw input keyboards test
and the plain Win32 input test, which call a driver's state function
themselves, pass under Wine. Built: Linux in full; DirectInput, raw
input and the plain Win32 driver with a mingw compiler; the Android
unity build with the NDK; Wayland; the Visual C++ 6 project and the
QNX driver on their stand-ins; a build with the optional features
off. Not compiled, there being no compiler for them here: Cocoa, UWP,
the web driver, SDL 1 and the console drivers (DOS, Wii, PS3, PS4,
PSP and Vita, Switch, Wii U); theirs is the same one line, taken out
by script.

The second of three pieces before steps 3 and 4 of the mapping
compiler (plan, section 21). The joypad, its info and the binds are
handed to the same call, and two drivers use any of it: the Wii's
reads one field of the info, the Wii U's asks the joypad for its
touch screen. With those two reworked the call would take the port
and what is asked, and nothing else.
2026-10-08 03:29:08 +02:00
LibretroAdmin 5129d6f84c input: an input driver's state call takes one joypad driver
input_driver_t::input_state was handed two joypad drivers: the one
there is, and the secondary, "for secondary input devices (eg MFi
controllers)". The frontend no longer has a secondary and passed NULL
for it at each of its nine calls; no driver did anything with it but
silence the warning about not using it.

The parameter is out of the interface, of the twenty-nine functions
that implement it - every input driver's, the null driver's and the
test stand-ins' in samples/ - and of the nine calls, and of the one
call a sample makes of a driver's function directly
(winraw_keyboards_test, which the sample link check caught). Nothing
else changes in any of them.

Every parameter list of that call in the tree was checked by script
for the new shape, including the drivers that cannot be compiled
here. Compiled: the frontend and the Linux drivers (X11, udev,
Wayland, SDL 1/2/3, linuxraw, test) with a table entry of the wrong
shape made an error; Windows (DirectInput, raw input); Android; the
Cocoa driver for macOS; PS4 and QNX against their stand-in headers.

Measured, the frame's input work over 300 frames (X11): 4,019,788
instructions to 4,017,937 with no controller, 4,690,524 to 4,688,673
with one and a hotkey enabler.

Checked: the X11 keyboard session's log is the same as before; the
hotkey and quit-combination sessions log the same lines on the
binary before this and the one after; the frontend harness passes
every lane; tools/sample_link_check.sh builds the nine samples that
link the changed files, and winraw_keyboards_test passes under Wine.

With this the secondary joypad is gone from the tree.
2026-10-07 14:16:15 +02:00
LibretroAdmin e73ded9c34 input: the test driver hands its keys to the frontend
The test input driver worked the RetroPad's buttons and the hotkeys out
itself, from the binds it was handed. It gives the frontend its keys
instead (test_keys_down()), as sixteen other drivers do, and reads no
bind.

Its answer for the whole pad at once was wrong besides: for each
button it looked at the right bind, then asked whether the key of the
bind at the number that asks for the whole pad (256) was down - a read
far past the end of a set of 96.

Run with a step file pressing A, then Right, then B and Start
together: a core reading the pad button by button and one reading it
whole both see 0100, 0080, 0009 and nothing between.

And the Wii U driver no longer tests whether a port's set is NULL: it
is an array, and never is.

Why now: the mapping compiler's third step drops the hotkey rows of
users 2 to 16 from the configured binds - the configuration loads
hotkeys for the first user only. That can only be done once no driver
reads a set it is handed, since drivers are asked for a hotkey by its
number. Six did. After this, four: PS4 and QNX, and the lightgun's
buttons in udev and Cocoa.
2026-10-07 11:48:19 +02:00
LibretroAdmin 774fd01b65 input: drivers ask for a setting by name and do not take the settings
A driver that needed a setting took all of them and picked the field
out:

  if (config_get_ptr()->uints.input_mouse_index[port] == 0)
  wr->nowinkey = config_get_ptr()->bools.input_nowinkey_enable;

Thirteen named calls on the frontend answer instead, each for one
setting or one question:

  if (input_config_get_mouse_index(port) == 0)
  wr->nowinkey = input_config_get_nowinkey_enable();

They join the input_config_get_...() calls that were there. What the
drivers depend on is that list; the layout of the settings is the
frontend's business. Each call sits under the condition its setting
has, and answers with the default before the settings are loaded,
which is what the drivers' own checks for that did.

Twenty-eight reads are converted, in thirteen files: the mouse index
in the SDL 1.2, SDL2, SDL3, DirectInput and X11 input drivers; the
Windows key, background keyboard, overlay and joypad driver in the raw
input and DirectInput drivers; XInput and Player Lights in the raw
input joypad driver; the rumble gain in the udev, SDL3 and Dingux
joypad drivers; the profile directory and system keyboard for SDL3;
the keyboard layout for xkb; the test drivers' scripts.

The samples that link a driver without the frontend get the calls from
one shared header, samples/input/input_config_stubs.h, which reads
their own settings.

Left, in tools/input_state_grab_check.py: 35 in 12 files - Android,
Apple, the consoles, udev's touch options, the replay code, and the
SDL2 input driver taking the video driver's window.

Built for Linux, Windows and Android; the bridge, udev, X11 and raw
input tests and the frontend harness pass.
2026-10-05 03:43:44 +02:00
LibretroAdmin 86f273d1bd input: the input code stops reaching into the video driver's state
The other direction of 5fd9105fb. input/ took video_state_get_ptr()
and worked on the video driver's fields: the overlay code read the
core's geometry and the output's size, fetched the overlay interface
and the driver's data, and showed and hid the mouse cursor through the
poke interface; the two test drivers read the frame count.

Those are calls into gfx/ now:

  video_driver_get_frame_count()
  video_driver_get_core_geometry()
  video_driver_show_mouse()
  video_driver_get_overlay_interface()   the interface and its data

and video_driver_get_output_dims(), which was there already.
video_driver_overlay_interface(), a static in input_driver.c that
reached into the video state from the input side, is the fourth of
these, moved to where the state is.

One file is left: the Android input driver, which creates and destroys
the window surface on the app's lifecycle events and names the video
state seven times doing it. That is lifecycle code that wants moving
as a piece, and running on a device, so it is not in this. A step in
the input samples workflow fails if any other file under input/ names
video_state_get_ptr.

Nothing is meant to behave differently. The three on-screen overlay
tests (overlay shown, overlay with the menu and mouse, LED packs;
threaded video off and on) pass on an X11 and GL build of this; the
overlay texture test and the frontend-overhead harness pass;
video_driver.c and input_driver.c compile for Windows and through the
Android unity build.
2026-10-03 05:44:27 +02:00
LibretroAdmin 030404f435 input: pack a keybind's label, key and valid flag into one word
msg_hash_enums needs 16 bits, retro_key tops out at RETROK_LAST so 15
is generous, and valid is a flag, so the three share one word and
struct retro_keybind packs to 20 bytes with no padding. Two full bind
sets exist per user, which is thousands of instances, and whole sets
are copied on every remap and autoconfig apply.

The default tables hand the three to RETRO_KEYBIND_PACK() rather than
listing them positionally; everywhere else reads and writes them
through the accessors.
2026-09-12 11:29:37 +02:00
LibretroAdmin df29e6046f tools: fail a .c that uses strlcpy without including compat/strl.h
modeline_edid.c called strlcpy with no <compat/strl.h> and reached
master: glibc 2.38 declares strlcpy and strlcat itself, so it built
clean here and passed both syntax-check passes, while MXE, clang and
the webOS toolchain - which have only libretro-common's declaration -
did not. Neither pass could have caught it, since both ask the host's
headers what exists.

A grep can, and does not care what the host provides: a .c that uses
strlcpy, strlcat, strlcpy_lit, strlcat_lit or strcasestr must include
the compat header itself rather than lean on whatever a project
header dragged in, which is the standing rule anyway. It runs as pass
0 of tools/mingw_syntax_check.sh, so it fires on the files being
checked before delivery and costs nothing.

Fourteen files were leaning on the transitive declaration and now
include it directly: the font driver and its freetype renderer, the
widgets, vulkan_common, the GX2, PS2 and OGA drivers, the Android
display server, the screensaver and cancel callbacks, the audio
driver, the test input and joypad drivers, and the webOS Wayland
helper. No behaviour changes; the ones this host can build were
checked, and the failures that remain there are the ones master
already had.
2026-09-11 08:30:20 +02:00
libretroadmin 8c7b823ac3 rjson callers: fix filestream_read_file failure check
1dfed08090 converted five small-file rjson readers from the
stat + open + chunked-callback pattern to filestream_read_file()
+ rjson_open_buffer(), on the premise that "filestream_read_file's
failure covers missing files".  It does, but not the way the
conversion tested for it: the function returns 1 on success and 0
on failure - never a negative value - and all five call sites
checked '< 0', a condition no return value satisfies.

The failure branch was therefore dead.  For any content whose
record file does not exist - which is the common case the commit
message itself called out - the reader sailed past the check with
buf == NULL and len == 0, handed that to the parser, and logged a
JSON format error for a file that was never there:

  [WARN] [Disk index file] Error parsing disk index file: "...".
  [ERROR] [Disk index file] Error: Invalid JSON at line 1,
  column 1 - reached end without any data.

Reported against the disk index record (single-disc content never
writes one, so every load logged the pair), but all five readers
were affected the same way: the runtime log spams one per playlist
entry without recorded runtime, and the test input drivers and
Remote RetroPad lose their quiet no-file path.  Worse than the
noise: on the exists-but-unreadable branch filestream_read_file
documents len as unspecified (in practice -1), and the missed
check would have sent (size_t)-1 as a buffer length into the
parser alongside a NULL buffer.

Test the return as the boolean it documents and every other caller
in the tree already treats it as.  The failure branches behave as
the conversion intended: silent return for a missing file,
path_is_valid classifying the failure worth logging otherwise.

Verified: all five translation units rebuilt clean; standalone
harness over file_stream + rjson confirms a missing file now takes
the quiet branch, a present record parses to RJSON_DONE, and that
the old '< 0' check misses both failure shapes.
2026-08-16 09:37:31 +02:00
LibretroAdmin 1dfed08090 rjson callers: read small JSON files whole instead of stat + chunked
Audit of every rjson / rxml call site's surrounding file I/O,
following the codecs' decoupling.  The rxml side needs nothing:
its production consumers parse buffers that arrive without the
adapter (logiqx through the scanner's budgeted incremental read,
natt from network payloads), and the filestream adapter is used
only by the sample harness and the treehash tool.  On the rjson
side, the large streaming consumers are already shaped right -
playlist, core info cache and the explore state read through
buffered (and RZIP-aware) streams with no redundant pre-open
checks, cloud sync opens tolerantly with no extra stats, and the
writer flushes in buffered chunks - but the small-file readers all
shared one wasteful pattern: stat the path (path_is_valid), open
it, let the stream adapter fstat it again for io block sizing,
then read a few hundred bytes through the chunked callback
machinery.

Five readers convert to filestream_read_file() +
rjson_open_buffer(): the runtime log (the hot one - playlist
sublabels showing per-core runtime build one of these per entry),
the disk index record, the two test input drivers, and the Remote
RetroPad core (the latter three being the reference code this
pattern kept getting copied from).  One open/size/read/close per
file, parse from memory, no callback crossings - and the
up-front stat is gone: filestream_read_file's failure covers
missing files, and path_is_valid now runs only inside the failure
branch to decide between the old quiet no-file path and the old
error message, so every log line and return value is preserved
while the common case pays one filesystem operation less.  These
files are a few hundred bytes to a few KB and always parsed in
full; holding them in memory for the parse is what the parser's
own input buffer was already doing, minus the chunking.

Verified: strict declaration-placement gates clean on the C89
TUs; the net-retropad translation unit syntax-checked standalone;
full Linux build links with HAVE_QT=1; no rjson_open_filestream
readers remain outside the write-side handles the buffered writer
still streams through.
2026-08-15 06:11:52 +02:00
LibretroAdmin fe5dd9217e rjson: move file I/O out of the codec
The contract for libretro-common/formats is that a codec imposes no
file I/O through its interface: parsing and writing run over
caller-supplied buffers or caller-supplied callbacks, and how bytes
reach the parser - filestream, intfstream, or anything else - is
the caller's decision, not the format's.  rjson violated it four
ways: rjson_open_stream / rjson_open_rfile and their writer
equivalents lived inside rjson.c, coupling the codec translation
unit to both stream layers for the sake of four thin shims.

The shims move to a new opt-in, header-only adapter
(formats/rjson_stream.h) as static INLINE functions with names that
say what they couple to: rjson_open_intfstream /
rjson_open_filestream and the rjsonwriter equivalents, preserving
the size-scaled io block heuristic.  Including the adapter couples
the including translation unit - and only it - to the stream
layers; rjson.c and rjson.h now reference no I/O at all, and a user
with their own I/O wires rjson_open_user / rjsonwriter_open_user
directly, exactly as the in-tree callers now demonstrate.

All sixteen call sites across the nine in-tree callers migrate
mechanically (core_info, net-retropad, disk_index_file, the two
test input drivers, menu_explore, playlist, runtime_file,
cloudsync).  One latent bug surfaced: rjson.c used INLINE while
reaching retro_inline.h only transitively through the stream
headers it no longer includes; it now includes it explicitly.

Verified: rjson.c passes the strict C89 gate standalone (it could
not before - the missing include was masked); full Linux build
links with HAVE_QT=1; strict gates clean on the migrated C89
callers; net-retropad translation unit syntax-checked; no
remaining references to the removed constructors anywhere in the
tree.
2026-08-15 05:51:06 +02:00
libretroadmin e20a598f93 test input: allocate the key matrix with the step array
The test input driver's keyboard matrix - eleven kilobytes across
pads and keycodes - was the last static of the test-driver family
still resident in every default binary. It now allocates alongside
the step array when the driver starts and frees on teardown, with
the keyboard clear running before the free and guarding an absent
matrix.
2026-07-07 16:46:56 +02:00
libretroadmin caddb4f067 input tests: allocate the step arrays when the feature starts
The test joypad driver, test input driver and built-in net-retropad
core each held a static two-hundred-step array - 54, 54 and 411
kilobytes - and the test drivers ship by default, so every binary
carried 520 kilobytes of test scaffolding in bss. On platforms with
demand paging untouched bss is free; on the consoles without it -
exactly where memory matters - bss is cleared at load and fully
resident. The arrays are now allocated when the driver or core
actually initializes and freed on teardown, taking the binary's bss
from 1620 to 1100 kilobytes. Both validation dumps byte-identical.

The same census flags the cloud-sync state at 297 kilobytes and the
Discord queue at 197 as the next candidates of this class.
2026-07-07 16:10:55 +02:00
U-DESKTOP-SPFP6AQ\twistedtechre 2effea9b34 More string_is_empty removal pt. 3 2026-04-07 07:23:12 +02:00
sonninnos b2ca569521 Logging unification cleanups 2025-07-10 05:59:06 +03:00
sonninnos 0785dd7548 Unused variable cleanups 2025-06-15 05:08:24 +03:00
LibretroAdmin f6006ae6ca Style nits 2025-02-12 10:17:35 +01:00
LibretroAdmin 47d888364d Standardize len variables - argument should always be named 'len',
while local len variables should have '_' prefix
2025-01-13 21:53:49 +01:00
libretroadmin b8391e233f * PATH_MAX_LENGTH redefined from 4096 to 2048
* Massive reduction in heap space allocation, going from settings struct
264kb to 119Kb
* Use NAME_MAX_LENGTH for base paths/names, etc
* Use DIR_MAX_LENGTH for directory sizes
2024-09-09 05:47:32 +02:00
zoltanvb 7db9a2de60 Test input driver and sensor test screen
A new input driver (test_input), similar to test joypad driver.
Takes its inputs from a json file provided in options. Supports
keyboard input and sensor input (accelerometer, gyroscope,
illuminance).

Remote Retropad extended with a sensor test screen.
2024-07-06 13:55:55 -05:00