]>
git.defcon.no Git - joysticktest/blob - joystickthread.cpp
1 #include "joystickthread.h"
11 int JoystickThread::open_joystick(char *joystick_device
)
13 joystick_fd
= open(joystick_device
, O_RDONLY
| O_NONBLOCK
);
17 int JoystickThread::read_joystick_event(struct js_event
*jse
)
21 bytes
= read(joystick_fd
, jse
, sizeof(*jse
));
26 if (bytes
== sizeof(*jse
))
32 JoystickThread::JoystickThread(JoystickData
*data
, QString device
)
34 this->device
= device
;
36 this->joystick_fd
= -1;
41 void JoystickThread::run()
46 fd
= open_joystick(this->device
.toLatin1().data());
51 rc
= read_joystick_event(&jse
);
54 if (jse
.type
== JS_EVENT_AXIS
)
58 jd
->setAxis(jse
.number
, jse
.value
);
61 if (jse
.type
== JS_EVENT_BUTTON
)
65 jd
->setButton(jse
.number
, jse
.value
);
75 void JoystickThread::stop()