complete register and unregister
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8807 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1436,49 +1436,6 @@ InputServer::MethodizeEvents(BList *,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Method: InputServer::StartStopDevices()
|
|
||||||
* Descr:
|
|
||||||
*/
|
|
||||||
status_t
|
|
||||||
InputServer::StartStopDevices(const char* deviceName,
|
|
||||||
input_device_type deviceType,
|
|
||||||
bool doStart)
|
|
||||||
{
|
|
||||||
CALLED();
|
|
||||||
for (int i = gInputDeviceList.CountItems() - 1; i >= 0; i--)
|
|
||||||
{
|
|
||||||
PRINT(("Device #%d\n", i));
|
|
||||||
InputDeviceListItem* item = (InputDeviceListItem*)gInputDeviceList.ItemAt(i);
|
|
||||||
if (NULL == item)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
BInputServerDevice* isd = item->mIsd;
|
|
||||||
input_device_ref dev = item->mDev;
|
|
||||||
|
|
||||||
PRINT(("Hey\n"));
|
|
||||||
|
|
||||||
if (NULL != isd)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (deviceType == dev.type) {
|
|
||||||
if (doStart) {
|
|
||||||
PRINT((" Starting: %s\n", dev.name));
|
|
||||||
isd->Start(dev.name, dev.cookie);
|
|
||||||
item->mStarted = true;
|
|
||||||
} else {
|
|
||||||
PRINT((" Stopping: %s\n", dev.name));
|
|
||||||
isd->Stop(dev.name, dev.cookie);
|
|
||||||
item->mStarted = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
EXIT();
|
|
||||||
|
|
||||||
return B_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Method: InputServer::StartStopDevices()
|
* Method: InputServer::StartStopDevices()
|
||||||
* Descr:
|
* Descr:
|
||||||
|
|||||||
@@ -159,7 +159,6 @@ public:
|
|||||||
bool SanitizeEvents(BList*);
|
bool SanitizeEvents(BList*);
|
||||||
bool MethodizeEvents(BList*, bool);
|
bool MethodizeEvents(BList*, bool);
|
||||||
|
|
||||||
static status_t StartStopDevices(const char *, input_device_type, bool);
|
|
||||||
static status_t StartStopDevices(BInputServerDevice *isd, bool);
|
static status_t StartStopDevices(BInputServerDevice *isd, bool);
|
||||||
status_t ControlDevices(const char *, input_device_type, unsigned long, BMessage*);
|
status_t ControlDevices(const char *, input_device_type, unsigned long, BMessage*);
|
||||||
|
|
||||||
|
|||||||
@@ -145,42 +145,32 @@ BInputServerDevice::RegisterDevices(input_device_ref **devices)
|
|||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
// Lock this section of code so that access to the device list
|
|
||||||
// is serialized. Be sure to release the lock before exitting.
|
|
||||||
//
|
|
||||||
BAutolock lock(InputServer::gInputDeviceListLocker);
|
BAutolock lock(InputServer::gInputDeviceListLocker);
|
||||||
|
|
||||||
//bool has_pointing_device = false;
|
|
||||||
//bool has_keyboard_device = false;
|
|
||||||
|
|
||||||
input_device_ref *device = NULL;
|
input_device_ref *device = NULL;
|
||||||
for (int i = 0; NULL != (device = devices[i]); i++) {
|
for (int i = 0; NULL != (device = devices[i]); i++) {
|
||||||
// :TODO: Check to make sure that each device is valid and
|
if (device->type != B_POINTING_DEVICE
|
||||||
// that it is not already registered.
|
&& device->type != B_KEYBOARD_DEVICE
|
||||||
// getDeviceIndex()
|
&& device->type != B_UNDEFINED_DEVICE)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
bool found = false;
|
||||||
|
for (int j = InputServer::gInputDeviceList.CountItems() - 1; j >= 0; j--) {
|
||||||
|
InputDeviceListItem* item = (InputDeviceListItem*)InputServer::gInputDeviceList.ItemAt(j);
|
||||||
|
if (!item)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (strcmp(device->name, item->mDev.name) == 0) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
InputServer::gInputDeviceList.AddItem(new InputDeviceListItem(this, *device) );
|
InputServer::gInputDeviceList.AddItem(new InputDeviceListItem(this, *device) );
|
||||||
|
Start(device->name, device->cookie);
|
||||||
//has_pointing_device = has_pointing_device || (device->type == B_POINTING_DEVICE);
|
|
||||||
//has_keyboard_device = has_keyboard_device || (device->type == B_KEYBOARD_DEVICE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the InputServer event loop is running, signal the InputServer
|
|
||||||
// to start all devices of the type managed by this InputServerDevice.
|
|
||||||
//
|
|
||||||
/*if (InputServer::EventLoopRunning() )
|
|
||||||
{
|
|
||||||
if (has_pointing_device)
|
|
||||||
{
|
|
||||||
InputServer::StartStopDevices(NULL, B_POINTING_DEVICE, true);
|
|
||||||
}
|
}
|
||||||
if (has_keyboard_device)
|
|
||||||
{
|
|
||||||
InputServer::StartStopDevices(NULL, B_KEYBOARD_DEVICE, true);
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
InputServer::StartStopDevices(this, true);
|
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
@@ -195,14 +185,22 @@ BInputServerDevice::UnregisterDevices(input_device_ref **devices)
|
|||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
// Lock this section of code so that access to the device list
|
|
||||||
// is serialized. Be sure to release the lock before exitting.
|
|
||||||
//
|
|
||||||
BAutolock lock(InputServer::gInputDeviceListLocker);
|
BAutolock lock(InputServer::gInputDeviceListLocker);
|
||||||
|
|
||||||
input_device_ref *device = NULL;
|
input_device_ref *device = NULL;
|
||||||
for (int i = 0; NULL != (device = devices[i]); i++) {
|
for (int i = 0; NULL != (device = devices[i]); i++) {
|
||||||
|
|
||||||
|
for (int j = InputServer::gInputDeviceList.CountItems() - 1; j >= 0; j--) {
|
||||||
|
InputDeviceListItem* item = (InputDeviceListItem*)InputServer::gInputDeviceList.ItemAt(j);
|
||||||
|
if (!item)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (strcmp(device->name, item->mDev.name) == 0) {
|
||||||
|
Stop(item->mDev.name, item->mDev.cookie);
|
||||||
|
InputServer::gInputDeviceList.RemoveItem(j);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|||||||
Reference in New Issue
Block a user