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
This commit is contained in:
@@ -37,6 +37,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
FILE *MouseInputDevice::sLogFile = NULL;
|
FILE *MouseInputDevice::sLogFile = NULL;
|
||||||
|
bool MouseInputDevice::sQuit = false;
|
||||||
|
|
||||||
// TODO: These are "stolen" from the kb_mouse driver on bebits, which uses
|
// 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
|
// 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"
|
extern "C"
|
||||||
BInputServerDevice *
|
BInputServerDevice *
|
||||||
instantiate_input_device()
|
instantiate_input_device()
|
||||||
@@ -69,7 +77,7 @@ instantiate_input_device()
|
|||||||
|
|
||||||
MouseInputDevice::MouseInputDevice()
|
MouseInputDevice::MouseInputDevice()
|
||||||
: fThread(-1),
|
: fThread(-1),
|
||||||
fQuit(false)
|
sQuit(false)
|
||||||
{
|
{
|
||||||
// TODO: Open "/dev/input/mouse/serial/0" as well, and what about USB mouses ?
|
// TODO: Open "/dev/input/mouse/serial/0" as well, and what about USB mouses ?
|
||||||
fFd = open("dev/input/mouse/ps2/0", O_RDWR);
|
fFd = open("dev/input/mouse/ps2/0", O_RDWR);
|
||||||
@@ -78,7 +86,8 @@ MouseInputDevice::MouseInputDevice()
|
|||||||
B_FIRST_REAL_TIME_PRIORITY+4, this);
|
B_FIRST_REAL_TIME_PRIORITY+4, this);
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
sLogFile = fopen("/var/log/mouse_device_log.log", "w");
|
if (sLogFile == NULL)
|
||||||
|
sLogFile = fopen("/var/log/mouse_device_log.log", "w");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,11 +229,10 @@ MouseInputDevice::DeviceWatcher(void *arg)
|
|||||||
mouse_movement movements;
|
mouse_movement movements;
|
||||||
BMessage *message;
|
BMessage *message;
|
||||||
char log[128];
|
char log[128];
|
||||||
while (!dev->fQuit) {
|
while (!sQuit) {
|
||||||
if (ioctl(dev->fFd, kGetMouseMovements, &movements) < B_OK)
|
if (ioctl(dev->fFd, kGetMouseMovements, &movements) < B_OK)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// TODO: send B_MOUSE_UP/B_MOUSE_DOWN messages
|
|
||||||
uint32 buttons = dev->fButtons ^ movements.buttons;
|
uint32 buttons = dev->fButtons ^ movements.buttons;
|
||||||
|
|
||||||
snprintf(log, 128, "buttons: %ld, x: %ld, y: %ld\n",
|
snprintf(log, 128, "buttons: %ld, x: %ld, y: %ld\n",
|
||||||
@@ -269,7 +277,6 @@ MouseInputDevice::DeviceWatcher(void *arg)
|
|||||||
dev->EnqueueMessage(message);
|
dev->EnqueueMessage(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
snooze(1000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -69,10 +69,10 @@ private:
|
|||||||
|
|
||||||
thread_id fThread;
|
thread_id fThread;
|
||||||
int fFd;
|
int fFd;
|
||||||
bool fQuit;
|
|
||||||
|
|
||||||
mouse_settings fSettings;
|
mouse_settings fSettings;
|
||||||
|
|
||||||
|
static bool sQuit;
|
||||||
static FILE *sLogFile;
|
static FILE *sLogFile;
|
||||||
|
|
||||||
static int32 DeviceWatcher(void *arg);
|
static int32 DeviceWatcher(void *arg);
|
||||||
|
|||||||
Reference in New Issue
Block a user