Commit graph

78 commits

Author SHA1 Message Date
xperia64
755393da90
Look at direction of analog axis travel instead of instantaneous sample (#5509)
* Look at direction of analog axis travel instead of instantaneous sample

* Clang-format

* Use map count, use unordered_map

* Improve digital vs. true analog axis heuristics
2021-01-02 21:09:26 -05:00
Vitor K
ce16653cc8
Automatic Controller Binding (#5100)
* Implement the basics of controller auto mapping. From testing doesn't currenlty work.
Opening the controller requires the device index, but it is only known and guaranteed
at boot time or when a controller is connected.

* Use the SDL_INIT_GAMECONTROLLER flag to initialize the controller
subsystem. It automatically initializes the joystick subsystem too,
so SDL_INIT_JOYSTICK is not needed.

* Implement the SDLGameController class to handle open game controllers.
Based on the SDLJoystick implementation.

* Address review comments

* Changes SDLJoystick and SDLGameController to use a custom default
constructible destructor, to improve readability. The only deleters
used previously were SDL_JoystickClose and SDL_GameControllerClose,
respectively, plus null lambdas. Given that both SDL functions
accept null pointers with just an early return, this should be
functionally the same.
with just an early return

* warn the user when a controller mapping is not found

* Get axis direction and threshold from SDL_ExtendedGameControllerBind

* Reject analog bind if it's not axis, for the couple of examples present in SDL2.0.10's db.
Also add SDL_CONTROLLER_BINDTYPE_NONE for the button bind switch, with a better log message.

* sdl_impl.cpp: Log the error returned by SDL_GetError upon failure to open joystick

* sdl: only use extended binding on SDL2.0.6 and up

* sdl_impl.cpp: minor changes
2021-01-01 10:01:07 +01:00
FearlessTobi
c37dc23481 udp/client: Take std::function by const reference with TestCommunication()
Avoids redundant copies.

Co-Authored-By: LC <712067+lioncash@users.noreply.github.com>
2020-12-05 23:07:08 +01:00
Hamish Milne
80c9f9abbb
Keep keyboard state independent of acquired buttons (#5255)
* Keep keyboard state independent of acquired buttons

* Review changes

* Address review comments

Co-authored-by: zhupengfei <zhupf321@gmail.com>
2020-11-15 12:58:12 +01:00
Vitor K
ff9c3b0531
Make sure some things are logged (#5515)
* sdl_impl.cpp: actually log the sdl error

* Log cpu slider and vsync
2020-10-01 09:23:37 +08:00
Tobias
f6b543886c
Port yuzu-emu/yuzu#4528: "common: Make use of [[nodiscard]] where applicable" (#5535)
Co-authored-by: LC <712067+lioncash@users.noreply.github.com>
2020-08-31 21:06:16 +02:00
z87
41facaece3 input_common: add TouchFromButtonDevice 2020-05-04 13:51:37 +03:00
Ben
ed304e2877
Merge pull request #5179 from vitor-k/reenable-hidapi
Reenable hidapi for SDL2.0.12 and up
2020-04-27 16:35:51 +02:00
Tobias
32cbb1bc77
input_common/udp: Port various changes from yuzu (#5133) 2020-04-17 02:50:28 +02:00
Vitor Kiguchi
69f7a83b0e Reenable hidapi for SDL2.0.12 and up 2020-04-04 20:30:09 -03:00
Marshall Mohror
3b1b8b7e1f
Merge pull request #5123 from vitor-k/disable-hidapi
SDL: Disable hidapi drivers due to compatibility problems with certain controllers
2020-04-03 23:23:03 -05:00
Vitor Kiguchi
8e3960b409 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-03-05 21:23:36 -03:00
FearlessTobi
4c2c27046d Fix compilation 2020-02-10 12:10:42 +01:00
Lioncash
7362fe48ac input_common/udp: Add missing override specifiers
Prevents trivial warnings and ensures interfaces are properly
maintained between the base class.
2020-02-09 23:00:02 +01:00
Lioncash
575ab92a76 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-09 23:00:02 +01:00
Lioncash
fcdc191107 input_common/udp: std::move shared_ptr within Client constructor
Gets rid of a trivially avoidable atomic reference count increment and
decrement.
2020-02-09 23:00:02 +01:00
Lioncash
8a0f8c3a4f udp/client: Replace deprecated from_string() call with make_address_v4()
Future-proofs code if boost is ever updated.
2020-02-09 23:00:02 +01:00
Lioncash
7d45fdc1df 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-09 23:00:01 +01:00
Lioncash
d7a58fe24d input_common/udp: Remove unnecessary inclusions 2020-02-09 23:00:01 +01:00
Lioncash
b39a611a3d input_common/udp: Add missing header guard 2020-02-09 23:00:01 +01:00
bunnei
dd31be16d9 input_common: main: Remove unnecessary HAVE_SDL2 check. 2019-07-07 11:01:00 -04:00
Lioncash
79439fc556 input_common/sdl/sdl_impl: Silence sign conversion warnings
Makes the conversions explicit, as opposed to implicit.
2019-06-01 02:10:46 +02:00
Tobias
623b0621ab
Port various minor changes from yuzu PRs (#4725)
* common/thread: Remove unused functions

Many of these functions are carried over from Dolphin (where they aren't
used anymore). Given these have no use (and we really shouldn't be
screwing around with OS-specific thread scheduler handling from the
emulator, these can be removed.

The function for setting the thread name is left, however, since it can
have debugging utility usages.

* input_common/sdl: Use a type alias to shorten declaration of GetPollers

Just makes the definitions a little bit more tidy.

* input_common/sdl: Correct return values within implementations of GetPollers()

In both cases, we weren't actually returning anything, which is
undefined behavior.

* yuzu/debugger/graphics_surface: Fill in missing surface format listings

Fills in the missing surface types that were marked as unknown. The
order corresponds with the TextureFormat enum within
video_core/texture.h.

We also don't need to all of these strings as translatable (only the
first string, as it's an English word).

* yuzu/debugger/graphics_surface: Clean up connection overload deduction

We can utilize qOverload with the signal connections to make the
function deducing a little less ugly.

* yuzu/debugger/graphics_surface: Tidy up SaveSurface

- Use QStringLiteral where applicable.

- Use const where applicable

- Remove unnecessary precondition check (we already assert the pixbuf
  being non null)

* yuzu/debugger/graphics_surface: Display error messages for file I/O errors

* core: Add missing override specifiers where applicable

Applies the override specifier where applicable. In the case of
destructors that are  defaulted in their definition, they can
simply be removed.

This also removes the unnecessary inclusions being done in audin_u and
audrec_u, given their close proximity.

* kernel/thread: Make parameter of GetWaitObjectIndex() const qualified

The pointed to member is never actually modified, so it can be made
const.

* kernel/thread: Avoid sign conversion within GetCommandBufferAddress()

Previously this was performing a u64 + int sign conversion. When dealing
with addresses, we should generally be keeping the arithmetic in the
same signedness type.

This also gets rid of the static lifetime of the constant, as there's no
need to make a trivial type like this potentially live for the entire
duration of the program.

* kernel/codeset: Make CodeSet's memory data member a regular std::vector

The use of a shared_ptr is an implementation detail of the VMManager
itself when mapping memory. Because of that, we shouldn't require all
users of the CodeSet to have to allocate the shared_ptr ahead of time.
It's intended that CodeSet simply pass in the required direct data, and
that the memory manager takes care of it from that point on.

This means we just do the shared pointer allocation in a single place,
when loading modules, as opposed to in each loader.

* kernel/wait_object: Make ShouldWait() take thread members by pointer-to-const

Given this is intended as a querying function, it doesn't make sense to
allow the implementer to modify the state of the given thread.
2019-05-01 14:28:49 +02:00
Lioncash
21c71d21ae 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-07 15:14:29 +02:00
Lioncash
bf4b0dd1f4 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-19 23:55:38 +01:00
Lioncash
ed31197402 input_common/sdl_impl: Remove unnecessary std::chrono::duration construction
Specifying the time unit itself is sufficient here.
2019-03-19 23:55:31 +01:00
Lioncash
a5c087f5de input_common/sdl_impl: Remove unused variable in SDLState constructor 2019-03-19 23:55:23 +01:00
Lioncash
e1a4912ade 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-03-02 18:13:10 +01:00
Lioncash
643472e24a 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-03-02 15:04:13 +01:00
Lioncash
db58652680 common/quaternion: Move Quaternion into the Common namespace
Quaternion is within the common library, so it should be using the
Common namespace.
2019-03-02 14:44:09 +01:00
Weiyi Wang
104829ae58 remove all occurance of specifying endianness inside BitField
This commit it automatically generated by command in zsh:
sed -i -- 's/BitField<\(.*\)_le>/BitField<\1>/g' **/*(D.)

BitField is now aware to endianness and default to little endian. It expects a value representation type without storage specification for its template parameter.
2019-01-28 22:09:43 -05:00
Valentin Vanelslande
8e614c3eb0 clang-format; address one comment 2018-12-28 23:31:55 -05:00
Weiyi Wang
53a3498aee
Merge pull request #4193 from B3n30/controller5
Joystick: Allow for background events; Add deadzone to SDLAnalog
2018-10-17 10:49:21 -04:00
Weiyi Wang
9adc407112
Merge pull request #4304 from B3n30/std_optional
Replace boost::optional with std::optional where possible
2018-10-11 12:40:00 -04:00
B3n30
ca77be3ac2 remove std::tie in sdl_impl 2018-10-09 23:19:24 +02:00
B3n30
2b46b838f1 fix deadzone max value 2018-10-09 21:23:50 +02:00
B3n30
2306af3600 Handle cases when std::optional does not contain a value 2018-10-05 16:51:33 +02:00
B3n30
d37a2270d6 Replace boost::optional with std::optional where possible 2018-10-05 13:51:09 +02:00
Weiyi Wang
22df17c303 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
2018-10-02 11:22:20 -04:00
B3n30
4831095610 fixup! Joystick: Allow for background events; Add deadzone to SDLAnalog 2018-10-01 16:02:19 +02:00
James Rowe
3f4a7f8f58 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
2018-09-22 14:13:50 -06:00
James Rowe
bfcc712132 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
2018-09-22 14:11:15 -06:00
B3n30
0238cf52b7 SDLJoystick: Addressed review comments 2018-09-11 14:50:41 +02:00
Ben
17978cf758
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
2018-09-08 19:01:30 +02:00
Weiyi Wang
7d8f115185 Prefix all size_t with std::
done automatically by executing regex replace `([^:0-9a-zA-Z_])size_t([^0-9a-zA-Z_])` -> `$1std::size_t$2`
2018-09-06 16:03:28 -04:00
James Rowe
50270fd791
Merge pull request #4059 from zhaowenlan1779/udp-input-ui
citra_qt: add motion/touch config
2018-08-26 11:56:50 -06:00
CodingKoopa
8cbb60c281 Change level of invalid UDP packet log message from Error to Debug. 2018-08-12 22:17:34 -04:00
zhupengfei
8af89b6979
input_common, common: Add a few functions
These functions include reloading udp client, testing communication and configuring calibration. I also added a function to common/thread.h to use WaitFor.
2018-08-11 14:09:35 +08:00
zhupengfei
e1ae14d508
input_common/udp: allow changing pad index 2018-08-11 13:23:10 +08:00
Lioncash
384c9e5382 input_common: Use std::move where applicable
Avoids unnecessary atomic reference count increments and decrements
2018-08-10 10:12:30 +08:00