fixed logging, a bit of worker

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8879 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval
2004-09-07 00:03:20 +00:00
parent e73537f459
commit 43ca889200
2 changed files with 14 additions and 12 deletions
@@ -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;
}
@@ -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();