Commit Graph
90 Commits
Author SHA1 Message Date
Rob Loach fcc219b172 sdl3: vsync, device reopen and input fixes 2026-10-28 14:48:06 +01:00
25ed47e118 input_keymaps: check the keysym lookup table allocation (#19748)
* input_keymaps: check the keysym lookup table allocation

input_keymaps_init_keyboard_lut wrote into the calloc'd lookup table
without checking it. On failure, leave the table empty; the lookup
already falls back to its slow path when the table is NULL.

Tests: none run; no harness links input_keymaps.c. RetroArch builds with the change and the file compiles without warnings.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* input_keymaps: test the keysym reverse table without memory

samples/input/keymaps_lut compiles input/input_keymaps.c into the test
with calloc() routed through it and checks that every mapped code
translates the same with the reverse table, with its allocation
failed, and with a map too wide for one. It also builds with mingw.

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: LibretroAdmin <[email protected]>
2026-10-09 04:56:00 +02:00
LibretroAdmin cb20568114 input: a driver for the keyboard and mouse from plain Win32
"win32": the keyboard and the mouse from the window and the oldest
calls of the Windows API. Raw input needs Windows XP and DirectInput 8
needs DirectX 8; a build for Windows 95 or NT 4.0 had neither, so it
had the null input driver and could not be given a key.

- Keys. The window procedure sees every key go down and come up and
  already turns each into a scancode for the key events it sends. It
  tells this driver the same (win32_input_key_message(), one call
  where the scancode is worked out): a bit a scancode. The window can
  be the video thread's, so the bits are atomic words - set and
  cleared there, loaded at the poll - and nothing is locked. The
  frontend asks for the keys it has binds for once a poll
  (keys_down), as it does of the other keyboard drivers.
- Its key map (rarch_key_map_win32) is DirectInput's in numbers:
  scancodes, the extended keys with 0x80 added. No DirectX header.
- Mouse. Where the cursor is in the window at each poll, and its left,
  right and middle buttons (GetAsyncKeyState(), the two swapped where
  the user has them swapped), published for the frontend to answer the
  mouse, the pointer and the lightgun from.
- Only while the window is the foreground one. Without it nothing is
  down, and a key held when the window lost the foreground is not down
  when it has it back.

What it does not have: a wheel, buttons four and five, motion past
the screen's edge (motion is how far the cursor went), a grab. And no
controllers - that is a joypad driver's, and the one for these
Windows, the multimedia library's joystick calls, is not written yet.

Built where HAVE_WIN32INPUT is defined (HAVE_WIN32INPUT=1), which
nothing turns on by default but the Visual C++ 6 project in the
commit after this. It is chosen by name, or where neither raw input
nor DirectInput is built or starts.

Run: the Windows build with it compiled in, under Wine, through the
scripted keyboard session - the core sees the same 63 lines with
"win32" as with "dinput", and DirectInput's own are the same as
before this. samples/input/win32_input runs the driver against a
real window under Wine: the key map both ways, keys down and up, an
extended key against the keypad key under it, the top bit of a word,
nothing down with another window in front, the mouse's place and
motion. Not run on a Windows machine, of any age.
2026-10-07 15:15:15 +02:00
LibretroAdmin f4ac9970fb gekko: USB keyboards on the Wii
Boot protocol HID keyboards on the Wii's USB ports type into the menu
and cores and drive the keyboard binds.  os/gekko finds them among the
HID devices IOS lists, sets the boot protocol and turns their reports
into connect, key and disconnect events; the gx input driver turns
those into key events and key state, US layout for characters.  The
HID pad driver leaves keyboards awake.  The USB HID usage key map is
shared with the Wii U as rarch_key_map_hid.
2026-10-03 22:58:07 +02:00
Rob Loach 8024e84c3f Add SDL3 video and input drivers 2026-08-03 05:30:30 +02:00
BinBashBananaandlibretroadmin c464c6620a Emscripten libretro-common fixes, use __EMSCRIPTEN__ (#19297)
* Emscripten libretro-common fixes

* memmap: gate the reserve/commit path off for emscripten instead of dropping mman

Emscripten was added to the "No mman available" platform list in
memmap.h, which reaches further than intended. That branch does not
just disable things: it makes memmap.c define mmap(), munmap() and
mprotect() as global symbols with malloc/free semantics on a platform
whose libc already provides working ones, and it declares mmap() with
a size_t offset where <sys/mman.h> uses off_t, so any translation unit
that pulls in both headers gets conflicting declarations. The shim's
mmap() also ignores fildes and offset, so a file-backed request would
return uninitialised memory; that is invisible today only because
Makefile.emscripten never sets HAVE_MMAP and the mapping path in
vfs_implementation.c is therefore compiled out.

What is actually unusable on emscripten is the reserve/commit model,
and that is unusable by construction rather than by omission: a wasm
linear memory grows monotonically, is committed in full, and has no
unmap, no shrink and no page protection. An anonymous PROT_NONE
mapping is a memalign of the whole length followed by a memset over
it, so memreserve() commits and touches every byte the reservation
existed to avoid, mprotect() and madvise() cannot make commit or
decommit mean anything, and munmap() only accepts an exact length
match, so the range cannot be released. Opening large content through
data_transfer would allocate the whole file up front and never give it
back.

Leave memmap.h alone and gate MEMMAP_HAVE_RESERVE instead, so
mempagesize() reports 0, memreserve() returns NULL and callers take
the bounded-allocation fallback they already have for platforms
without virtual memory. memsync() is excluded from the msync() branch
for the same reason: emscripten's msync() only accepts the exact base
of a live mapping and returns -EINVAL for an arbitrary range, while a
wasm linear memory has no separate instruction cache to flush, so the
fallthrough's 0 is both correct and the only honest answer.

mmap(), munmap(), mprotect() and memprotect() keep working through
libc as before.

* memmap: round memrelease() to the page size memreserve() rounded to

memreserve() rounds the requested length up to a whole number of pages
and maps that, but memrelease() passed the caller's unrounded length
straight to munmap(). Linux rounds the length up internally so the
mismatch is invisible there, which is how it survived; an
implementation that takes the length literally and declines a partial
unmap fails the call outright and leaks the entire reservation
whenever the length was not already page-aligned.

Apply the same rounding on the way out. mempagesize() is non-zero
wherever this branch compiles - MEMMAP_HAVE_RESERVE is only defined
when _SC_PAGESIZE is available - but the guard costs nothing and keeps
the expression from dividing the range by zero if that ever changes.

* Revert "memmap: gate the reserve/commit path off for emscripten instead of dropping mman"

This reverts commit 11b85a9421.

* Fix remaining uses of EMSCRIPTEN define

---------

Co-authored-by: libretroadmin <[email protected]>
2026-08-03 04:56:58 +02:00
U-DESKTOP-SPFP6AQ\twistedtechre a1d4129408 dxsdk: add SAL compatibility shim for MSVC 2003 through 2010
The bundled DirectX headers in gfx/include/dxsdk/ are modern Windows
8.x/10 SDK headers and use SAL annotations throughout their function
prototypes. These annotations come in two generations:

  * SAL 1 (double-underscore): __in, __out, __inout, __in_ecount,
    __out_bcount, __deref_out, etc.
  * SAL 2 (leading underscore + trailing underscore): _In_, _Out_,
    _Inout_, _In_reads_(s), _Out_writes_bytes_(s), _COM_Outptr_,
    _Always_(x), _Outptr_opt_result_maybenull_, etc.

Older Microsoft toolchains ship incomplete or nonexistent sal.h:

  * MSVC 2003 (_MSC_VER 1310): no sal.h at all. Both SAL 1 and SAL 2
    macros are undefined.
  * MSVC 2005 (_MSC_VER 1400) and MSVC 2008 RTM (_MSC_VER 1500): sal.h
    has SAL 1 only.
  * MSVC 2008 SP1 and MSVC 2010 (_MSC_VER 1600): sal.h ships a partial
    SAL 2 set (_In_, _Out_, _Inout_, etc.) but is missing the
    buffer-size, COM-outptr, and wrapper families.
  * MSVC 2012+ (_MSC_VER >= 1700): full SAL 2 in sal.h.

Without definitions for these macros, the preprocessor treats them as
unknown identifiers and every function declaration that uses one fails
to parse, producing cascades like:

  error C2143: syntax error : missing ')' before 'type'
  error C2081: '_COM_Outptr_' : name in formal parameter list illegal

Add gfx/include/dxsdk/dxsdk_sal_compat.h which stubs out the missing
SAL 1 and SAL 2 macros to empty (or to a pass-through for wrapper forms
like _Always_(x) / _When_(c,x)) so declarations using them parse as
plain C. The shim is structured in four tiers:

  * Skip the whole thing on MSVC 2012+ via _MSC_VER < 1700 gate.
  * Skip #include <sal.h> on MSVC 2003, where the header does not
    exist, via a _MSC_VER >= 1400 gate.
  * Stub the SAL 1 family, guarded per-macro with #ifndef so MSVC 2005
    through 2010 (which already have them) leave them untouched and
    MSVC 2003 gets working definitions.
  * Stub the SAL 2 family the same way, filling in whatever the
    toolchain is missing without redefinition warnings.

Every macro is wrapped in #ifndef to avoid C4005 redefinition warnings
on toolchains that ship a partial SAL set.

Include the shim from the three bundled headers that tripped MSVC 2008
in griffin builds:

  * gfx/include/dxsdk/d3dcommon.h
  * gfx/include/dxsdk/d3d11shader.h
  * gfx/include/dxsdk/d3dcompiler.h

The shim's outer include guard makes repeat inclusion free, so if
additional DX headers surface the same errors in future build
configurations they can be added with a one-line #include.

This is a build-only fix. The stubs discard static-analysis
information, which older MSVC versions could not consume anyway.
No behavior change on any supported toolchain.
2026-04-16 14:39:27 +02:00
zoltanvb 24027ab1b3 More DOS updates: (#18700) 2026-02-14 14:01:13 +01:00
zoltanvb cf3c678de5 Fix Enter not working in menu on Android keyboards (#18405) 2025-11-16 20:59:32 +01:00
LibretroAdmin 25edbe17d2 Some UCRT buildfixes 2025-07-18 13:44:56 +02:00
zoltanvb 69a9e05067 Minor Android keymap fixes
Some enhancement possibilities found while investigating another
issue - shift keys were swapped (especially noticeable in menu),
enter may be mapped to DPAD_CENTER by the system, but unfortunately
the 102. key can not be mapped separately.
2025-06-22 21:14:49 +02:00
LibretroAdmin c57c4fbd1a Style nits 2025-02-10 13:59:25 +01:00
LibretroAdmin 31b7812720 Function argument name standardization 2025-01-17 04:16:12 +01:00
Emanuel Haupt 7a0d568f04 Incorporate FreeBSD port patches (#16221)
This commit imports a series of patches from the FreeBSD port of RetroArch to
improve build compatibility and address specific issues encountered in the
FreeBSD environment. These patches, sourced from the FreeBSD Ports collection
(https://cgit.freebsd.org/ports/tree/games/retroarch/files), have been adapted
and tested to ensure they integrate seamlessly with the current build process.
2024-09-10 18:11:40 -07:00
zoltanvb 49aeeee1f7 Cosmetical fix (xvfk -> xfvk), #16631 2024-06-08 11:17:42 -05:00
zoltanvb 198656eb20 Add support for multimedia keys (#16502)
Extended RETROK_ values with 18 new items, commonly found on
"multimedia" keyboards.

Mapping added for SDL, X11, Wayland, dinput, winraw keymaps.

Keyboard tester function of Remote Retropad extended to cover new keys.

One fix in Android mapping for #12986
2024-05-11 17:06:54 -07:00
nfore 9ca5c5e623 Revive/rewrite Keyboard Overlay and OSK Toggle
Add keyboard overlay preset, keyboard submenu, and osk_toggle hotkey. Use overlay caching for osk_toggle.

For now, keyboard menu has only preset path, auto-scale toggle, and opacity.

Related fixes:
- input_keyboard_event: Don't check hotkey binds when device is RETRO_DEVICE_POINTER
- Add input_keymaps_translate_rk_to_ascii() for correct character input to input_keyboard_event
- input_overlay_poll: Delay clearing INPUT_OVERLAY_BLOCKED flag until there is no overlay input (Avoids stray input after osk_toggle)
- Send keyboard events for modifiers before other keys (for correct modifier+key input if hitboxes overlap)
2023-07-09 04:42:49 +02:00
libretroadmin 3f3262fba3 (PS3) Cleanups - don't assume GLSL is the default shader for PSL1GHT 2023-02-23 10:43:33 +01:00
LibretroAdmin 491c495249 Unify ps3 (#15014)
* Unify PS3 input driver

* Fix builds

* Add missing variable

* (PS3/Keyboard) Add more missing defines
2023-02-23 00:35:46 +01:00
libretroadmin daa9e352cc Remove asserts 2023-01-09 00:51:05 +01:00
redenvelope2000 89d9fe9981 Fixed RETROK_LMETA not working on macOS port. (#14538)
The RETROK_LMETA key was not defined in the rarch_key_map_apple_hid[].
2022-10-20 15:59:14 +02:00
LibretroAdmin ace21d28f7 Fix C++ comments 2022-10-01 17:56:16 +02:00
OsirizX c6d51fdb32 [ORBIS] Initial changes for PS4 2022-05-21 16:31:10 +02:00
sonninnos 2c47d94bf5 (WINRAW) Change legacy virtual keys to scan codes 2021-08-04 19:23:56 +03:00
p-sam ac8a977492 Replace deprecated HID APIs 2021-06-28 17:38:17 +02:00
David Carlier 3b7e0a8db1 FreeBSD build fix proposal 2021-05-01 15:37:14 +01:00
sonninnos 1e95683c06 (WINRAW) Key position fixes 2021-03-20 00:58:11 +02:00
myfreeweb 65b1ae8a41 Remove incorrect ifdef for Wayland on non-Linux - fix #10056 2021-01-14 16:36:14 +03:00
Tony Jansson c2e8752395 (DINPUT+WINRAW) Keyboard fixes 2020-10-14 21:23:06 +03:00
jdgleaver 3fa1166ec4 (udev/linuxraw/wayland) Fix return key keyboard input 2020-09-29 11:23:35 +01:00
Matthew Bauer 210dcfbd8c Map libcec-daemon keys to RETROK
From https://github.com/bramp/libcec-daemon, we have some keys that
aren’t recognized by RetroArch right now. So we can map them to actual
RETROK_ codes. They are:

- KEY_EXIT -> RETROK_CLEAR
- KEY_OK -> RETROK_RETURN
- KEY_SELECT -> RETROK_RETURN

See
https://github.com/bramp/libcec-daemon/blob/fe9df5ddf7356daa521f893c16872a09c8e6fb59/src/main.cpp#L233-L312
for a full list
2020-09-06 16:01:12 -05:00
twinaphex 33578eda08 Cleanup 2020-09-05 10:14:19 +02:00
twinaphex cf02814fd4 Remove unused apple_key_name_map 2020-09-05 10:13:06 +02:00
twinaphex 0ef0ceb0e4 Fix C89_BUILD and CXX_BUILD 2020-08-04 14:34:07 +02:00
twinaphex 14647915a1 Add comments 2020-08-04 02:24:06 +02:00
twinaphex 498f31229c Backport
https://github.com/neil4/RetroArch-Lite/commit/fe284542d0a18a5a09e6a8af0d7c02edffd26e0b
-
Added reverse look-up table for better keyboard driver efficiency
2020-08-04 02:23:20 +02:00
Vladimir Serbinenko 5b668ae421 Implement psl1ght keyboard 2020-04-17 00:56:23 +02:00
twinaphex d3bc82d2c3 Header cleanups 2020-03-05 14:12:20 +01:00
twinaphex 09da302b8d Try to make it more portable for BSD 2020-02-16 19:37:59 +01:00
twinaphex 4c69dad0ce Define DEFAULT_MAX_PADS inside config.def.h - get rid of the messy
MAX_PADS macros everywhere
2019-07-19 12:55:38 +02:00
rsn8887 28ef222886 [VITA] Bluetooth mouse and keyboard support 2019-03-22 21:32:59 -05:00
rsn8887 f943688dff [LIBNX] USB keyboard support 2019-03-19 08:43:46 -05:00
Vladimir Serbinenko 2d56ceedfd input_keymaps: Add 102nd key 2019-03-12 23:52:50 +01:00
David Skywalker 347519a4d8 now X11 driver using keycodes instead keysyms, fixes international layouts problems. 2019-01-31 12:50:58 +01:00
Greg V f1e516bfaf keymaps: define 'x11' and 'linux' on any platform with Wayland
Such as FreeBSD
2019-01-01 03:03:29 +03:00
krzys-h b201d669b5 First iteration of UWP support
Enough to kind of run

Working drivers: xinput, d3d11
Still missing: input driver with keyboard support, audio driver
2018-12-28 22:09:22 +01:00
David Walters b592f254b9 Support for "OEM-102" key (usually '\' on Euro keyboards) 2018-09-02 18:24:51 +01:00
Toad King 1e212b4248 use emscripten HTML5 API for keyboard events instead of old JS library 2018-01-13 17:56:00 -06:00
gblues 6904101c44 Clean up trailing whitespace
== DETAILS

Really simple code cleanup, because my editor flags trailing whitespaces
and it's pretty annoying.
2017-12-12 00:24:18 -08:00
Twinaphex 5c5c5ecbdf Revert "udev input: support controlling the menu with a TV remote control" 2017-06-22 20:53:07 +02:00