Prevent input_server from hogging the CPU when input devices fail.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14476 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
a21a8b1324
commit
106d748c45
@ -618,10 +618,15 @@ KeyboardInputDevice::DeviceWatcher(void *arg)
|
||||
|
||||
memset(states, 0, sizeof(states));
|
||||
|
||||
LOG("%s\n", __PRETTY_FUNCTION__);
|
||||
|
||||
while (dev->active) {
|
||||
LOG("%s\n", __PRETTY_FUNCTION__);
|
||||
|
||||
if (ioctl(dev->fd, kGetNextKey, &buffer) == B_OK) {
|
||||
if (ioctl(dev->fd, kGetNextKey, &buffer) != B_OK) {
|
||||
snooze(10000); // this is a realtime thread, and something is wrong...
|
||||
continue;
|
||||
}
|
||||
|
||||
uint32 keycode = 0;
|
||||
bool is_keydown = false;
|
||||
bigtime_t timestamp = 0;
|
||||
@ -769,10 +774,6 @@ KeyboardInputDevice::DeviceWatcher(void *arg)
|
||||
activeDeadKey = newDeadKey;
|
||||
}
|
||||
lastKeyCode = keycode;
|
||||
} else {
|
||||
LOG("kGetNextKey error 2\n");
|
||||
snooze(100000);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -339,8 +339,10 @@ MouseInputDevice::DeviceWatcher(void *arg)
|
||||
BMessage *message = NULL;
|
||||
while (dev->active) {
|
||||
memset(&movements, 0, sizeof(movements));
|
||||
if (ioctl(dev->fd, MS_READ, &movements) < B_OK)
|
||||
if (ioctl(dev->fd, MS_READ, &movements) != B_OK) {
|
||||
snooze(10000); // this is a realtime thread, and something is wrong...
|
||||
continue;
|
||||
}
|
||||
|
||||
uint32 buttons = buttons_state ^ movements.buttons;
|
||||
|
||||
|
@ -251,9 +251,10 @@ MouseInputDevice::DeviceWatcher(void* arg)
|
||||
while (dev->active)
|
||||
{
|
||||
memset(&movements, 0, sizeof(movements));
|
||||
|
||||
if (dev->sm->GetMouseEvent(&movements) < B_OK)
|
||||
if (dev->sm->GetMouseEvent(&movements) != B_OK) {
|
||||
snooze(10000); // this is a realtime thread, and something is wrong...
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
LOG("%s: buttons: 0x%lx, x: %ld, y: %ld, clicks:%ld, wheel_x:%ld, \
|
||||
wheel_y:%ld\n", dev->device_ref.name, movements.buttons,
|
||||
|
@ -306,11 +306,8 @@ SerialMouse::GetMouseEvent(mouse_movement* mm)
|
||||
if (GetPacket(data) != B_OK)
|
||||
return B_ERROR; // not enough, or out-of-sync, data.
|
||||
|
||||
if (PacketToMM(data, mm) != B_OK) {
|
||||
// Something went wrong, clean up.
|
||||
memset(mm, 0, sizeof(mouse_movement));
|
||||
return B_ERROR;
|
||||
}
|
||||
if (PacketToMM(data, mm) != B_OK)
|
||||
return B_ERROR; // something went wrong
|
||||
|
||||
#ifdef DEBUG_SERIAL_MOUSE
|
||||
DumpData(mm);
|
||||
@ -344,8 +341,10 @@ SerialMouse::GetPacket(char data[])
|
||||
// TODO: Shall we block here instead of leaving after a timeout?
|
||||
// Yes, if we get called it's because there IS a mouse out there.
|
||||
|
||||
if (fSerialPort->Read(&c, 1) != 1)
|
||||
if (fSerialPort->Read(&c, 1) != 1) {
|
||||
snooze(5000); // this is a realtime thread, and something is wrong...
|
||||
break;
|
||||
}
|
||||
|
||||
if (bytes_read == 0) {
|
||||
if ((c & mp[fMouseID].sync[0]) != mp[fMouseID].sync[1]) {
|
||||
@ -383,7 +382,7 @@ SerialMouse::PacketToMM(char data[], mouse_movement* mm)
|
||||
const uint8 kTertiaryButton = 4;
|
||||
|
||||
static uint8 previous_buttons = 0; // only meaningful for kMicrosoft.
|
||||
|
||||
|
||||
mm->timestamp = system_time();
|
||||
|
||||
switch (fMouseID) {
|
||||
|
@ -322,8 +322,10 @@ TabletInputDevice::DeviceWatcher(void *arg)
|
||||
BMessage *message;
|
||||
while (dev->active) {
|
||||
memset(&movements, 0, sizeof(movements));
|
||||
if (ioctl(dev->fd, MS_READ, &movements) < B_OK)
|
||||
if (ioctl(dev->fd, MS_READ, &movements) != B_OK) {
|
||||
snooze(10000); // this is a realtime thread, and something is wrong...
|
||||
continue;
|
||||
}
|
||||
|
||||
uint32 buttons = buttons_state ^ movements.buttons;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user