Commit Graph

42 Commits

Author SHA1 Message Date
Lioncash
8c58848556 input_common/sdl/sdl_impl: Simplify SDL_Joystick deleter handling
The deleter can just be set in the constructor and maintained throughout
the lifetime of the object.

If a contained pointer is null, then the deleter won't execute, so this
is safe to do. We don't need to swap it out with a version of a deleter
that does nothing.
2019-06-03 16:56:46 -04:00
Lioncash
1b36d4a894 input_common/sdl/sdl_impl: Resolve two sign conversion warnings
Silences the final two warnings in SDL code.
2019-06-03 16:56:46 -04:00
Lioncash
73f12a38b8 input_common/sdl: Remove unused header includes and forward declarations
Gets rid of a few unnecessary inclusion dependencies. It also uncovered
a few indirect inclusion dependencies being relied upon.
2019-06-03 16:56:42 -04:00
Lioncash
9c241164c0 input_common/sdl/sdl_impl: Use nested namespace specifiers where applicable 2019-06-03 15:49:04 -04:00
Lioncash
612aca69b7 input_common/sdl/sdl_impl: Silence sign conversion warnings
Makes the conversions explicit, as opposed to implicit.
2019-05-31 04:47:02 -03:00
Lioncash
60a06381e3 general: Use deducation guides for std::lock_guard and std::unique_lock
Since C++17, the introduction of deduction guides for locking facilities
means that we no longer need to hardcode the mutex type into the locks
themselves, making it easier to switch mutex types, should it ever be
necessary in the future.
2019-04-01 12:53:47 -04:00
Lioncash
fe20183115 input_common/sdl: Correct return values within implementations of GetPollers()
In both cases, we weren't actually returning anything, which is
undefined behavior.
2019-03-18 11:40:38 -04:00
Lioncash
889b27205b input_common/sdl: Use a type alias to shorten declaration of GetPollers
Just makes the definitions a little bit more tidy.
2019-03-18 11:40:35 -04:00
Lioncash
59a4eb0d66 input_common/sdl_impl: Make lambda capture more specific in SDLState constructor
We don't need to universally capture by reference. We specifically just
need to capture the this pointer.
2019-03-17 04:02:52 -04:00
Lioncash
650c185515 input_common/sdl_impl: Remove unnecessary std::chrono::duration construction
Specifying the time unit itself is sufficient here.
2019-03-17 04:02:52 -04:00
Lioncash
641f65789b input_common/sdl_impl: Remove unused variable in SDLState constructor 2019-03-17 04:02:48 -04:00
B3n30
f7805dc236 fixup! Joystick: Allow for background events; Add deadzone to SDLAnalog 2019-03-02 19:12:46 +01:00
Weiyi Wang
800de7ead8 input/sdl: lock map mutex after SDL call
Any SDL invocation can call the even callback on the same thread, which can call GetSDLJoystickBySDLID and eventually cause double lock on joystick_map_mutex. To avoid this, lock guard should be placed as closer as possible to the object accessing code, so that any SDL invocation is with the mutex unlocked
2019-03-02 19:09:58 +01:00
James Rowe
dff2319b9b Input: Remove global variables from SDL Input
Changes the interface as well to remove any unique methods that
frontends needed to call such as StartJoystickEventHandler by
conditionally starting the polling thread only if the frontend hasn't
started it already. Additionally, moves all global state into a single
SDLState class in order to guarantee that the destructors are called in
the proper order
2019-03-02 19:09:34 +01:00
James Rowe
f4bd1fce6f Input: Copy current SDL.h/cpp files to impl
This should make reviewing much easier as you can then see what changed
happened between the old file and the new one
2019-03-02 18:38:11 +01:00
Lioncash
5a5287d917 common/math_util: Move contents into the Common namespace
These types are within the common library, so they should be within the
Common namespace.
2019-02-27 03:38:39 -05:00
Lioncash
7ff6e73155 common/vector_math: Move Vec[x] types into the Common namespace
These types are within the common library, so they should be using the
Common namespace.
2019-02-26 22:38:36 -05:00
Lioncash
898d317430 common/quaternion: Move Quaternion into the Common namespace
Quaternion is within the common library, so it should be using the
Common namespace.
2019-02-26 22:31:17 -05:00
Tobias
86b3a18a93 Port #4141 from citra: Joystick hotplug support (#1275)
* Joystick hotplug support (#4141)

* use SDL_PollEvent instead of SDL_JoystickUpdate

Register hot plugged controller by GUID if they were configured in a previous session

* Move SDL_PollEvent into its own thread

* Don't store SDLJoystick pointer in Input Device; Get pointer on each GetStatus call

* Fix that joystick_list gets cleared after SDL_Quit

* Add VirtualJoystick for InputDevices thats never nullptr

* fixup! Add VirtualJoystick for InputDevices thats never nullptr

* fixup! fixup! Add VirtualJoystick for InputDevices thats never nullptr

* Remove SDL_GameController, make SDL_Joystick* unique_ptr

* fixup! Remove SDL_GameController, make SDL_Joystick* unique_ptr

* Adressed feedback; fixed handling of same guid reconnects

* fixup! Adressed feedback; fixed handling of same guid reconnects

* merge the two joystick_lists into one

* make SDLJoystick a member of VirtualJoystick

* fixup! make SDLJoystick a member of VirtualJoystick

* fixup! make SDLJoystick a member of VirtualJoystick

* fixup! fixup! make SDLJoystick a member of VirtualJoystick

* SDLJoystick: Addressed review comments

* Address one missed review comment
2018-09-10 21:29:59 -04:00
Lioncash
436a2c57ea input_common: Use std::move where applicable
Avoids unnecessary atomic reference count increments and decrements
2018-08-02 21:51:11 -04:00
Lioncash
02b5592618 input_common: Add missing override specifiers 2018-08-02 21:44:25 -04:00
James Rowe
847a518200 Rename logging macro back to LOG_* 2018-07-02 21:45:47 -04:00
Lioncash
f7e5368f1d input_common: Move old logging macros over to fmt-capable ones 2018-04-26 19:09:25 -04:00
Lioncash
ae5156dc73 math_util: Remove the Clamp() function
C++17 adds clamp() to the standard library, so we can remove ours in
favor of it.
2018-04-20 10:14:13 -04:00
James Rowe
7d396de27a Format: Run the new clang format on everything 2018-01-20 16:45:11 -07:00
bunnei
fdfefda960 Merge pull request #84 from lioncash/cmake
CMakeLists: Derive the source directory grouping from targets themselves
2018-01-18 01:37:17 -05:00
Lioncash
6091001deb CMakeLists: Derive the source directory grouping from targets themselves
Removes the need to store to separate SRC and HEADER variables, and then
construct the target in most cases.
2018-01-17 21:51:43 -05:00
Lioncash
90b17d2f16 input_common/sdl: Silence a -Wpessimizing-move warning 2018-01-17 18:44:16 -05:00
muemart
2b8800dd00 Adding meumart's Citra SDL Joystick support. Citra PR #3116 2018-01-15 20:02:30 -05:00
wwylele
c05a90135d motion_emu: fix initialization order 2017-08-22 11:43:44 +03:00
James Rowe
78d01dd905 Merge pull request #2861 from wwylele/motion-refactor
Refactor MotionEmu into a InputDevice
2017-08-19 23:43:01 -06:00
wwylele
c7570dc130 motion_emu: no need to include thread in header 2017-08-19 07:21:02 +03:00
Dave Leaver
d062d550cb Fix Spelling/English mistakes 2017-08-14 09:15:39 +12:00
wwylele
88451a0b73 move MotionEmu from core/frontend to input_common as a InputDevice 2017-08-11 11:05:08 +03:00
danzel
d56b74ac58 Fix some spelling mistakes 2017-08-11 19:51:16 +12:00
Yuri Kunde Schlesner
bd753b8131 CMake: Define an interface target for SDL2 definitions 2017-05-27 21:38:49 -07:00
Yuri Kunde Schlesner
4a5d297fe7 CMake: Correct inter-module dependencies and library visibility
Modules didn't correctly define their dependencies before, which relied
on the frontends implicitly including every module for linking to
succeed.

Also changed every target_link_libraries call to specify visibility of
dependencies to avoid leaking definitions to dependents when not
necessary.
2017-05-27 18:41:24 -07:00
wwylele
2bb38b3a76 input_common/sdl: add support for binding button to axis 2017-04-17 14:14:35 +03:00
wwylele
c22571a470 citra-qt: release all buttons when render window focus is lost
credit to @Hawkheart for the original idea
2017-03-17 21:41:25 +02:00
wwylele
e61d586a0d InputCommon: add SDL joystick support 2017-03-01 23:30:57 +02:00
wwylele
b0898ce5f5 InputCommon: add AnalogFromButton 2017-03-01 23:30:57 +02:00
wwylele
1e713bccda InputCommon: add Keyboard 2017-03-01 23:30:57 +02:00