Joystick/gamepad speed problem

Previous topic - Next topic


I need to read data from a gamepad every millisecond. GL-Basic can read the joystick this quickly but from testing it appears that the data only gets updated every 7-8 millliseconds. I presume that this is a function of the Windows built in USB-HID driver, but I don't know for sure. I also know that a USB data frame can be sent every millisecond.

Does anyone know if there is a way to modify the gamepad/joystick driver to make it report data more frequently?

Kitty Hello

GLBasic is polling the Joystick at every GETJOY... call. The 7ms result in 140FPS, that's the most high refresh rate of your screen.

You might try to put 10 GETJOY... calls in a loop and then call SHOWSCREEN (which creates a pause of 6 ms I guess)


Actually, I have since discovered that Windows XP only polls the usbport.sys driver at 8ms intervals. It does this regardless of what the firmware in the usb device specifies in it's firmware descriptor (this may be only applicable to HID-class USB devices like Joysticks keyboards and gamepads, but it is hard-wired in Windows XP.)

Since the only user inputs available in GL Basic are those three devices, there seems to be no way to get real-world events that occur more frequently than 8ms into the programming environment. I did find an XP patch for usbport.sys that can reduce the usb device poll time to 4 or 2 ms... however some of the usb devices I tried could not keep up with the increased speed... but some could. In the end I had to discontinue using the usbport.sys patch as I also need the slower usb devices to remain working.

The only complete solution would be to use a faster (i.e. full-speed or high speed) usb input device. I'm currently looking at using a usb-parallel printer port cable as the hardware piece. But I will need a way to be able to access the device's data from GL-Basic.

So I'm wondering if there is a way to write and complie a C++ function which would specify the input parameters (like the usb devices name, and the size (X) bytes of the data to be returned). The function would return a string containing the X bytes. GL basic would need to add a new generic external function (such as... USER(ext_fn_filename, input_parametr1, input_parametr2, ... ,numbytes_returned) that would read the complied external C++ code into memory and then execute calls to it like any other built-in function...

Would this be possible? This would then be a means for adding functionality at the user-level which could then be shared through out the community...

Any thoughts?

J.S. Hart