✅ Windows Joystick API

What's the recommended Windows API to use for Joystick/Gamepad input these days if one needs background (non-focused window, problem for Windows.Gaming.Input) input, and one is not willing to take a dependency on the GDK (Read: No GameInput) whilst also being able to read independently the two triggers of the Xbox-style gamepad controllers (Problem for DirectInput) and working with various types of controllers that are NOT XInput-compatible (Like the PS4 controllers, problem for XInput) ?
20 Replies
Jester
Jester14mo ago
Raw Input - Win32 apps
This section describes how the system provides raw input to your application and how an application receives and processes that input.
RazorSharpFang
RazorSharpFang14mo ago
I am a bit intimidated by the RawInput APIs catsweat
Jester
Jester14mo ago
i dont think its as bad as it looks
RazorSharpFang
RazorSharpFang14mo ago
If you want joystick and button inputs it looks like you have to start using these APIs HidP_GetUsages https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/hidpi/nf-hidpi-hidp_getusages
HidP_GetUsages function (hidpi.h) - Windows drivers
The HidP_GetUsages routine returns a list of all the HID control button usages that are on a specified usage page and are set to ON in a HID report.
Jester
Jester14mo ago
uhm does this help u?
RazorSharpFang
RazorSharpFang14mo ago
No, that's for keyboard and mouse input, not for joystick/gamepad input
Jester
Jester14mo ago
just a small change to the register code to change it to joystick
RazorSharpFang
RazorSharpFang14mo ago
Okay but I'm struggling with actually getting the joystick state from the device
Jester
Jester14mo ago
<:PES_SadShrug:646092743378206760>
RazorSharpFang
RazorSharpFang14mo ago
To be clear, I'm struggling most with getting the state from the HID device, not registering for raw-input
WM_INPUT: Type: 2, Device: 0x717c0911, Size: 16, Count: 1, data: 0, GetRawInputDeviceInfoW says buffer size of 940 required. We have 1 buttons and 6 axes I think you have 16 buttons
Is one of my app's log statements. Does an Xbox controller really have 16 buttons?
Jester
Jester14mo ago
i have no idea i dont know much about controllers
RazorSharpFang
RazorSharpFang14mo ago
HidP_GetUsages returns only those buttons in usage which are actually pressed.
catthinking can confirm with much misery and with great lamentations that RawInput suffers from the same limitation that DirectInput has; it groups the left and right triggers as a single analog input rather than two discrete separate inputs. This literally ruins my entire purpose of trying to use RawInput. This makes me very sad.
RazorSharpFang
RazorSharpFang14mo ago
I may have to instead use DirectInput and ignore XInput capable devices https://learn.microsoft.com/en-us/windows/win32/xinput/xinput-and-directinput
Comparison of XInput and DirectInput features - Win32 apps
Compares XInput and DirectInput APIs and features.
RazorSharpFang
RazorSharpFang14mo ago
I have no idea how to associate a DirectInput device that is an XInput device with a specific XInput user index
sibber
sibber14mo ago
yes 4 (abxy) + 4 (dpad) + 2 (joysticks) + 1 (menu) + 1 (button next to menu) + 2 (bumpers) + 2 (triggers)
RazorSharpFang
RazorSharpFang14mo ago
The dpad is registered as one value provider instead of a series of buttons.
sibber
sibber14mo ago
oh
Accord
Accord14mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
RazorSharpFang
RazorSharpFang14mo ago
I do not have nor have found any good solutions to this, without taking the dependency on the GDK and utilizing GameInput, which is only going for work for Windows 10+ and may require a redistributable for older builds of Windows 10 that haven't received the Windows Gaming Services updates that supply the computer with the required runtime and libraries.
Want results from more Discord servers?
Add your server
More Posts
❔ why is there a comma in the [] when working in a multidimensional arrayim fairly advanced with c# but had no use to use multidimensional arrays for what im working on so i❔ LINQ expressions with "pipeline" patternBasically I need to process an AST in multiple steps to generate a LINQ expression from it. To that ❔ MAUI blazor windows handle URIHey so, I've been trying to get MAUI blazor to run as a single instance to handle custom URIs, with ✅ Tutorial For Desktop App Development???I've looked all over google and I cannot find a tutorial to teach me how to build a desktop applicat❔ can anyone help me figure out hashauth?Trying to edit debug settings but they're locked behind hashauth, anyone know how it works? https:/❔ Razor pages asp-validation-for="MyProperty " vs asp-validation-summary="All"I am working on a simple registration form using a Razor page, and having trouble getting a message ❔ ✅ Register instance of List as singletonThis feels like a dumb question, but I'm trying to keep a singleton instance of a List that can be a❔ Octokit can find the git hub repo but not the latest repository```csharp using Microsoft.AspNetCore.Mvc; using MooMooBotWebAPI.TokenAuthentication; using System.Ne❔ Dusplicate type names: using namespace vs changing the type names.Lets say you have 2 models with the same name like `MyApp.Customers.Orders` and `MyApp.Employees.Ord❔ How to create a list of generic objects?``` public class Item { DateTime Date; string Name; int Age; } public class ReportSetup<T> {