From 0dbc4bef4976e237dfc3ff3e3116582020e3d129 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Fri, 3 Sep 2004 07:43:56 +0000 Subject: [PATCH] Changed the fQuit variable to a static sQuit. Removed the snooze() in the device watcher thread function. Started implementing the "one thread per device" design. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8810 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../devices/mouse/MouseInputDevice.cpp | 17 ++++++++++++----- .../devices/mouse/MouseInputDevice.h | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/add-ons/input_server/devices/mouse/MouseInputDevice.cpp b/src/add-ons/input_server/devices/mouse/MouseInputDevice.cpp index d2a5d9a886..35deba5b21 100644 --- a/src/add-ons/input_server/devices/mouse/MouseInputDevice.cpp +++ b/src/add-ons/input_server/devices/mouse/MouseInputDevice.cpp @@ -37,6 +37,7 @@ #endif FILE *MouseInputDevice::sLogFile = NULL; +bool MouseInputDevice::sQuit = false; // TODO: These are "stolen" from the kb_mouse driver on bebits, which uses // the same protocol as BeOS one. They're just here to test this add-on with @@ -59,6 +60,13 @@ struct mouse_movement { }; +struct mouse_device { + int driver_fd; + thread_id device_watcher; + uint32 buttons_state; +}; + + extern "C" BInputServerDevice * instantiate_input_device() @@ -69,7 +77,7 @@ instantiate_input_device() MouseInputDevice::MouseInputDevice() : fThread(-1), - fQuit(false) + sQuit(false) { // TODO: Open "/dev/input/mouse/serial/0" as well, and what about USB mouses ? fFd = open("dev/input/mouse/ps2/0", O_RDWR); @@ -78,7 +86,8 @@ MouseInputDevice::MouseInputDevice() B_FIRST_REAL_TIME_PRIORITY+4, this); #if DEBUG - sLogFile = fopen("/var/log/mouse_device_log.log", "w"); + if (sLogFile == NULL) + sLogFile = fopen("/var/log/mouse_device_log.log", "w"); #endif } @@ -220,11 +229,10 @@ MouseInputDevice::DeviceWatcher(void *arg) mouse_movement movements; BMessage *message; char log[128]; - while (!dev->fQuit) { + while (!sQuit) { if (ioctl(dev->fFd, kGetMouseMovements, &movements) < B_OK) continue; - // TODO: send B_MOUSE_UP/B_MOUSE_DOWN messages uint32 buttons = dev->fButtons ^ movements.buttons; snprintf(log, 128, "buttons: %ld, x: %ld, y: %ld\n", @@ -269,7 +277,6 @@ MouseInputDevice::DeviceWatcher(void *arg) dev->EnqueueMessage(message); } } - snooze(1000); } return 0; diff --git a/src/add-ons/input_server/devices/mouse/MouseInputDevice.h b/src/add-ons/input_server/devices/mouse/MouseInputDevice.h index d58dc5374c..6c881d6014 100644 --- a/src/add-ons/input_server/devices/mouse/MouseInputDevice.h +++ b/src/add-ons/input_server/devices/mouse/MouseInputDevice.h @@ -69,10 +69,10 @@ private: thread_id fThread; int fFd; - bool fQuit; mouse_settings fSettings; + static bool sQuit; static FILE *sLogFile; static int32 DeviceWatcher(void *arg);