Commit graph

57 commits

Author SHA1 Message Date
Admiral H. Curtiss
d657ad5932
InputCommon/SDL: Check for errors from SDL_JoystickNumButtons(), SDL_JoystickNumAxes(), SDL_JoystickNumHats(). 2024-01-15 15:18:38 +01:00
Admiral H. Curtiss
959c39133b
InputCommon/SDL: Fix incorrect use of std::vector::assign() and check bounds. 2024-01-15 15:17:32 +01:00
Martino Fontana
51e05f468a SDL: Add GameController API, cleanup 2024-01-13 16:10:25 +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
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
TellowKrinkle
72eadc6520 InputCommon:SDL: Add SDL 2.26 left and right motion inputs 2022-11-24 15:12:07 -06:00
Jordan Woyak
44a4573303 ControllerInterface: Add InputBackend interface and SDL implementation. 2022-11-01 21:59:08 -05:00
Shawn Hoffman
f92541fbd9 StripSpaces: only strip spaces
StripWhitespace maintains old behavior
2022-07-25 18:40:12 -07:00
Admiral H. Curtiss
e79c7d4985
InputCommon: Don't force-link against SDL2.lib on Windows. 2022-07-13 01:37:05 +02:00
Shawn Hoffman
54b4ad8f55 ci/sdl: pump messages for SDL_hidapi so device detection works 2022-07-10 15:39:06 -07:00
Shawn Hoffman
ddf83462ac sdl: enable SDL_HINT_JOYSTICK_THREAD
fixes window message pumping
2022-07-10 15:39:06 -07:00
Shawn Hoffman
dd20c7cf78 ci/sdl: re-add the x360 controller block 2022-07-10 15:39:06 -07:00
Shawn Hoffman
3f7a2c6d4d ci/sdl: minor cleanup 2022-07-10 15:39:06 -07:00
Jun Bo Bi
6cb936d0cf Add SDL motion input and rumble support 2022-07-10 14:49:49 -07:00
TellowKrinkle
994210e369 InputCommon: SDL 2.0.22 init crash workaround
See https://github.com/libsdl-org/SDL/pull/5598
2022-06-14 21:02:45 -05:00
Pokechu22
6e5f4125e3 Use Common::ToLower and Common::ToUpper 2022-01-16 17:00:12 -08:00
Pierre Bourdon
e149ad4f0a
treewide: convert GPLv2+ license info to SPDX tags
SPDX standardizes how source code conveys its copyright and licensing
information. See https://spdx.github.io/spdx-spec/1-rationale/ . SPDX
tags are adopted in many large projects, including things like the Linux
kernel.
2021-07-05 04:35:56 +02:00
Filoppi
2aa941081e ControllerInterface: make SDL use PlatformPopulateDevices()
and avoid waiting on SDL async population being finished for no reason
2021-06-07 11:07:06 +03:00
Filoppi
81092cf7e4 InputCommon: replace SerialInterface log with ControllerInterface
where appropriate. SerialInterface was a leftover from the past,
and makes no sense to be used on actual/real controllers.
2021-05-05 00:16:08 +03:00
Shawn Hoffman
7e1df34735 rename InputCommon/ControllerInterface/Device to CoreDevice 2021-01-27 14:29:48 -08:00
Lioncash
a5e1415e74 InputCommon: Migrate logging over to fmt
Continues the migration of the logging calls over to the fmt capable
ones.
2020-10-23 13:16:18 -04:00
Lioncash
ec60027f56 InputCommon: Use nested namespace specifiers where applicable 2019-06-17 16:51:41 -04:00
Jordan Woyak
0bdfa19650 ControllerInterface: SDL: Replace unclear bool parameter with enum class. 2019-03-17 08:53:53 -05:00
Jordan Woyak
4fb68c530b ControllerInterface: SDL cleanup and FF effect fixes. 2019-03-17 08:53:13 -05:00
Michael M
932ca644aa Add hotplug support to SDL2 controller backend 2018-06-04 17:50:08 +02:00
Michael M
7062967b5b SDLJoystick: store name on creation
Otherwise, Dolphin will crash when the joystick is removed.
2018-06-04 17:49:21 +02:00
Michael Maltese
3e69d066f5 ControllerInterface: replace Reinitialize with RefreshDevices
The SDL backend crashes when you close a joystick after SDL_Quit has
been called. Some backends don't need to be shutdown and
re-initialized everytime, we can just ask to enumerate devices again.
2016-11-30 16:07:55 -08:00
Léo Lam
788e19f54d ControllerInterface: Make the ID assigning code common
This makes the device ID assigning code common to all backends, by
moving it to AddDevice() instead of copy-pasting or replicating
the logic in the backends.

Also, to prepare for hotplugging, instead of relying on a name usage
count, the new ID assigning system always starts from ID 0 and tries
to assign the first ID that is not used.
2016-07-14 10:50:53 +02:00
Léo Lam
8678133e87 ControllerInterface: Switch to std::shared_ptr
Small cleanup by using std::shared_ptr and getting rid of
ciface.Devices() which just returned the m_devices (which defeats the
point of making m_devices protected).

Incidentally, this should make the code safer when we have
different threads accessing devices in the future (for hotplug?).

A lot of code use Device references directly so there is
no easy way to remove FindDevice() and make those unique_ptrs.
2016-06-25 21:46:39 +02:00
Léo Lam
fd29e5c4cc ControllerInterface: Don't pass m_devices to the backends
Previously, the devices vector would be passed to all backends. They
would then manually push_back to it to add new devices. This was fine
but caused issues when trying to add synchronisation.

Instead, backends now call AddDevice() to fill m_devices so that it is
not accessible from the outside.
2016-06-25 13:46:53 +02:00
Pierre Bourdon
3570c7f03a Reformat all the things. Have fun with merge conflicts. 2016-06-24 10:43:46 +02:00
Matthew Parlane
9e1aab663f Revert "SDL: handle SDL_QUIT event" 2015-06-08 13:43:39 +12:00
Tillmann Karras
9ec5a4544f SDL: handle SDL_QUIT event
Using SDL_INIT_JOYSTICK implies SDL_INIT_EVENTS which installs a signal
handler for SIGINT and SIGTERM. There will be a way to prevent this in
2.0.4 but for now we'll need to handle SDL_QUIT.
2015-06-05 19:34:06 +02:00
Tillmann Karras
30ebb2459e Set copyright year to when a file was created 2015-05-25 13:22:31 +02:00
Tillmann Karras
cefcb0ace9 Update license headers to GPLv2+ 2015-05-25 13:22:31 +02:00
Ryan Houdek
817abdd579 Remove an assumption in SDL.
We can compile with haptic support, and then not initialize due to haptics not being available.
So if we are compiling with haptics, test initializing with haptics and if that fails attempt to initialize without haptics before bailing out.
2015-01-19 16:07:28 -06:00
Adam D. Moss
3300c176e4 SDL haptic: minor style change based on review feedback 2015-01-13 16:00:35 +00:00
Adam D. Moss
076c2b8ec7 SDL input: unhardcode a few values.
& change effect length to half a second instead of infinite, in futile attempt to avoid runaway rumbles.
2015-01-11 11:57:48 +00:00
Adam D. Moss
63660cb17c SDL Input: More minor refactoring of SDL haptic effects 2015-01-11 11:42:30 +00:00
Adam D. Moss
f47cce2210 SDL: Refactor the SDL haptic effects a little. 2015-01-08 15:17:29 +00:00
Karol Herbst
17ad68ff86 SDL: more global memset 2015-01-08 13:37:06 +01:00
Adam Moss
306c8d14db SDL Input: Support more types of force feedback for controllers through SDL. 2015-01-06 19:17:43 +00:00
comex
fba3abe4cf Manually revert d34418100b 2014-12-20 00:33:15 -05:00
Jasper St. Pierre
1b3d0173f5 SDL: Apply updates immediately rather than going through UpdateOutput
We're going to remove UpdateOutput as it's redundant, and horribly
complicates the code.
2014-11-28 10:54:03 -08:00
Jasper St. Pierre
f2787f620e ControllerInterface: Make UpdateInput / UpdateOutput return void
The return values here have never been checked, so it doesn't make sense
to return a value to begin with.
2014-11-28 10:50:45 -08:00
Rachel Bryk
5adbc83453 Change ControlState typedef to double, and change all related floats/doubles to use it.
Fixes an off by 1 issue related to double->float->double conversion, and eliminates numerous warnings.
2014-09-03 03:08:09 -04:00
degasus
22e1aa5bb4 mark all local functions as static 2014-07-11 16:07:23 +02:00
Ryan Houdek
c88b83699e Don't use SDL devices that report invalid ranges.
If Buttons, Axes, Hats, or Balls > 255 then reject it.
2014-04-16 16:28:57 -05:00
Matthew Parlane
31cfc73a09 Fixes spacing for "for", "while", "switch" and "if"
Also moved && and || to ends of lines instead of start.
Fixed misc vertical alignments and some { needed newlining.
2014-03-11 00:35:07 +13:00