Commit Graph
308 Commits
Author SHA1 Message Date
ZengGengSen b80f67d383 input: preserve relative mouse motion between polls (#2593)
## Changes

- Accumulate relative mouse movement until it is read and consumed by an
input mapping.
- Maintain an independent read position for each `InputRelative`
binding.
- Synchronize relative input positions when input bindings or mouse
capture state changes.
- Apply the same relative-motion handling to the Raw Input, NSEvent, and
Xlib mouse drivers.

## Motivation

In my testing, `InputManager::poll()` is called approximately once every
8ms on my system, with observed intervals generally no shorter than 5ms.
At 60Hz, each frame lasts approximately 16.67ms, so input is normally
polled twice per frame.

Each poll retrieves the mouse-axis movement accumulated during the
preceding approximately 8ms. However, emulator cores generally read
relative input only once per frame. This means that `InputManager` may
complete its second poll before the core reads the movement value.

The previous implementation retained only the mouse-axis movement
reported by the most recent poll. The second poll therefore overwrote
the result of the first, allowing the core to observe only the movement
from the latest approximately 8ms. Mouse movement from the earlier
approximately 8ms of the frame was lost.

This change accumulates all relative mouse movement produced between
consecutive core input reads. As a result, even when
`InputManager::poll()` runs multiple times within a single frame, the
core can still retrieve the complete mouse-axis movement accumulated
during that period.
2026-07-30 20:29:09 +01:00
ZengGengSen 53ba720c8d ruby: normalize Windows Raw Input mouse motion (#2592)
## Abstract

Support the absolute mouse movement events in the native input driver
for Windows.
Modifications:

- Convert the absolute original input coordinates to relative motion
increments;
- Handle the coordinate spaces of the main desktop and virtual desktop
while maintaining independent absolute coordinate positions;
- Add locking in the `poll` function to prevent partial data loss in the
event of multi-threaded competition.

## Reasons 

When I used 'Windows Remote Desktop Connection' for remote debugging, I
found that 'win raw input' did not provide the corresponding 'relative
mouse event'. Since 'ruby' ignored the 'absolute mouse event', the input
relying on the mouse (such as the crosshair of a gun sight) could
receive key operations, but it was unable to move.
2026-07-29 10:25:01 +01:00
Stefan Schlosser 6dc3f3306c ruby: improve SDL3 audio performance
Some platforms experienced very poor performance with the SDL3 audio
driver, especially in combination with a demanding core like the N64.
It is assumed that SDL couldn't keep up filling the output device buffer
with the audio data from the input queue buffer. Increasing the amount
of generated input data before feeding it to the device buffer has shown
to greatly improve the performance.

This sparked the following idea and change to how the SDL3 audio driver
fills its buffers: request a fixed-sized 10ms device buffer and apply
the latency to the input buffer, i.e. the input buffer holds a multiple
of 10ms worth of audio. This allows SDL to steadily consume audio from
the input buffer and feed it into the 10ms device buffer, while the user
can still control the latency.

Additionally add the value 30 to the possible latency options. This
allows users to specify a lower latency than 40 if 20 is just a tiny bit
shy of being good enough.
2026-06-24 15:43:37 +01:00
remutro 7032bc6ef0 Complete SDL device enum and settings reorganization 2026-06-12 19:04:14 +01:00
remutro 4ceadb9549 SDL device enum, starting moving settings 2026-06-12 19:04:14 +01:00
remutro 2ce75dde67 Restore audio device setting 2026-06-12 19:04:14 +01:00
remutro c3c2b79015 Squash audio abstractions into a single audio struct 2026-06-09 13:32:43 +01:00
remutro 8c41639a76 Increase bytes to wait in SDL audio to help performance 2026-06-09 13:32:43 +01:00
remutro 8bcb10f36b Minor cleanup 2026-06-09 13:32:43 +01:00
remutro 0ec4b5f953 Remove plugin related functions, add SDL build 2026-06-09 13:32:43 +01:00
remutro e70cb9fb58 SDL fixed 10ms latency 2026-06-09 13:32:43 +01:00
remutro 40474c4987 Fix MacOS build 2026-06-09 13:32:43 +01:00
remutro 53d8b81ade Update non-windows cmake files 2026-06-09 13:32:43 +01:00
remutro bb3c36cd96 Delete unused files 2026-06-09 13:32:43 +01:00
remutro 5ee7e9a5ba Make SDL the only available audio & controller input driver 2026-06-09 13:32:43 +01:00
remutro 0aafd85789 Fix build warning 2026-05-28 13:42:30 +01:00
Luke Usher 67b0bf7aac ruby: improve SDL audio sync on non-stereo devices
Use the application stream format rather than the physical device format.

Some outputs, such as HDMI/TV devices with Dolby processing enabled,
may expose a multichannel device format even though ares is submitting
stereo float audio to SDL. Using the device format for queue sizing and
drain timing could make the blocking sync path sleep for the wrong
amount of time, causing the emulator to run too slowly.

General cleanup:
 - avoid heap allocation for every audio packet
 - add proper failure checks
 - correctly teardown SDL_Audio on shutdown
2026-05-28 08:47:04 +01:00
Luke Usher c7d667fa07 ruby: fix keyboard mappings on macOS by adding missing left/right modifier keys 2026-05-25 11:36:27 +01:00
Luke Usher 54fc194182 desktop-ui: persist SDL joypad mappings by GUID slot
Add an optional stable text identifier to HID devices and use it for
persisted input mappings when available.

SDL joypads now expose a GUID/slot identifier, so newly saved controller
mappings no longer depend on SDL serial or device path values that can
change across disconnects, reconnects, or app launches. This keeps
multiplayer controllers distinguishable by assigning slots per matching
GUID while avoiding unstable path-derived IDs.

The input mapping parser remains backward compatible with existing
numeric 0x<deviceID>/<group>/<input> mappings. Drivers that do not set a
stable identifier continue to save and load mappings using the existing
numeric HID device ID format.
2026-05-24 17:38:35 +01:00
Luke Usher 164f5648bf ruby: stabilize joypad identity and duplicate device handling for the SDL driver 2026-05-21 14:45:20 +01:00
remutro b9f8347d57 Update libchdr to version 0.3.0 2026-05-11 10:56:14 +01:00
ZengGengSen 1ce484be52 cmake: add FindXAudio2 module and fix debug symbol detection on MinGW
Add cmake/finders/FindXAudio2.cmake to replace the ad-hoc XAudio2
link logic in os-windows.cmake. On MinGW, the module uses
check_cxx_source_compiles to probe for xaudio2_9 and xaudio2_8 in
the sysroot; on MSVC and other toolchains the Windows SDK umbrella
library is used directly. An imported target XAudio2::XAudio2 is
exported so call sites need no platform conditionals.

Replace the generator-expression-based -gcodeview selection in
compilerconfig.cmake with an explicit check_cxx_compiler_flag probe
at configure time (ARES_COMPILER_SUPPORTS_GCODEVIEW). This avoids
passing -gcodeview to toolchains that do not support it and makes
the fallback to DWARF visible in the configure log rather than
silently resolved at build time.

- ruby/cmake/os-windows.cmake: call find_package(XAudio2) and
  consume XAudio2::XAudio2 via a generator expression; remove the
  old MSVC/else block that unconditionally linked xaudio2/xaudio2_9
- cmake/windows/compilerconfig.cmake: add -gcodeview capability
  probe; rewrite Clang and GCC debug-symbol blocks to branch on the
  cached result instead of a generator expression
2026-03-17 16:11:06 +00:00
remutro b15ce04e5d XAudio2 latency adjustment 2026-03-10 10:52:42 +00:00
awsms 5a80359443 ruby(audio): enable SDL_HINT_NO_SIGNAL_HANDLERS to avoid ctrl+C hijacks 2026-03-06 10:07:23 +00:00
awsms 67163a9fbe ruby: enable SDL_HINT_NO_SIGNAL_HANDLERS to avoid ctrl+C hijacks 2026-03-05 13:56:48 +00:00
remutro 0d1c90c616 Remove OpenGL macOS Video Driver 2026-03-04 13:06:56 +00:00
remutro fac53a08ca Windows OpenGL 4.6 Core Profile Driver 2026-02-08 17:31:32 +00:00
remutro 25482bc539 Single xaudio2 source file, fix vector calls in asio.cpp 2026-01-19 14:34:34 +00:00
remutro 847e2a24cf Fix silly mistake 2026-01-19 14:34:34 +00:00
remutro 514933d459 Fix MSVC Linking 2026-01-19 14:34:34 +00:00
remutro 04e4f0ffa0 Fix MSVC builds 2026-01-19 14:34:34 +00:00
remutro 109c669056 Update XAudio2 from 2.1 to 2.9 2026-01-19 14:34:34 +00:00
Luke Usher 538078f6d0 ruby: prefer 'metal' video driver as both optimal and safest on macOS. 2026-01-07 10:11:43 +00:00
Luke Usher 2a4be17f56 ruby: remove erroneous include 2026-01-06 23:15:36 +00:00
Luke Usher 23cd8772f5 ruby: allow drivers to set controller names and use deterministic device id in SDL driver 2026-01-06 12:09:44 +00:00
remutro 934e9d36c3 Update dependencies (post-v147) 2026-01-02 16:21:26 +00:00
Giovanni Bajo 90b6c0902d stdc++: remove nall::shared_pointer, now unused 2025-10-02 14:19:44 +01:00
Giovanni Bajo 4e1b4b79ef stdc++: start migrating nall::shared_pointer to std::shared_ptr 2025-10-02 14:19:44 +01:00
Giovanni Bajo fc36600a6a stdc++: convert nall::unique_pointer to std::unique_ptr 2025-09-29 14:24:14 +01:00
Giovanni Bajo 038bcb91c2 stdc++: migrate nall::function to std::function 2025-09-29 14:24:14 +01:00
Giovanni Bajo cdbc88f92e stdc++: ruby: fix freebsd build 2025-09-16 06:42:29 +01:00
Giovanni Bajo ff8bdbcdc6 stdc++: add vector-helpers merge/split; migrate includes; use merge() in N64 disassemblers; std::vector<string> split 2025-09-08 14:32:44 +01:00
Giovanni Bajo 247dd180ce stdc++: fixes from review 2025-09-02 22:04:32 +01:00
Giovanni Bajo 9ad89d134e stdc++: use range syntax in more places 2025-09-02 22:04:32 +01:00
Giovanni Bajo 92fe0d2e44 stdc++: Introduce range-helpers and nall::index_of. 2025-09-02 22:04:32 +01:00
Giovanni Bajo 864ca3d91e stdc++: C++20 compactness pass (branch-local):
- Use std::erase and ranges::find where shorter.
- Replace ranges::distance with iterator subtraction.
- Enable <ranges> in hiro core/extension; use views::reverse for reverse-destruction loops.
- Minor cleanups (array_view ctor from vector, build fixes).
2025-09-02 22:04:32 +01:00
Giovanni Bajo 89be74aab5 stdc++: Apply changes from review 2025-09-02 22:04:32 +01:00
Giovanni Bajo 24c5e367cc stdc++: Fix CI: map remaining vector-only APIs to std::vector equivalents: gtk keyboard keycodes push_back; windows menu-bar use erase/push_back and clear; WASAPI/XAudio2/WaveOut: use std algorithms and front()/empty() instead of vector truthiness/first/find; compute indices explicitly. 2025-09-02 22:04:32 +01:00
Giovanni Bajo 3eeecf1cc2 stdc++: Fix CI: std::vector<bool> copy; BrowserDialog truthiness; replace remaining .append/remove/reset in joypad/combo/icon-view; GTK TabFrame tabs as std::vector; ALSA/OSS device selection via std algorithms; fix reverse iteration and setSelected signature. 2025-09-02 22:04:32 +01:00
Giovanni Bajo 31380a1976 stdc++: ruby: migrate nall::vector to std::vector; mechanical API alignment
- Replace nall::vector with std::vector across ruby (audio/input) and hiro glue; update overrides to std::vector.

- Map vector APIs: append/reset/remove/truthiness -> push_back/clear/erase/empty(); adjust DropPaths guards and BrowserDialog callers.

- Fix Windows/GTK fallout: DropPaths checks and Windows TableView indexing; Keyboard::poll returns std::vector<bool>.

- Source-only commit; excludes build outputs and submodules.
2025-09-02 22:04:32 +01:00