Jump to content
  • Advertisement
Sign in to follow this  
matt77hias

RegisterDeviceNotification for XBox One Controller

Recommended Posts

How do I need to register to receive device notifications for changes to an XBox One Controller? More concretely I want to receive WM_DEVICECHANGE messages with wParam == DBT_DEVNODES_CHANGED.

DEV_BROADCAST_DEVICEINTERFACE notification_filter =
{
  .dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE),
  .dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE
};

RegisterDeviceNotification(m_window, &notification_filter,
                           DEVICE_NOTIFY_WINDOW_HANDLE | DEVICE_NOTIFY_ALL_INTERFACE_CLASSES);

I already use XInput to query the state and capabilities of the controllers, but to avoid polling the (potentially wireless) controllers every frame, I would use the change message to conditionally poll instead.

Share this post


Link to post
Share on other sites
Advertisement

The above code actually works. Unfortunately, it only sends multiple messages upon connecting or disconnecting the controller. Is it possible to receive some message (of possibly different type) in case of a change (e.g., button press, thumbstick move, etc.)? 

Edited by matt77hias

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!