I am using the "joyGetPosEx" function to detect the joystick inputs:
JOYINFOEX joyInfoEx;
ZeroMemory(&joyInfoEx, sizeof(joyInfoEx));
joyInfoEx.dwSize = sizeof(joyInfoEx);
// poll for values
joyGetPosEx(JOYSTICKID1, &joyInfoEx);
When the joystick is connected, every thing is working fine and the function returns "JOYERR_NOERROR".
However, if during the program run, i disconnect the joystick and connect it to a different USB port, the "joyGetPosEx(JOYSTICKID1, &joyInfoEx);" keeps returning a "JOYERR_UNPLUGGED" value.
If i reconnect the device to the initial USB port, it srtarts working again.
Does any one know how to make the joystick work even if it gets connected to a new port?
Thanks in advance!