mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-29 20:27:12 +01:00
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
This commit is contained in:
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;
|
static int x, y, xmin = 0xffff, ymin = 0xffff, xmax = 0, ymax = 0;
|
||||||
|
|
||||||
if (joy->hwdata->type == BSDJOY_JOY) {
|
if (joy->hwdata->type == BSDJOY_JOY) {
|
||||||
if (read(joy->hwdata->fd, &gameport, sizeof gameport) !=
|
while (read(joy->hwdata->fd, &gameport, sizeof gameport) == sizeof gameport) {
|
||||||
sizeof gameport)
|
|
||||||
return;
|
|
||||||
if (abs(x - gameport.x) > 8) {
|
if (abs(x - gameport.x) > 8) {
|
||||||
x = gameport.x;
|
x = gameport.x;
|
||||||
if (x < xmin) {
|
if (x < xmin) {
|
||||||
@ -489,23 +487,22 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joy)
|
|||||||
if (gameport.b2 != joy->buttons[1]) {
|
if (gameport.b2 != joy->buttons[1]) {
|
||||||
SDL_PrivateJoystickButton(joy, 1, gameport.b2);
|
SDL_PrivateJoystickButton(joy, 1, gameport.b2);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif /* defined(__FREEBSD__) || SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H */
|
#endif /* defined(__FREEBSD__) || SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H */
|
||||||
|
|
||||||
rep = &joy->hwdata->inreport;
|
rep = &joy->hwdata->inreport;
|
||||||
|
|
||||||
if (read(joy->hwdata->fd, REP_BUF_DATA(rep), rep->size) != rep->size) {
|
while (read(joy->hwdata->fd, REP_BUF_DATA(rep), rep->size) == rep->size) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
#if defined(USBHID_NEW) || (defined(__FREEBSD__) && __FreeBSD_kernel_version >= 500111) || defined(__FreeBSD_kernel__)
|
#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);
|
hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input, rep->rid);
|
||||||
#else
|
#else
|
||||||
hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input);
|
hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input);
|
||||||
#endif
|
#endif
|
||||||
if (hdata == NULL) {
|
if (hdata == NULL) {
|
||||||
fprintf(stderr, "%s: Cannot start HID parser\n", joy->hwdata->path);
|
/*fprintf(stderr, "%s: Cannot start HID parser\n", joy->hwdata->path);*/
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (nbutton = 0; hid_get_item(hdata, &hitem) > 0;) {
|
for (nbutton = 0; hid_get_item(hdata, &hitem) > 0;) {
|
||||||
@ -552,8 +549,7 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joy)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
hid_end_parse(hdata);
|
hid_end_parse(hdata);
|
||||||
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Function to close a joystick after use */
|
/* Function to close a joystick after use */
|
||||||
|
Loading…
Reference in New Issue
Block a user