* Removed the log file stuff; debug output is now using debug_printf() instead.
* Removed an inconsistency: both mouse and keyboad input device add-ons would scan /dev/input/keyboard respectively /dev/input/mouse when loaded, but then only monitor certain subdirectories from it. Now they monitor all. * Made KeyboardInputDevice::InitCheck() do what the name says, ie. nothing else. * Now uses BObjectList instead of BList, which also simplifies the code a bit. * Make use of the new BPathMonitor messages: as those contain a path, they greatly simplify their handling. * Cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28242 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -2,7 +2,7 @@ SubDir HAIKU_TOP src add-ons input_server devices keyboard ;
|
|||||||
|
|
||||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||||
|
|
||||||
UsePrivateHeaders input interface tracker ;
|
UsePrivateHeaders input interface shared tracker ;
|
||||||
UsePrivateSystemHeaders ;
|
UsePrivateSystemHeaders ;
|
||||||
|
|
||||||
Addon <input>keyboard :
|
Addon <input>keyboard :
|
||||||
|
|||||||
@@ -1,11 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2004-2006, Jérôme Duval. All rights reserved.
|
* Copyright 2004-2006, Jérôme Duval. All rights reserved.
|
||||||
|
* Copyright 2005-2008, Axel Dörfler, [email protected].
|
||||||
|
*
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "KeyboardInputDevice.h"
|
#include "KeyboardInputDevice.h"
|
||||||
#include "kb_mouse_driver.h"
|
|
||||||
|
#include <errno.h>
|
||||||
|
#include <new>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <Autolock.h>
|
#include <Autolock.h>
|
||||||
@@ -15,22 +22,23 @@
|
|||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include "kb_mouse_driver.h"
|
||||||
#include <new>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
|
|
||||||
#if DEBUG
|
//#define TRACE_KEYBOARD_DEVICE
|
||||||
FILE *KeyboardInputDevice::sLogFile = NULL;
|
#ifdef TRACE_KEYBOARD_DEVICE
|
||||||
|
# define LOG(text...) debug_printf(text)
|
||||||
|
# define LOG_ERR(text...) LOG(text)
|
||||||
|
#else
|
||||||
|
# define LOG(text...) do {} while (0)
|
||||||
|
# define LOG_ERR(text...) debug_printf(text)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const static uint32 kKeyboardThreadPriority = B_FIRST_REAL_TIME_PRIORITY + 4;
|
#define CALLED() LOG("%s\n", __PRETTY_FUNCTION__)
|
||||||
const static char *kKeyboardDevicesDirectory = "/dev/input/keyboard";
|
|
||||||
|
|
||||||
// "/dev/" is automatically prepended by StartMonitoringDevice()
|
|
||||||
const static char *kKeyboardDevicesDirectoryPS2 = "input/keyboard/at";
|
const static uint32 kKeyboardThreadPriority = B_FIRST_REAL_TIME_PRIORITY + 4;
|
||||||
const static char *kKeyboardDevicesDirectoryUSB = "input/keyboard/usb";
|
const static char* kKeyboardDevicesDirectory = "/dev/input/keyboard";
|
||||||
|
|
||||||
const static uint32 kATKeycodeMap[] = {
|
const static uint32 kATKeycodeMap[] = {
|
||||||
0x1, // Esc
|
0x1, // Esc
|
||||||
@@ -327,16 +335,15 @@ const static uint32 kATKeycodeMap[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
extern "C"
|
extern "C" BInputServerDevice*
|
||||||
BInputServerDevice *
|
|
||||||
instantiate_input_device()
|
instantiate_input_device()
|
||||||
{
|
{
|
||||||
return new (std::nothrow) KeyboardInputDevice();
|
return new(std::nothrow) KeyboardInputDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static char *
|
static char*
|
||||||
get_short_name(const char *longName)
|
get_short_name(const char* longName)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
BString string(longName);
|
BString string(longName);
|
||||||
@@ -366,31 +373,21 @@ get_short_name(const char *longName)
|
|||||||
|
|
||||||
KeyboardInputDevice::KeyboardInputDevice()
|
KeyboardInputDevice::KeyboardInputDevice()
|
||||||
:
|
:
|
||||||
fTMWindow(NULL),
|
fDevices(2, true),
|
||||||
|
fTeamMonitorWindow(NULL),
|
||||||
fKeymapLock("keymap lock")
|
fKeymapLock("keymap lock")
|
||||||
{
|
{
|
||||||
#if DEBUG
|
|
||||||
if (sLogFile == NULL)
|
|
||||||
sLogFile = fopen("/var/log/keyboard_device_log.log", "a");
|
|
||||||
#endif
|
|
||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
|
StartMonitoringDevice(kKeyboardDevicesDirectory);
|
||||||
|
_RecursiveScan(kKeyboardDevicesDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
KeyboardInputDevice::~KeyboardInputDevice()
|
KeyboardInputDevice::~KeyboardInputDevice()
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
StopMonitoringDevice(kKeyboardDevicesDirectoryUSB);
|
StopMonitoringDevice(kKeyboardDevicesDirectory);
|
||||||
StopMonitoringDevice(kKeyboardDevicesDirectoryPS2);
|
|
||||||
|
|
||||||
int count = fDevices.CountItems();
|
|
||||||
while (count-- > 0) {
|
|
||||||
delete (keyboard_device *)fDevices.RemoveItem((int32)0);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if DEBUG
|
|
||||||
fclose(sLogFile);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -398,25 +395,25 @@ status_t
|
|||||||
KeyboardInputDevice::SystemShuttingDown()
|
KeyboardInputDevice::SystemShuttingDown()
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
if (fTMWindow)
|
if (fTeamMonitorWindow)
|
||||||
fTMWindow->PostMessage(SYSTEM_SHUTTING_DOWN);
|
fTeamMonitorWindow->PostMessage(SYSTEM_SHUTTING_DOWN);
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
KeyboardInputDevice::_InitFromSettings(void *cookie, uint32 opcode)
|
KeyboardInputDevice::_InitFromSettings(void* cookie, uint32 opcode)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
keyboard_device *device = (keyboard_device *)cookie;
|
keyboard_device* device = (keyboard_device*)cookie;
|
||||||
|
|
||||||
if (opcode == 0 || opcode == B_KEY_REPEAT_RATE_CHANGED) {
|
if (opcode == 0 || opcode == B_KEY_REPEAT_RATE_CHANGED) {
|
||||||
if (get_key_repeat_rate(&device->settings.key_repeat_rate) != B_OK)
|
if (get_key_repeat_rate(&device->settings.key_repeat_rate) != B_OK)
|
||||||
LOG_ERR("error when get_key_repeat_rate\n");
|
LOG_ERR("error when get_key_repeat_rate\n");
|
||||||
else if (ioctl(device->fd, KB_SET_KEY_REPEAT_RATE,
|
else if (ioctl(device->fd, KB_SET_KEY_REPEAT_RATE,
|
||||||
&device->settings.key_repeat_rate) != B_OK)
|
&device->settings.key_repeat_rate) != B_OK)
|
||||||
LOG_ERR("error when KB_SET_KEY_REPEAT_RATE, fd:%d\n", device->fd);
|
LOG_ERR("error when KB_SET_KEY_REPEAT_RATE, fd:%d\n", device->fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -424,12 +421,11 @@ KeyboardInputDevice::_InitFromSettings(void *cookie, uint32 opcode)
|
|||||||
if (get_key_repeat_delay(&device->settings.key_repeat_delay) != B_OK)
|
if (get_key_repeat_delay(&device->settings.key_repeat_delay) != B_OK)
|
||||||
LOG_ERR("error when get_key_repeat_delay\n");
|
LOG_ERR("error when get_key_repeat_delay\n");
|
||||||
else if (ioctl(device->fd, KB_SET_KEY_REPEAT_DELAY,
|
else if (ioctl(device->fd, KB_SET_KEY_REPEAT_DELAY,
|
||||||
&device->settings.key_repeat_delay) != B_OK)
|
&device->settings.key_repeat_delay) != B_OK)
|
||||||
LOG_ERR("error when KB_SET_KEY_REPEAT_DELAY, fd:%d\n", device->fd);
|
LOG_ERR("error when KB_SET_KEY_REPEAT_DELAY, fd:%d\n", device->fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opcode == 0
|
if (opcode == 0 || opcode == B_KEY_MAP_CHANGED
|
||||||
|| opcode == B_KEY_MAP_CHANGED
|
|
||||||
|| opcode == B_KEY_LOCKS_CHANGED) {
|
|| opcode == B_KEY_LOCKS_CHANGED) {
|
||||||
BAutolock lock(fKeymapLock);
|
BAutolock lock(fKeymapLock);
|
||||||
fKeymap.LoadCurrent();
|
fKeymap.LoadCurrent();
|
||||||
@@ -445,25 +441,15 @@ status_t
|
|||||||
KeyboardInputDevice::InitCheck()
|
KeyboardInputDevice::InitCheck()
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
status_t status = BInputServerDevice::InitCheck();
|
return BInputServerDevice::InitCheck();
|
||||||
if (status < B_OK)
|
|
||||||
return status;
|
|
||||||
|
|
||||||
// TODO: this doesn't belong here!
|
|
||||||
_RecursiveScan(kKeyboardDevicesDirectory);
|
|
||||||
|
|
||||||
StartMonitoringDevice(kKeyboardDevicesDirectoryPS2);
|
|
||||||
StartMonitoringDevice(kKeyboardDevicesDirectoryUSB);
|
|
||||||
|
|
||||||
return B_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
KeyboardInputDevice::Start(const char *name, void *cookie)
|
KeyboardInputDevice::Start(const char* name, void* cookie)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
keyboard_device *device = (keyboard_device *)cookie;
|
keyboard_device* device = (keyboard_device*)cookie;
|
||||||
|
|
||||||
if ((device->fd = open(device->path, O_RDWR)) < B_OK) {
|
if ((device->fd = open(device->path, O_RDWR)) < B_OK) {
|
||||||
fprintf(stderr, "error when opening %s: %s\n", device->path, strerror(errno));
|
fprintf(stderr, "error when opening %s: %s\n", device->path, strerror(errno));
|
||||||
@@ -487,10 +473,10 @@ KeyboardInputDevice::Start(const char *name, void *cookie)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
KeyboardInputDevice::Stop(const char *name, void *cookie)
|
KeyboardInputDevice::Stop(const char* name, void* cookie)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
keyboard_device *device = (keyboard_device *)cookie;
|
keyboard_device* device = (keyboard_device*)cookie;
|
||||||
|
|
||||||
LOG("Stop(%s)\n", name);
|
LOG("Stop(%s)\n", name);
|
||||||
|
|
||||||
@@ -505,9 +491,9 @@ KeyboardInputDevice::Stop(const char *name, void *cookie)
|
|||||||
wait_for_thread(device->device_watcher, &dummy);
|
wait_for_thread(device->device_watcher, &dummy);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fTMWindow) {
|
if (fTeamMonitorWindow) {
|
||||||
fTMWindow->PostMessage(B_QUIT_REQUESTED);
|
fTeamMonitorWindow->PostMessage(B_QUIT_REQUESTED);
|
||||||
fTMWindow = NULL;
|
fTeamMonitorWindow = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -515,8 +501,8 @@ KeyboardInputDevice::Stop(const char *name, void *cookie)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
KeyboardInputDevice::Control(const char *name, void *cookie,
|
KeyboardInputDevice::Control(const char* name, void* cookie,
|
||||||
uint32 command, BMessage *message)
|
uint32 command, BMessage* message)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
LOG("Control(%s, code: %lu)\n", name, command);
|
LOG("Control(%s, code: %lu)\n", name, command);
|
||||||
@@ -532,57 +518,35 @@ KeyboardInputDevice::Control(const char *name, void *cookie,
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
KeyboardInputDevice::_HandleMonitor(BMessage *message)
|
KeyboardInputDevice::_HandleMonitor(BMessage* message)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
int32 opcode = 0;
|
|
||||||
status_t status;
|
|
||||||
if ((status = message->FindInt32("opcode", &opcode)) < B_OK)
|
|
||||||
return status;
|
|
||||||
|
|
||||||
if (opcode != B_ENTRY_CREATED
|
const char* path;
|
||||||
&& opcode != B_ENTRY_REMOVED)
|
int32 opcode;
|
||||||
return B_OK;
|
if (message->FindInt32("opcode", &opcode) != B_OK
|
||||||
|
|| opcode != B_ENTRY_CREATED && opcode != B_ENTRY_REMOVED
|
||||||
BEntry entry;
|
|| message->FindString("path", &path) != B_OK)
|
||||||
BPath path;
|
return B_BAD_VALUE;
|
||||||
dev_t device;
|
|
||||||
ino_t directory;
|
|
||||||
const char *name = NULL;
|
|
||||||
|
|
||||||
message->FindInt32("device", &device);
|
|
||||||
message->FindInt64("directory", &directory);
|
|
||||||
message->FindString("name", &name);
|
|
||||||
|
|
||||||
entry_ref ref(device, directory, name);
|
|
||||||
|
|
||||||
if ((status = entry.SetTo(&ref)) != B_OK)
|
|
||||||
return status;
|
|
||||||
if ((status = entry.GetPath(&path)) != B_OK)
|
|
||||||
return status;
|
|
||||||
if ((status = path.InitCheck()) != B_OK)
|
|
||||||
return status;
|
|
||||||
|
|
||||||
if (opcode == B_ENTRY_CREATED)
|
if (opcode == B_ENTRY_CREATED)
|
||||||
_AddDevice(path.Path());
|
return _AddDevice(path);
|
||||||
else
|
|
||||||
_RemoveDevice(path.Path());
|
|
||||||
|
|
||||||
return status;
|
return _RemoveDevice(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
KeyboardInputDevice::_AddDevice(const char *path)
|
KeyboardInputDevice::_AddDevice(const char* path)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
keyboard_device *device = new (std::nothrow) keyboard_device(path);
|
keyboard_device* device = new(std::nothrow) keyboard_device(path);
|
||||||
if (device == NULL)
|
if (device == NULL)
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
device->owner = this;
|
device->owner = this;
|
||||||
|
|
||||||
input_device_ref *devices[2];
|
input_device_ref* devices[2];
|
||||||
devices[0] = &device->device_ref;
|
devices[0] = &device->device_ref;
|
||||||
devices[1] = NULL;
|
devices[1] = NULL;
|
||||||
|
|
||||||
@@ -593,15 +557,15 @@ KeyboardInputDevice::_AddDevice(const char *path)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
KeyboardInputDevice::_RemoveDevice(const char *path)
|
KeyboardInputDevice::_RemoveDevice(const char* path)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
keyboard_device *device;
|
keyboard_device* device;
|
||||||
for (int i = 0; (device = (keyboard_device *)fDevices.ItemAt(i)) != NULL; i++) {
|
for (int i = 0; (device = fDevices.ItemAt(i)) != NULL; i++) {
|
||||||
if (!strcmp(device->path, path)) {
|
if (!strcmp(device->path, path)) {
|
||||||
fDevices.RemoveItem(device);
|
fDevices.RemoveItemAt(i);
|
||||||
|
|
||||||
input_device_ref *devices[2];
|
input_device_ref* devices[2];
|
||||||
devices[0] = &device->device_ref;
|
devices[0] = &device->device_ref;
|
||||||
devices[1] = NULL;
|
devices[1] = NULL;
|
||||||
UnregisterDevices(devices);
|
UnregisterDevices(devices);
|
||||||
@@ -616,10 +580,10 @@ KeyboardInputDevice::_RemoveDevice(const char *path)
|
|||||||
|
|
||||||
|
|
||||||
/*static*/ int32
|
/*static*/ int32
|
||||||
KeyboardInputDevice::_DeviceWatcher(void *arg)
|
KeyboardInputDevice::_DeviceWatcher(void* arg)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
keyboard_device* device = (keyboard_device *)arg;
|
keyboard_device* device = (keyboard_device*)arg;
|
||||||
KeyboardInputDevice* owner = device->owner;
|
KeyboardInputDevice* owner = device->owner;
|
||||||
uint8 buffer[16];
|
uint8 buffer[16];
|
||||||
uint8 activeDeadKey = 0;
|
uint8 activeDeadKey = 0;
|
||||||
@@ -643,17 +607,17 @@ KeyboardInputDevice::_DeviceWatcher(void *arg)
|
|||||||
LOG("KB_READ :");
|
LOG("KB_READ :");
|
||||||
|
|
||||||
if (device->isAT) {
|
if (device->isAT) {
|
||||||
at_kbd_io *at_kbd = (at_kbd_io *)buffer;
|
at_kbd_io* atKeyboard = (at_kbd_io*)buffer;
|
||||||
if (at_kbd->scancode > 0)
|
if (atKeyboard->scancode > 0)
|
||||||
keycode = kATKeycodeMap[at_kbd->scancode-1];
|
keycode = kATKeycodeMap[atKeyboard->scancode - 1];
|
||||||
isKeyDown = at_kbd->is_keydown;
|
isKeyDown = atKeyboard->is_keydown;
|
||||||
timestamp = at_kbd->timestamp;
|
timestamp = atKeyboard->timestamp;
|
||||||
LOG(" %02x", at_kbd->scancode);
|
LOG(" %02x", atKeyboard->scancode);
|
||||||
} else {
|
} else {
|
||||||
raw_key_info *raw_kbd = (raw_key_info *)buffer;
|
raw_key_info* rawKeyInfo= (raw_key_info*)buffer;
|
||||||
isKeyDown = raw_kbd->is_keydown;
|
isKeyDown = rawKeyInfo->is_keydown;
|
||||||
timestamp = raw_kbd->timestamp;
|
timestamp = rawKeyInfo->timestamp;
|
||||||
keycode = raw_kbd->be_keycode;
|
keycode = rawKeyInfo->be_keycode;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keycode == 0)
|
if (keycode == 0)
|
||||||
@@ -692,11 +656,11 @@ KeyboardInputDevice::_DeviceWatcher(void *arg)
|
|||||||
LOG("TeamMonitor called\n");
|
LOG("TeamMonitor called\n");
|
||||||
|
|
||||||
// show the team monitor
|
// show the team monitor
|
||||||
if (owner->fTMWindow == NULL)
|
if (owner->fTeamMonitorWindow == NULL)
|
||||||
owner->fTMWindow = new (std::nothrow) TMWindow();
|
owner->fTeamMonitorWindow = new (std::nothrow) TMWindow();
|
||||||
|
|
||||||
if (owner->fTMWindow != NULL) {
|
if (owner->fTeamMonitorWindow != NULL) {
|
||||||
owner->fTMWindow->Enable();
|
owner->fTeamMonitorWindow->Enable();
|
||||||
|
|
||||||
// cancel timer only for R5
|
// cancel timer only for R5
|
||||||
if (ioctl(device->fd, KB_CANCEL_CONTROL_ALT_DEL, NULL) == B_OK)
|
if (ioctl(device->fd, KB_CANCEL_CONTROL_ALT_DEL, NULL) == B_OK)
|
||||||
@@ -710,7 +674,7 @@ KeyboardInputDevice::_DeviceWatcher(void *arg)
|
|||||||
if (modifiers
|
if (modifiers
|
||||||
&& (!(modifiers & (B_CAPS_LOCK | B_NUM_LOCK | B_SCROLL_LOCK))
|
&& (!(modifiers & (B_CAPS_LOCK | B_NUM_LOCK | B_SCROLL_LOCK))
|
||||||
|| isKeyDown)) {
|
|| isKeyDown)) {
|
||||||
BMessage *msg = new BMessage;
|
BMessage* msg = new BMessage;
|
||||||
if (msg == NULL)
|
if (msg == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -739,12 +703,13 @@ KeyboardInputDevice::_DeviceWatcher(void *arg)
|
|||||||
newDeadKey = keymap->IsDeadKey(keycode, device->modifiers);
|
newDeadKey = keymap->IsDeadKey(keycode, device->modifiers);
|
||||||
|
|
||||||
if (newDeadKey == 0) {
|
if (newDeadKey == 0) {
|
||||||
char *string = NULL, *rawString = NULL;
|
char* string = NULL;
|
||||||
|
char* rawString = NULL;
|
||||||
int32 numBytes = 0, rawNumBytes = 0;
|
int32 numBytes = 0, rawNumBytes = 0;
|
||||||
keymap->GetChars(keycode, device->modifiers, activeDeadKey, &string, &numBytes);
|
keymap->GetChars(keycode, device->modifiers, activeDeadKey, &string, &numBytes);
|
||||||
keymap->GetChars(keycode, 0, 0, &rawString, &rawNumBytes);
|
keymap->GetChars(keycode, 0, 0, &rawString, &rawNumBytes);
|
||||||
|
|
||||||
BMessage *msg = new BMessage;
|
BMessage* msg = new BMessage;
|
||||||
if (msg == NULL) {
|
if (msg == NULL) {
|
||||||
free(string);
|
free(string);
|
||||||
free(rawString);
|
free(rawString);
|
||||||
@@ -796,7 +761,7 @@ KeyboardInputDevice::_DeviceWatcher(void *arg)
|
|||||||
} else if (isKeyDown) {
|
} else if (isKeyDown) {
|
||||||
// start of a dead key
|
// start of a dead key
|
||||||
if (device->EnqueueInlineInputMethod(B_INPUT_METHOD_STARTED) == B_OK) {
|
if (device->EnqueueInlineInputMethod(B_INPUT_METHOD_STARTED) == B_OK) {
|
||||||
char *string = NULL;
|
char* string = NULL;
|
||||||
int32 numBytes = 0;
|
int32 numBytes = 0;
|
||||||
keymap->GetChars(keycode, device->modifiers, 0, &string, &numBytes);
|
keymap->GetChars(keycode, device->modifiers, 0, &string, &numBytes);
|
||||||
|
|
||||||
@@ -822,7 +787,7 @@ KeyboardInputDevice::_DeviceWatcher(void *arg)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
KeyboardInputDevice::_RecursiveScan(const char *directory)
|
KeyboardInputDevice::_RecursiveScan(const char* directory)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
BEntry entry;
|
BEntry entry;
|
||||||
@@ -839,7 +804,7 @@ KeyboardInputDevice::_RecursiveScan(const char *directory)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
KeyboardInputDevice::_SetLeds(keyboard_device *device)
|
KeyboardInputDevice::_SetLeds(keyboard_device* device)
|
||||||
{
|
{
|
||||||
if (device->fd < 0)
|
if (device->fd < 0)
|
||||||
return;
|
return;
|
||||||
@@ -861,7 +826,7 @@ KeyboardInputDevice::_SetLeds(keyboard_device *device)
|
|||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
keyboard_device::keyboard_device(const char *path)
|
keyboard_device::keyboard_device(const char* path)
|
||||||
: BHandler("keyboard device"),
|
: BHandler("keyboard device"),
|
||||||
owner(NULL),
|
owner(NULL),
|
||||||
fd(-1),
|
fd(-1),
|
||||||
@@ -923,7 +888,7 @@ keyboard_device::EnqueueInlineInputMethod(int32 opcode,
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
keyboard_device::MessageReceived(BMessage *message)
|
keyboard_device::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
if (message->what != B_INPUT_METHOD_EVENT) {
|
if (message->what != B_INPUT_METHOD_EVENT) {
|
||||||
BHandler::MessageReceived(message);
|
BHandler::MessageReceived(message);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2004-2006, Jérôme Duval. All rights reserved.
|
* Copyright 2004-2008, Jérôme Duval. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
#ifndef KEYBOARD_INPUT_DEVICE_H
|
#ifndef KEYBOARD_INPUT_DEVICE_H
|
||||||
@@ -15,80 +15,67 @@
|
|||||||
#include <Locker.h>
|
#include <Locker.h>
|
||||||
#include <List.h>
|
#include <List.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <ObjectList.h>
|
||||||
|
|
||||||
|
|
||||||
class KeyboardInputDevice;
|
class KeyboardInputDevice;
|
||||||
|
|
||||||
struct keyboard_device : public BHandler {
|
struct keyboard_device : public BHandler {
|
||||||
keyboard_device(const char *path);
|
keyboard_device(const char* path);
|
||||||
virtual ~keyboard_device();
|
virtual ~keyboard_device();
|
||||||
|
|
||||||
virtual void MessageReceived(BMessage* message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
status_t EnqueueInlineInputMethod(int32 opcode, const char* string = NULL,
|
status_t EnqueueInlineInputMethod(int32 opcode,
|
||||||
bool confirmed = false, BMessage* keyDown = NULL);
|
const char* string = NULL,
|
||||||
|
bool confirmed = false,
|
||||||
|
BMessage* keyDown = NULL);
|
||||||
|
|
||||||
KeyboardInputDevice *owner;
|
KeyboardInputDevice* owner;
|
||||||
input_device_ref device_ref;
|
input_device_ref device_ref;
|
||||||
char path[B_PATH_NAME_LENGTH];
|
char path[B_PATH_NAME_LENGTH];
|
||||||
int fd;
|
int fd;
|
||||||
thread_id device_watcher;
|
thread_id device_watcher;
|
||||||
kb_settings settings;
|
kb_settings settings;
|
||||||
volatile bool active;
|
volatile bool active;
|
||||||
bool isAT;
|
bool isAT;
|
||||||
volatile bool input_method_started;
|
volatile bool input_method_started;
|
||||||
uint32 modifiers;
|
uint32 modifiers;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class KeyboardInputDevice : public BInputServerDevice {
|
class KeyboardInputDevice : public BInputServerDevice {
|
||||||
public:
|
public:
|
||||||
KeyboardInputDevice();
|
KeyboardInputDevice();
|
||||||
~KeyboardInputDevice();
|
~KeyboardInputDevice();
|
||||||
|
|
||||||
virtual status_t InitCheck();
|
virtual status_t InitCheck();
|
||||||
|
|
||||||
virtual status_t Start(const char *name, void *cookie);
|
virtual status_t Start(const char* name, void* cookie);
|
||||||
virtual status_t Stop(const char *name, void *cookie);
|
virtual status_t Stop(const char* name, void* cookie);
|
||||||
|
|
||||||
virtual status_t Control(const char *name, void *cookie,
|
virtual status_t Control(const char* name, void* cookie,
|
||||||
uint32 command, BMessage *message);
|
uint32 command, BMessage* message);
|
||||||
|
|
||||||
virtual status_t SystemShuttingDown();
|
virtual status_t SystemShuttingDown();
|
||||||
|
|
||||||
#ifdef DEBUG
|
private:
|
||||||
static FILE *sLogFile;
|
status_t _HandleMonitor(BMessage* message);
|
||||||
#endif
|
status_t _InitFromSettings(void* cookie, uint32 opcode = 0);
|
||||||
|
void _RecursiveScan(const char* directory);
|
||||||
|
|
||||||
private:
|
status_t _AddDevice(const char* path);
|
||||||
status_t _HandleMonitor(BMessage *message);
|
status_t _RemoveDevice(const char* path);
|
||||||
status_t _InitFromSettings(void *cookie, uint32 opcode = 0);
|
|
||||||
void _RecursiveScan(const char *directory);
|
|
||||||
|
|
||||||
status_t _AddDevice(const char *path);
|
void _SetLeds(keyboard_device* device);
|
||||||
status_t _RemoveDevice(const char *path);
|
|
||||||
|
|
||||||
static int32 _DeviceWatcher(void *arg);
|
static int32 _DeviceWatcher(void* arg);
|
||||||
|
|
||||||
void _SetLeds(keyboard_device *device);
|
BObjectList<keyboard_device> fDevices;
|
||||||
|
Keymap fKeymap;
|
||||||
BList fDevices;
|
TMWindow* fTeamMonitorWindow;
|
||||||
Keymap fKeymap;
|
BLocker fKeymapLock;
|
||||||
TMWindow *fTMWindow;
|
|
||||||
BLocker fKeymapLock;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern "C" BInputServerDevice *instantiate_input_device();
|
extern "C" BInputServerDevice* instantiate_input_device();
|
||||||
|
|
||||||
#if DEBUG
|
|
||||||
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); }
|
|
||||||
#define LOG_ERR(text...) LOG(text)
|
|
||||||
#else
|
|
||||||
#define LOG(text...)
|
|
||||||
#define LOG_ERR(text...) fprintf(stderr, text)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define CALLED() LOG("%s\n", __PRETTY_FUNCTION__)
|
|
||||||
|
|
||||||
#endif // KEYBOARD_INPUT_DEVICE_H
|
#endif // KEYBOARD_INPUT_DEVICE_H
|
||||||
|
|||||||
@@ -259,7 +259,6 @@ TMView::Pulse()
|
|||||||
void
|
void
|
||||||
TMView::UpdateList()
|
TMView::UpdateList()
|
||||||
{
|
{
|
||||||
CALLED();
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
|
||||||
for (int32 i = 0; i < fListView->CountItems(); i++) {
|
for (int32 i = 0; i < fListView->CountItems(); i++) {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ SubDir HAIKU_TOP src add-ons input_server devices mouse ;
|
|||||||
|
|
||||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||||
|
|
||||||
UsePrivateHeaders input ;
|
UsePrivateHeaders input shared ;
|
||||||
|
|
||||||
Addon <input>mouse :
|
Addon <input>mouse :
|
||||||
MouseInputDevice.cpp
|
MouseInputDevice.cpp
|
||||||
|
|||||||
@@ -10,8 +10,12 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "MouseInputDevice.h"
|
#include "MouseInputDevice.h"
|
||||||
#include "kb_mouse_settings.h"
|
|
||||||
#include "kb_mouse_driver.h"
|
#include <errno.h>
|
||||||
|
#include <new>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <Debug.h>
|
#include <Debug.h>
|
||||||
#include <Directory.h>
|
#include <Directory.h>
|
||||||
@@ -21,28 +25,25 @@
|
|||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include "kb_mouse_settings.h"
|
||||||
#include <new>
|
#include "kb_mouse_driver.h"
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
#if DEBUG
|
|
||||||
FILE *MouseInputDevice::sLogFile = NULL;
|
//#define TRACE_MOUSE_DEVICE
|
||||||
|
#ifdef TRACE_MOUSE_DEVICE
|
||||||
|
# define LOG(text...) debug_printf(text)
|
||||||
# define LOG_ERR(text...) LOG(text)
|
# define LOG_ERR(text...) LOG(text)
|
||||||
#else
|
#else
|
||||||
# define LOG(text...)
|
# define LOG(text...) do {} while (0)
|
||||||
# define LOG_ERR(text...) fprintf(stderr, text)
|
# define LOG_ERR(text...) debug_printf(text)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CALLED() LOG("%s\n", __PRETTY_FUNCTION__)
|
#define CALLED() LOG("%s\n", __PRETTY_FUNCTION__)
|
||||||
|
|
||||||
const static uint32 kMouseThreadPriority = B_FIRST_REAL_TIME_PRIORITY + 4;
|
|
||||||
const static char *kMouseDevicesDirectory = "/dev/input/mouse";
|
|
||||||
|
|
||||||
// "/dev/" is automatically prepended by StartMonitoringDevice()
|
const static uint32 kMouseThreadPriority = B_FIRST_REAL_TIME_PRIORITY + 4;
|
||||||
const static char *kMouseDevicesDirectoryPS2 = "input/mouse/ps2";
|
const static char* kMouseDevicesDirectory = "/dev/input/mouse";
|
||||||
const static char *kMouseDevicesDirectoryUSB = "input/mouse/usb";
|
|
||||||
|
|
||||||
class MouseDevice {
|
class MouseDevice {
|
||||||
public:
|
public:
|
||||||
@@ -59,7 +60,7 @@ class MouseDevice {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void _Run();
|
void _Run();
|
||||||
static status_t _ThreadFunction(void *arg);
|
static status_t _ThreadFunction(void* arg);
|
||||||
|
|
||||||
BMessage* _BuildMouseMessage(uint32 what, uint64 when, uint32 buttons,
|
BMessage* _BuildMouseMessage(uint32 what, uint64 when, uint32 buttons,
|
||||||
int32 deltaX, int32 deltaY) const;
|
int32 deltaX, int32 deltaY) const;
|
||||||
@@ -83,30 +84,17 @@ class MouseDevice {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#if DEBUG
|
extern "C" BInputServerDevice*
|
||||||
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, MouseInputDevice::sLogFile); fflush(MouseInputDevice::sLogFile);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
extern "C" BInputServerDevice *
|
|
||||||
instantiate_input_device()
|
instantiate_input_device()
|
||||||
{
|
{
|
||||||
return new (std::nothrow) MouseInputDevice();
|
return new(std::nothrow) MouseInputDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
MouseDevice::MouseDevice(BInputServerDevice& target, const char *driverPath)
|
MouseDevice::MouseDevice(BInputServerDevice& target, const char* driverPath)
|
||||||
:
|
:
|
||||||
fTarget(target),
|
fTarget(target),
|
||||||
fDevice(-1),
|
fDevice(-1),
|
||||||
@@ -151,7 +139,7 @@ MouseDevice::Start()
|
|||||||
snprintf(threadName, B_OS_NAME_LENGTH, "%s watcher", fDeviceRef.name);
|
snprintf(threadName, B_OS_NAME_LENGTH, "%s watcher", fDeviceRef.name);
|
||||||
|
|
||||||
fThread = spawn_thread(_ThreadFunction, threadName,
|
fThread = spawn_thread(_ThreadFunction, threadName,
|
||||||
kMouseThreadPriority, (void *)this);
|
kMouseThreadPriority, (void*)this);
|
||||||
|
|
||||||
status_t status;
|
status_t status;
|
||||||
if (fThread < B_OK)
|
if (fThread < B_OK)
|
||||||
@@ -256,7 +244,7 @@ MouseDevice::_Run()
|
|||||||
movements.clicks, movements.wheel_xdelta, movements.wheel_ydelta);
|
movements.clicks, movements.wheel_xdelta, movements.wheel_ydelta);
|
||||||
LOG("%s: x: %ld, y: %ld\n", fDeviceRef.name, deltaX, deltaY);
|
LOG("%s: x: %ld, y: %ld\n", fDeviceRef.name, deltaX, deltaY);
|
||||||
|
|
||||||
BMessage *message = NULL;
|
BMessage* message = NULL;
|
||||||
|
|
||||||
// Send single messages for each event
|
// Send single messages for each event
|
||||||
|
|
||||||
@@ -303,7 +291,7 @@ MouseDevice::_Run()
|
|||||||
status_t
|
status_t
|
||||||
MouseDevice::_ThreadFunction(void* arg)
|
MouseDevice::_ThreadFunction(void* arg)
|
||||||
{
|
{
|
||||||
MouseDevice* device = (MouseDevice *)arg;
|
MouseDevice* device = (MouseDevice*)arg;
|
||||||
device->_Run();
|
device->_Run();
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@@ -384,7 +372,7 @@ MouseDevice::_RemapButtons(uint32 buttons) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char *
|
char*
|
||||||
MouseDevice::_BuildShortName() const
|
MouseDevice::_BuildShortName() const
|
||||||
{
|
{
|
||||||
BString string(fPath);
|
BString string(fPath);
|
||||||
@@ -412,15 +400,12 @@ MouseDevice::_BuildShortName() const
|
|||||||
|
|
||||||
|
|
||||||
MouseInputDevice::MouseInputDevice()
|
MouseInputDevice::MouseInputDevice()
|
||||||
|
:
|
||||||
|
fDevices(2, true)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
|
||||||
sLogFile = fopen("/var/log/mouse_device_log.log", "a");
|
|
||||||
#endif
|
|
||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
StartMonitoringDevice(kMouseDevicesDirectoryPS2);
|
StartMonitoringDevice(kMouseDevicesDirectory);
|
||||||
StartMonitoringDevice(kMouseDevicesDirectoryUSB);
|
|
||||||
|
|
||||||
_RecursiveScan(kMouseDevicesDirectory);
|
_RecursiveScan(kMouseDevicesDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -428,17 +413,7 @@ MouseInputDevice::MouseInputDevice()
|
|||||||
MouseInputDevice::~MouseInputDevice()
|
MouseInputDevice::~MouseInputDevice()
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
StopMonitoringDevice(kMouseDevicesDirectoryUSB);
|
StopMonitoringDevice(kMouseDevicesDirectory);
|
||||||
StopMonitoringDevice(kMouseDevicesDirectoryPS2);
|
|
||||||
|
|
||||||
int32 count = fDevices.CountItems();
|
|
||||||
while (count-- > 0) {
|
|
||||||
delete (MouseDevice *)fDevices.RemoveItem(count);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if DEBUG
|
|
||||||
fclose(sLogFile);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -451,7 +426,7 @@ MouseInputDevice::InitCheck()
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
MouseInputDevice::Start(const char *name, void *cookie)
|
MouseInputDevice::Start(const char* name, void* cookie)
|
||||||
{
|
{
|
||||||
LOG("%s(%s)\n", __PRETTY_FUNCTION__, name);
|
LOG("%s(%s)\n", __PRETTY_FUNCTION__, name);
|
||||||
MouseDevice* device = (MouseDevice*)cookie;
|
MouseDevice* device = (MouseDevice*)cookie;
|
||||||
@@ -461,7 +436,7 @@ MouseInputDevice::Start(const char *name, void *cookie)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
MouseInputDevice::Stop(const char *name, void *cookie)
|
MouseInputDevice::Stop(const char* name, void* cookie)
|
||||||
{
|
{
|
||||||
LOG("%s(%s)\n", __PRETTY_FUNCTION__, name);
|
LOG("%s(%s)\n", __PRETTY_FUNCTION__, name);
|
||||||
MouseDevice* device = (MouseDevice*)cookie;
|
MouseDevice* device = (MouseDevice*)cookie;
|
||||||
@@ -495,50 +470,27 @@ MouseInputDevice::_HandleMonitor(BMessage* message)
|
|||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
|
const char* path;
|
||||||
int32 opcode;
|
int32 opcode;
|
||||||
if (message->FindInt32("opcode", &opcode) < B_OK)
|
if (message->FindInt32("opcode", &opcode) != B_OK
|
||||||
|
|| opcode != B_ENTRY_CREATED && opcode != B_ENTRY_REMOVED
|
||||||
|
|| message->FindString("path", &path) != B_OK)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
if (opcode != B_ENTRY_CREATED && opcode != B_ENTRY_REMOVED)
|
|
||||||
return B_OK;
|
|
||||||
|
|
||||||
BEntry entry;
|
|
||||||
BPath path;
|
|
||||||
dev_t device;
|
|
||||||
ino_t directory;
|
|
||||||
const char *name;
|
|
||||||
|
|
||||||
if (message->FindInt32("device", &device) < B_OK
|
|
||||||
|| message->FindInt64("directory", &directory) < B_OK
|
|
||||||
|| message->FindString("name", &name) < B_OK)
|
|
||||||
return B_BAD_VALUE;
|
|
||||||
|
|
||||||
entry_ref ref(device, directory, name);
|
|
||||||
status_t status;
|
|
||||||
|
|
||||||
if ((status = entry.SetTo(&ref)) != B_OK)
|
|
||||||
return status;
|
|
||||||
if ((status = entry.GetPath(&path)) != B_OK)
|
|
||||||
return status;
|
|
||||||
if ((status = path.InitCheck()) != B_OK)
|
|
||||||
return status;
|
|
||||||
|
|
||||||
if (opcode == B_ENTRY_CREATED)
|
if (opcode == B_ENTRY_CREATED)
|
||||||
status = _AddDevice(path.Path());
|
return _AddDevice(path);
|
||||||
else
|
|
||||||
status = _RemoveDevice(path.Path());
|
|
||||||
|
|
||||||
return status;
|
return _RemoveDevice(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MouseDevice*
|
MouseDevice*
|
||||||
MouseInputDevice::_FindDevice(const char *path)
|
MouseInputDevice::_FindDevice(const char* path)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
for (int32 i = fDevices.CountItems(); i-- > 0;) {
|
for (int32 i = fDevices.CountItems(); i-- > 0;) {
|
||||||
MouseDevice* device = (MouseDevice*)fDevices.ItemAt(i);
|
MouseDevice* device = fDevices.ItemAt(i);
|
||||||
if (!strcmp(device->Path(), path))
|
if (!strcmp(device->Path(), path))
|
||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
@@ -548,11 +500,11 @@ MouseInputDevice::_FindDevice(const char *path)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
MouseInputDevice::_AddDevice(const char *path)
|
MouseInputDevice::_AddDevice(const char* path)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
MouseDevice* device = new (std::nothrow) MouseDevice(*this, path);
|
MouseDevice* device = new(std::nothrow) MouseDevice(*this, path);
|
||||||
if (!device) {
|
if (!device) {
|
||||||
LOG("No memory\n");
|
LOG("No memory\n");
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
@@ -563,7 +515,7 @@ MouseInputDevice::_AddDevice(const char *path)
|
|||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
input_device_ref *devices[2];
|
input_device_ref* devices[2];
|
||||||
devices[0] = device->DeviceRef();
|
devices[0] = device->DeviceRef();
|
||||||
devices[1] = NULL;
|
devices[1] = NULL;
|
||||||
|
|
||||||
@@ -572,7 +524,7 @@ MouseInputDevice::_AddDevice(const char *path)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
MouseInputDevice::_RemoveDevice(const char *path)
|
MouseInputDevice::_RemoveDevice(const char* path)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
@@ -582,7 +534,7 @@ MouseInputDevice::_RemoveDevice(const char *path)
|
|||||||
|
|
||||||
fDevices.RemoveItem(device);
|
fDevices.RemoveItem(device);
|
||||||
|
|
||||||
input_device_ref *devices[2];
|
input_device_ref* devices[2];
|
||||||
devices[0] = device->DeviceRef();
|
devices[0] = device->DeviceRef();
|
||||||
devices[1] = NULL;
|
devices[1] = NULL;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2004-2006, Haiku.
|
* Copyright 2004-2008, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -11,39 +11,34 @@
|
|||||||
|
|
||||||
#include <InputServerDevice.h>
|
#include <InputServerDevice.h>
|
||||||
#include <InterfaceDefs.h>
|
#include <InterfaceDefs.h>
|
||||||
#include <List.h>
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <ObjectList.h>
|
||||||
|
|
||||||
|
|
||||||
class MouseDevice;
|
class MouseDevice;
|
||||||
|
|
||||||
class MouseInputDevice : public BInputServerDevice {
|
class MouseInputDevice : public BInputServerDevice {
|
||||||
public:
|
|
||||||
MouseInputDevice();
|
|
||||||
virtual ~MouseInputDevice();
|
|
||||||
|
|
||||||
virtual status_t InitCheck();
|
|
||||||
|
|
||||||
virtual status_t Start(const char* name, void* cookie);
|
|
||||||
virtual status_t Stop(const char* name, void* cookie);
|
|
||||||
|
|
||||||
virtual status_t Control(const char* name, void* cookie,
|
|
||||||
uint32 command, BMessage* message);
|
|
||||||
|
|
||||||
private:
|
|
||||||
status_t _HandleMonitor(BMessage* message);
|
|
||||||
void _RecursiveScan(const char* directory);
|
|
||||||
|
|
||||||
MouseDevice* _FindDevice(const char* path);
|
|
||||||
status_t _AddDevice(const char* path);
|
|
||||||
status_t _RemoveDevice(const char* path);
|
|
||||||
|
|
||||||
BList fDevices;
|
|
||||||
#ifdef DEBUG
|
|
||||||
public:
|
public:
|
||||||
static FILE *sLogFile;
|
MouseInputDevice();
|
||||||
#endif
|
virtual ~MouseInputDevice();
|
||||||
|
|
||||||
|
virtual status_t InitCheck();
|
||||||
|
|
||||||
|
virtual status_t Start(const char* name, void* cookie);
|
||||||
|
virtual status_t Stop(const char* name, void* cookie);
|
||||||
|
|
||||||
|
virtual status_t Control(const char* name, void* cookie,
|
||||||
|
uint32 command, BMessage* message);
|
||||||
|
|
||||||
|
private:
|
||||||
|
status_t _HandleMonitor(BMessage* message);
|
||||||
|
void _RecursiveScan(const char* directory);
|
||||||
|
|
||||||
|
MouseDevice* _FindDevice(const char* path);
|
||||||
|
status_t _AddDevice(const char* path);
|
||||||
|
status_t _RemoveDevice(const char* path);
|
||||||
|
|
||||||
|
BObjectList<MouseDevice> fDevices;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern "C" BInputServerDevice* instantiate_input_device();
|
extern "C" BInputServerDevice* instantiate_input_device();
|
||||||
|
|||||||
Reference in New Issue
Block a user