Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I access the Joystick on windows in a non-deprecated way?

I want to write a Windows application which accesses the joystick. It is just a very simple application which reads the values and sends them to a server, so I am not using any game programming framework. However, I am confused about which API to use.

I looked at the Multimedia Joystick API, but this is described as superseded by DirectInput. So I looked at DirectInput, but this is also deprecated in favour of XInput. However the XInput documentation talks only about Xbox360 controllers, and says it does not support "legacy DirectInput devices".

Have Microsoft consigned the entire HID Joystick usage type to the dustbin and given up on supporting them in favour of their own proprietary controller products, or am I missing something?

like image 354
Jonathan Avatar asked Dec 10 '16 15:12

Jonathan


People also ask

Is DirectInput still used?

Even though XInput has been around now for 17 years, some modern games still support DirectInput controllers. One reason why is because there's a large installed base of legacy controllers out there that some people still like to use.

What is controller XInput?

XInput is an API that allows applications to receive input from the Xbox Controller for Windows.

What is gamepad API?

The Gamepad API is a way for developers and designers to access and use gamepads and other game controllers. The Gamepad API introduces new events on the Window object for reading gamepad and controller (hereby referred to as gamepad) state.

Where is XInput?

xinput is a utility to configure and test X input devices, such as mouses, keyboards, and touchpads. It is found in the xorg-xinput package.


1 Answers

The most common solution is to use a combination of XInput and DirectInput so your application can properly access both type of devices. Microsoft even provides instructions on how to do this.

Please note that DirectInput is not available for Windows Store apps so if you intend to distribute through there, that's not an option.

XInput devices like the XBox 360 controller will also work with DirectInput but with some limitations. Notably, the left and right trigger will be mapped to the same axis instead of being independents, and vibration effects will not be available.

like image 195
Zomby Avatar answered Nov 14 '22 22:11

Zomby