-
Notifications
You must be signed in to change notification settings - Fork 1.7k
SD: Windows Joystick API Improvements
SFML currently uses DirectInput
as its method of handling joystick events for users on Windows. This is now considered a legacy API, and has issues with supporting certain device types that are common joystick peripherals that users of SFML may like to support. For instance a developer attempting to use sf::Joystick
to support an Xbox 360 game controller (and subsequent controllers for recent Microsoft Xbox consoles) would find it unusable. This is because when using DirectInput the left and right triggers will behave as a singular button, not as independently (see here for more info). This limitation is fairly substantial and renders supporting a very common game controller on Windows difficult (if not for some, impossible).
To remedy this it is necessary for SFML to consider the various APIs available on Windows and decide on a way to allow sf::Joystick
to be able to handle this common device type.
With minimal consuming API changes, allow applications to receive input on both triggers simultaneously for Xbox controllers, bringing them up to the same standard of support available on other operating systems when using SFML.
*1 - Windows Update will push GameInput.dll (dependency), but if not present a redistributable exists to install it on client installations (E.g.: Could be part of the installation process)
DirectInput | XInput | Raw Input | Windows.Gaming.Input | GameInput | |
---|---|---|---|---|---|
Availability | Windows 2000 and above | Windows XP and above | Windows 95 and above | Windows 8.1 and above | Windows 10 and above *1 |
Xbox Triggers | One Axis | Two Axes | One Axis | Two Axes | Two Axes |
Limitations | One Axis for Xbox Controllers | Only works with Xbox Controllers | Annoying to use, uses the WM_INPUT window message, and only one axis for Xbox controllers. | Only provides values whilst the window is in focus. No background input. | Requires the GDK to develop applications with, the license for GameInput.h precludes redistributing the header or keeping it in source-control. |
Header | dinput.h | xinput.h | hidpi.h, winuser.h | winrt/Windows.Gaming.Input.h | gameinput.h |
Header file found in | Windows SDK | Windows SDK | Windows SDK | Windows SDK | Microsoft GDK |
API Style | NanoCOM | Simple C-API | Windows Messaging and HID | WinRT classes | NanoCOM |