Commit graph

1315 commits

Author SHA1 Message Date
Admiral H. Curtiss
07c035e659
Core/SystemTimers: Refactor to class, move to System. 2024-01-04 23:35:19 +01:00
Filoppi
e456bef163 Input: Improve Controller Interface devices threading
This specific issue was already addressed by https://github.com/dolphin-emu/dolphin/pull/11635
though I felt like there was something more we could do, and wasn't too happy with the
likelihood of devices update calls being skipped (due to `m_devices_population_mutex` being locked).
2023-12-18 21:45:22 +02:00
Tilka
8cbb2c2e44
Merge pull request #12399 from lioncash/erasing
General: Make use of std::erase_if/std::erase where applicable
2023-12-12 20:54:52 +00:00
Lioncash
ded2d55438 ExpressionParser: Avoid some miscellaneous copies
Just some trivial copies that can be eliminated or turned into moves.
2023-12-12 14:03:41 -05:00
Lioncash
a5bbeb721a ExpressionParser: Mark constructors explicit where applicable
Makes for consistency with the surrounding code.
2023-12-12 14:00:27 -05:00
Lioncash
ea71a76ea9 ExpressionParser: Pass control qualifiers by const reference
These aren't necessarily cheap to copy, since a control qualifier will
have around 3 std::strings inside of it, so passing by value can churn
allocations a little bit.
2023-12-12 13:50:46 -05:00
Lioncash
9aea481e59 ExpressionParser: Make use of std::erase_if 2023-12-12 13:31:58 -05:00
Lioncash
196f8e5123 MappingCommon: Make use of std::erase_if 2023-12-12 13:31:18 -05:00
Mai
ac53766058
Merge pull request #12215 from JosJuice/android-si-devices
Android: Add more GameCube controller types
2023-11-28 19:21:29 +01:00
Dentomologist
2d3bae9c79 SDL: Add default case to switch statement
Fix -WSwitch warning about unhandled enum value SDL_NUM_LOG_PRIORITIES.

log_level is initialized to LNOTICE right before the switch statement so
this doesn't cause any behavior changes.
2023-11-10 12:05:20 -08:00
Jordan Woyak
30ce1f2ec2 ControllerInterface/SDL: Remove Xbox 360 controller disabling hack. 2023-10-26 18:04:11 -05:00
JosJuice
d6c0f8e749 Android: Get profile name from core
To avoid duplicating information between Kotlin and C++.
2023-10-01 18:47:49 +02:00
Admiral H. Curtiss
53df01f7d8
Merge pull request #12172 from ArcaneNibble/sd
Steam Deck: Periodically reenable gyro
2023-09-28 04:10:27 +02:00
get
63467559b2
fmt 10.0.0-10.1.1 compile fixes
Implicit conversion operators and enums was removed for parity with std::format (fce74caa15).
2023-09-21 01:19:23 +02:00
R
860acfb15d Steam Deck: Periodically reenable gyro 2023-09-07 19:56:58 +01:00
Admiral H. Curtiss
2502e412b3
Merge pull request #12117 from JosJuice/config-callback-cpu
Don't call RunAsCPUThread in config callbacks
2023-08-26 16:34:46 +02:00
Admiral H. Curtiss
9a51215af3
Merge pull request #12083 from JosJuice/android-controlled-by-gamepad
InputConfig: Update IsControllerControlledByGamepadDevice for Android input overhaul
2023-08-18 21:27:26 +02:00
JosJuice
7197e3abd0 Use structs for config callback IDs
This way you can't mix up regular config callback IDs and CPU thread
config callback IDs. (It would be rather bad if you did!)
2023-08-17 19:19:26 +02:00
Admiral H. Curtiss
2cbc1e6f3e
Merge pull request #12109 from JosJuice/android-adddevice-null
ControllerInterface/Android: Add null check to AddDevice
2023-08-15 22:22:45 +02:00
JosJuice
1d77bddc3b ControllerInterface/Android: Add null check to AddDevice
The Google Play Console is showing some users getting a crash here,
and indeed, InputDevice.getDevice can return null.
2023-08-15 13:31:18 +02:00
Dentomologist
274b11e4e9 GCAdapter: Fix Android unused constant warning
CONTROLLER_OUTPUT_INIT_PAYLOAD_SIZE is only used by the libusb
implementation.
2023-08-12 20:20:42 -07:00
Dentomologist
77d33d61de GCAdapter: Fix spelling of constants 2023-08-12 20:20:41 -07:00
JosJuice
02b0e287cb InputConfig: Update IsControllerControlledByGamepadDevice for Android input overhaul
This only matters for analytics, but still.
2023-08-01 19:35:55 +02:00
nyanpasu64
5d0f1bd10b Switch libusb_config_descriptor to RAII type 2023-07-05 20:38:22 -07:00
nyanpasu64
c893ccca58 Workaround GC adapter detection breaking when reset fails 2023-07-05 20:38:22 -07:00
nyanpasu64
559a16da49 Reset GC adapter upon IO error after sleep-wake
Fixes GC adapter breaking on sleep-wake on Linux and burning a full CPU
core. This is cleaner than alternative approaches.
2023-07-05 20:38:22 -07:00
nyanpasu64
afb5eff426 Don't burn a CPU core and spam logs when GC Adapter fails 2023-07-05 20:38:22 -07:00
nyanpasu64
54850e936c Fix memory leak in libusb code 2023-07-05 20:38:22 -07:00
Admiral H. Curtiss
fa81006b51
Merge pull request #11955 from TellowKrinkle/CMakeDependencies
CMake: Allow ignoring system packages
2023-06-30 19:06:04 +02:00
Admiral H. Curtiss
5d7b5822c9
Merge pull request #11972 from Minty-Meeo/string-improvements-part-1c
Replace std::ostringstream usage with fmt::format
2023-06-19 02:18:30 +02:00
get
ffabb6c57b Replace std::ostringstream usage with fmt::format 2023-06-18 18:37:32 -05:00
get
80575c4489 DITConfiguration: Use File::ReadFileToString 2023-06-17 19:38:15 -05:00
TellowKrinkle
5b10a80401 CMake: Use targets for all optionally-external dependencies 2023-06-15 01:41:41 -05:00
Dentomologist
527f8e783c ControllerEmu: Convert Translatability to enum class 2023-06-12 18:11:04 -07:00
Admiral H. Curtiss
7845fb00ee
Merge pull request #11681 from iwubcode/asset_management
VideoCommon: migrate texture packs to use the asset loader system
2023-06-08 22:21:12 +02:00
Admiral H. Curtiss
e8c87dc4fd
Merge pull request #11902 from Minty-Meeo/regex-best-practices
static const std::regex
2023-06-08 20:52:11 +02:00
get
1df482d51f Prefer static const std::regex
std::regex has a relatively expensive constructor, and these are unchanging regexes.
2023-06-08 09:39:23 -05:00
iwubcode
e831d7b6bb InputCommon / VideoCommon: remove dynamic input reloading the texture cache, this is no longer needed, assets reload automatically! 2023-06-07 18:30:10 -05:00
JosJuice
71ac6ec239 InputCommon: Don't treat two analog inputs as a spurious trigger combo
I've received a report from an Android user with a gamepad (a "BSP-D3")
where one physical trigger is controlling two analog axes at the same
time. This was causing RemoveSpuriousTriggerCombinations to delete both
axes, which is clearly not a desireable outcome.

With this change, now the axis with the greatest smoothness is kept,
or both in case they have the same smoothness.
2023-06-06 22:07:14 +02:00
Admiral H. Curtiss
38b033a476
Merge pull request #11762 from jbosboom/xinput2-raw-event-query
Xinput2: use raw events and queries
2023-06-06 18:14:51 +02:00
Admiral H. Curtiss
da77084d2f
Merge pull request #11819 from JosJuice/android-input-device-null
ControllerInterface/Android: Use InputEvent.getDeviceId
2023-05-29 19:27:30 +02:00
Jeffrey Bosboom
620955d397 XInput2: Listen to master devices only
A comment removed by this commit gives two reasons for listening to
slave devices, both of which no longer apply:

- "Only slaves emit raw motion events": perhaps this was true when the
comment was written, but now master devices provide raw motion events
along with the other raw events.

- "Selecting slave keyboards avoids dealing with key focus": we get raw
key events regardless of the focus.

Listening to both master and slave devices results in duplicate raw
events.  For button and key events, that's a tiny waste of time setting
the update flag a second time, but for raw mouse events the raw motion
will be processed twice.  That makes this commit a user-facing change.
2023-05-19 14:20:10 -07:00
Jeffrey Bosboom
b2a98c41ee XInput2: Use raw events and queries for buttons and keys
In X, the ButtonPress events generated when a mouse button is pressed
have a special property: if they don't activate an existing passive
grab, the X server automatically activates the "implicit passive grab"
on behalf of the client the event is delivered to.  This ensures the
ButtonRelease event is delivered to the same client even if the pointer
moves between windows, but it also causes all events from that pointer
to be delivered exclusively to that client.  As a consequence of the
implicit passive grab, for each window, only one client can listen for
ButtonPress events; any further listeners would never receive the event.

XInput 1 made the implicit grab optional and explicit by allowing
clients to listen for DeviceButtonPress events without
DeviceButtonPressGrab events.  XInput 2 does not have a separate grab
event class, but multiple clients can listen for XI_ButtonPress on the
same window.  When a button is pressed, the X server first tries to
deliver an XI_ButtonPress event; if no clients want it, then the server
tries to deliver a DeviceButtonPress event; if no clients want it, then
the server tries to deliver a ButtonPress event.  Once an event has been
delivered, event processing stops and earlier protocol levels are not
considered.  The reason for this rule is not obviously documented, but
it is probably because of the implicit passive grab; a client receiving
a ButtonPress event assumes it is the only client receiving that event,
and later protocols maintain that property for backward compatibility.

Before this commit, Dolphin listened for XI_ButtonPress events on the
root window.  This interferes with window managers that expect to
receive ButtonPress events on the root window, such as awesome and
Openbox.  In Openbox, applications are often launched from a menu
activated by clicking on the root window, and desktops are switched by
scroll wheel input on the root window.  This makes normal use of other
applications difficult when Dolphin is open (though Openbox keyboard
shortcuts still work).  Conversely, Dolphin only receives XI_ButtonPress
events for clicks on the root window or window decorations (title bars),
not on Dolphin's windows' content or the render window.  In window
managers that use a "virtual root window" covering the actual root
window, such as Mutter running in X, Dolphin and the window manager do
not conflict, but clicks delivered to other applications using XInput2
(for testing, try xinput --test-xi2) are not seen by Dolphin, which is
relevant when background input is enabled.

This commit changes Dolphin to listen for XI_RawButtonPress (and the raw
versions of other events); Dolphin was already listening to XI_RawMotion
for raw mouse movement.  Raw events are always and exclusively delivered
to the root window and are delivered to every client listening for them,
so Dolphin will not interfere with (or be interfered with by) other
applications listening for events.

As part of being raw, button numbers and keycodes in raw events have not
had mapping applied.  If a left-handed user swapped the left and right
buttons on their mouse, raw events do not reflect that.  It is possible
to query the mappings for each device and apply them manually, but that
would require a fair amount of code, including listening for mapping
changes.

Instead, Dolphin now uses the events only to set a "changed" flag, then
queries the current button and key state after processing all events.
Dolphin was already querying the pointer to get its absolute position
and querying the keyboard to filter the key bitmap it created from
events; now Dolphin also uses the button state from the pointer query
and uses the keyboard query directly.

Queries have a performance cost because they are synchronous requests to
the X server (Dolphin waits for the result).  Commit 2b640a4f made the
pointer query conditional on receiving a motion event to "cut down on
round trips", but commit bbb12a75 added an unconditional keyboard query,
and there have apparently been no performance complaints.  This commit
queries the pointer slightly more often (on button events in addition to
motion), but only queries the keyboard after key events, so the total
rate of queries should be substantially reduced.

Fixes: https://bugs.dolphin-emu.org/issues/10668
2023-05-19 14:20:10 -07:00
Jeffrey Bosboom
46540ea42b XInput2: Request XInput 2.1
We need XInput 2.1 to get raw events on the root window even while
another client has a grab.  We currently use raw events for relative
mouse input, and upcoming commits will use raw events for buttons and
keys.
2023-05-19 14:20:09 -07:00
Jeffrey Bosboom
a902480cb0 XInput2: Make button state a u32
Because we care how many bits it has, not its arithmetic range.  No
functional change on all supported platforms.
2023-05-19 14:20:09 -07:00
Admiral H. Curtiss
50fe493990
Merge pull request #11739 from OatmealDome/iokit-be-gone
InputCommon: Remove OSX (IOKit) input backend
2023-05-19 19:31:40 +02:00
Admiral H. Curtiss
279fcafdc3
Merge pull request #11758 from jbosboom/xinput2-client-pointer
XInput2: Accept input from keyboards other than the first master
2023-05-19 19:29:24 +02:00
Lioncash
a9f1edeb61 StringUtil: Move IsAlpha() into Common namespace 2023-05-16 14:11:02 -04:00
R
c5d2ad99d2 Support Steam Deck controls directly through hidraw
This reads Steam Deck controls bypassing Steam Input. This allows for access to
motion controls as well as independent access to thumb sticks, trackpads, and
back grip buttons.
2023-05-10 13:28:32 +01:00
JosJuice
82f70cdf94 ControllerInterface/Android: Add some missing DeleteLocalRef calls 2023-05-07 18:44:43 +02:00