diff --git a/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp b/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp index 3f6ee5cfc8..c82f5fc33a 100644 --- a/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp +++ b/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp @@ -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; diff --git a/src/add-ons/input_server/devices/mouse/MouseInputDevice.cpp b/src/add-ons/input_server/devices/mouse/MouseInputDevice.cpp index 4ef79fdf97..8a10297469 100644 --- a/src/add-ons/input_server/devices/mouse/MouseInputDevice.cpp +++ b/src/add-ons/input_server/devices/mouse/MouseInputDevice.cpp @@ -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; diff --git a/src/add-ons/input_server/devices/serial_mouse/MouseInputDevice.cpp b/src/add-ons/input_server/devices/serial_mouse/MouseInputDevice.cpp index 36fed92aae..1d083aa0b7 100644 --- a/src/add-ons/input_server/devices/serial_mouse/MouseInputDevice.cpp +++ b/src/add-ons/input_server/devices/serial_mouse/MouseInputDevice.cpp @@ -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, diff --git a/src/add-ons/input_server/devices/serial_mouse/SerialMouse.cpp b/src/add-ons/input_server/devices/serial_mouse/SerialMouse.cpp index 1858cb6cfe..f1414dcb65 100644 --- a/src/add-ons/input_server/devices/serial_mouse/SerialMouse.cpp +++ b/src/add-ons/input_server/devices/serial_mouse/SerialMouse.cpp @@ -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) { diff --git a/src/add-ons/input_server/devices/tablet/TabletInputDevice.cpp b/src/add-ons/input_server/devices/tablet/TabletInputDevice.cpp index 76b7f3a8cb..00eecd2ed2 100644 --- a/src/add-ons/input_server/devices/tablet/TabletInputDevice.cpp +++ b/src/add-ons/input_server/devices/tablet/TabletInputDevice.cpp @@ -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;