Commit Graph

150 Commits

Author SHA1 Message Date
Sam Lantinga
aefe19ff08 Added support for the NACON Revolution Pro Controller 3 and the GameStop PS4 Fun Controller 2020-06-09 11:31:39 -07:00
Sam Lantinga
1e5dd06f83 Added support for the HORI Real Arcade Pro on Mac OSX and Linux 2020-05-06 12:19:58 -07:00
Sam Lantinga
11723411ab Added support for the Razer Kishi 2020-05-04 10:16:10 -07:00
Sam Lantinga
c6b24b4b7c Added support for the following controllers:
* 8BitDo N30 Pro 2
* 8BitDo SN30 Gamepad
* 8BitDo SN30 Pro+
* 8BitDo Zero 2
* SZMY-POWER PC Gamepad
* ThrustMaster eSwap PRO Controller
* ZEROPLUS P4 Wired Gamepad

In additional, all 8BitDo controllers use SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS to have the correct mapping based on user preferences.
2020-04-23 11:07:07 -07:00
Sam Lantinga
aba2792896 Added a Windows Gaming Input joystick driver
This driver supports the Razer Atrox Arcade Stick

Some of the quirks of this driver, inherent in Windows Gaming Input:
* There will never appear to be controllers connected at startup. You must support hot-plugging in order to see these controllers.
* You can't read the state of the guide button
* You can't get controller events in the background
2020-04-18 21:41:37 -07:00
Sam Lantinga
2be75c6a61 Fixed bug 5028 - Virtual Joysticks (new joystick backend)
David Ludwig

I have created a new driver for SDL's Joystick and Game-Controller subsystem: a Virtual driver.  This driver allows one to create a software-based joystick, which to SDL applications will look and react like a real joystick, but whose state can be set programmatically.  A primary use case for this is to help enable developers to add touch-screen joysticks to their apps.

The driver comes with a set of new, public APIs, with functions to attach and detach joysticks, set virtual-joystick state, and to determine if a joystick is a virtual-one.

Use of virtual joysticks goes as such:

1. Attach one or more virtual joysticks by calling SDL_JoystickAttachVirtual.  If successful, this returns the virtual-device's joystick-index.
2. Open the virtual joysticks (using indicies returned by SDL_JoystickAttachVirtual).
3. Call any of the SDL_JoystickSetVirtual* functions when joystick-state changes.  Please note that virtual-joystick state will only get applied on the next call to SDL_JoystickUpdate, or when pumping or polling for SDL events (via SDL_PumpEvents or SDL_PollEvent).


Here is a listing of the new, public APIs, at present and subject to change:

------------------------------------------------------------

/**
 * Attaches a new virtual joystick.
 * Returns the joystick's device index, or -1 if an error occurred.
 */
extern DECLSPEC int SDLCALL SDL_JoystickAttachVirtual(SDL_JoystickType type, int naxes, int nballs, int nbuttons, int nhats);

/**
 * Detaches a virtual joystick
 * Returns 0 on success, or -1 if an error occurred.
 */
extern DECLSPEC int SDLCALL SDL_JoystickDetachVirtual(int device_index);

/**
 * Indicates whether or not a virtual-joystick is at a given device index.
 */
extern DECLSPEC SDL_bool SDLCALL SDL_JoystickIsVirtual(int device_index);

/**
 * Set values on an opened, virtual-joystick's controls.
 * Returns 0 on success, -1 on error.
 */
extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualAxis(SDL_Joystick * joystick, int axis, Sint16 value);
extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualBall(SDL_Joystick * joystick, int ball, Sint16 xrel, Sint16 yrel);
extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualButton(SDL_Joystick * joystick, int button, Uint8 value);
extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualHat(SDL_Joystick * joystick, int hat, Uint8 value);

------------------------------------------------------------

Miscellaneous notes on the initial patch, which are also subject to change:

1. no test code is present in SDL, yet.  This should, perhaps, change.  Initial development was done with an ImGui-based app, which potentially is too thick for use in SDL-official.  If tests are to be added, what kind of tests?  Automated?  Graphical?

2. virtual game controllers can be created by calling SDL_JoystickAttachVirtual with a joystick-type of SDL_JOYSTICK_TYPE_GAME_CONTROLLER, with naxes (num axes) set to SDL_CONTROLLER_AXIS_MAX, and with nbuttons (num buttons) set to SDL_CONTROLLER_BUTTON_MAX.  When updating their state, values of type SDL_GameControllerAxis or SDL_GameControllerButton can be casted to an int and used for the control-index (in calls to SDL_JoystickSetVirtual* functions).

3. virtual joysticks' guids are mostly all-zeros with the exception of the last two bytes, the first of which is a 'v', to indicate that the guid is a virtual one, and the second of which is a SDL_JoystickType that has been converted into a Uint8.

4. virtual joysticks are ONLY turned into virtual game-controllers if and when their joystick-type is set to SDL_JOYSTICK_TYPE_GAMECONTROLLER.  This is controlled by having SDL's default list of game-controllers have a single entry for a virtual game controller (of guid, "00000000000000000000000000007601", which is subject to the guid-encoding described above).

5. regarding having to call SDL_JoystickUpdate, either directly or indirectly via SDL_PumpEvents or SDL_PollEvents, before new virtual-joystick state becomes active (as specified via SDL_JoystickSetVirtual* function-calls), this was done to match behavior found in SDL's other joystick drivers, almost all of which will only update SDL-state during SDL_JoystickUpdate.

6. the initial patch is based off of SDL 2.0.12

7. the virtual joystick subsystem is disabled by default.  It should be possible to enable it by building with SDL_JOYSTICK_VIRTUAL=1



Questions, comments, suggestions, or bug reports very welcome!
2020-03-13 19:08:45 -07:00
Sam Lantinga
255c9c23d4 Fixed bug 4921 - Do not swap B/X buttons on GameCube controller unless it's requested
The binding for the Mayflash GameCube controller adapter now respects the SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS hint
2020-03-13 13:28:33 -07:00
Sam Lantinga
cb2f78b12d Updated 8BitDo SF30 Pro mapping with hint support, added Android binding for the 8BitDo M30 Gamepad 2020-03-13 13:05:38 -07:00
Sam Lantinga
db3b3a1d84 Added support for SDL hints in the game controller mapping database 2020-03-12 19:47:28 -07:00
Sam Lantinga
49564c8b8d Added support for the PDP Victrix Pro FS with Touch Pad for PS4 2020-03-02 10:47:48 -08:00
Sam Lantinga
ad225047b6 Added Android SDK conditionals to game controller mappings
The Nintendo Switch Pro controller has a different mapping on Android 10 and newer
2020-02-17 14:15:47 -08:00
Sam Lantinga
a199cb89ad Updated the Android Xbox One Wireless Controller mapping for the latest Xbox controller firmware update 2020-02-05 09:29:46 -08:00
Sam Lantinga
43b377b077 Fixed wired PS4 controller support on Android 2020-01-28 17:11:17 -08:00
Sam Lantinga
2ae41b9c61 Fixed mapping for both versions of the Xbox One Elite Series 2 controller firmware connecting over Bluetooth 2020-01-23 12:53:43 -08:00
Sam Lantinga
48240ac88e Added mapping for the Xbox One controller connected via the wireless dongle using xow 2020-01-23 12:53:41 -08:00
Sam Lantinga
27035425e0 There are multiple bindings for XBox One controller model 1708, depending on firmware revision 2020-01-17 11:09:57 -08:00
Sam Lantinga
bde1a371d1 Added support for the NACON GC-400ES 2020-01-17 11:07:19 -08:00
Sam Lantinga
a8780c6a28 Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
Sam Lantinga
6705e27c9f Added D-PAD bindings for the Linux Steam Controller 2020-01-13 22:05:58 -08:00
Sam Lantinga
d33b122f4f The Xbox One S Bluetooth controller with older firmware uses b16 as the guide button. The same controller with newer firmware uses b12 as the guide button. Map both buttons so both firmware revisions will work with the same mapping. 2020-01-11 04:34:28 -08:00
Sam Lantinga
f4375e86f9 Added support for the 8BitDo M30 GamePad 2020-01-07 18:43:40 -08:00
Sam Lantinga
eb3d39bc8b Added support for the 8Bitdo FC30 Pro 2020-01-06 12:18:51 -08:00
Sam Lantinga
202c966a44 Added support for the Nintendo GameCube Controller, using the Mayflash GameCube adapter. 2019-12-19 16:14:22 -08:00
Sam Lantinga
52b6ab2196 Added support for the SteelSeries Stratus Duo 2019-12-16 17:11:23 -08:00
Sam Lantinga
9f8009f2e1 Added mappings for the Razer Serval on Windows and Mac OSX 2019-12-13 16:12:41 -08:00
Sam Lantinga
cf9af481e0 Added support for the 8Bitdo NES30 GamePad in wired mode 2019-12-13 16:12:39 -08:00
Sam Lantinga
89401b21e9 Added support for the Razer Raion Fightpad for PS4 2019-12-10 13:09:52 -08:00
Sam Lantinga
6d00166813 Get full axis range for PS3 controller triggers on Linux 2019-12-05 13:18:53 -08:00
Sam Lantinga
b98808f639 Updated DPAD binding for 8Bitdo Zero controller 2019-11-28 14:23:24 -08:00
Sam Lantinga
a3a8fcef77 Added support for the 8Bitdo SN30 Pro, wired connection 2019-11-28 10:04:05 -08:00
Sam Lantinga
98cc9cf208 Added support for the Google Stadia Controller 2019-11-27 12:38:53 -08:00
Sam Lantinga
43cb7b3c51 Added support for the Hori Fighting Commander 2019-11-27 12:38:51 -08:00
Sam Lantinga
8243a3e801 Added support for the Hyperkin X91 2019-11-25 15:02:50 -08:00
Sam Lantinga
13006ba9e1 Added support for the PDP Versus Fighting Pad 2019-11-22 13:44:40 -08:00
Sam Lantinga
a132b183cd Fixed the guide button on the NVIDIA Controller v01.04 2019-11-21 13:09:00 -08:00
Sam Lantinga
cc4f890521 Added support for the NVIDIA Controller v01.04 on Linux and Mac OS X 2019-11-21 12:11:47 -08:00
Sam Lantinga
2a7b635b9b Added support for the NVIDIA Controller v01.04 on Android 2019-11-21 11:52:50 -08:00
Sam Lantinga
51487a71b9 Added support for the MOGA XP5-A Plus 2019-11-21 10:14:57 -08:00
Sam Lantinga
972a70d844 Added support for the Xbox One Elite Series 2 controller on Mac OSX 2019-11-19 15:15:00 -08:00
Sam Lantinga
2bfcf5cd96 Added Linux controller mapping for the Xbox One Elite Series 2 controller in Bluetooth mode 2019-11-18 14:08:05 -08:00
Sam Lantinga
4f304fd88c Added support for the BDA PS4 Fightpad 2019-10-17 18:07:52 -07:00
Sam Lantinga
ce3b16fc9e Fixed bug 4475 - add Gasia Co. Ltd PS(R) Gamepad support
Frank

This gamepad/controller is sold in Germany https://www.amazon.de/gp/product/B01AQTPSA6/ref=ppx_yo_dt_b_asin_title_o03__o00_s00 but isn't supported right now. It identifies as "Gasia Co. Ltd PS(R) Gamepad"
2019-08-26 10:08:25 -07:00
Sam Lantinga
d52ffcf985 Added support for a few controllers on Android 2019-08-02 17:12:49 -07:00
Sam Lantinga
89de2512e5 Added support for the Victrix Pro Fight Stick for PS4 2019-07-17 13:01:44 -07:00
Sam Lantinga
064d1223f0 Fixed bug 4723 - Generic Xbox pad controller bindings seem odd/broken
alexrice999

I have a knock off wired xbox 360 controller called afterglow for xbox 360 controller. Despite there being a few afterglow controllers in the controller mapping the guid of my controller seems to map to Generic Xbox pad. This binding is as follows:
```
 "030000006f0e00001304000000010000,Generic X-Box pad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:a0,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:a3,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
```
When running openmw I have a strange issue that the joysticks work for up and down movements but not for side to side. I managed to track this down to the side to side events being classified as joystick events instead of gamepad events.
I believe this is due to both "leftstick" and "leftx" being bound to "a0" which seems odd to me. If I change openmw's mappings to remove these the controller works as expected. I was hoping someone who knows a lot more than me (as I have only been exploring this today trying to fix my controller) would know what is happening
2019-07-14 16:59:39 -07:00
Sam Lantinga
4eb3c0c387 Added support for Xbox and PS4 wireless controllers on iOS and tvOS
Also implemented SDL_JoystickGetDevicePlayerIndex() on iOS and tvOS, and added support for reading the new menu button state available in iOS and tvOS 13.
2019-06-14 13:56:52 -07:00
Benjamin Valentin
1e8d9e01dc Add mapping for Chinese-made Xbox Controller
This device is a copy of the Xbox Controller S and currently the one most sold
when shopping for a 'new' Xbox gamepad on eBay and AliExpress.
Except for the quirky USB ID id behaves just like a normal Xbox controller (when
ignoring the subpar build quality)
2019-03-17 23:47:12 +01:00
Sam Lantinga
a73dacbf62 Backed out Ben's chinese Xbox controller patch, as the generic catch-all for Xbox controllers should handle it. 2019-06-08 14:58:49 -07:00
Benjamin Valentin
f3c6b1f51a Add mapping for Chinese-made Xbox Controller
This device is a copy of the Xbox Controller S and currently the one most sold
when shopping for a 'new' Xbox gamepad on eBay and AliExpress.
Except for the quirky USB ID id behaves just like a normal Xbox controller (when
ignoring the subpar build quality)
2019-03-17 23:47:12 +01:00
Sam Lantinga
20ec866484 Added support for the Rotor Riot gamepad, and upcoming Xbox and PS4 controller support on iOS and tvOS
Patch contributed by Nat Brown
2019-06-06 08:20:53 -07:00