mirror of
https://review.haiku-os.org/haiku
synced 2025-02-07 14:25:58 +01:00
Cleanup. Removed the weird SingletonMouseDevice
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15575 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
4722c56e4c
commit
4c0af4a82e
@ -53,8 +53,6 @@ FILE *MouseInputDevice::sLogFile = NULL;
|
|||||||
|
|
||||||
#define CALLED() LOG("%s\n", __PRETTY_FUNCTION__)
|
#define CALLED() LOG("%s\n", __PRETTY_FUNCTION__)
|
||||||
|
|
||||||
static MouseInputDevice *sSingletonMouseDevice = NULL;
|
|
||||||
|
|
||||||
const static uint32 kMouseThreadPriority = B_FIRST_REAL_TIME_PRIORITY + 4;
|
const static uint32 kMouseThreadPriority = B_FIRST_REAL_TIME_PRIORITY + 4;
|
||||||
const static char *kMouseDevicesDirectory = "/dev/input/mouse";
|
const static char *kMouseDevicesDirectory = "/dev/input/mouse";
|
||||||
|
|
||||||
@ -74,6 +72,12 @@ struct mouse_device {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct watcher_params {
|
||||||
|
MouseInputDevice *object;
|
||||||
|
mouse_device *device;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// forward declarations
|
// forward declarations
|
||||||
static char *get_short_name(const char *longName);
|
static char *get_short_name(const char *longName);
|
||||||
|
|
||||||
@ -87,10 +91,7 @@ instantiate_input_device()
|
|||||||
|
|
||||||
|
|
||||||
MouseInputDevice::MouseInputDevice()
|
MouseInputDevice::MouseInputDevice()
|
||||||
{
|
{
|
||||||
ASSERT(sSingletonMouseDevice == NULL);
|
|
||||||
sSingletonMouseDevice = this;
|
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
sLogFile = fopen("/var/log/mouse_device_log.log", "a");
|
sLogFile = fopen("/var/log/mouse_device_log.log", "a");
|
||||||
#endif
|
#endif
|
||||||
@ -187,9 +188,11 @@ MouseInputDevice::Start(const char *name, void *cookie)
|
|||||||
char threadName[B_OS_NAME_LENGTH];
|
char threadName[B_OS_NAME_LENGTH];
|
||||||
snprintf(threadName, B_OS_NAME_LENGTH, "%s watcher", name);
|
snprintf(threadName, B_OS_NAME_LENGTH, "%s watcher", name);
|
||||||
|
|
||||||
|
|
||||||
|
const watcher_params params = { this, device };
|
||||||
device->active = true;
|
device->active = true;
|
||||||
device->device_watcher = spawn_thread(DeviceWatcher, threadName,
|
device->device_watcher = spawn_thread(ThreadFunction, threadName,
|
||||||
kMouseThreadPriority, device);
|
kMouseThreadPriority, (void *)¶ms);
|
||||||
|
|
||||||
if (device->device_watcher < B_OK) {
|
if (device->device_watcher < B_OK) {
|
||||||
LOG_ERR("%s: can't spawn watching thread: %s\n",
|
LOG_ERR("%s: can't spawn watching thread: %s\n",
|
||||||
@ -330,10 +333,16 @@ MouseInputDevice::RemoveDevice(const char *path)
|
|||||||
|
|
||||||
|
|
||||||
int32
|
int32
|
||||||
MouseInputDevice::DeviceWatcher(void *arg)
|
MouseInputDevice::ThreadFunction(void *arg)
|
||||||
|
{
|
||||||
|
watcher_params *params = (watcher_params *)arg;
|
||||||
|
return params->object->DeviceWatcher(params->device);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32
|
||||||
|
MouseInputDevice::DeviceWatcher(mouse_device *dev)
|
||||||
{
|
{
|
||||||
mouse_device *dev = (mouse_device *)arg;
|
|
||||||
|
|
||||||
mouse_movement movements;
|
mouse_movement movements;
|
||||||
uint32 buttons_state = 0;
|
uint32 buttons_state = 0;
|
||||||
BMessage *message = NULL;
|
BMessage *message = NULL;
|
||||||
@ -363,7 +372,7 @@ MouseInputDevice::DeviceWatcher(void *arg)
|
|||||||
message->AddInt32("x", xdelta);
|
message->AddInt32("x", xdelta);
|
||||||
message->AddInt32("y", ydelta);
|
message->AddInt32("y", ydelta);
|
||||||
|
|
||||||
sSingletonMouseDevice->EnqueueMessage(message);
|
EnqueueMessage(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -381,7 +390,7 @@ MouseInputDevice::DeviceWatcher(void *arg)
|
|||||||
message->AddInt32("buttons", movements.buttons);
|
message->AddInt32("buttons", movements.buttons);
|
||||||
message->AddInt32("x", xdelta);
|
message->AddInt32("x", xdelta);
|
||||||
message->AddInt32("y", ydelta);
|
message->AddInt32("y", ydelta);
|
||||||
sSingletonMouseDevice->EnqueueMessage(message);
|
EnqueueMessage(message);
|
||||||
buttons_state = movements.buttons;
|
buttons_state = movements.buttons;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -392,7 +401,7 @@ MouseInputDevice::DeviceWatcher(void *arg)
|
|||||||
message->AddFloat("be:wheel_delta_x", movements.wheel_xdelta);
|
message->AddFloat("be:wheel_delta_x", movements.wheel_xdelta);
|
||||||
message->AddFloat("be:wheel_delta_y", movements.wheel_ydelta);
|
message->AddFloat("be:wheel_delta_y", movements.wheel_ydelta);
|
||||||
|
|
||||||
sSingletonMouseDevice->EnqueueMessage(message);
|
EnqueueMessage(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -402,25 +411,6 @@ MouseInputDevice::DeviceWatcher(void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// mouse_device
|
|
||||||
mouse_device::mouse_device(const char *driver_path)
|
|
||||||
{
|
|
||||||
fd = -1;
|
|
||||||
device_watcher = -1;
|
|
||||||
active = false;
|
|
||||||
strcpy(path, driver_path);
|
|
||||||
device_ref.name = get_short_name(path);
|
|
||||||
device_ref.type = B_POINTING_DEVICE;
|
|
||||||
device_ref.cookie = this;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
mouse_device::~mouse_device()
|
|
||||||
{
|
|
||||||
free(device_ref.name);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MouseInputDevice::RecursiveScan(const char *directory)
|
MouseInputDevice::RecursiveScan(const char *directory)
|
||||||
{
|
{
|
||||||
@ -448,6 +438,26 @@ MouseInputDevice::RecursiveScan(const char *directory)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// mouse_device
|
||||||
|
mouse_device::mouse_device(const char *driver_path)
|
||||||
|
:
|
||||||
|
fd(-1),
|
||||||
|
device_watcher(-1),
|
||||||
|
active(false)
|
||||||
|
{
|
||||||
|
strcpy(path, driver_path);
|
||||||
|
device_ref.name = get_short_name(path);
|
||||||
|
device_ref.type = B_POINTING_DEVICE;
|
||||||
|
device_ref.cookie = this;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
mouse_device::~mouse_device()
|
||||||
|
{
|
||||||
|
free(device_ref.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
get_short_name(const char *longName)
|
get_short_name(const char *longName)
|
||||||
{
|
{
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include <List.h>
|
#include <List.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
struct mouse_device;
|
||||||
class MouseInputDevice : public BInputServerDevice {
|
class MouseInputDevice : public BInputServerDevice {
|
||||||
public:
|
public:
|
||||||
MouseInputDevice();
|
MouseInputDevice();
|
||||||
@ -52,7 +53,8 @@ private:
|
|||||||
status_t AddDevice(const char *path);
|
status_t AddDevice(const char *path);
|
||||||
status_t RemoveDevice(const char *path);
|
status_t RemoveDevice(const char *path);
|
||||||
|
|
||||||
static int32 DeviceWatcher(void *arg);
|
int32 DeviceWatcher(mouse_device *device);
|
||||||
|
static int32 ThreadFunction(void *arg);
|
||||||
|
|
||||||
BList fDevices;
|
BList fDevices;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
Loading…
x
Reference in New Issue
Block a user