How does Windows' 'Game Controllers' properties connect to a joystick?

Robin Holenweger 0 Reputation points
2024-05-28T14:57:32.6533333+00:00

The situation: We need to use a new game controller (with a joystick only) hardware on Windows 10 IoT. In the properties of "Game Controllers", moving the joystick is visible in the displayed rectangle with the '+'. Our software using DirectX8 API only reads 0 values for x/y axes.

What I've tried so far:

  • DirectX 8: obviously doesn't work, also, it's deprecated
  • Using Gaming.Input: not an option, we have no UWP
  • XInput: not an option, we have no XBox (compatible) device
  • Using joyGetPosEx from MultiMediaSystem: doesn't work

The question: Obviously Windows somehow can "see" the controller and also recognizes the joystick movements; so what API do they use in this little "Game Controllers" window?

Any other suggestion on how to read joystick data?

Windows for IoT
Windows for IoT
A family of Microsoft operating systems designed for use in Internet of Things (IoT) devices.
400 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,758 questions
{count} votes

4 answers

Sort by: Most helpful
  1. Castorix31 85,806 Reputation points
    2024-05-28T16:09:43.1633333+00:00

    The question: Obviously Windows somehow can "see" the controller and also recognizes the joystick movements; so what API do they use in this little "Game Controllers" window?

    It uses DirectInput (mainly IDirectInputDevice8::Poll)


  2. Sander van de Velde | MVP 32,891 Reputation points MVP
    2024-05-28T16:29:04.4066667+00:00

    Hello @Robin Holenweger,

    welcome to this moderated Azure community forum.

    What kind of game controller do you mean?

    If this is an XBOX gamecontroller, in the past I was able to connect to it using C#. Check out this blog post for details.

    I used a Xbox One controller with wireless adapter for windows (to connect it to a laptop). More details are found here.

    As you can see, I had to execute "Gamepad.GetCurrentReading();" in a infinite loop.

    The library supports many more devices so you need to test this probably to see if this works with your game controller:

    User's image

    I hope this seems familiar to you.


    If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.


  3. kwikc 131 Reputation points
    2024-05-28T21:29:35.26+00:00

    Any other suggestion on how to read joystick data?

    Use Raw Input, https://learn.microsoft.com/en-us/windows/win32/inputdev/about-raw-input.


  4. Robin Holenweger 0 Reputation points
    2024-06-25T08:05:48.2566667+00:00

    Thanks for the contributions.

    Meanwhile I found a working solution: joystick api (mmsystem.h/winmm.lib):- joyGetPos() to get the axis position (joyGetPosEx() if buttons and the like need to be read as well)

    • joyConfigChanged() in case joyGetPos() returns an error, to force the driver to re-read the registry/configuration (e.g. for the case the joystick was exchanged)

    This API seems to be older than DirectX 8 / DirectInput, but I have not found any hints that this might be deprecated (as compared to DirectInput).

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.