Commit Graph

6799 Commits

Author SHA1 Message Date
Sam Lantinga
1981d23f4b Fixed bug 5466 - Add haptic support for Stadia Controller
Dimitriy Ryazantcev

Consider adding support for Stadia Controller haptics.

Here is example code how to deal with it:
99314be815/device/gamepad/hid_haptic_gamepad.cc (L45)
2021-01-24 00:51:26 -05:00
Sam Lantinga
96cfb81232 Fixed bug 5467 - SDL sys timer Mac OS update proposal
David Carlier

Change of api from 2016 which reduce code complexity a bit.
2021-01-24 00:51:25 -05:00
JibbSmart
0f57864c9e Hint SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS added so we can recognise a Joy-Con as half a Pro Controller, so we can read its analog input and read its sensors just like we do a Pro Controller. 2021-01-24 00:51:25 -05:00
Cameron Gutman
bd553ea868 Implement support for inhibiting the screensaver on Wayland
We support both the org.freedesktop.ScreenSaver D-Bus API (same as the X11
backend) and the Wayland idle_inhibit_unstable_v1 protocol.

Some Wayland compositors only support one or the other, so we need both to
for broad compatibility.
2021-01-24 00:51:25 -05:00
Cameron Gutman
7ff3832e4d Fix continuous scrolling speed on Wayland
Wayland compositors seem to have standardized on 10 units per "wheel tick" for
continuous scroll events, so we need to convert these axis values to ticks by
dividing by 10 before reporting them in SDL_MOUSEWHEEL events.
2021-01-24 00:51:25 -05:00
Cameron Gutman
8c921d8201 Implement keyboard grab support for Windows
This is implemented via a low-level keyboard hook. Unfortunately, this is
rather invasive, but it's how Microsoft recommends that it be done [0].
We want to do as little as possible in the hook, so we only intercept a few
crucial modifier keys there, while leaving other keys to the normal event
processing flow.

We will only install this hook if SDL_HINT_GRAB_KEYBOARD=1, which is not
the default. This will reduce any compatibility concerns to just the SDL
applications that explicitly ask for this behavior.

We also remove the hook when the grab is terminated to ensure that we're
not unnecessarily staying involved in key event processing when it's not
required anymore.

[0]: https://docs.microsoft.com/en-us/windows/win32/dxtecharts/disabling-shortcut-keys-in-games
2021-01-24 00:51:25 -05:00
Ozkan Sezer
fd65aaa9a8 move outdated winmm and psp joystick codes to struct _SDL_JoystickDriver
build-tested only. (bug #5472.)
2021-01-24 00:51:25 -05:00
Ozkan Sezer
8f1025899a os2audio: changed backend name from MMOS2 to DART (like SDL-1.2) 2021-01-24 00:51:25 -05:00
Ozkan Sezer
2376458841 renamed SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H to SDL_HAVE_MACHINE_JOYSTICK_H 2021-01-24 00:51:25 -05:00
Ozkan Sezer
02e61a88fb added SDL_JOYSTICK_OS2 to SDL_config.h.in and SDL_config.h.cmake 2021-01-24 00:51:25 -05:00
Ozkan Sezer
d0c5097cdc minor autotools build system updates. 2021-01-24 00:51:25 -05:00
Ozkan Sezer
4eb2b9f809 fix permissions of config.guess and config.sub 2021-01-24 00:51:25 -05:00
Sam Lantinga
f68b36df75 Added support for the EVORETRO GameCube Adapter in PC mode 2021-01-24 00:51:25 -05:00
Sam Lantinga
9c88eac856 ControllerList: fix typo 2021-01-24 00:51:25 -05:00
Ozkan Sezer
11fce32162 SDL_dinputjoystick.c: fixes to dfDIJoystick2[] array from Wine git.
Fix V/A/FSlider dwOfs values in c_dfDIJoystick2
af2f419426

Add missing ASPECT flags for c_dfDIJoystick2
e2e100272f

Closes bug #5474.
2021-01-24 00:51:25 -05:00
Ozkan Sezer
4a776557af old os2 analogue joystick code ported from SDL-1.2. disabled by default,
build-tested only.
2021-01-24 00:51:25 -05:00
Ozkan Sezer
e91f83c1e0 hidapi.h: adjust so that it gives a smaller diff against mainstream 2021-01-24 00:51:25 -05:00
Sam Lantinga
d4794028bb Fixed build 2021-01-24 00:51:25 -05:00
Sam Lantinga
9e45372a2f Fixed build on Android and iOS 2021-01-24 00:51:25 -05:00
Cameron Gutman
19236b462a Implement support for minimizing windows on Wayland
This required a bit of extra code to deal with the transition from minimized
back to fullscreen
2021-01-24 00:51:25 -05:00
Cameron Gutman
cf84ec441f Improve reliability of cursor hiding on GNOME Wayland
Hiding the cursor doesn't appear to work reliably on GNOME when another window
steals mouse focus right as we call SDL_ShowCursor(SDL_DISABLE). This can happen
when the keyboard shortcut inhibition permission prompt appears in response to a
call to SDL_SetRelativeMouseMode() with SDL_HINT_GRAB_KEYBOARD=1. The result is
that the default cursor is stuck locked in position and visible on screen
indefinitely.

By redrawing the cursor on pointer focus enter, the cursor now disappears upon
the first mouse motion event. It's not perfect but it's way better than the
current behavior.
2021-01-24 00:51:25 -05:00
Sam Lantinga
bf53651d73 Make sure we only do GameCube adapter initialization if we were able to load libusb 2021-01-24 00:51:24 -05:00
Sam Lantinga
3527b49459 Fixed initializing the Nyko and EVORETRO GameCube adaptors
This requires root on most Linux distributions, as we have to directly send USB messages to the devices to enable input reports.
2021-01-24 00:51:24 -05:00
Ozkan Sezer
b6ae9a7cba renamed my_gradd.h to SDL_gradd.h 2021-01-24 00:51:24 -05:00
Sam Lantinga
178ae70a29 Don't add paddle mappings for the Xbox One Elite Series 1 controller, since they can't be unmapped and read directly on that controller. 2021-01-24 00:51:24 -05:00
Cameron Gutman
d789ba8332 Implement keyboard grab support for Wayland
Use zwp_keyboard_shortcuts_inhibit_manager_v1 to allow SDL applications
to capture system keyboard shortcuts like Alt+Tab when keyboard grab is
enabled via SDL_HINT_GRAB_KEYBOARD.
2021-01-24 00:51:24 -05:00
Cameron Gutman
6e97170e96 Use PS4 rumble hint as the default for the PS5 rumble hint
Existing SDL applications may not know about the need to set a specific
hint to enable rumble on PS5 controllers, even though they may already
set the equivalent SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE hint for PS4
controller rumble support.

Rather than requiring those developers update their apps, let's use the
SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE value as an indication of the behavior
they are expected for all PlayStation controllers.
2021-01-24 00:51:24 -05:00
Ozkan Sezer
07f83cd5a6 hidapi/libusb/hid.c: fix race condition on device close (bug #5484)
From hidapi mainstream git: https://github.com/libusb/hidapi/issues/142
d2c3a9862e

Read callback may fire itself on its own even after its been requested
to stop and exactly before the calling code waits for its completion in
indefinite loop.  Explicitly preventing re-fireing the submission loop
fixes the issue.
2021-01-24 00:51:24 -05:00
Manuel Alfayate Corchete
ee93f0edee [KMS/DRM] Revert unaproved fix for bug #5465. 2021-01-24 00:51:24 -05:00
Ozkan Sezer
6393d14de5 SDL_virtualjoystick.c: remove wrong #endif comment. 2021-01-24 00:51:24 -05:00
Ozkan Sezer
327ea97436 hidapi/libusb/hid.c: whitespace tidy-up. 2021-01-24 00:51:24 -05:00
Ozkan Sezer
282558379e fix AC_CHECK_HEADER for libusb.h 2021-01-24 00:51:24 -05:00
Sylvain Becker
4fbb9f31ab Fix declarations after statement 2021-01-24 00:51:24 -05:00
Sylvain Becker
0e7d435f13 Add basic testgles2_sdf program to demonstrate sign distance field with opengles2 2021-01-24 00:51:24 -05:00
Manuel Alfayate Corchete
e1d932f8b6 [KMS/DRM] Fix for bug #5468: corruption on dynamic cursor changing caused by wrong buffer size. 2021-01-24 00:51:24 -05:00
Manuel Alfayate Corchete
99facb1df3 [KMS/DRM] Fix for bug #5470: ratio correction for fullscreen windows with no matching resolution. Correct bracket position in else statements so they follow the coding style. 2021-01-24 00:51:24 -05:00
Sam Lantinga
c265e73f3b Fixed bug 5473 - Add WSCONS support for NetBSD
wahil1976

This patch adds WSCONS support for NetBSD.
2021-01-24 00:51:24 -05:00
Ozkan Sezer
f3835702d3 fix build with --disable-directx 2021-01-24 00:51:24 -05:00
Sam Lantinga
2ea393bd83 Fixed the screenshot button mapping on third party Bluetooth Nintendo Switch Pro controllers 2021-01-24 00:51:23 -05:00
Manuel Alfayate Corchete
03665004d0 [KMS/DRM] Small fix to KMSDRM_Waitpageflip(). More comments on how it works. 2021-01-24 00:51:23 -05:00
Ozkan Sezer
bdb3e6b84f SDL_hidapi_switch.c: fix build with older compilers 2021-01-15 12:40:00 +03:00
Sam Lantinga
69bd7ebbca Fixed build 2021-01-15 00:02:33 -08:00
Sam Lantinga
e3dbae5010 Get the serial number for the Nintendo Switch Pro controller 2021-01-14 23:49:41 -08:00
Sam Lantinga
5fc743c4fd Phantom Nintendo Switch Pro Controller initialization problem 2021-01-14 23:49:37 -08:00
Sam Lantinga
92742306a6 Fixed rumble reset failing for Switch Pro controllers in USB mode 2021-01-14 23:49:33 -08:00
Sam Lantinga
d0b87fede6 Added HIDAPI rumble debug info 2021-01-14 23:49:27 -08:00
Sam Lantinga
e2f46ed8ef Always lock the HIDAPI device when closing, in case rumble is pending 2021-01-14 23:49:20 -08:00
Sam Lantinga
907b8eebc3 Make sure the HIDAPI device is locked when closing it, in case there is rumble pending that didn't complete 2021-01-14 23:49:16 -08:00
Sam Lantinga
b3848c5120 Fixed bug 5445 - Incorrect Switch Pro Controller face buttons when SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS disabled
jibb

I'm testing with DualShock 4, DualSense, Switch Pro Controller, and PowerA Switch Controller.

I'm using the standard mapping file from here:
https://raw.github.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt

With SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS turned off (set to "0") I expect the button positions to be the same on all devices, based on Xbox controller button naming (eg SDL_GameControllerGetButton(g, SDL_CONTROLLER_BUTTON_Y) gives me whether the North face button is pressed).

However, the Switch Pro Controller layout is wrong (matching labels rather than positions, so X and Y are swapped and A and B are swapped). And with the PowerA controller the East and West buttons are correct, but the North and South buttons are swapped instead.

Mathias Kaerlev

Also seeing this on 2.0.14. This is most likely a regression, since we weren't seeing this on an earlier SDL version.

I suspect it might be caused by this commit:
a569b21188 (diff-da9344d94c66b8c702a45e7649f412039f08bba83bd82de33f5c80ea9c8c39d5)

It seems like both the HIDAPI driver and SDL_gamecontroller.c will try to swap the buttons if the hint is set to 0, causing the button remap to cancel out.
2021-01-14 15:15:57 -08:00
Sam Lantinga
bdc6e4ffc5 Fixed bug 5195 - Replugging in "mixed" controller types crashes on macOS
RustyM

This is related to Bug 5034, but crashes under a somewhat different condition.

In the latest tip (changeset 13914) or with the SDL 2.0.12 source + David?s 5034 patch, unplugging and then replugging in certain controller types on macOS will crash. A mix of new controllers like Switch Pro, PS4 and Xbox One all work without issue. But if a controller without a rumble function, like many SNES retro USB gamepads, is mixed with a PS4 or Switch Pro controller it will crash.

File: joystick/darwin/SDL_sysjoystick.c
Function: static recDevice *FreeDevice(recDevice *removeDevice)
On line 159: while (device->pNext != removeDevice) {
Causes: Thread 1: EXC_BAD_ACCESS (code=1, address=0x188)

This can be reproduced in testgamecontroller" by starting the test program with both a ?retro? controller plugged in and a ?modern rumble? controller (Switch Pro/PS4). This may crash on launch, but it depends on which controller ends up as device 0. If it doesn?t crash, unplug the ?modern rumble? controller and plug it back in.

Some of the "retro" controllers I?ve seen this crash with:
- iBuffalo SNES Controller
- 8Bitdo SN30 Gamepad (in MacOS mode)
- Retrolink NES Controller
- HuiJia SNES Controller Adaptor

The issue appears macOS specific. Seen on 10.12.6 and 10.14.6. Not seen on Windows 10.

The while loop in FreeDevice() assumes that every device is not NULL.

    recDevice *device = gpDeviceList;
    while (device->pNext != removeDevice) {
        device = device->pNext;
    }
    device->pNext = pDeviceNext;

So maybe we should check for NULL here? Or instead prevent adding NULL devices to the list in the first place? Checking device for NULL before entering the loop appears to work.

    recDevice *device = gpDeviceList;
    if (!device) {
        while (device->pNext != removeDevice) {
            device = device->pNext;
        }
    }
    device->pNext = pDeviceNext;
2021-01-14 15:03:11 -08:00