c++ - Using DirectInput to receive signal after plugging in joystick -


i have c++ program enumerates input devices (using direct input) @ start of program. if program started, , plug in controller, controller won't recognized until program restarted. know of event can use cause program enumerate of devices after new 1 plugged in?

this article discusses how detect game pad changes. first of all, can handle wm_devicechange message , check wparam dbt_devicearrival or dbt_deviceremovecomplete. seems in order receive these wparams, though, need call registerdevicenotification first.

the article's example of how follows:

dev_broadcast_deviceinterface notificationfilter; zeromemory(&notificationfilter, sizeof(notificationfilter));  notificationfilter.dbcc_devicetype = dbt_devtyp_deviceinterface; notificationfilter.dbcc_size = sizeof(notificationfilter);  hdevnotify hdevnotify; hdevnotify = registerdevicenotification(m_hwnd, &notificationfilter,    device_notify_window_handle |    device_notify_all_interface_classes);  if(hdevnotify == null) {    // error handling } 

the other thing watch out minimum supported os xp, need put in appropriate #define before including windows headers.

depending on want do, might not have call function first. instead, can check dbt_devnodes_changed not differentiate between device being plugged or unplugged. save code if don't care.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -