-5

I need to write an easy function that only return bool answer.

if there is joystick plugged in the computer - true,else - false. how can i do this?

I have tried to write this code, but i only get the num of deviced that plug by usb to my computer, i need to know that this usb is joystick.

UINT pNum = 0;
RAWINPUTDEVICELIST* arr = new RAWINPUTDEVICELIST;
PRAWINPUTDEVICELIST pRawInputDeviceList = arr;
GetRawInputDeviceList(pRawInputDeviceList, &pNum, sizeof(RAWINPUTDEVICELIST));
std::cout << "Num entered: " << pNum << std::endl;
Meitarb12
  • 51
  • 1
  • 1
  • 4

1 Answers1

0

Use the joyGetPos function to determine whether a given joystick is physically attached to the system. If the specified joystick is not connected, joyGetPos returns a JOYERR_UNPLUGGED error value.

The joyGetNumDevs function returns the number of joysticks supported by the current driver or zero if no driver is installed.

Rita Han
  • 9,574
  • 1
  • 11
  • 24