From 43ca889200bc77465991e806bd6d467bd5662512 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Tue, 7 Sep 2004 00:03:20 +0000 Subject: [PATCH] fixed logging, a bit of worker git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8879 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../devices/keyboard/KeyboardInputDevice.cpp | 20 ++++++++++--------- .../devices/keyboard/KeyboardInputDevice.h | 6 +++--- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp b/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp index 18c5d90beb..829a69e410 100644 --- a/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp +++ b/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.cpp @@ -36,7 +36,8 @@ #define DEBUG 1 #if DEBUG - #define LOG(text) fputs(text, sLogFile); fflush(sLogFile) + inline void LOG(const char *fmt, ...) { char buf[1024]; va_list ap; va_start(ap, fmt); vsprintf(buf, fmt, ap); va_end(ap); \ + fputs(buf, KeyboardInputDevice::sLogFile); fflush(KeyboardInputDevice::sLogFile); } #else #define LOG(text) #endif @@ -137,10 +138,7 @@ KeyboardInputDevice::Stop(const char *name, void *cookie) { keyboard_device *device = (keyboard_device *)cookie; - char log[128]; - snprintf(log, 128, "Stop(%s)\n", name); - - LOG(log); + LOG("Stop(%s)\n", name); device->active = false; if (device->device_watcher >= 0) { @@ -156,10 +154,7 @@ status_t KeyboardInputDevice::Control(const char *name, void *cookie, uint32 command, BMessage *message) { - char log[128]; - snprintf(log, 128, "Control(%s, code: %lu)\n", name, command); - - LOG(log); + LOG("Control(%s, code: %lu)\n", name, command); if (command == B_NODE_MONITOR) HandleMonitor(message); @@ -269,6 +264,13 @@ int32 KeyboardInputDevice::DeviceWatcher(void *arg) { keyboard_device *dev = (keyboard_device *)arg; + uint8 buffer[12]; + + while (dev->active) { + if (ioctl(dev->fd, kGetNextKey, &buffer) < B_OK) + continue; + LOG("kGetNextKey : %lx%lx%lx\n", (uint32*)buffer, (uint32*)buffer+1, (uint32*)buffer+2); + } return 0; } diff --git a/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.h b/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.h index 8329934871..027a3e9725 100644 --- a/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.h +++ b/src/add-ons/input_server/devices/keyboard/KeyboardInputDevice.h @@ -48,6 +48,8 @@ public: virtual status_t Control(const char *name, void *cookie, uint32 command, BMessage *message); + + static FILE *sLogFile; private: status_t HandleMonitor(BMessage *message); status_t InitFromSettings(void *cookie, uint32 opcode = 0); @@ -59,9 +61,7 @@ private: static int32 DeviceWatcher(void *arg); static char *GetShortName(const char *longName); - BList fDevices; - - static FILE *sLogFile; + BList fDevices; }; extern "C" BInputServerDevice *instantiate_input_device();