Sam Lantinga
022235012c
Fixed crash if WGI didn't give us the name for a controller
2021-08-02 16:40:58 -07:00
Sam Lantinga
9d457aa446
Don't uninitialize COM because of what appears to be a bug in Microsoft WGI reference counting.
...
This fixes https://github.com/libsdl-org/SDL/issues/4488
2021-07-29 14:25:13 -07:00
Sam Lantinga
d4ac6b5ed9
Detect buffer overflow when getting DirectInput device state
...
This fixes bug https://github.com/libsdl-org/SDL/issues/4528
2021-07-24 15:58:33 -07:00
Sam Lantinga
adb75d642c
Fixed hotplug detection not working on UWP or when SDL isn't pumping Windows events
...
This fixes bugs:
https://github.com/libsdl-org/SDL/issues/4321
https://github.com/libsdl-org/SDL/issues/4147
Thanks to DJm00n for the suggestion!
2021-07-23 23:45:18 -07:00
Sam Lantinga
24059a19c5
The RAWINPUT driver is no longer tied to HIDAPI in any way
2021-07-09 18:11:42 -07:00
Sam Lantinga
d135c0762f
Added SDL_GameControllerSendEffect() and SDL_JoystickSendEffect() to allow applications to send custom effects to the PS4 and PS5 controllers
...
See testgamecontroller.c for an example of a custom PS5 trigger effect
2021-07-08 13:22:41 -07:00
Dimitriy Ryazantcev
39302c9214
Add Steam Virtual Gamepad and Xbox 360 Wired Controller defines instead of magic values
...
See https://partner.steamgames.com/doc/features/steam_controller/steam_input_gamepad_emulation_bestpractices for details on what is Steam Virtual Gamepad.
2021-06-30 08:48:13 -07:00
Sam Lantinga
205b951b46
SDL_DINPUT_JoystickPresent() needs to do the full device enumeration
...
It is called from WGI before the normal joystick detection has been run, so it needs to actually enumerate currently connected devices.
We can skip the logic checking for other drivers also supporting this device, because that logic is duplicated from the call site.
2021-06-25 14:20:08 -07:00
Dimitriy Ryazantcev
f5122377c9
Move SDL_IsXInputDevice check above actual joystick allocation
2021-06-10 16:41:09 -07:00
Dimitriy Ryazantcev
766d81ec86
Rewrite SDL_DINPUT_JoystickPresent method to avoid costly IDirectInput8_CreateDevice calls
2021-06-10 16:41:09 -07:00
Dimitriy Ryazantcev
a6da2fbf73
Rename haptic methods to avoid confusion with joystick:
...
`SDL_DINPUT_MaybeAddDevice`->`SDL_DINPUT_HapticMaybeAddDevice`
`SDL_DINPUT_MaybeRemoveDevice`->`SDL_DINPUT_HapticMaybeRemoveDevice`
`SDL_XINPUT_MaybeAddDevice`->`SDL_XINPUT_HapticMaybeAddDevice`
`SDL_XINPUT_MaybeRemoveDevice`->`SDL_XINPUT_HapticMaybeRemoveDevice`
2021-06-10 16:41:09 -07:00
Dimitriy Ryazantcev
73dc68a7ae
Simplify and cleanup DirectInput joystick backend code:
...
- Do not call IDirectInputDevice8_QueryInterface(device, &IID_IDirectInputDevice8,...) on DIRECTINPUTDEVICE8 device
- Get joystick VendorID and ProductID via IDirectInputDevice8_GetProperty(.., DIPROP_VIDPID, ..) call instead of messing with DIDEVICEINSTANCE.guidProduct
- Normalize HID device interface path to upper case for stable operation of XInput check
- Remove useless RawInput calls in SDL_IsXInputDevice() - just check for "IG_" string in HID device interface path that we already have
There shouldn't be any observable behavior changes.
2021-06-10 16:41:09 -07:00
Dimitriy Ryazantcev
f2f759dca3
Remove not used DirectInput ignored_devices list
2021-06-10 16:41:09 -07:00
Dimitriy Ryazantcev
adc2d362ba
Remove outdated and not used WIN_IsXInputDevice code
2021-06-10 16:41:09 -07:00
Ozkan Sezer
f498c281e1
fixed build with SDL_JOYSTICK_RAWINPUT enabled after commit b81969d46f
...
See: https://github.com/libsdl-org/SDL/pull/4388#issuecomment-852713792
2021-06-02 14:10:50 +03:00
Ethan Lee
40210f8945
winrt: Always use a thread for joystick support
2021-04-26 21:29:56 -04:00
Sam Lantinga
fadfa51022
Don't uncorrelate while rumble is active and stay correlated longer in case raw input messages are lagging a bit.
2021-02-10 10:22:19 -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
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
f3835702d3
fix build with --disable-directx
2021-01-24 00:51:24 -05:00
Ozkan Sezer
a594b85031
use WIN_StringToUTF8W macro instead of WIN_StringToUTF8, where needed:
...
i.e. where the string is known guaranteed to be WCHAR*, in:
- SDL_dinputjoystick.c (WIN_IsXInputDevice): VARIANT->var is BSTR (WCHAR*)
- SDL_rawinputjoystick.c (RAWINPUT_AddDevice): string is WCHAR*
- SDL_windows_gaming_input.c (IEventHandler_CRawGameControllerVtbl_InvokeAdded):
string is WCHAR*
There should be more of these..
2021-01-04 10:00:30 +03:00
Ozkan Sezer
f2bd861cd7
move SDL_tcsstr definition to core/windows/SDL_windows.h
2021-01-04 08:50:00 +03:00
Ozkan Sezer
ae18109a92
SDL_windowsjoystick.c (SDL_CreateDeviceNotification): use L, not TEXT()
...
cf. bug #5435 .
2021-01-04 01:23:50 +03:00
Ozkan Sezer
398d2764c7
RAWINPUT_InitWindowsGamingInput: change pNamespace from LPTSTR to PCWSTR
...
because WindowsCreateStringReference specifically accepts const WCHAR *
- WGI_JoystickInit(): ditto.
cf. bug #5435 .
2021-01-04 01:23:50 +03:00
Ozkan Sezer
f09e0af7aa
SDL_dinputjoystick.c (IsXInputDevice): adjust to be ANSI/UNICODE-agnostic
...
cf. bug #5435 .
2021-01-04 01:23:50 +03:00
Sam Lantinga
9130f7c377
Updated copyright for 2021
2021-01-02 10:25:38 -08:00
Sam Lantinga
cbe13d232d
Fixed controller hotplug detection when joystick thread is not enabled
2020-12-18 13:10:36 -08:00
Ozkan Sezer
90456670b5
more "'for' loop initial declarations are only allowed in C99 mode" fixes
2020-12-17 14:11:00 +03:00
Sam Lantinga
9ee0e8886c
Whoops, make the hint actually default to false
2020-12-12 22:11:00 -08:00
Sam Lantinga
13a4caf1d7
Fixed bug 4286 - Joystick subsystem causes "not responding" when app is in the background
...
Added a hint to control whether a separate thread should be used for joystick events.
This is off by default because dispatching messages in other threads appears to cause problems on some versions of Windows.
2020-12-12 22:08:02 -08:00
Sam Lantinga
797a6910fd
Fixed bug 5375 - WGI: Fix HSTRING memory leak.
...
Joel Linn
TLDR; https://godbolt.org/z/43fd8G
Let's deduce this from C++ reference code:
https://docs.microsoft.com/en-us/cpp/cppcx/wrl/how-to-activate-and-use-a-windows-runtime-component-using-wrl?view=msvc-160
At the bottom of the page there is this snippet:
```
int wmain()
{
/* ... more code ... */
// Get the domain part of the URI.
HString domainName;
hr = uri->get_Domain(domainName.GetAddressOf());
if (FAILED(hr))
{
return PrintError(__LINE__, hr);
}
// Print the domain name and return.
wprintf_s(L"Domain name: %s\n", domainName.GetRawBuffer(nullptr));
// All smart pointers and RAII objects go out of scope here.
}
```
`HString` is defined in `corewrappers.h` and the call chain for the destructor is:
`~HString() -> Release() -> ::WindowsDeleteString()`
QED
2020-12-09 20:28:51 -08:00
Sam Lantinga
a77a07152a
Disabled raw input debug output
2020-12-09 07:50:15 -08:00
Sam Lantinga
cb36189692
Fixed bug 5235 - All internal sources should include SDL_assert.h
...
Ryan C. Gordon
We should really stick this in SDL_internal.h or something so it's always available.
2020-12-09 07:16:22 -08:00
Sam Lantinga
f2fff21762
Fixed bug 5374 - WGI: Use fast-pass strings.
...
Joel Linn
Eliminate additional heap allocation for short-lived HSTRINGs.
Uses `WindowsCreateStringReference()` to disable reference counting and memory management by the Window Runtime.
2020-12-09 06:24:40 -08:00
Sam Lantinga
1031231b29
Fixed duplicating a device between XInput and HIDAPI
2020-12-03 18:17:03 -08:00
Sam Lantinga
c78ca2d170
Fixed bug 5371 - Rawinput: Fix truncating cast of string length.
...
Joel Linn
Fixes an implicit truncation of a string length on 64bit systems.
2020-12-01 13:38:42 -08:00
Sam Lantinga
a3ccf9adca
Fixed bug 5373 - [PATCH] Rawinput: Get correlated XInput battery info
...
Joel Linn
Currently the rawinput driver always reports a device as "wired". This changes that to "unknown" and updates it once the device is correlated with xinput.
2020-12-01 13:36:41 -08:00
Sam Lantinga
1f2f536bd2
Fixed XInput correlation for raw input controllers after hotplug events
2020-11-27 18:57:40 -08:00
Sam Lantinga
1c865c460b
Load the raw input device list at init time so it's available when DirectInput is doing device detection
2020-11-27 18:57:36 -08:00
Sam Lantinga
a0c5bfa3bd
Moved raw input event processing from the main thread to the joystick thread
...
This allows fast joystick event delivery regardless of what the main thread is doing.
2020-11-27 13:08:40 -08:00
Sam Lantinga
4fbefbe20d
Sort the raw input axes by usage, so X comes before Y, etc.
2020-11-27 11:33:53 -08:00
Sam Lantinga
4ddac485db
Backed out minor optimization that prevented correlation_id from being set
2020-11-27 11:33:51 -08:00
Sam Lantinga
8973a25849
Enable dispatching of WM_INPUT_DEVICE_CHANGE events directly, in case the application hasn't created a window with the normal message loop
2020-11-27 10:44:56 -08:00
Sam Lantinga
e8adc64810
Enable dispatching of WM_INPUT events directly, in case the application hasn't created a window with the normal message loop
2020-11-27 10:44:55 -08:00
Sam Lantinga
0252235e82
Recheck devices if another API queries raw input for a new device
2020-11-27 10:44:53 -08:00
Sam Lantinga
a7dede7e36
Re-enable axis correlation for raw input controllers, for twin stick shooters that don't need face buttons
2020-11-27 10:44:51 -08:00
Sam Lantinga
ce77966da8
Fixed RAWINPUT_IsDevicePresent() not returning TRUE for Xbox One controllers
2020-11-27 10:44:49 -08:00
Sam Lantinga
8a449de20d
Fixed Xbox 360 wireless controller being picked up by WGI when it's being managed by RAWINPUT
2020-11-27 10:44:47 -08:00
Sam Lantinga
37c9e4afa3
Fixed processing WM_INPUT_DEVICE_CHANGE at startup
2020-11-27 06:03:15 -08:00
Sam Lantinga
248fc75bd2
Correlate just based on buttons, joystick axes are not as precise and could potentially cause incorrect uncorrelation.
...
It's okay if the triggers aren't precise until someone presses a button on their controller.
2020-11-27 05:53:56 -08:00