Fixed bug 2090 - Some joystick inputs are delayed on FreeBSD
kikuchan Some joysticks with high sampling rate need to be read() more fast, otherwise it delay user inputs due to internal queue. Especially, an app that issues SDL_PollEvent() not so frequent
parent
10ffa28a28
commit
dc9ddf1f61
|
@ -446,9 +446,7 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joy)
|
|||
static int x, y, xmin = 0xffff, ymin = 0xffff, xmax = 0, ymax = 0;
|
||||
|
||||
if (joy->hwdata->type == BSDJOY_JOY) {
|
||||
if (read(joy->hwdata->fd, &gameport, sizeof gameport) !=
|
||||
sizeof gameport)
|
||||
return;
|
||||
while (read(joy->hwdata->fd, &gameport, sizeof gameport) == sizeof gameport) {
|
||||
if (abs(x - gameport.x) > 8) {
|
||||
x = gameport.x;
|
||||
if (x < xmin) {
|
||||
|
@ -489,23 +487,22 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joy)
|
|||
if (gameport.b2 != joy->buttons[1]) {
|
||||
SDL_PrivateJoystickButton(joy, 1, gameport.b2);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif /* defined(__FREEBSD__) || SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H */
|
||||
|
||||
rep = &joy->hwdata->inreport;
|
||||
|
||||
if (read(joy->hwdata->fd, REP_BUF_DATA(rep), rep->size) != rep->size) {
|
||||
return;
|
||||
}
|
||||
while (read(joy->hwdata->fd, REP_BUF_DATA(rep), rep->size) == rep->size) {
|
||||
#if defined(USBHID_NEW) || (defined(__FREEBSD__) && __FreeBSD_kernel_version >= 500111) || defined(__FreeBSD_kernel__)
|
||||
hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input, rep->rid);
|
||||
#else
|
||||
hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input);
|
||||
#endif
|
||||
if (hdata == NULL) {
|
||||
fprintf(stderr, "%s: Cannot start HID parser\n", joy->hwdata->path);
|
||||
return;
|
||||
/*fprintf(stderr, "%s: Cannot start HID parser\n", joy->hwdata->path);*/
|
||||
continue;
|
||||
}
|
||||
|
||||
for (nbutton = 0; hid_get_item(hdata, &hitem) > 0;) {
|
||||
|
@ -552,8 +549,7 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joy)
|
|||
}
|
||||
}
|
||||
hid_end_parse(hdata);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Function to close a joystick after use */
|
||||
|
|
Loading…
Reference in New Issue