Commit graph

458 commits

Author SHA1 Message Date
german
e46f0e084c Implement full mouse support 2020-11-25 23:59:30 -06:00
german
2c2b586d86 Add multiple udp server support 2020-11-25 23:44:41 -06:00
Jan Beich
e48e9a406c input_common: ignore some Clang warnings after 5c4774e8ce
error: unknown warning option '-Werror=unused-but-set-parameter'; did you mean '-Werror=unused-parameter'? [-Werror,-Wunknown-warning-option]
error: unknown warning option '-Werror=unused-but-set-variable'; did you mean '-Werror=unused-const-variable'? [-Werror,-Wunknown-warning-option]
2020-11-25 23:57:11 +00:00
bunnei
d1da7eb119
Merge pull request #4905 from german77/AnalogFromButton
Allow to dial any angle with digital joystick
2020-11-24 16:04:55 -08:00
bunnei
6694e11303
input_common: Fix typo in gc_poller.cpp with [[maybe_unused]]. 2020-11-23 21:42:06 -08:00
bunnei
7fb7540d69 input_common: Add more missing [[maybe_unused]] from #4927. 2020-11-23 20:50:35 -08:00
Lioncash
5c4774e8ce input_common: Treat warnings as errors
Migrates over warnings as errors for input common to match how the
common library treats warnings as errors.
2020-11-22 04:50:03 -05:00
german77
5b6545b141 Modify rumble amplification 2020-11-19 11:30:52 -06:00
bunnei
abda366362
Merge pull request #4866 from Morph1984/mjolnir-p3-prod
Project Mjölnir: Part 3 - Controller Profiles and Vibration Rework
2020-11-17 20:02:27 -08:00
Morph
e7e8a87927 sdl_impl: Pump SDL Events at 1000 Hz 2020-11-15 23:33:21 -05:00
Morph
117bdc71e0 sdl_impl: Revert to the "old" method of mapping sticks
Not all controllers have a SDL_GameController binding. This caused controllers not present in the SDL GameController database to have buttons mapped instead of axes.

Furthermore, it was not possible to invert the axes when it could be useful such as emulating a horizontal single joycon or other potential cases. This allows us to invert the axes by reversing the order of mapping (vertical, then horizontal).
2020-11-15 23:33:21 -05:00
Morph
30e0d1c973 controllers/npad: Remove the old vibration filter
Previously we used a vibration filter that filters out amplitudes close to each other. It turns out there are cases where this results into vibrations that are too inaccurate. Remove this and move the 100Hz vibration filter (Only allowing a maximum of 100 vibrations per second) from sdl_impl to npad when enable_accurate_vibrations is set to false.
2020-11-15 23:33:21 -05:00
Morph
e9e1876e82 input_common: Add VibrationDevice and VibrationDeviceFactory
A vibration device is an input device that returns an unsigned byte as status.
It represents whether the vibration device supports vibration or not.
If the status returns 1, it supports vibration. Otherwise, it does not support vibration.
2020-11-15 23:33:20 -05:00
Morph
38110dd485 configure_input: Add per-player vibration
Allows for enabling and modifying vibration and vibration strength per player.
Also adds a toggle for enabling/disabling accurate vibrations.

Co-authored-by: Its-Rei <kupfel@gmail.com>
2020-11-15 23:33:20 -05:00
Morph
9b501af8e3 controllers/npad: Add heuristics to reduce rumble state changes
Sending too many state changes in a short period of time can cause massive performance issues.
As a result, we have to use several heuristics to reduce the number of state changes to minimize/eliminate this performance impact while maintaining the quality of these vibrations as much as possible.
2020-11-15 23:33:20 -05:00
Morph
ceb7b11f16 configure_input_player: Change "Defaults" button behavior
RestoreDefaults() now restores the selected devices' mappings using UpdateMappingWithDefaults().
This allows us to move the keyboard mapping from RestoreDefaults() to UpdateMappingWithDefaults().
2020-11-15 23:33:20 -05:00
Morph
8ead176639 udp/client: Reduce testing period to 5 seconds 2020-11-15 23:33:19 -05:00
Morph
75eaab2e0f configure_input_player: Implement input exclusivity and persistence
With this, the "Input Devices" combobox should accurately reflect the input device being used and disallows inputs from other input devices unless the input device is set to "Any".
2020-11-15 23:33:19 -05:00
Lioncash
0a50ba3bd1 motion_input: Mark constructor as explicit 2020-11-15 14:20:41 -05:00
Lioncash
cb826bcee7 motion_input: Mark member functions as [[nodiscard]] where applicable 2020-11-15 14:18:09 -05:00
german
f5110340e6 fix minor clang error 2020-11-10 10:38:15 -06:00
german
70df449d0a Allow to dial any angle with digital joystick 2020-11-08 09:15:33 -06:00
german
5333db91c1 Add hotplug, rumble and fix 3rd party adapters for the GC adapter 2020-10-28 21:12:34 -05:00
Morph
2f852f182a sdl_impl: Fix controller reconnection issues
It turns out that after a controller is disconnected, there is a chance that events from the previous controller are sent/processed after it has been disconnected.
This causes the previously disconnected controller to reappear as connected due to GetSDLJoystickBySDLID() emplacing this controller back to the map.

Fix this by only returning an SDLJoystick if and only if it exists in the map.
2020-10-21 09:41:30 -04:00
LC
ea8345cdcd
Merge pull request #4809 from Morph1984/mjolnir-p3
configure_input_player: Fix modifier buttons
2020-10-20 15:00:06 -04:00
bunnei
e03dc4d569
Merge pull request #4627 from Morph1984/fix-dinput-controller-disconnect
sdl_impl: Erase the SDLJoystick entry after removing a controller
2020-10-20 11:40:06 -07:00
Morph
ff82f3894a configure_input_player: Fix modifier buttons
Fix them for real this time, now they finally work.
2020-10-20 14:23:25 -04:00
Lioncash
30b1e71066 udp/client: Make use of designated initializers in TestCommunication()
Same behavior, but makes the callback list nicer to look at.
2020-10-16 06:23:51 -04:00
Lioncash
36cfb234d5 udp/client: Take std::function by const reference with TestCommunication()
Avoids redundant copies.
2020-10-16 06:22:29 -04:00
Morph
7b3f5845d2 sdl_impl: Erase the SDLJoystick entry after removing a controller
Previously, disconnecting a controller still leaves a null SDLJoystick entry within the vector of SDLJoysticks mapped by GUID.
When a DirectInput device of the same GUID is reconnected, it adds that device to a new port causing non-detectable input.
Furthermore, opening the "Configure" menu would cause yuzu to crash since it first tries to resolve the name of a null SDLJoystick entry that was not removed.
Resolve this by properly erasing the SDLJoystick entry from the vector.
2020-10-16 00:04:59 -04:00
Lioncash
046c0c91a3 input_common/CMakeLists: Make some warnings errors
Makes the input_common code warnings consistent with the rest of the
codebase.
2020-10-15 19:37:51 -04:00
bunnei
f250011ba0
Merge pull request #4757 from german77/BetterMotion
InputCommon: Add compatibility with only accelerometer and auto calibrate for drift
2020-10-09 23:37:08 -07:00
bunnei
06e65de93c
Merge pull request #4677 from german77/ShakeFromButton
InputCommon: Add random motion input for buttons
2020-10-08 10:18:39 -07:00
bunnei
e9b81e9f01
Merge pull request #4727 from FrogTheFrog/patch-1
Reduce the "shake" requirements when configuring UDP.
2020-10-06 15:29:28 -07:00
german
a54aee290f Address comments 2020-10-04 18:15:53 -05:00
german
a220d8799e Add compatibility with only accelerometer and auto calibrate for drift 2020-10-03 22:22:01 -05:00
Lukas Senionis
6ee1a784b8 Reduce the "shake" requirements when configuring UDP. 2020-09-30 10:30:33 +03:00
german
ab88c2f611 First implementation of controller rumble 2020-09-29 10:38:25 -04:00
german
2978232390 Add random motion input to keyboard 2020-09-25 17:59:52 -05:00
german
03b574ae22 Add random motion input to SDL 2020-09-25 17:59:52 -05:00
german
c5e257017f Add automap feature for GC adapter 2020-09-18 16:51:16 -05:00
bunnei
3f6d83b27c
Merge pull request #4594 from german77/MotionHID
hid/configuration: Implement motion controls to HID
2020-09-17 12:39:01 -07:00
ReinUsesLisp
bc8ace9917 gc_adapter: Disable MSVC nonstandard extension warning on libusb.h
Pragma disable zero-sized array nonstandard extension warning on MSVC.
2020-09-14 19:38:08 -03:00
Lioncash
c715fc4c5e gc_adapter: Make DeviceConnected() a const member function
This doesn't modify instance state, so it can be made const.
2020-09-07 02:49:13 -04:00
german
797564599f Minor cleanup 2020-09-05 09:42:21 -04:00
german
6ee8eab670 Add cemu hook changes related to PR #4609 2020-09-04 21:48:13 -05:00
german
0774b17846 Remove RealMotionDevice 2020-09-04 21:48:13 -05:00
german
ff679f3d17 Include HID and configuration changes related to motion 2020-09-04 21:48:03 -05:00
bunnei
3b0fe38e86
Merge pull request #4583 from lioncash/trunc
gc_poller: Resolve compilation warnings on MSVC
2020-09-03 20:23:33 -04:00
Morph
45ecd601be input_common/motion_input: Make use of Common::PI constant
Also amend the copyright notice to yuzu's instead of Dolphin's, which was mistakenly copy-pasted from another file.
2020-09-02 11:58:15 -04:00
bunnei
f64917a852
Merge pull request #4570 from german77/motionInput
input_common: Add a basic class for motion devices
2020-09-02 11:09:18 -04:00
bunnei
3dcccabd1d
Merge pull request #4382 from FearlessTobi/port-udp-config
yuzu: Add motion and touch configuration from Citra
2020-09-01 13:56:37 -04:00
Vitor Kiguchi
e6f9fe1f60 sdl_joystick: disable the use of the hidapi drivers due to many problems caused by them.
The main problem is the loss of compatibility with some controllers, but there are also
unwanted changes to the behaviour of PS4 controllers (hardcoded lightbar color).
2020-08-30 05:06:49 +02:00
FearlessTobi
d1e1ea0fef Address second batch of reviews 2020-08-30 00:43:25 +02:00
FearlessTobi
d176feffad Address review comments and fix code compilation 2020-08-29 20:56:51 +02:00
FearlessTobi
e6bd1fd1b8 yuzu: Add motion and touch configuration 2020-08-29 18:56:34 +02:00
Lioncash
69fa6b4906 sdl_impl: Reduce allocations in GetButtonMappingForDevice()
These maps can be constexpr arrays of std::pair.
2020-08-28 21:24:17 -04:00
Lioncash
f2a680ca89 sdl_impl: Make use of std::move on std::string where applicable
Avoids redundant copies.
2020-08-28 21:14:54 -04:00
Lioncash
e92164e6a0 sdl_impl: Make use of insert_or_assign() where applicable
Avoids churning ParamPackage instances.
2020-08-28 21:13:26 -04:00
Lioncash
f3ac088345 sdl_impl: Prevent type truncation in BuildAnalogParamPackageForButton() default arguments
We need to add the 'f' suffix to make the right hand side a float and
not a double.
2020-08-28 21:08:08 -04:00
Lioncash
2e2dde2f95 sdl_impl: Simplify make_tuple call
The purpose of make_tuple is that you don't need to explicitly type out
the types of the things that comprise said tuple.

Given this just returns default values, we can simplify this a bit.
2020-08-28 21:04:18 -04:00
Lioncash
2680526e6b sdl_impl: Mark FromEvent() as a const member function
This doesn't modify internal member state, so it can be marked as const.
2020-08-28 20:58:49 -04:00
Lioncash
98f5d8a713 input_common/main: Remove unnecessary headers 2020-08-28 19:23:19 -04:00
Lioncash
4b9b203c09 input_common/main: Remove unimplemented prototype
I forgot to remove this in the rebase when removing most of the global
variables within the input common codebase.
2020-08-28 19:11:17 -04:00
german
1be18dc110 Fix orientation errors and improve drift correction 2020-08-27 17:19:21 -05:00
german
e6fc3b5662 Address comments 2020-08-27 17:19:21 -05:00
german
2d207ec609 Implement a basic class for motion devices 2020-08-27 17:19:21 -05:00
Lioncash
9e1b0af259 input_common: Eliminate most global state
Abstracts most of the input mechanisms under an InputSubsystem class
that is managed by the frontends, eliminating any static constructors
and destructors. This gets rid of global accessor functions and also
allows the frontends to have a more fine-grained control over the
lifecycle of the input subsystem.

This also makes it explicit which interfaces rely on the input subsystem
instead of making it opaque in the interface functions. All that remains
to migrate over is the factories, which can be done in a separate
change.
2020-08-27 16:11:17 -04:00
Morph
8ffc491546 input_common/main: Add "/Mouse" to the display name 2020-08-26 22:41:51 -04:00
Morph
de79897f04 input_common: Fix directional deadzone values
The hardware tested value is 0.5 which translates to SHRT_MAX / 2
2020-08-26 02:32:32 -04:00
Morph
efa0b7a056 Address feedback 2020-08-26 02:32:32 -04:00
Morph
f0fac0c7fb Project Mjölnir: Part 1
Co-authored-by: James Rowe <jroweboy@gmail.com>
Co-authored-by: Its-Rei <kupfel@gmail.com>
2020-08-26 02:32:32 -04:00
Lioncash
f60d5aac3e gc_poller: Resolve compilation warnings on MSVC
We just need to make our intentional implicit truncations explicit.
2020-08-25 23:03:12 -04:00
Lioncash
b724a4d90c General: Tidy up clang-format warnings part 2 2020-08-13 14:19:08 -04:00
ameerj
d6672501ac Remove UI changes
This PR is now only the Analog devices handling the range value defaulting at 100%
2020-08-10 12:46:14 -04:00
ameerj
9c6ae697f5 Add range slider functionality for gc adapter 2020-08-10 12:46:14 -04:00
Ameer
8928aa3008 undo unnecessary newlines, slider range 50-150 2020-08-10 12:46:14 -04:00
Ameer
ed51c2abda Add range slider for analog sticks 2020-08-10 12:46:14 -04:00
Brian J. Tarricone
d840ed90e1 GCAdapter: only join worker thread if running & joinable 2020-07-26 14:54:02 -07:00
bunnei
4524e1bd54
Merge pull request #4418 from lioncash/udp-warn
udp/client: Remove unused boost include
2020-07-25 21:50:37 -07:00
Lioncash
1a7cf26884 udp/client: Remove unused boost include
Also silences a deprecation warning from boost on Clang/GCC.
2020-07-25 03:42:03 -04:00
Lioncash
ac7e4e2cab gc_adapter: Resolve C++20 deprecation warning 2020-07-25 03:38:22 -04:00
Lioncash
04699c366b gc_poller: Resolve -Wsign-compare warning 2020-07-25 03:37:22 -04:00
Lioncash
e19972dfc4 gc_poller: Resolve -Wredundant-move warning 2020-07-25 03:35:40 -04:00
ameerj
68d6d3e173 Fix axis thresholding while polling
axes were very sensitive when mapping controls.
2020-07-19 11:49:26 -04:00
ameerj
1e7bed0a45 std::size_t where appropriate, make error message more clear if can't read 2020-07-17 12:10:32 -04:00
Ameer
94f5f29573 Refactor adapter code 2020-07-16 13:00:04 -04:00
Ameer
93fe982a0c Rebase to master 2020-07-14 13:04:02 -04:00
Ameer
ab65de2f96 Fix crash if gc configured but adapter not connected 2020-07-14 11:23:10 -04:00
bunnei
393cdb15f5
Merge pull request #4314 from lioncash/input-warn
gcadapter: Tidy up compiler warnings
2020-07-14 10:20:12 -04:00
bunnei
edb291b3be
Merge pull request #4315 from lioncash/udp-warn
udp: Silence a C++20 deprecation warning
2020-07-14 09:33:16 -04:00
Ameer
b284c43385 input_common: drop unused libusb.h include
Remnant of an early implementation.
2020-07-14 01:50:34 +00:00
Jan Beich
883fab2fff input_common: make libusb private to gc_adapter 2020-07-13 18:48:19 +00:00
Lioncash
8df93132cd udp: Silence a C++20 deprecation warning
C++20 deprecates using the = lambda capture to implicitly capture the
this pointer. Instead, we must specify it explicitly.
2020-07-12 15:49:42 -04:00
Lioncash
a1dddca4ab gc_poller: Mark GCButtonFactory::GetNextInput() as const
This doesn't modify class instance state.
2020-07-12 15:43:07 -04:00
Lioncash
839c91cd14 gc_poller: Get rid of undefined behavior in Create()
Ensures that the function always has returns in all control paths.
2020-07-12 15:41:35 -04:00
Lioncash
a8ba6dc3c9 gc_poller: Silence sign conversion warnings 2020-07-12 15:40:22 -04:00
Lioncash
32b6fc4062 gc_adapter: Remove deprecated usage of = in lambda captures
It's deprecated in C++20 to use = to capture the this pointer.

Instead, we can simply pass this as an argument to the thread
constructor.
2020-07-12 15:38:19 -04:00
Lioncash
9ce6ea648f gc_adapter: Silence sign conversion warnings 2020-07-12 15:36:27 -04:00
Ameer
042c6602a0 Break out of scan loop if can't find adapter on first run 2020-07-10 11:07:43 -04:00
Jan Beich
48ff15602e cmake: pass libusb include directory as well
In file included from src/input_common/gcadapter/gc_adapter.cpp:8:
src/./input_common/gcadapter/gc_adapter.h:11:10: fatal error: 'libusb.h' file not found
 #include <libusb.h>
          ^~~~~~~~~~
2020-07-09 15:26:54 +00:00
Ameer
4489ea6f53 Rebase to master, fix merge conflicts 2020-07-08 21:15:49 -04:00
bunnei
5311b562aa
Merge pull request #4266 from jbeich/freebsd
gcadapter: unbreak build on FreeBSD
2020-07-08 16:30:26 -04:00
Ameer
3c7a115afe Address comments for better clarity/signed dev count 2020-07-08 14:18:54 -04:00
Ameer
ec13746e4d Add more libusb error checks 2020-07-08 13:19:33 -04:00
Ameer
b57475887b Address PR feedback, fix axis button thresholding 2020-07-07 12:20:59 -04:00
Jan Beich
1db10b8f4c input_common/gcadapter: add missing C++11 header required by libc++
In file included from src/input_common/gcadapter/gc_adapter.cpp:8:
src/./input_common/gcadapter/gc_adapter.h:77:10: error: no template named 'unordered_map' in namespace 'std'
    std::unordered_map<int, bool> buttons;
    ~~~~~^
src/./input_common/gcadapter/gc_adapter.h:78:10: error: no template named 'unordered_map' in namespace 'std'
    std::unordered_map<int, u16> axes;
    ~~~~~^
2020-07-07 10:02:03 +00:00
Ameer
e3253b5f18 Brace the code! Fix compile error due to class member construction order 2020-07-06 23:01:57 -04:00
Ameer
86abff48e1 Recalibrate reconnected controllers 2020-07-06 22:09:07 -04:00
Ameer
7ad423923d Save origin state of GC controller analog features, compare against origin for input detection 2020-07-06 21:58:31 -04:00
Ameer
d00972fce1 Fix for always firing triggers on some controllers, trigger threshold more universal 2020-07-04 00:40:48 -04:00
Ameer
e69d715e3d Address lioncash feedback: Log formatting, extern const PadButtonArray, little touch ups 2020-07-03 11:52:07 -04:00
Ameer
6e1639c7b0 Fix unnecessary diffs 2020-07-02 16:51:16 -04:00
Ameer
6b7c8e469b Add LR triggers as axes, half press to initiate a press, add GC axis id in config, clarify some code blocks for better readability 2020-07-02 15:54:44 -04:00
Ameer
34a590e509 Reset adapter state on init, fixes errors relating driver hang from unexpected unplug 2020-07-01 12:52:50 -04:00
Ameer
a76e11e7f0 Address feedback regarding increments, const vars, and general cleanup 2020-06-30 17:28:02 -04:00
Ameer
dfdf87d844 fix implicit conversion of size_t type to int 2020-06-30 11:44:55 -04:00
Ameer J
bd697bef03
left const auto&, comment punctuation.
Co-authored-by: Morph <39850852+Morph1984@users.noreply.github.com>
2020-06-26 23:46:49 -04:00
Ameer J
ecbc813711
const& to button in button array
Co-authored-by: VolcaEM <63682805+VolcaEM@users.noreply.github.com>
2020-06-25 19:46:50 -04:00
Ameer
3f739514e3 Stop reading loop if error is encountered 2020-06-25 19:31:51 -04:00
Ameer
c18dc9c707 padbutton enum class and struct initiailization 2020-06-24 11:39:30 -04:00
Ameer
743e1f02a0 cleanup check access, read, and factory GetNextInput funcs. Use size rather than magic number 2020-06-23 17:37:15 -04:00
Ameer
d4e07fd95e Fix deallocation of GC Adapter 2020-06-23 12:47:58 -04:00
Ameer
fcc23139f6 std::array and const reference passing of non-trivial objects 2020-06-22 18:11:59 -04:00
ameerj
f5d2a1e8bd Update src/input_common/main.cpp
Co-authored-by: LC <mathew1800@gmail.com>

update libusb submodule (hopefully windows build error fixed)
2020-06-22 17:05:50 -04:00
Ameer
28046ae3a9 Tidy up the pointers, use pair over tuple where appropriate 2020-06-21 23:56:56 -04:00
Ameer
0f729ef078 fix for sleep using stl 2020-06-21 22:58:53 -04:00
Ameer
46b4461fbb shared_ptr for the GC adapter class, constexpr constants 2020-06-21 21:50:58 -04:00
Ameer
968d631aa5 std::arrays where appropriate, clear q in adapter class, other touch ups 2020-06-21 21:17:46 -04:00
Ameer
5f0fa4cb82 fix include thread 2020-06-21 21:17:46 -04:00
Ameer
121af3646d Singleton GC Adapter class, remove globals, fix naming convention
Fix clang formatting

Manual fix for configure_input_player formatting

Add missing lib usb cmake command
2020-06-21 21:17:07 -04:00
Ameer
c94583d867 Clang Formatting 2020-06-21 15:31:57 -04:00
Ameer
0076a08d04 Cleanup after linter 2020-06-21 13:02:43 -04:00
Ameer
0248614add GC Adapter Implementation 2020-06-21 12:36:28 -04:00
MerryMage
c6a963c48e input_common/motion_emu: Remove redundant move
Named return value optimization automatically applies here.
2020-06-19 14:29:59 +01:00
MerryMage
8272f53cf9 input_common/keyboard: Remove redundant move
Named return value optimization automatically applies here.
2020-06-19 14:29:36 +01:00
FearlessTobi
3d1e741645 input_common: fix build when SDL2 is disabled 2020-05-02 21:47:17 +02:00
bunnei
79c1269f0f
Merge pull request #3673 from lioncash/extra
CMakeLists: Specify -Wextra on linux builds
2020-04-16 21:12:33 -04:00
Markus Wick
94c2c828a5 input_common: Use the CMake target instead of the variable. 2020-04-16 16:42:59 +02:00
Lioncash
1c340c6efa CMakeLists: Specify -Wextra on linux builds
Allows reporting more cases where logic errors may exist, such as
implicit fallthrough cases, etc.

We currently ignore unused parameters, since we currently have many
cases where this is intentional (virtual interfaces).

While we're at it, we can also tidy up any existing code that causes
warnings. This also uncovered a few bugs as well.
2020-04-15 21:33:46 -04:00
bunnei
e70451d967
Merge pull request #3525 from FearlessTobi/linux-compile-error
input_common/udp: Fix Linux build by using a backwards compatible way of error checking
2020-03-21 16:04:45 -04:00
ReinUsesLisp
716d6aee30 input_common/udp: Fix clang build issues 2020-03-18 04:30:26 -03:00
FearlessTobi
230ac6a4e8 input_common/udp: Fix Linux build by using a backwards compatible way of error checking
Should fix https://github.com/yuzu-emu/yuzu/issues/3487.

error_code::failed is a function which has been introduced in Boost 1.69.
This version of boost hasn't landed in most major distros yet.
2020-03-17 12:29:25 +01:00
James Rowe
002d9508a0 input/udp - Add minor error handling to prevent bad input from crashing 2020-03-03 23:46:05 -07:00
James Rowe
2cdda8c564 input/udp - Dont log on invalid packet received 2020-03-03 19:52:16 -07:00
CJBok
23c4cc80e2 analog_from_button get direction implementation 2020-02-18 06:45:37 +01:00
Lioncash
c7678c3044 input_common/udp: Ensure that UDP is shut down within Shutdown()
Previously the UDP backend would never actually get shut down.
2020-02-03 09:29:15 -05:00
Lioncash
83f8090273 input_common/udp: Add missing override specifiers
Prevents trivial warnings and ensures interfaces are properly
maintained between the base class.
2020-02-03 09:26:53 -05:00
Lioncash
5c61e0ba39 input_common/udp: std::move SocketCallback instances where applicable
std::function is allowed to heap allocate if the size of the captures
associated with each lambda exceed a certain threshold. This prevents
potentially unnecessary reallocations from occurring.
2020-02-03 09:24:05 -05:00
Lioncash
fb9c9ddcc9 input_common/udp: std::move shared_ptr within Client constructor
Gets rid of a trivially avoidable atomic reference count increment and
decrement.
2020-02-03 09:21:46 -05:00
Lioncash
9bb6ab77f4 udp/client: Replace deprecated from_string() call with make_address_v4()
Future-proofs code if boost is ever updated.
2020-02-03 09:20:40 -05:00
Lioncash
881408445a input_common/udp: Silence -Wreorder warning for Socket
Amends the constructor initializer list to specify the order of its
elements in the same order that initialization would occur.
2020-02-03 09:15:32 -05:00
Lioncash
36524465a6 input_common/udp: Remove unnecessary inclusions 2020-02-03 09:13:40 -05:00
Lioncash
4aa9c9632d input_common/udp: Add missing header guard 2020-02-03 09:09:06 -05:00
bunnei
69a6796de1
Merge pull request #3284 from CJBok/hid-fix
hid: Fix analog sticks directional states
2020-02-01 14:02:41 -05:00
FearlessTobi
bbd85a495a Address second part of review comments 2020-01-23 20:55:26 +01:00
FearlessTobi
0fe11746fc Address review comments 2020-01-23 20:55:26 +01:00
fearlessTobi
ac3690f205 Input: UDP Client to provide motion and touch controls
An implementation of the cemuhook motion/touch protocol, this adds the
ability for users to connect several different devices to citra to send
direct motion and touch data to citra.

Co-Authored-By: jroweboy <jroweboy@gmail.com>
2020-01-23 20:55:26 +01:00
CJBok
635deb70d4 Moved analog direction logic to sdl_impl 2020-01-15 11:25:15 +01:00
Lioncash
5ccf2a7b82 input_common/sdl/sdl_impl: Correct logging string in SDLState constructor
If this path was ever taken, a runtime exception would occur due to the
lack of a formatting specifier to insert the error code into the format
string.
2019-06-03 16:56:47 -04:00
Lioncash
cfac942e63 input_common/sdl/sdl_impl: Move documentation comments to header where applicable
Places the documentation comments with the rest of SDLState's member
function documentation.
2019-06-03 16:56:47 -04:00
Lioncash
b9b23c98ff input_common/sdl/sdl_impl: Amend names for axes for SDLAnalogPoller
Adds another underscore to clearly indicate the axis names.
2019-06-03 16:56:47 -04:00
Lioncash
50048d9f5a input_common/sdl/sdl_impl: Mark variables const where applicable
Make it explicit that these aren't modified elsewhere (either through
functions by reference, or by other operations).
2019-06-03 16:56:47 -04:00
Lioncash
ca7ca2919c input_common/sdl/sdl_impl: Mark SDLEventToButtonParamPackage() as static
Its prototype declared at the top of the translation unit contains the
static qualifier, so the function itself should also contain it to make
it a proper internally linked function.
2019-06-03 16:56:47 -04:00
Lioncash
b73ea457cc input_common/sdl/sdl_impl: Convert reinterpret_cast into a static_cast
It's valid to static_cast a void pointer back into its proper type.
2019-06-03 16:56:46 -04:00
Lioncash
2c679cda51 input_common/sdl/sdl_impl: Use insert_or_assign() where applicable
Same behavior, but without a potential need to unnecessarily default
construct a value.
2019-06-03 16:56:46 -04:00
Lioncash
b46e615551 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
7ea07c6063 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
cf0d01a5d7 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
00f0827a26 input_common/sdl/sdl_impl: Use nested namespace specifiers where applicable 2019-06-03 15:49:04 -04:00
Lioncash
e70f16fff7 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
781ab8407b 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
eb335f51ca 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
874826b6dd 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
114060fd87 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
d74aa13bd3 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
834d3fe336 input_common/sdl_impl: Remove unused variable in SDLState constructor 2019-03-17 04:02:48 -04:00
B3n30
71817afbe9 fixup! Joystick: Allow for background events; Add deadzone to SDLAnalog 2019-03-02 19:12:46 +01:00
Weiyi Wang
8b98f60e3c 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
09ac66388c 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
c8554d218b 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
b9238edd0d 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
1b855efd5e 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
a1574aabd5 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
804115b2a4 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
684fc2c320 input_common: Use std::move where applicable
Avoids unnecessary atomic reference count increments and decrements
2018-08-02 21:51:11 -04:00
Lioncash
29b6afb82f input_common: Add missing override specifiers 2018-08-02 21:44:25 -04:00
James Rowe
638956aa81 Rename logging macro back to LOG_* 2018-07-02 21:45:47 -04:00
Lioncash
376f6397c6
input_common: Move old logging macros over to fmt-capable ones 2018-04-26 19:09:25 -04:00
Lioncash
fae2dd0344
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
096be16636 Format: Run the new clang format on everything 2018-01-20 16:45:11 -07:00
bunnei
be0e14ab3e
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
e710a1b989 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
ed296e47f1 input_common/sdl: Silence a -Wpessimizing-move warning 2018-01-17 18:44:16 -05:00
muemart
eaff98dbb3 Adding meumart's Citra SDL Joystick support. Citra PR #3116 2018-01-15 20:02:30 -05:00
wwylele
4d058cfb76 motion_emu: fix initialization order 2017-08-22 11:43:44 +03:00
James Rowe
bbfa9d0635 Merge pull request #2861 from wwylele/motion-refactor
Refactor MotionEmu into a InputDevice
2017-08-19 23:43:01 -06:00
wwylele
223bd35450 motion_emu: no need to include thread in header 2017-08-19 07:21:02 +03:00
Dave Leaver
bf71fc0342 Fix Spelling/English mistakes 2017-08-14 09:15:39 +12:00
wwylele
188194908c move MotionEmu from core/frontend to input_common as a InputDevice 2017-08-11 11:05:08 +03:00
danzel
8d3f48d0a3 Fix some spelling mistakes 2017-08-11 19:51:16 +12:00
Yuri Kunde Schlesner
776cb91785 CMake: Define an interface target for SDL2 definitions 2017-05-27 21:38:49 -07:00
Yuri Kunde Schlesner
7b81903756 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
4ad82f2e5a input_common/sdl: add support for binding button to axis 2017-04-17 14:14:35 +03:00
wwylele
5245c86f26 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
51b1c1f211 InputCommon: add SDL joystick support 2017-03-01 23:30:57 +02:00
wwylele
a6bd7917cb InputCommon: add AnalogFromButton 2017-03-01 23:30:57 +02:00
wwylele
38e800f70d InputCommon: add Keyboard 2017-03-01 23:30:57 +02:00