Commit Graph

614 Commits

Author SHA1 Message Date
Lioncash e7c5737e2e input_engine: Remove left-over namespace qualifiers
These types are part of the InputCommon namespace.
2021-12-13 09:57:51 -05:00
Lioncash f8db0a76af input_engine: Iterate by reference rather than by value where applicable
Avoids creating copies of several object instances (some of which being
over 100 bytes in size).
2021-12-13 09:57:51 -05:00
Lioncash 190cfc5997 input_engine: Take BasicMotion by const reference with SetMotion() and TriggerOnMotionChange()
Copies the BasicMotion instance once instead of twice.
2021-12-13 09:57:39 -05:00
Lioncash e0e9f98fc6 input_engine: std::move InputIdentifier in SetCallback()
Allows avoiding std::function allocations.
2021-12-13 09:23:23 -05:00
Lioncash cd45635f56 input_engine: Pass LedStatus by const reference
Avoids copies where reasonably applicable
2021-12-13 09:20:58 -05:00
Lioncash f41c22d30f input_engine: Pass VibrationStatus by const reference in SetRumble()
Avoids creating copies of the struct where not necessary.
2021-12-13 09:16:10 -05:00
Lioncash 54e164d9de input_engine: std::move engine name where applicable
We can allow the name to be moved into, allowing allocations to be
avoided.
2021-12-13 09:05:50 -05:00
Lioncash d62545828a input_engine: Remove callback clearing in constructor
The callback map is a member variable, so this will always be empty on
initial construction.
2021-12-13 08:54:23 -05:00
Lioncash 7e34562d34 input_engine: Remove unnecessary semi-colons
Silences -Wextra-semi warnings
2021-12-13 08:53:01 -05:00
Lioncash caae5d3868 input_engine: Remove unnecessary return
This is a void function, so it doesn't need this.
2021-12-13 08:52:09 -05:00
Narr the Reg 48537c07cd input_common: Fix error with thread name 2021-11-29 22:03:47 -05:00
vperus e899505921 Revert of 1dabf6d
Caused worker_thread to be stuck in Stage1Completed state until job's destruction.
2021-11-29 16:37:11 +02:00
vperus bd95c199bc [input_common] Add completion test for CalibrationConfigurationJob 2021-11-29 16:33:12 +02:00
Narr the Reg 7b56b2cab6 input_common: Fully implement UDP controllers 2021-11-26 15:46:36 -06:00
german77 b8b849dc2e input_common: Move button names to the frontend 2021-11-24 20:30:28 -06:00
german77 bc9641614d input_common: Fix SDL controller with inverted axis 2021-11-24 20:30:28 -06:00
german77 30de38ee7f kraken: Address comments from review
Fix compiler bug
2021-11-24 20:30:28 -06:00
german77 25521cd948 core/hid: Improve accuary of mouse implementation 2021-11-24 20:30:28 -06:00
german77 dfb63175d1 core/hid: Fully implement native mouse 2021-11-24 20:30:28 -06:00
german77 6032358402 input_common: Allow keyboard to be backwards compatible 2021-11-24 20:30:28 -06:00
german77 ebfe40dec8 core/hid: Improve accuracy of the keyboard implementation 2021-11-24 20:30:28 -06:00
german77 94c972fb36 input_common: Fix motion from 3 axis 2021-11-24 20:30:27 -06:00
german77 a4cdafed54 core/hid: Prevent Emulated controller from flapping with multiple inputs devices 2021-11-24 20:30:27 -06:00
german77 93997b234f core/hid: Fully emulate motion from button 2021-11-24 20:30:27 -06:00
german77 4736326a05 second commit lion review 2021-11-24 20:30:26 -06:00
german77 a8852024b6 settings: Fix Debug controller type options 2021-11-24 20:30:26 -06:00
german77 9f91335a71 kraken: Address comments from review
start lion review
2021-11-24 20:30:26 -06:00
german77 f63c6fce6d input_common: Revert deleted TAS functions 2021-11-24 20:30:26 -06:00
german77 254d133be2 input_common: Fix GC adapter initialization
Fix GC controller
2021-11-24 20:30:26 -06:00
german77 3cd0dd4227 input_common: Fix UDP uuid 2021-11-24 20:30:26 -06:00
german77 124404e756 input_common: Add multiple vibration curves 2021-11-24 20:30:26 -06:00
german77 012691087a core/hid: Rework battery mappings 2021-11-24 20:30:26 -06:00
german77 ae6ba2c8bd input_common: Add manual update options to input devices 2021-11-24 20:30:26 -06:00
german77 d1bac9024d settings: Fix mouse and keyboard mappings 2021-11-24 20:30:25 -06:00
german77 b3f59b4407 kraken: Address comments from review
review fixes
2021-11-24 20:30:25 -06:00
german77 8ea02d19a1 service/hid: Fix gesture input 2021-11-24 20:30:25 -06:00
german77 6774c7988b configuration: Migrate controller settings to emulated controller 2021-11-24 20:30:25 -06:00
german77 6c7814bc9c core/hid: Fix rumble too strong at 1% 2021-11-24 20:30:24 -06:00
german77 00f654cd22 core/hid: Only signal when needed 2021-11-24 20:30:24 -06:00
german77 0292fe0198 kraken: Fix errors from rebase and format files 2021-11-24 20:30:24 -06:00
german77 66cf94709a core/hid: Add output devices 2021-11-24 20:30:24 -06:00
german77 547a1e6dc9 input_common: Rewrite main and add the new drivers 2021-11-24 20:30:23 -06:00
german77 4fc8607f61 input_common: Remove obsolete files 2021-11-24 20:30:23 -06:00
german77 9a108578ed input_common: Rewrite SDL 2021-11-24 20:30:23 -06:00
german77 13413c2290 input_common: Rewrite udp client 2021-11-24 20:30:22 -06:00
german77 ec744b3b04 input_common: Rewrite tas input 2021-11-24 20:30:22 -06:00
german77 78a8ed6290 input_common: Rewrite gc_adapter 2021-11-24 20:30:22 -06:00
german77 86a57fb096 input_common: Rewrite touch 2021-11-24 20:30:22 -06:00
german77 280342cd0a input_common: Rewrite mouse 2021-11-24 20:30:22 -06:00
german77 00d3c058c5 input_common: Rewrite keyboard 2021-11-24 20:30:22 -06:00
german77 1d0e9b62da input_common: Move touch and analog from button. Move udp protocol 2021-11-24 20:30:22 -06:00
german77 783c01771a input_common: Create input poller and mapping 2021-11-24 20:30:22 -06:00
german77 312dd2fb89 input_common: Create input_engine 2021-11-24 20:30:22 -06:00
Fernando S 0b63955efe Revert "input_common: Fix data race on GC implementation" 2021-10-23 23:32:16 +02:00
Fernando S 8eda2922b2 Merge pull request #6515 from german77/gc_thread_safe
input_common: Fix data race on GC implementation
2021-10-23 23:28:22 +02:00
ameerj 1dabf6d025 input_common: Fix VS2022 compilation errors 2021-10-20 01:21:59 -04:00
german77 cfa3acd4a5 input_common/sdl: Fix joystick range 2021-10-11 01:03:01 -05:00
bunnei ceafd4f92c Merge pull request #6979 from german77/joycon_name
input_common: Add alternative string for joycons
2021-10-02 02:58:25 -07:00
ameerj d7977be416 general: Update style to clang-format-12 2021-09-24 15:52:05 -04:00
german77 1b060a47b2 UI: Relocate tas menu and add brief description 2021-09-18 23:23:03 +02:00
german77 d71f067db8 input_common/tas: Document the main class 2021-09-18 23:22:48 +02:00
german77 d552f84322 input_common/tas: Add swap controller 2021-09-18 23:22:42 +02:00
german77 368c9db4ee input_common/tas: overwrite file dialog 2021-09-18 23:22:42 +02:00
MonsterDruide1 1b67085cda input_common/tas: Fallback to simple update 2021-09-18 23:22:30 +02:00
german77 bba1ab83d6 config: Move TAS options to it's own menu 2021-09-18 23:22:30 +02:00
MonsterDruide1 cce0d58312 core: Hacky TAS syncing & load pausing
To keep the TAS inputs synced to the game speed even through lag spikes and loading zones, deeper access is required.

First, the `TAS::UpdateThread` has to be executed exactly once per frame. This is done by connecting it to the service method the game calls to pass parameters to the GPU: `Service::VI::QueueBuffer`.

Second, the loading time of new subareas and/or kingdoms (SMO) can vary. To counteract that, the `CPU_BOOST_MODE` can be detected: In the `APM`-interface, the call to enabling/disabling the boost mode can be caught and forwarded to the TASing system, which can pause the script execution if neccessary and enabled in the settings.
2021-09-18 23:22:20 +02:00
MonsterDruide1 31068a63a9 input_common/tas: Base playback & recording system
The base playback system supports up to 8 controllers (specified by `PLAYER_NUMBER` in `tas_input.h`), which all change their inputs simulataneously when `TAS::UpdateThread` is called.

The recording system uses the controller debugger to read the state of the first controller and forwards that data to the TASing system for recording. Currently, this process sadly is not frame-perfect and pixel-accurate.

Co-authored-by: Naii-the-Baf <sfabian200@gmail.com>
Co-authored-by: Narr-the-Reg <juangerman-13@hotmail.com>
2021-09-18 23:22:00 +02:00
german77 0cea589993 input_common: Enable steam controllers and 8 player support 2021-09-10 00:58:12 -05:00
german77 94028da35e input_common: Add alternative string for joycons 2021-09-06 22:20:19 -05:00
german77 134a2c23ac input_common: Disable sdl raw input mode 2021-08-12 13:17:07 -05:00
german77 32e0572a68 input_common: Improve SDL joystick and hide toggle option 2021-08-07 23:11:23 -05:00
Rodrigo Locatti 84bdc6969f input_common: Fix data race on GC implementation 2021-08-07 16:46:26 -05:00
bunnei 18a787b357 Merge pull request #6654 from german77/custom_threshold
input_common: Make button threshold customizable
2021-07-21 20:31:33 -04:00
bunnei def3f59ed9 Merge pull request #6649 from german77/toggle_sdl
input_common: Support SDL toggle buttons
2021-07-20 20:35:20 -04:00
Nicolas Jallamion d417596f27 input/sdl_impl: fix rumble support on DualSense. (#6683)
- value return can be different 0, is not error is normal, error is only -1.
2021-07-20 04:00:07 -04:00
bunnei 40a1066bf7 Merge pull request #6652 from lat9nq/cmd-vulkan-fixes
yuzu-cmd: Linux Vulkan fixes
2021-07-19 20:54:03 -04:00
german77 0fb8912834 input_common: Fix mouse panning behaivour 2021-07-16 18:57:29 -05:00
lat9nq 7a30ae6845 sdl_impl, emu_window: Remove clang ignore
Fixed upstream by
libsdl-org/SDL@25fc40b0bd
2021-07-16 15:43:12 -04:00
german77 9e0f89e081 input_common: Make button threshold customizable 2021-07-15 23:56:57 -05:00
bunnei 24f798804c Merge pull request #6579 from ameerj/float-settings
settings: Eliminate usage of float-point setting values
2021-07-15 18:03:11 -04:00
german77 f098c2163b input_common: Support SDL toggle buttons 2021-07-15 14:31:58 -05:00
german77 77db68f9e3 input_common: Fix build with sdl disabled 2021-07-10 20:02:02 -05:00
ameerj 4e2d71a8ce configure_input: Use u8 for mouse sensitivity 2021-07-08 23:24:31 -04:00
Ameer J 60e29dd3b0 Merge pull request #6539 from lat9nq/default-setting
general: Move most settings' defaults and labels into their definition
2021-07-08 14:46:31 -04:00
lat9nq d9109a708b general: Code formatting improvements
Slight improvements to readability.

Dropped suggestions for string_view (settings.h:101), pass by value
(settings.h:82), reverting double to a float (config.cpp:316), and other
smaller ones, some out of scope.

Addresses review feedback.

Co-authored-by: Ameer J <52414509+ameerj@users.noreply.github.com>
2021-07-08 14:07:10 -04:00
Morph 64f22684d4 CMakeLists: Treat -Wsign-compare as an error on GCC/Clang
Treats (un)signed comparison mismatches as errors to be consistent with MSVC
2021-07-06 12:50:09 -04:00
bunnei 88cb6c26f3 Merge pull request #6537 from Morph1984/warnings
general: Enforce multiple warnings in MSVC
2021-07-05 17:09:23 -07:00
german77 cf1280874f input_common: Add missing modifier callback to analog from button 2021-07-05 11:39:42 -05:00
lat9nq 3352742284 core, input_common: Miscellaneous fixes
bcat: Fix settings access

telemetry_session: Fix settings accesses

So this is what I get for testing with the web service disabled.

touch_from_button: Fix settings access for clang
2021-06-28 20:56:17 -04:00
lat9nq 794c444285 general: Make most settings a BasicSetting
Creates a new BasicSettings class in common/settings, and forces setting
a default and label for each setting that uses it in common/settings.
Moves defaults and labels from both frontends into common settings.
Creates a helper function in each frontend to facillitate reading the
settings now with the new default and label properties.

Settings::Setting is also now a subclass of Settings::BasicSetting. Also
adds documentation for both Setting and BasicSetting.
2021-06-28 17:32:17 -04:00
Morph 1917128312 input_common: Remove #pragma warning directives for external headers 2021-06-28 14:20:25 -04:00
Morph b6c7707fe9 input_common: Enforce C4242 2021-06-28 14:20:25 -04:00
Chloe a9a9167009 Add missing includes (#6521)
* Add missing includes

* Add array
2021-06-24 03:24:17 -04:00
Rodrigo Locatti 65df2a2ba0 input_common/mouse_input: Fix data race
Fix data race using std::jthread and std::stop_token.
2021-06-22 02:31:39 -03:00
bunnei 78d9caa5df Merge pull request #6407 from lat9nq/fix-libusb-2
cmake: Use autotools for libusb linking generally on GNU, and cleanup
2021-06-10 23:35:30 -07:00
bunnei 65505640b9 Merge pull request #6389 from german77/Analog_button_fix
input_common: Analog button, use time based position
2021-06-03 21:06:38 -07:00
lat9nq 21d81ee941 cmake: General improvements to libusb linking
Delegates libusb external communication to externals/CMakeLists.txt
Ensures an interface library `usb` for every pathway
input_common just links to the `usb` library now
externals/libusb/CMakeLists.txt sets variables to override SDL2's libusb
finding
Other minor cleanup
2021-06-03 03:49:35 -04:00
bunnei bfacb2dd28 Merge pull request #6318 from german77/dualJoycon
input_common: Add dual joycon support
2021-06-01 00:51:00 -07:00
german77 b398e0783e input_common: Analog button, use time based position instead of frequent updates 2021-05-30 00:13:51 -05:00
bunnei c1f4c84db4 Merge pull request #6312 from german77/analogMapping
input_common: Rewrite sdl analog mapping and fix controller disconnection crash
2021-05-24 12:02:37 -07:00
german77 e99220d321 input_common: Add dual joycon support 2021-05-22 18:40:53 -05:00
bunnei 1e4bc2cb20 Merge pull request #6310 from german77/nanMotion
input_common: Sanitize motion data
2021-05-19 15:47:48 -07:00
german77 b79310def9 input_common: Implement SDL motion 2021-05-15 08:56:58 -05:00
german77 2d3df5d3f4 input_common: Fix crash when controller disconnects 2021-05-15 08:27:19 -05:00
german77 b41d05a12c input_common: Rewrite sdl analog mapping 2021-05-14 21:17:08 -05:00
german77 eac788499b input_common: Sanitize motion data 2021-05-13 13:41:32 -05:00
german77 1562858963 input_common: Release mouse buttons on out of focus 2021-05-02 19:08:33 -05:00
bunnei 1838d41120 Merge pull request #6243 from german77/GCresetOrigin
input_common: Reset GC sticks center by measuring multiple packets
2021-04-30 12:02:05 -07:00
german77 7d6d399f26 input_common: Reset GC sticks center by measuring multiple packets 2021-04-26 18:34:00 -05:00
german77 c8845b4fdf hid: Implement SevenSixAxis and ConsoleSixAxisSensor 2021-04-23 22:12:41 -05:00
lat9nq 1e36a11626 general: Ignore implicit-fallthrough for SDL.h
SDL 2.0.14 introduces an incompatibility with Clang, causing it to
trigger -Wimplicit-fallthrough even though it is marked. Ignore it for
now, with a comment mentioning why this is needed.
2021-04-18 01:31:26 -04:00
lat9nq c8a26a2cbf cmake: Use SDL 2.0.14 and fix CMake scope issue
Forces using SDL 2.0.14. Upgrades the SDL external to that version. Adds
a message when switching to the external.

Fixes an error where input_common only links to SDL when SDL2_FOUND is
set, but externals/CMakeLists cannot set that variable to the required
scope. Switch to using ENABLE_SDL2, which we can use since we now
include the SDL source.
2021-04-17 23:42:57 -04:00
bunnei f527e7a748 Merge pull request #6119 from german77/SDLMapping
InputCommon: Address mapping and naming issues with SDL2
2021-04-15 21:40:35 -07:00
bunnei 7a76bc30fa common: Move settings to common from core.
- Removes a dependency on core and input_common from common.
2021-04-14 16:24:03 -07:00
german77 129c89b47d Use a single connection for UDP server, make connection test longer and check all pads instead of only the first one 2021-03-30 22:17:08 -05:00
german77 ad6e6210db InputCommon: Name properly xbox 360 and one controllers, Fix mappings for Nintendo Pro controllers 2021-03-30 21:40:36 -05:00
bunnei d0933e20e0 Merge pull request #6040 from german77/toggleKeyboard
Enable toggle buttons for keyboard and mouse
2021-03-11 11:00:44 -08:00
bunnei f16c081cfd Merge pull request #5990 from german77/mousePanningV2
InputCommon: Mouse fixes
2021-03-08 14:50:58 -08:00
german77 9c42c9e164 Enable mouse toggle buttons 2021-03-06 13:27:02 -06:00
german 03c81d5e1f Enable button toggle for keyboard in the modifier button 2021-03-05 19:21:04 -06:00
german 0cb68543e2 inputCommon: Use an unique client id for each socket instance 2021-03-01 09:19:33 -06:00
german77 a380976857 inputCommon: Mouse fixes 2021-02-27 17:53:10 -06:00
Morph ebf4986174 Revert "Port citra-emu/citra#5123: "SDL: Disable hidapi drivers due to compatibility problems with certain controllers"" 2021-02-18 11:16:14 -05:00
Morph fd772cb778 Merge pull request #5929 from german77/mousePanning
Improve mouse panning
2021-02-16 22:52:35 +08:00
bunnei 0563f37708 Merge pull request #3603 from FearlessTobi/port-5123
Port citra-emu/citra#5123: "SDL: Disable hidapi drivers due to compatibility problems with certain controllers"
2021-02-15 16:25:53 -08:00
bunnei 0ff94cb0cc Merge pull request #4940 from german77/nativeGC
HID: Implement GC controller in game
2021-02-15 10:32:19 -08:00
german 47f0b00c9d Improve mouse panning 2021-02-13 22:23:32 -06:00
bunnei 152e089482 Merge pull request #5869 from german77/mousePanning
input_common: Add mouse panning
2021-02-11 09:58:23 -08:00
Lioncash 4681f5b60b udp: Silence unused member variable warnings
Simply mark them as unused for now.
2021-02-09 17:38:45 -05:00
Lioncash 70b6d985e7 udp/client: Define ClientData constructor/destructor in cpp file
Prevents compilation errors on clang 12 due to incomplete types within a
unique_ptr member.
2021-02-09 17:36:32 -05:00
german 020c22f53d hid: Implement GC controller 2021-02-07 22:59:46 -06:00
german c7cae8769f Add mouse panning 2021-02-07 20:31:58 -06:00
german cbe925c31a Add SL SR vectors, change dual joycon view, add missing raw data from keyboard/mouse 2021-02-06 09:43:42 -06:00
german 93ac87f29e Make settings controller image change with controller input 2021-02-06 09:43:41 -06:00
ameerj 37e544492e analog_from_button: Fix update_thread.join exception
This commit aims to address an exception that occurs when trying to join the Analog object's update_thread.

By using an atomic bool for the status of the update thread, we ensure its value is consistent across the threads accessing it.
2021-01-29 18:41:22 -05:00
Morph 6b5e5ad224 sdl_impl: Set the maximum vibration duration to 1 second 2021-01-23 08:06:07 -05:00
german b92717bec6 Always initialize keyboard input 2021-01-15 09:05:17 -06:00
german df1070a735 Add mutitouch support for touch screens 2021-01-15 09:05:17 -06:00
german f452fbfc88 Allow to return up to 16 touch inputs per engine 2021-01-15 09:05:17 -06:00
Morph 23413c0d44 general: Fix various spelling errors 2021-01-02 10:23:41 -05:00
bunnei 2a5e0d3d92 Merge pull request #5265 from german77/port5509
Port citra-emu/citra#5509 "Look at direction of analog axis travel instead of instantaneous sample"
2020-12-30 22:24:30 -08:00
german f04be5803d Port citra-emu/citra#5509 2020-12-30 22:29:20 -06:00
bunnei ae5e92e2fb Merge pull request #5236 from gal20/udp_client_patch
input_common: process udp packets only for the correct pad
2020-12-29 02:51:40 -08:00
gal20 2f5fb99b94 udp client: process packets only for the correct pad 2020-12-27 22:22:48 +02:00
german 139222d3a5 Allow to invert analog axis with right click 2020-12-26 17:46:14 -06:00
Morph 439488a842 Merge pull request #5020 from german77/AnalogfromButtonFix
Disable analog joystick from buttons by default
2020-12-08 10:30:21 +08:00
german 1a3e4518ec Disable analog joystick from buttons by default 2020-12-07 19:34:52 -06:00
Lioncash 8e4a23e129 mouse_poller: Remove unused includes 2020-12-03 10:41:13 -05:00
Lioncash 11e20efc1d mouse_input: Invert conditional in UpdateYuzuSettings()
Allows the struct to be constructed in place.
2020-12-03 10:41:13 -05:00
Lioncash f8b5b65d6b mouse_input: Remove two casts and amend some formatting
Removes the use of two static casts and improves the readability of some
vectors slightly.
2020-12-03 10:41:09 -05:00
Lioncash 64daafbaa0 mouse_input: Resolve a -Wdocumentation warning 2020-12-03 10:26:50 -05:00
Lioncash 09b2703682 mouse_input: Remove unused includes 2020-12-03 10:26:30 -05:00
bunnei eba344f859 Merge pull request #4937 from german77/multiUDP
InputCommon: Add multiple udp server support
2020-12-01 11:47:37 -08:00
LC 1ec79d0982 Merge pull request #5047 from german77/MouseInput
InputCommon: Fix implicit conversion in mouse input
2020-12-01 09:40:46 -05:00
german 544417cd49 Fix implicit conversion in mouse input 2020-11-30 21:48:18 -06:00
bunnei 0c0c14ca1e Merge pull request #4939 from german77/MouseInput
InputCommon: Implement full mouse support
2020-11-29 22:59:50 -08:00
german 56a8fee35a Implement full mouse support 2020-11-25 23:59:30 -06:00
german 6708e0ec0e Add multiple udp server support 2020-11-25 23:44:41 -06:00
Jan Beich 805312e278 input_common: ignore some Clang warnings after c8aec32f12
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 e4938afd40 Merge pull request #4905 from german77/AnalogFromButton
Allow to dial any angle with digital joystick
2020-11-24 16:04:55 -08:00
bunnei f2bb584578 input_common: Fix typo in gc_poller.cpp with [[maybe_unused]]. 2020-11-23 21:42:06 -08:00
bunnei 2382020d8d input_common: Add more missing [[maybe_unused]] from #4927. 2020-11-23 20:50:35 -08:00
Lioncash c8aec32f12 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 3edd74463f Modify rumble amplification 2020-11-19 11:30:52 -06:00
bunnei afa4ced6e4 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 f5ee5e7f3c sdl_impl: Pump SDL Events at 1000 Hz 2020-11-15 23:33:21 -05:00
Morph 24cfdbc7fe 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 bd42b2093c 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 ad3905fe27 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 cce389221b 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 ed9df522ec 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 b29a52982a 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 5eb160d4c6 udp/client: Reduce testing period to 5 seconds 2020-11-15 23:33:19 -05:00
Morph ad9a909bc7 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 eccf766a39 motion_input: Mark constructor as explicit 2020-11-15 14:20:41 -05:00
Lioncash 93312282aa motion_input: Mark member functions as [[nodiscard]] where applicable 2020-11-15 14:18:09 -05:00
german fbab229893 fix minor clang error 2020-11-10 10:38:15 -06:00
german b1f65683bc Allow to dial any angle with digital joystick 2020-11-08 09:15:33 -06:00
german 2aafcc5f4b Add hotplug, rumble and fix 3rd party adapters for the GC adapter 2020-10-28 21:12:34 -05:00
Morph 62e0851476 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 bd5383ad7e Merge pull request #4809 from Morph1984/mjolnir-p3
configure_input_player: Fix modifier buttons
2020-10-20 15:00:06 -04:00
bunnei d49a2e305e 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 6fa2144d90 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 c3c19060dd 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 3232d03657 udp/client: Take std::function by const reference with TestCommunication()
Avoids redundant copies.
2020-10-16 06:22:29 -04:00
Morph 7f475ec996 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 d44d662529 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 7eaad002f5 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 86a98a3137 Merge pull request #4677 from german77/ShakeFromButton
InputCommon: Add random motion input for buttons
2020-10-08 10:18:39 -07:00
bunnei b3767ab3be Merge pull request #4727 from FrogTheFrog/patch-1
Reduce the "shake" requirements when configuring UDP.
2020-10-06 15:29:28 -07:00
german ec0a0a94b4 Address comments 2020-10-04 18:15:53 -05:00
german 0d4c60c3ef Add compatibility with only accelerometer and auto calibrate for drift 2020-10-03 22:22:01 -05:00
Lukas Senionis e237086658 Reduce the "shake" requirements when configuring UDP. 2020-09-30 10:30:33 +03:00
german 782aab6cf2 First implementation of controller rumble 2020-09-29 10:38:25 -04:00
german ef4f095aae Add random motion input to keyboard 2020-09-25 17:59:52 -05:00
german db47701464 Add random motion input to SDL 2020-09-25 17:59:52 -05:00
german 9f70da1a9b Add automap feature for GC adapter 2020-09-18 16:51:16 -05:00
bunnei 9a2553c952 Merge pull request #4594 from german77/MotionHID
hid/configuration: Implement motion controls to HID
2020-09-17 12:39:01 -07:00
ReinUsesLisp 67dd8466b3 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 14d5340a9d 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 b26bc3864a Minor cleanup 2020-09-05 09:42:21 -04:00
german 82eb4be33b Add cemu hook changes related to PR #4609 2020-09-04 21:48:13 -05:00
german 17b48f8d42 Remove RealMotionDevice 2020-09-04 21:48:13 -05:00
german 876e6fc255 Include HID and configuration changes related to motion 2020-09-04 21:48:03 -05:00
bunnei 9c6972fda5 Merge pull request #4583 from lioncash/trunc
gc_poller: Resolve compilation warnings on MSVC
2020-09-03 20:23:33 -04:00
Morph f3417b01e1 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 60e59d1d0c 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 99ae6cfc68 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 52df885a42 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 ee199ead59 Address second batch of reviews 2020-08-30 00:43:25 +02:00
FearlessTobi 01dbe3a624 Address review comments and fix code compilation 2020-08-29 20:56:51 +02:00
FearlessTobi 2903f0f7ce yuzu: Add motion and touch configuration 2020-08-29 18:56:34 +02:00
Lioncash 56d39caa1d sdl_impl: Reduce allocations in GetButtonMappingForDevice()
These maps can be constexpr arrays of std::pair.
2020-08-28 21:24:17 -04:00
Lioncash eb2ab15bdb sdl_impl: Make use of std::move on std::string where applicable
Avoids redundant copies.
2020-08-28 21:14:54 -04:00
Lioncash 285e3386e2 sdl_impl: Make use of insert_or_assign() where applicable
Avoids churning ParamPackage instances.
2020-08-28 21:13:26 -04:00
Lioncash 3413c8c046 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 1338c58d37 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 4dc59a4b64 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 0322ffa4fd input_common/main: Remove unnecessary headers 2020-08-28 19:23:19 -04:00
Lioncash 72d5a883a1 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 f327977dfa Fix orientation errors and improve drift correction 2020-08-27 17:19:21 -05:00
german dbf0608afd Address comments 2020-08-27 17:19:21 -05:00
german 0e11d1c09a Implement a basic class for motion devices 2020-08-27 17:19:21 -05:00
Lioncash affbf8e188 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 4ca910101f input_common/main: Add "/Mouse" to the display name 2020-08-26 22:41:51 -04:00
Morph 5e4f03f663 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 24ce544120 Address feedback 2020-08-26 02:32:32 -04:00
Morph 34a209d15c 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 fa4a1718a7 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 78ddcbe3ba General: Tidy up clang-format warnings part 2 2020-08-13 14:19:08 -04:00
ameerj 5d4750541b 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 ac3cdc1741 Add range slider functionality for gc adapter 2020-08-10 12:46:14 -04:00
Ameer 6afee6b0c8 undo unnecessary newlines, slider range 50-150 2020-08-10 12:46:14 -04:00
Ameer 1eb1eff48c Add range slider for analog sticks 2020-08-10 12:46:14 -04:00
Brian J. Tarricone f637cfec64 GCAdapter: only join worker thread if running & joinable 2020-07-26 14:54:02 -07:00
bunnei c021c9f3ae Merge pull request #4418 from lioncash/udp-warn
udp/client: Remove unused boost include
2020-07-25 21:50:37 -07:00
Lioncash 5987e39f21 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 bc2f95ea67 gc_adapter: Resolve C++20 deprecation warning 2020-07-25 03:38:22 -04:00
Lioncash 6efd1a2675 gc_poller: Resolve -Wsign-compare warning 2020-07-25 03:37:22 -04:00
Lioncash e94ad47152 gc_poller: Resolve -Wredundant-move warning 2020-07-25 03:35:40 -04:00
ameerj bb2375ec9d Fix axis thresholding while polling
axes were very sensitive when mapping controls.
2020-07-19 11:49:26 -04:00
ameerj 45584cf459 std::size_t where appropriate, make error message more clear if can't read 2020-07-17 12:10:32 -04:00
Ameer 05174770cc Refactor adapter code 2020-07-16 13:00:04 -04:00
Ameer ed995fe27e Rebase to master 2020-07-14 13:04:02 -04:00
Ameer 2b38468a0b Fix crash if gc configured but adapter not connected 2020-07-14 11:23:10 -04:00
bunnei f18dca4b04 Merge pull request #4314 from lioncash/input-warn
gcadapter: Tidy up compiler warnings
2020-07-14 10:20:12 -04:00
bunnei 1434f790a0 Merge pull request #4315 from lioncash/udp-warn
udp: Silence a C++20 deprecation warning
2020-07-14 09:33:16 -04:00
Ameer a8deadbb2b input_common: drop unused libusb.h include
Remnant of an early implementation.
2020-07-14 01:50:34 +00:00
Jan Beich cfc73b4188 input_common: make libusb private to gc_adapter 2020-07-13 18:48:19 +00:00
Lioncash cb588c9ef1 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 7c05493952 gc_poller: Mark GCButtonFactory::GetNextInput() as const
This doesn't modify class instance state.
2020-07-12 15:43:07 -04:00
Lioncash 340875a12f 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 ff47456e8b gc_poller: Silence sign conversion warnings 2020-07-12 15:40:22 -04:00
Lioncash 1fe8261049 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 6b6d076f51 gc_adapter: Silence sign conversion warnings 2020-07-12 15:36:27 -04:00
Ameer a885855ff4 Break out of scan loop if can't find adapter on first run 2020-07-10 11:07:43 -04:00
Jan Beich 64cab91fac 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 d875341016 Rebase to master, fix merge conflicts 2020-07-08 21:15:49 -04:00
bunnei b84af2cd28 Merge pull request #4266 from jbeich/freebsd
gcadapter: unbreak build on FreeBSD
2020-07-08 16:30:26 -04:00
Ameer 6e2876d7da Address comments for better clarity/signed dev count 2020-07-08 14:18:54 -04:00
Ameer 0e21c24052 Add more libusb error checks 2020-07-08 13:19:33 -04:00
Ameer f1790c7b34 Address PR feedback, fix axis button thresholding 2020-07-07 12:20:59 -04:00
Jan Beich 9ea600e888 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 3eeb56e064 Brace the code! Fix compile error due to class member construction order 2020-07-06 23:01:57 -04:00
Ameer 9a989c4ff9 Recalibrate reconnected controllers 2020-07-06 22:09:07 -04:00
Ameer 68a4bc8179 Save origin state of GC controller analog features, compare against origin for input detection 2020-07-06 21:58:31 -04:00
Ameer e081fb0718 Fix for always firing triggers on some controllers, trigger threshold more universal 2020-07-04 00:40:48 -04:00
Ameer 670614dbf4 Address lioncash feedback: Log formatting, extern const PadButtonArray, little touch ups 2020-07-03 11:52:07 -04:00
Ameer 33c08afba9 Fix unnecessary diffs 2020-07-02 16:51:16 -04:00
Ameer 12e679c39c 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 34e6084c8d Reset adapter state on init, fixes errors relating driver hang from unexpected unplug 2020-07-01 12:52:50 -04:00
Ameer 0c6128cc3a Address feedback regarding increments, const vars, and general cleanup 2020-06-30 17:28:02 -04:00
Ameer ed72085227 fix implicit conversion of size_t type to int 2020-06-30 11:44:55 -04:00
Ameer J 21ae845d69 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 eb06e3e8bf 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 677a07c253 Stop reading loop if error is encountered 2020-06-25 19:31:51 -04:00
Ameer 7c10c568da padbutton enum class and struct initiailization 2020-06-24 11:39:30 -04:00
Ameer 39ca7c675c cleanup check access, read, and factory GetNextInput funcs. Use size rather than magic number 2020-06-23 17:37:15 -04:00
Ameer ef0b52563d Fix deallocation of GC Adapter 2020-06-23 12:47:58 -04:00
Ameer f071a70fec std::array and const reference passing of non-trivial objects 2020-06-22 18:11:59 -04:00
ameerj 14bb562028 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 5479427335 Tidy up the pointers, use pair over tuple where appropriate 2020-06-21 23:56:56 -04:00
Ameer a0f8f1dc5e fix for sleep using stl 2020-06-21 22:58:53 -04:00
Ameer 92a812d815 shared_ptr for the GC adapter class, constexpr constants 2020-06-21 21:50:58 -04:00
Ameer 4a54dc6bbf std::arrays where appropriate, clear q in adapter class, other touch ups 2020-06-21 21:17:46 -04:00
Ameer 5ebed7b1bb fix include thread 2020-06-21 21:17:46 -04:00
Ameer eddf2d0f4e 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 77ae7fe5dd Clang Formatting 2020-06-21 15:31:57 -04:00
Ameer 243dbee81e Cleanup after linter 2020-06-21 13:02:43 -04:00
Ameer dbe1ad4fe4 GC Adapter Implementation 2020-06-21 12:36:28 -04:00
MerryMage b26ff8fa86 input_common/motion_emu: Remove redundant move
Named return value optimization automatically applies here.
2020-06-19 14:29:59 +01:00
MerryMage 38f25284c8 input_common/keyboard: Remove redundant move
Named return value optimization automatically applies here.
2020-06-19 14:29:36 +01:00
FearlessTobi 358d645018 input_common: fix build when SDL2 is disabled 2020-05-02 21:47:17 +02:00
bunnei 7a4ed2581d Merge pull request #3673 from lioncash/extra
CMakeLists: Specify -Wextra on linux builds
2020-04-16 21:12:33 -04:00
Markus Wick ea1146eba0 input_common: Use the CMake target instead of the variable. 2020-04-16 16:42:59 +02:00
Lioncash 02e095313a 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 1429f883b2 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 d8191c0d7f input_common/udp: Fix clang build issues 2020-03-18 04:30:26 -03:00
FearlessTobi a38b732a6c 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 37cf312477 input/udp - Add minor error handling to prevent bad input from crashing 2020-03-03 23:46:05 -07:00