Reset screensaver counter on linux when joystick event was received
This commit is contained in:
parent
7ae541e638
commit
78cd8efdd4
@ -2081,11 +2081,13 @@ void CIrrDeviceLinux::pollJoysticks()
|
|||||||
for (u32 j= 0; j< ActiveJoysticks.size(); ++j)
|
for (u32 j= 0; j< ActiveJoysticks.size(); ++j)
|
||||||
{
|
{
|
||||||
JoystickInfo & info = ActiveJoysticks[j];
|
JoystickInfo & info = ActiveJoysticks[j];
|
||||||
|
bool event_received = false;
|
||||||
|
|
||||||
#ifdef __FreeBSD__
|
#ifdef __FreeBSD__
|
||||||
struct joystick js;
|
struct joystick js;
|
||||||
if (read(info.fd, &js, sizeof(js)) == sizeof(js))
|
if (read(info.fd, &js, sizeof(js)) == sizeof(js))
|
||||||
{
|
{
|
||||||
|
event_received = true;
|
||||||
info.persistentData.JoystickEvent.ButtonStates = js.b1 | (js.b2 << 1); /* should be a two-bit field */
|
info.persistentData.JoystickEvent.ButtonStates = js.b1 | (js.b2 << 1); /* should be a two-bit field */
|
||||||
info.persistentData.JoystickEvent.Axis[0] = js.x; /* X axis */
|
info.persistentData.JoystickEvent.Axis[0] = js.x; /* X axis */
|
||||||
info.persistentData.JoystickEvent.Axis[1] = js.y; /* Y axis */
|
info.persistentData.JoystickEvent.Axis[1] = js.y; /* Y axis */
|
||||||
@ -2098,14 +2100,23 @@ void CIrrDeviceLinux::pollJoysticks()
|
|||||||
{
|
{
|
||||||
case JS_EVENT_BUTTON:
|
case JS_EVENT_BUTTON:
|
||||||
if (event.value)
|
if (event.value)
|
||||||
info.persistentData.JoystickEvent.ButtonStates |= (1 << event.number);
|
{
|
||||||
|
event_received = true;
|
||||||
|
info.persistentData.JoystickEvent.ButtonStates |= (1 << event.number);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
info.persistentData.JoystickEvent.ButtonStates &= ~(1 << event.number);
|
{
|
||||||
|
event_received = true;
|
||||||
|
info.persistentData.JoystickEvent.ButtonStates &= ~(1 << event.number);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case JS_EVENT_AXIS:
|
case JS_EVENT_AXIS:
|
||||||
if (event.number < SEvent::SJoystickEvent::NUMBER_OF_AXES)
|
if (event.number < SEvent::SJoystickEvent::NUMBER_OF_AXES)
|
||||||
|
{
|
||||||
|
event_received = true;
|
||||||
info.persistentData.JoystickEvent.Axis[event.number] = event.value;
|
info.persistentData.JoystickEvent.Axis[event.number] = event.value;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -2116,6 +2127,13 @@ void CIrrDeviceLinux::pollJoysticks()
|
|||||||
|
|
||||||
// Send an irrlicht joystick event once per ::run() even if no new data were received.
|
// Send an irrlicht joystick event once per ::run() even if no new data were received.
|
||||||
(void)postEventFromUser(info.persistentData);
|
(void)postEventFromUser(info.persistentData);
|
||||||
|
|
||||||
|
#ifdef _IRR_COMPILE_WITH_X11_
|
||||||
|
if (event_received)
|
||||||
|
{
|
||||||
|
XResetScreenSaver(display);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
|
#endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user