Added filtering. Commented now former unused addon code.
We now load and manage device and filter addons successfully. Tested with nervous and InputRecorder devices and InputRecorder filter. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8626 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -22,14 +22,6 @@
|
|||||||
#include "InputServer.h"
|
#include "InputServer.h"
|
||||||
|
|
||||||
|
|
||||||
#if DEBUG>=1
|
|
||||||
#define EXIT() printf("EXIT %s\n", __PRETTY_FUNCTION__)
|
|
||||||
#define CALLED() printf("CALLED %s\n", __PRETTY_FUNCTION__)
|
|
||||||
#else
|
|
||||||
#define EXIT() ((void)0)
|
|
||||||
#define CALLED() ((void)0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
AddOnManager::AddOnManager()
|
AddOnManager::AddOnManager()
|
||||||
:
|
:
|
||||||
fLock("add-on manager")
|
fLock("add-on manager")
|
||||||
@@ -52,6 +44,8 @@ AddOnManager::LoadState()
|
|||||||
void
|
void
|
||||||
AddOnManager::SaveState()
|
AddOnManager::SaveState()
|
||||||
{
|
{
|
||||||
|
CALLED();
|
||||||
|
UnregisterAddOns();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -103,6 +97,7 @@ AddOnManager::RegisterAddOn(BEntry &entry)
|
|||||||
|
|
||||||
RegisterDevice(isd, ref, addon_image);
|
RegisterDevice(isd, ref, addon_image);
|
||||||
|
|
||||||
|
|
||||||
} else if (pathString.FindFirst("input_server/filters")>0) {
|
} else if (pathString.FindFirst("input_server/filters")>0) {
|
||||||
BInputServerFilter *(*instantiate_func)();
|
BInputServerFilter *(*instantiate_func)();
|
||||||
|
|
||||||
@@ -188,6 +183,7 @@ AddOnManager::UnregisterAddOn(BEntry &entry)
|
|||||||
device_info *pinfo;
|
device_info *pinfo;
|
||||||
for (fDeviceList.Rewind(); fDeviceList.GetNext(&pinfo);) {
|
for (fDeviceList.Rewind(); fDeviceList.GetNext(&pinfo);) {
|
||||||
if (!strcmp(pinfo->ref.name, ref.name)) {
|
if (!strcmp(pinfo->ref.name, ref.name)) {
|
||||||
|
InputServer::StartStopDevices(pinfo->isd, false);
|
||||||
delete pinfo->isd;
|
delete pinfo->isd;
|
||||||
delete pinfo->addon;
|
delete pinfo->addon;
|
||||||
if (pinfo->addon_image >= B_OK)
|
if (pinfo->addon_image >= B_OK)
|
||||||
@@ -259,10 +255,10 @@ AddOnManager::RegisterAddOns()
|
|||||||
const directory_which directories[] = {
|
const directory_which directories[] = {
|
||||||
B_USER_ADDONS_DIRECTORY,
|
B_USER_ADDONS_DIRECTORY,
|
||||||
B_COMMON_ADDONS_DIRECTORY,
|
B_COMMON_ADDONS_DIRECTORY,
|
||||||
B_BEOS_ADDONS_DIRECTORY,
|
// B_BEOS_ADDONS_DIRECTORY,
|
||||||
};
|
};
|
||||||
const char subDirectories[][24] = {
|
const char subDirectories[][24] = {
|
||||||
// "input_server/devices",
|
"input_server/devices",
|
||||||
"input_server/filters",
|
"input_server/filters",
|
||||||
"input_server/methods",
|
"input_server/methods",
|
||||||
};
|
};
|
||||||
@@ -291,6 +287,54 @@ AddOnManager::RegisterAddOns()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AddOnManager::UnregisterAddOns()
|
||||||
|
{
|
||||||
|
BMessenger messenger(fAddOnMonitor);
|
||||||
|
messenger.SendMessage(B_QUIT_REQUESTED);
|
||||||
|
int32 exit_value;
|
||||||
|
wait_for_thread(fAddOnMonitor->Thread(), &exit_value);
|
||||||
|
delete fHandler;
|
||||||
|
|
||||||
|
BAutolock locker(fLock);
|
||||||
|
|
||||||
|
// we have to stop manually the addons because the monitor doesn't disable them on exit
|
||||||
|
|
||||||
|
{
|
||||||
|
device_info *pinfo;
|
||||||
|
for (fDeviceList.Rewind(); fDeviceList.GetNext(&pinfo);) {
|
||||||
|
InputServer::StartStopDevices(pinfo->isd, false);
|
||||||
|
delete pinfo->isd;
|
||||||
|
delete pinfo->addon;
|
||||||
|
if (pinfo->addon_image >= B_OK)
|
||||||
|
unload_add_on(pinfo->addon_image);
|
||||||
|
fDeviceList.RemoveCurrent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
filter_info *pinfo;
|
||||||
|
for (fFilterList.Rewind(); fFilterList.GetNext(&pinfo);) {
|
||||||
|
delete pinfo->isf;
|
||||||
|
if (pinfo->addon_image >= B_OK)
|
||||||
|
unload_add_on(pinfo->addon_image);
|
||||||
|
fFilterList.RemoveCurrent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
method_info *pinfo;
|
||||||
|
for (fMethodList.Rewind(); fMethodList.GetNext(&pinfo);) {
|
||||||
|
delete pinfo->ism;
|
||||||
|
delete pinfo->addon;
|
||||||
|
if (pinfo->addon_image >= B_OK)
|
||||||
|
unload_add_on(pinfo->addon_image);
|
||||||
|
fMethodList.RemoveCurrent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AddOnManager::RegisterDevice(BInputServerDevice *device, const entry_ref &ref, image_id addon_image)
|
AddOnManager::RegisterDevice(BInputServerDevice *device, const entry_ref &ref, image_id addon_image)
|
||||||
{
|
{
|
||||||
@@ -337,6 +381,10 @@ AddOnManager::RegisterFilter(BInputServerFilter *filter, const entry_ref &ref, i
|
|||||||
info.isf = filter;
|
info.isf = filter;
|
||||||
|
|
||||||
fFilterList.Insert(info);
|
fFilterList.Insert(info);
|
||||||
|
|
||||||
|
BAutolock lock2(InputServer::gInputFilterListLocker);
|
||||||
|
|
||||||
|
InputServer::gInputFilterList.AddItem(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -362,6 +410,10 @@ AddOnManager::RegisterMethod(BInputServerMethod *method, const entry_ref &ref, i
|
|||||||
info.addon = new _BMethodAddOn_;
|
info.addon = new _BMethodAddOn_;
|
||||||
|
|
||||||
fMethodList.Insert(info);
|
fMethodList.Insert(info);
|
||||||
|
|
||||||
|
BAutolock lock2(InputServer::gInputMethodListLocker);
|
||||||
|
|
||||||
|
InputServer::gInputMethodList.AddItem(method);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ class AddOnManager {
|
|||||||
status_t RegisterAddOn(BEntry &entry);
|
status_t RegisterAddOn(BEntry &entry);
|
||||||
status_t UnregisterAddOn(BEntry &entry);
|
status_t UnregisterAddOn(BEntry &entry);
|
||||||
void RegisterAddOns();
|
void RegisterAddOns();
|
||||||
|
void UnregisterAddOns();
|
||||||
|
|
||||||
void RegisterDevice(BInputServerDevice *isd, const entry_ref &ref, image_id addon_image);
|
void RegisterDevice(BInputServerDevice *isd, const entry_ref &ref, image_id addon_image);
|
||||||
void RegisterFilter(BInputServerFilter *isf, const entry_ref &ref, image_id addon_image);
|
void RegisterFilter(BInputServerFilter *isf, const entry_ref &ref, image_id addon_image);
|
||||||
|
|||||||
+199
-118
@@ -42,15 +42,6 @@
|
|||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
|
|
||||||
#if DEBUG>=1
|
|
||||||
#define EXIT() printf("EXIT %s\n", __PRETTY_FUNCTION__)
|
|
||||||
#define CALLED() printf("CALLED %s\n", __PRETTY_FUNCTION__)
|
|
||||||
#else
|
|
||||||
#define EXIT() ((void)0)
|
|
||||||
#define CALLED() ((void)0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "InputServer.h"
|
#include "InputServer.h"
|
||||||
#include "InputServerDeviceListEntry.h"
|
#include "InputServerDeviceListEntry.h"
|
||||||
#include "InputServerFilterListEntry.h"
|
#include "InputServerFilterListEntry.h"
|
||||||
@@ -76,9 +67,15 @@ extern "C" void RegisterDevices(input_device_ref** devices)
|
|||||||
BList InputServer::gInputDeviceList;
|
BList InputServer::gInputDeviceList;
|
||||||
BLocker InputServer::gInputDeviceListLocker;
|
BLocker InputServer::gInputDeviceListLocker;
|
||||||
|
|
||||||
BList InputServer::mInputServerDeviceList;
|
BList InputServer::gInputFilterList;
|
||||||
|
BLocker InputServer::gInputFilterListLocker;
|
||||||
|
|
||||||
|
BList InputServer::gInputMethodList;
|
||||||
|
BLocker InputServer::gInputMethodListLocker;
|
||||||
|
|
||||||
|
/*BList InputServer::mInputServerDeviceList;
|
||||||
BList InputServer::mInputServerFilterList;
|
BList InputServer::mInputServerFilterList;
|
||||||
BList InputServer::mInputServerMethodList;
|
BList InputServer::mInputServerMethodList;*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -122,7 +119,6 @@ InputServer::InputServer(void) : BApplication("application/x-vnd.OBOS-input_serv
|
|||||||
InputServer::~InputServer(void)
|
InputServer::~InputServer(void)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
fAddOnManager->SaveState();
|
|
||||||
delete fAddOnManager;
|
delete fAddOnManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,7 +166,7 @@ InputServer::InitKeyboardMouseStates(void)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
/*void
|
||||||
InputServer::InitTestDevice()
|
InputServer::InitTestDevice()
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
@@ -216,13 +212,13 @@ InputServer::InitTestDevice()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
EXIT();
|
EXIT();
|
||||||
}
|
}*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Method: InputServer::InitDevices()
|
* Method: InputServer::InitDevices()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
void
|
/*void
|
||||||
InputServer::InitDevices(void)
|
InputServer::InitDevices(void)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
@@ -257,14 +253,14 @@ InputServer::InitDevices(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
EXIT();
|
EXIT();
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Method: InputServer::AddInputServerDevice()
|
* Method: InputServer::AddInputServerDevice()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
status_t
|
/*status_t
|
||||||
InputServer::AddInputServerDevice(const char* path)
|
InputServer::AddInputServerDevice(const char* path)
|
||||||
{
|
{
|
||||||
image_id addon_image= load_add_on(path);
|
image_id addon_image= load_add_on(path);
|
||||||
@@ -289,7 +285,7 @@ InputServer::AddInputServerDevice(const char* path)
|
|||||||
new InputServerDeviceListEntry(path, isd_status, isd) );
|
new InputServerDeviceListEntry(path, isd_status, isd) );
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
mInputServerDeviceList.AddItem(
|
/*mInputServerDeviceList.AddItem(
|
||||||
new InputServerDeviceListEntry(path, B_NO_INIT, NULL) );
|
new InputServerDeviceListEntry(path, B_NO_INIT, NULL) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -302,14 +298,14 @@ InputServer::AddInputServerDevice(const char* path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Method: InputServer::InitFilters()
|
* Method: InputServer::InitFilters()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
void
|
/*void
|
||||||
InputServer::InitFilters(void)
|
InputServer::InitFilters(void)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
@@ -344,14 +340,14 @@ InputServer::InitFilters(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
EXIT();
|
EXIT();
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Method: InputServer::AddInputServerFilter()
|
* Method: InputServer::AddInputServerFilter()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
status_t
|
/*status_t
|
||||||
InputServer::AddInputServerFilter(const char* path)
|
InputServer::AddInputServerFilter(const char* path)
|
||||||
{
|
{
|
||||||
image_id addon_image= load_add_on(path);
|
image_id addon_image= load_add_on(path);
|
||||||
@@ -376,7 +372,7 @@ InputServer::AddInputServerFilter(const char* path)
|
|||||||
new InputServerFilterListEntry(path, isf_status, isf );
|
new InputServerFilterListEntry(path, isf_status, isf );
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
mInputServerFilterList.AddItem(
|
/*mInputServerFilterList.AddItem(
|
||||||
new InputServerFilterListEntry(path, B_NO_INIT, NULL) );
|
new InputServerFilterListEntry(path, B_NO_INIT, NULL) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -389,14 +385,14 @@ InputServer::AddInputServerFilter(const char* path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Method: InputServer::InitMethods()
|
* Method: InputServer::InitMethods()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
void
|
/*void
|
||||||
InputServer::InitMethods(void)
|
InputServer::InitMethods(void)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
@@ -431,14 +427,14 @@ InputServer::InitMethods(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
EXIT();
|
EXIT();
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Method: InputServer::AddInputServerMethod()
|
* Method: InputServer::AddInputServerMethod()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
status_t
|
/*status_t
|
||||||
InputServer::AddInputServerMethod(const char* path)
|
InputServer::AddInputServerMethod(const char* path)
|
||||||
{
|
{
|
||||||
image_id addon_image= load_add_on(path);
|
image_id addon_image= load_add_on(path);
|
||||||
@@ -463,7 +459,7 @@ InputServer::AddInputServerMethod(const char* path)
|
|||||||
new InputServerMethodListEntry(path, ism_status, ism) );
|
new InputServerMethodListEntry(path, ism_status, ism) );
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
mInputServerMethodList.AddItem(
|
/*mInputServerMethodList.AddItem(
|
||||||
new InputServerMethodListEntry(path, B_NO_INIT, NULL) );
|
new InputServerMethodListEntry(path, B_NO_INIT, NULL) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -476,7 +472,7 @@ InputServer::AddInputServerMethod(const char* path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -487,6 +483,7 @@ bool
|
|||||||
InputServer::QuitRequested(void)
|
InputServer::QuitRequested(void)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
|
fAddOnManager->SaveState();
|
||||||
|
|
||||||
kill_thread(ISPortThread);
|
kill_thread(ISPortThread);
|
||||||
delete_port(EventLooperPort);
|
delete_port(EventLooperPort);
|
||||||
@@ -1017,8 +1014,15 @@ InputServer::HandleNodeMonitor(BMessage *message)
|
|||||||
status_t
|
status_t
|
||||||
InputServer::EnqueueDeviceMessage(BMessage *message)
|
InputServer::EnqueueDeviceMessage(BMessage *message)
|
||||||
{
|
{
|
||||||
//return (write_port(fEventPort, (int32)message, NULL, 0));
|
CALLED();
|
||||||
return (write_port(EventLooperPort, (int32)message, NULL, 0));
|
|
||||||
|
status_t err;
|
||||||
|
|
||||||
|
ssize_t length = message->FlattenedSize();
|
||||||
|
char buffer[length];
|
||||||
|
if ((err = message->Flatten(buffer,length)) < B_OK)
|
||||||
|
return err;
|
||||||
|
return write_port(EventLooperPort, 0, buffer, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1027,9 +1031,17 @@ InputServer::EnqueueDeviceMessage(BMessage *message)
|
|||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
status_t
|
status_t
|
||||||
InputServer::EnqueueMethodMessage(BMessage *)
|
InputServer::EnqueueMethodMessage(BMessage *message)
|
||||||
{
|
{
|
||||||
return 0;
|
CALLED();
|
||||||
|
|
||||||
|
status_t err;
|
||||||
|
|
||||||
|
ssize_t length = message->FlattenedSize();
|
||||||
|
char buffer[length];
|
||||||
|
if ((err = message->Flatten(buffer,length)) < B_OK)
|
||||||
|
return err;
|
||||||
|
return write_port(EventLooperPort, 0, buffer, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1037,7 +1049,8 @@ InputServer::EnqueueMethodMessage(BMessage *)
|
|||||||
* Method: InputServer::UnlockMethodQueue()
|
* Method: InputServer::UnlockMethodQueue()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
status_t InputServer::UnlockMethodQueue(void)
|
status_t
|
||||||
|
InputServer::UnlockMethodQueue(void)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -1047,7 +1060,8 @@ status_t InputServer::UnlockMethodQueue(void)
|
|||||||
* Method: InputServer::LockMethodQueue()
|
* Method: InputServer::LockMethodQueue()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
status_t InputServer::LockMethodQueue(void)
|
status_t
|
||||||
|
InputServer::LockMethodQueue(void)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -1080,7 +1094,8 @@ InputServer::SetActiveMethod(_BMethodAddOn_ *)
|
|||||||
* Method: InputServer::MethodReplicant()
|
* Method: InputServer::MethodReplicant()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
const BMessenger* InputServer::MethodReplicant(void)
|
const BMessenger*
|
||||||
|
InputServer::MethodReplicant(void)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -1109,7 +1124,8 @@ InputServer::EventLoop(void *)
|
|||||||
* Method: InputServer::EventLoopRunning()
|
* Method: InputServer::EventLoopRunning()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
bool InputServer::EventLoopRunning(void)
|
bool
|
||||||
|
InputServer::EventLoopRunning(void)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1122,16 +1138,30 @@ bool InputServer::EventLoopRunning(void)
|
|||||||
bool
|
bool
|
||||||
InputServer::DispatchEvents(BList *eventList)
|
InputServer::DispatchEvents(BList *eventList)
|
||||||
{
|
{
|
||||||
BMessage *event;
|
CALLED();
|
||||||
|
|
||||||
|
CacheEvents(eventList);
|
||||||
|
|
||||||
|
if (fEventsCache.CountItems()>50) {
|
||||||
|
|
||||||
|
BMessage *event;
|
||||||
|
|
||||||
|
for ( int32 i = 0; NULL != (event = (BMessage *)fEventsCache.ItemAt(i)); i++ ) {
|
||||||
|
// now we must send each event to the app_server
|
||||||
|
DispatchEvent(event);
|
||||||
|
|
||||||
|
delete event;
|
||||||
|
}
|
||||||
|
|
||||||
|
fEventsCache.MakeEmpty();
|
||||||
|
|
||||||
for ( int32 i = 0; NULL != (event = (BMessage *)eventList->ItemAt(i)); i++ ) {
|
|
||||||
// now we must send each event to the app_server
|
|
||||||
DispatchEvent(event);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}// end DispatchEvents()
|
}// end DispatchEvents()
|
||||||
|
|
||||||
int InputServer::DispatchEvent(BMessage *message)
|
|
||||||
|
int
|
||||||
|
InputServer::DispatchEvent(BMessage *message)
|
||||||
{
|
{
|
||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
@@ -1348,8 +1378,16 @@ int InputServer::DispatchEvent(BMessage *message)
|
|||||||
* Method: InputServer::CacheEvents()
|
* Method: InputServer::CacheEvents()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
bool InputServer::CacheEvents(BList *)
|
bool
|
||||||
|
InputServer::CacheEvents(BList *eventsToCache)
|
||||||
{
|
{
|
||||||
|
CALLED();
|
||||||
|
|
||||||
|
FilterEvents(eventsToCache);
|
||||||
|
|
||||||
|
fEventsCache.AddList(eventsToCache);
|
||||||
|
eventsToCache->MakeEmpty();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1358,7 +1396,8 @@ bool InputServer::CacheEvents(BList *)
|
|||||||
* Method: InputServer::GetNextEvents()
|
* Method: InputServer::GetNextEvents()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
const BList* InputServer::GetNextEvents(BList *)
|
const BList*
|
||||||
|
InputServer::GetNextEvents(BList *)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -1375,6 +1414,8 @@ const BList* InputServer::GetNextEvents(BList *)
|
|||||||
bool
|
bool
|
||||||
InputServer::FilterEvents(BList *eventsToFilter)
|
InputServer::FilterEvents(BList *eventsToFilter)
|
||||||
{
|
{
|
||||||
|
CALLED();
|
||||||
|
|
||||||
if (NULL == eventsToFilter)
|
if (NULL == eventsToFilter)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -1383,21 +1424,19 @@ InputServer::FilterEvents(BList *eventsToFilter)
|
|||||||
int32 filter_index = 0;
|
int32 filter_index = 0;
|
||||||
int32 event_index = 0;
|
int32 event_index = 0;
|
||||||
|
|
||||||
while (NULL != (current_filter = (BInputServerFilter*)mInputServerFilterList.ItemAt(filter_index) ) )
|
while (NULL != (current_filter = (BInputServerFilter*)gInputFilterList.ItemAt(filter_index) ) ) {
|
||||||
{
|
|
||||||
// Apply the current filter to all available event messages.
|
// Apply the current filter to all available event messages.
|
||||||
//
|
//
|
||||||
while (NULL != (current_event = (BMessage*)eventsToFilter->ItemAt(event_index) ) )
|
while (NULL != (current_event = (BMessage*)eventsToFilter->ItemAt(event_index) ) ) {
|
||||||
{
|
|
||||||
// Storage for new event messages generated by the filter.
|
// Storage for new event messages generated by the filter.
|
||||||
//
|
//
|
||||||
BList out_list;
|
BList out_list;
|
||||||
|
|
||||||
// Apply the current filter to the current event message.
|
// Apply the current filter to the current event message.
|
||||||
//
|
//
|
||||||
|
PRINT(("InputServer::FilterEvents Filter called\n"));
|
||||||
filter_result result = current_filter->Filter(current_event, &out_list);
|
filter_result result = current_filter->Filter(current_event, &out_list);
|
||||||
if (B_DISPATCH_MESSAGE == result)
|
if (B_DISPATCH_MESSAGE == result) {
|
||||||
{
|
|
||||||
// Use the result in current_message; ignore out_list.
|
// Use the result in current_message; ignore out_list.
|
||||||
//
|
//
|
||||||
event_index++;
|
event_index++;
|
||||||
@@ -1406,12 +1445,8 @@ InputServer::FilterEvents(BList *eventsToFilter)
|
|||||||
//
|
//
|
||||||
void *out_item;
|
void *out_item;
|
||||||
for (int32 i = 0; NULL != (out_item = out_list.ItemAt(i) ); i++)
|
for (int32 i = 0; NULL != (out_item = out_list.ItemAt(i) ); i++)
|
||||||
{
|
|
||||||
delete out_item;
|
delete out_item;
|
||||||
}
|
} else if (B_SKIP_MESSAGE == result) {
|
||||||
}
|
|
||||||
else if (B_SKIP_MESSAGE == result)
|
|
||||||
{
|
|
||||||
// Use the result in out_list (if any); ignore current message.
|
// Use the result in out_list (if any); ignore current message.
|
||||||
//
|
//
|
||||||
eventsToFilter->RemoveItem(event_index);
|
eventsToFilter->RemoveItem(event_index);
|
||||||
@@ -1419,16 +1454,12 @@ InputServer::FilterEvents(BList *eventsToFilter)
|
|||||||
event_index += out_list.CountItems();
|
event_index += out_list.CountItems();
|
||||||
|
|
||||||
// NOTE: eventsToFilter now owns out_list's items.
|
// NOTE: eventsToFilter now owns out_list's items.
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// Error - Free resources associated with items in out_list and return.
|
// Error - Free resources associated with items in out_list and return.
|
||||||
//
|
//
|
||||||
void* out_item;
|
void* out_item;
|
||||||
for (int32 i = 0; NULL != (out_item = out_list.ItemAt(i) ); i++)
|
for (int32 i = 0; NULL != (out_item = out_list.ItemAt(i) ); i++)
|
||||||
{
|
|
||||||
delete out_item;
|
delete out_item;
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1450,7 +1481,8 @@ InputServer::FilterEvents(BList *eventsToFilter)
|
|||||||
* Method: InputServer::SanitizeEvents()
|
* Method: InputServer::SanitizeEvents()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
bool InputServer::SanitizeEvents(BList *)
|
bool
|
||||||
|
InputServer::SanitizeEvents(BList *)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1460,9 +1492,12 @@ bool InputServer::SanitizeEvents(BList *)
|
|||||||
* Method: InputServer::MethodizeEvents()
|
* Method: InputServer::MethodizeEvents()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
bool InputServer::MethodizeEvents(BList *,
|
bool
|
||||||
|
InputServer::MethodizeEvents(BList *,
|
||||||
bool)
|
bool)
|
||||||
{
|
{
|
||||||
|
CALLED();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1471,7 +1506,8 @@ bool InputServer::MethodizeEvents(BList *,
|
|||||||
* Method: InputServer::StartStopDevices()
|
* Method: InputServer::StartStopDevices()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
status_t InputServer::StartStopDevices(const char* deviceName,
|
status_t
|
||||||
|
InputServer::StartStopDevices(const char* deviceName,
|
||||||
input_device_type deviceType,
|
input_device_type deviceType,
|
||||||
bool doStart)
|
bool doStart)
|
||||||
{
|
{
|
||||||
@@ -1480,21 +1516,60 @@ status_t InputServer::StartStopDevices(const char* deviceName,
|
|||||||
{
|
{
|
||||||
PRINT(("Device #%d\n", i));
|
PRINT(("Device #%d\n", i));
|
||||||
InputDeviceListItem* item = (InputDeviceListItem*)gInputDeviceList.ItemAt(i);
|
InputDeviceListItem* item = (InputDeviceListItem*)gInputDeviceList.ItemAt(i);
|
||||||
if (NULL != item)
|
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()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
status_t
|
||||||
|
InputServer::StartStopDevices(BInputServerDevice *isd,
|
||||||
|
bool doStart)
|
||||||
|
{
|
||||||
|
CALLED();
|
||||||
|
for (int i = gInputDeviceList.CountItems() - 1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
PRINT(("%s Device #%d\n", __PRETTY_FUNCTION__, i));
|
||||||
|
InputDeviceListItem* item = (InputDeviceListItem*)gInputDeviceList.ItemAt(i);
|
||||||
|
if (NULL != item && isd == item->mIsd)
|
||||||
{
|
{
|
||||||
BInputServerDevice* isd = item->mIsd;
|
|
||||||
input_device_ref dev = item->mDev;
|
input_device_ref dev = item->mDev;
|
||||||
PRINT(("Hey\n"));
|
|
||||||
if ( (NULL != isd) )
|
if (doStart) {
|
||||||
{
|
PRINT((" Starting: %s\n", dev.name));
|
||||||
PRINT((" Starting/stopping: %s\n", dev.name));
|
isd->Start(dev.name, dev.cookie);
|
||||||
if (deviceType == dev.type)
|
item->mStarted = true;
|
||||||
{
|
} else {
|
||||||
if (doStart)
|
PRINT((" Stopping: %s\n", dev.name));
|
||||||
isd->Start(dev.name, dev.cookie);
|
isd->Stop(dev.name, dev.cookie);
|
||||||
else
|
item->mStarted = false;
|
||||||
isd->Stop(dev.name, dev.cookie);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1508,7 +1583,8 @@ status_t InputServer::StartStopDevices(const char* deviceName,
|
|||||||
* Method: InputServer::ControlDevices()
|
* Method: InputServer::ControlDevices()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
status_t InputServer::ControlDevices(const char* deviceName,
|
status_t
|
||||||
|
InputServer::ControlDevices(const char* deviceName,
|
||||||
input_device_type deviceType,
|
input_device_type deviceType,
|
||||||
unsigned long command,
|
unsigned long command,
|
||||||
BMessage* message)
|
BMessage* message)
|
||||||
@@ -1517,7 +1593,7 @@ status_t InputServer::ControlDevices(const char* deviceName,
|
|||||||
|
|
||||||
for (int i = gInputDeviceList.CountItems() - 1; i >= 0; i--)
|
for (int i = gInputDeviceList.CountItems() - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
PRINT(("ControlDevice #%d\n", i));
|
PRINT(("%s Device #%d\n", __PRETTY_FUNCTION__, i));
|
||||||
InputDeviceListItem* item = (InputDeviceListItem*)gInputDeviceList.ItemAt(i);
|
InputDeviceListItem* item = (InputDeviceListItem*)gInputDeviceList.ItemAt(i);
|
||||||
if (NULL != item)
|
if (NULL != item)
|
||||||
{
|
{
|
||||||
@@ -1546,7 +1622,8 @@ status_t InputServer::ControlDevices(const char* deviceName,
|
|||||||
* Method: InputServer::DoMouseAcceleration()
|
* Method: InputServer::DoMouseAcceleration()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
bool InputServer::DoMouseAcceleration(long *,
|
bool
|
||||||
|
InputServer::DoMouseAcceleration(long *,
|
||||||
long *)
|
long *)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@@ -1557,7 +1634,8 @@ bool InputServer::DoMouseAcceleration(long *,
|
|||||||
* Method: InputServer::SetMousePos()
|
* Method: InputServer::SetMousePos()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
bool InputServer::SetMousePos(long *,
|
bool
|
||||||
|
InputServer::SetMousePos(long *,
|
||||||
long *,
|
long *,
|
||||||
long,
|
long,
|
||||||
long)
|
long)
|
||||||
@@ -1570,7 +1648,8 @@ bool InputServer::SetMousePos(long *,
|
|||||||
* Method: InputServer::SetMousePos()
|
* Method: InputServer::SetMousePos()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
bool InputServer::SetMousePos(long *,
|
bool
|
||||||
|
InputServer::SetMousePos(long *,
|
||||||
long *,
|
long *,
|
||||||
BPoint)
|
BPoint)
|
||||||
{
|
{
|
||||||
@@ -1582,7 +1661,8 @@ bool InputServer::SetMousePos(long *,
|
|||||||
* Method: InputServer::SetMousePos()
|
* Method: InputServer::SetMousePos()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
bool InputServer::SetMousePos(long *,
|
bool
|
||||||
|
InputServer::SetMousePos(long *,
|
||||||
long *,
|
long *,
|
||||||
float,
|
float,
|
||||||
float)
|
float)
|
||||||
@@ -1595,60 +1675,61 @@ bool InputServer::SetMousePos(long *,
|
|||||||
* Method: InputServer::SafeMode()
|
* Method: InputServer::SafeMode()
|
||||||
* Descr:
|
* Descr:
|
||||||
*/
|
*/
|
||||||
bool InputServer::SafeMode(void)
|
bool
|
||||||
|
InputServer::SafeMode(void)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 InputServer::ISPortWatcher(void *arg)
|
|
||||||
|
int32
|
||||||
|
InputServer::ISPortWatcher(void *arg)
|
||||||
{
|
{
|
||||||
InputServer *self = (InputServer*)arg;
|
InputServer *self = (InputServer*)arg;
|
||||||
self->WatchPort();
|
self->WatchPort();
|
||||||
return (B_NO_ERROR);
|
return B_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputServer::WatchPort()
|
|
||||||
|
void
|
||||||
|
InputServer::WatchPort()
|
||||||
{
|
{
|
||||||
int32 code;
|
|
||||||
ssize_t length;
|
|
||||||
char *buffer;
|
|
||||||
status_t err;
|
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
// Block until we find the size of the next message
|
// Block until we find the size of the next message
|
||||||
length = port_buffer_size(EventLooperPort);
|
ssize_t length = port_buffer_size(EventLooperPort);
|
||||||
buffer = (char*)malloc(length);
|
|
||||||
PRINT(("[Event Looper] BMessage Size = %lu\n", length));
|
PRINT(("[Event Looper] BMessage Size = %lu\n", length));
|
||||||
//event = NULL;
|
|
||||||
BMessage *event = new BMessage();
|
int32 code;
|
||||||
err = read_port(EventLooperPort, &code, buffer, length);
|
char buffer[length];
|
||||||
|
|
||||||
|
status_t err = read_port(EventLooperPort, &code, buffer, length);
|
||||||
if(err != length) {
|
if(err != length) {
|
||||||
if(err >= 0) {
|
if(err >= 0) {
|
||||||
printf("InputServer: failed to read full packet (read %lu of %lu)\n",err,length);
|
printf("InputServer: failed to read full packet (read %lu of %lu)\n", err, length);
|
||||||
} else {
|
} else {
|
||||||
printf("InputServer: read_port error: (0x%lx) %s\n",err,strerror(err));
|
printf("InputServer: read_port error: (0x%lx) %s\n", err, strerror(err));
|
||||||
}
|
}
|
||||||
} else {
|
continue;
|
||||||
|
|
||||||
if ((err = event->Unflatten(buffer)) < 0) {
|
|
||||||
printf("[InputServer] Unflatten() error: (0x%lx) %s\n",err,strerror(err));
|
|
||||||
} else {
|
|
||||||
// This is where the message should be processed.
|
|
||||||
PRINT_OBJECT(*event);
|
|
||||||
|
|
||||||
HandleSetMousePosition(event, event);
|
|
||||||
|
|
||||||
DispatchEvent(event);
|
|
||||||
|
|
||||||
PRINT(("Event writen to port\n"));
|
|
||||||
delete(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
free(buffer);
|
|
||||||
if(event!=NULL) {
|
BMessage *event = new BMessage;
|
||||||
//delete(event);
|
|
||||||
event = NULL;
|
if ((err = event->Unflatten(buffer)) < 0) {
|
||||||
|
printf("[InputServer] Unflatten() error: (0x%lx) %s\n", err, strerror(err));
|
||||||
|
delete event;
|
||||||
|
} else {
|
||||||
|
// This is where the message should be processed.
|
||||||
|
//PRINT_OBJECT(*event);
|
||||||
|
|
||||||
|
HandleSetMousePosition(event, event);
|
||||||
|
|
||||||
|
//DispatchEvent(&event);
|
||||||
|
BList list;
|
||||||
|
list.AddItem(event);
|
||||||
|
DispatchEvents(&list);
|
||||||
|
|
||||||
|
PRINT(("Event written to port\n"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,6 +48,14 @@
|
|||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
|
#if DEBUG>=1
|
||||||
|
#define EXIT() printf("EXIT %s\n", __PRETTY_FUNCTION__)
|
||||||
|
#define CALLED() printf("CALLED %s\n", __PRETTY_FUNCTION__)
|
||||||
|
#else
|
||||||
|
#define EXIT() ((void)0)
|
||||||
|
#define CALLED() ((void)0)
|
||||||
|
#endif
|
||||||
|
|
||||||
class BPortLink;
|
class BPortLink;
|
||||||
|
|
||||||
class InputDeviceListItem
|
class InputDeviceListItem
|
||||||
@@ -88,9 +96,9 @@ public:
|
|||||||
|
|
||||||
void InitKeyboardMouseStates(void);
|
void InitKeyboardMouseStates(void);
|
||||||
|
|
||||||
void InitDevices(void);
|
//void InitDevices(void);
|
||||||
void InitFilters(void);
|
//void InitFilters(void);
|
||||||
void InitMethods(void);
|
//void InitMethods(void);
|
||||||
|
|
||||||
virtual bool QuitRequested(void);
|
virtual bool QuitRequested(void);
|
||||||
virtual void ReadyToRun(void);
|
virtual void ReadyToRun(void);
|
||||||
@@ -142,6 +150,7 @@ public:
|
|||||||
bool MethodizeEvents(BList*, bool);
|
bool MethodizeEvents(BList*, bool);
|
||||||
|
|
||||||
static status_t StartStopDevices(const char *, input_device_type, bool);
|
static status_t StartStopDevices(const char *, input_device_type, 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*);
|
||||||
|
|
||||||
bool DoMouseAcceleration(long*, long*);
|
bool DoMouseAcceleration(long*, long*);
|
||||||
@@ -154,12 +163,18 @@ public:
|
|||||||
static BList gInputDeviceList;
|
static BList gInputDeviceList;
|
||||||
static BLocker gInputDeviceListLocker;
|
static BLocker gInputDeviceListLocker;
|
||||||
|
|
||||||
|
static BList gInputFilterList;
|
||||||
|
static BLocker gInputFilterListLocker;
|
||||||
|
|
||||||
|
static BList gInputMethodList;
|
||||||
|
static BLocker gInputMethodListLocker;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void InitTestDevice();
|
/*void InitTestDevice();
|
||||||
|
|
||||||
status_t AddInputServerDevice(const char* path);
|
status_t AddInputServerDevice(const char* path);
|
||||||
status_t AddInputServerFilter(const char* path);
|
status_t AddInputServerFilter(const char* path);
|
||||||
status_t AddInputServerMethod(const char* path);
|
status_t AddInputServerMethod(const char* path);*/
|
||||||
|
|
||||||
bool sEventLoopRunning;
|
bool sEventLoopRunning;
|
||||||
bool sSafeMode;
|
bool sSafeMode;
|
||||||
@@ -188,14 +203,16 @@ private:
|
|||||||
|
|
||||||
static bool doStartStopDevice(void*, void*);
|
static bool doStartStopDevice(void*, void*);
|
||||||
|
|
||||||
static BList mInputServerDeviceList;
|
//static BList mInputServerDeviceList;
|
||||||
static BList mInputServerFilterList;
|
//static BList mInputServerFilterList;
|
||||||
static BList mInputServerMethodList;
|
//static BList mInputServerMethodList;
|
||||||
|
|
||||||
// added this to communicate via portlink
|
// added this to communicate via portlink
|
||||||
|
|
||||||
BPortLink *serverlink;
|
BPortLink *serverlink;
|
||||||
AddOnManager *fAddOnManager;
|
AddOnManager *fAddOnManager;
|
||||||
|
|
||||||
|
BList fEventsCache;
|
||||||
|
|
||||||
//fMouseState;
|
//fMouseState;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
#include <Autolock.h>
|
||||||
#include <InputServerDevice.h>
|
#include <InputServerDevice.h>
|
||||||
#include "InputServer.h"
|
#include "InputServer.h"
|
||||||
|
|
||||||
@@ -50,6 +50,29 @@ BInputServerDevice::BInputServerDevice()
|
|||||||
*/
|
*/
|
||||||
BInputServerDevice::~BInputServerDevice()
|
BInputServerDevice::~BInputServerDevice()
|
||||||
{
|
{
|
||||||
|
CALLED();
|
||||||
|
// Lock this section of code so that access to the device list
|
||||||
|
// is serialized. Be sure to release the lock before exitting.
|
||||||
|
//
|
||||||
|
InputServer::gInputDeviceListLocker.Lock();
|
||||||
|
|
||||||
|
for (int i = InputServer::gInputDeviceList.CountItems() - 1;
|
||||||
|
i >= 0 && i < InputServer::gInputDeviceList.CountItems(); i--) {
|
||||||
|
|
||||||
|
PRINT(("%s Device #%d\n", __PRETTY_FUNCTION__, i));
|
||||||
|
InputDeviceListItem* item = (InputDeviceListItem*) InputServer::gInputDeviceList.ItemAt(i);
|
||||||
|
if (NULL != item && this == item->mIsd) {
|
||||||
|
if (item->mStarted) {
|
||||||
|
input_device_ref dev = item->mDev;
|
||||||
|
PRINT((" Stopping: %s\n", dev.name));
|
||||||
|
Stop(dev.name, dev.cookie);
|
||||||
|
}
|
||||||
|
InputServer::gInputDeviceList.RemoveItem(i++);
|
||||||
|
delete item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
InputServer::gInputDeviceListLocker.Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -120,32 +143,32 @@ BInputServerDevice::Control(const char *device,
|
|||||||
status_t
|
status_t
|
||||||
BInputServerDevice::RegisterDevices(input_device_ref **devices)
|
BInputServerDevice::RegisterDevices(input_device_ref **devices)
|
||||||
{
|
{
|
||||||
/*
|
CALLED();
|
||||||
|
|
||||||
// Lock this section of code so that access to the device list
|
// Lock this section of code so that access to the device list
|
||||||
// is serialized. Be sure to release the lock before exitting.
|
// is serialized. Be sure to release the lock before exitting.
|
||||||
//
|
//
|
||||||
InputServer::gInputDeviceListLocker.Lock();
|
BAutolock lock(InputServer::gInputDeviceListLocker);
|
||||||
|
|
||||||
bool has_pointing_device = false;
|
//bool has_pointing_device = false;
|
||||||
bool has_keyboard_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
|
// :TODO: Check to make sure that each device is valid and
|
||||||
// that it is not already registered.
|
// that it is not already registered.
|
||||||
// getDeviceIndex()
|
// getDeviceIndex()
|
||||||
|
|
||||||
InputServer::gInputDeviceList.AddItem(new InputDeviceListItem(this, device) );
|
InputServer::gInputDeviceList.AddItem(new InputDeviceListItem(this, *device) );
|
||||||
|
|
||||||
has_pointing_device = has_pointing_device || (device->type == B_POINTING_DEVICE);
|
//has_pointing_device = has_pointing_device || (device->type == B_POINTING_DEVICE);
|
||||||
has_keyboard_device = has_keyboard_device || (device->type == B_KEYBOARD_DEVICE);
|
//has_keyboard_device = has_keyboard_device || (device->type == B_KEYBOARD_DEVICE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the InputServer event loop is running, signal the InputServer
|
// If the InputServer event loop is running, signal the InputServer
|
||||||
// to start all devices of the type managed by this InputServerDevice.
|
// to start all devices of the type managed by this InputServerDevice.
|
||||||
//
|
//
|
||||||
if (InputServer::EventLoopRunning() )
|
/*if (InputServer::EventLoopRunning() )
|
||||||
{
|
{
|
||||||
if (has_pointing_device)
|
if (has_pointing_device)
|
||||||
{
|
{
|
||||||
@@ -155,10 +178,10 @@ BInputServerDevice::RegisterDevices(input_device_ref **devices)
|
|||||||
{
|
{
|
||||||
InputServer::StartStopDevices(NULL, B_KEYBOARD_DEVICE, true);
|
InputServer::StartStopDevices(NULL, B_KEYBOARD_DEVICE, true);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
InputServer::StartStopDevices(this, true);
|
||||||
|
|
||||||
InputServer::gInputDeviceListLocker.Unlock();
|
|
||||||
*/
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,9 +193,19 @@ BInputServerDevice::RegisterDevices(input_device_ref **devices)
|
|||||||
status_t
|
status_t
|
||||||
BInputServerDevice::UnregisterDevices(input_device_ref **devices)
|
BInputServerDevice::UnregisterDevices(input_device_ref **devices)
|
||||||
{
|
{
|
||||||
status_t dummy;
|
CALLED();
|
||||||
|
|
||||||
return dummy;
|
// 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);
|
||||||
|
|
||||||
|
input_device_ref *device = NULL;
|
||||||
|
for (int i = 0; NULL != (device = devices[i]); i++) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -183,21 +216,6 @@ BInputServerDevice::UnregisterDevices(input_device_ref **devices)
|
|||||||
status_t
|
status_t
|
||||||
BInputServerDevice::EnqueueMessage(BMessage *message)
|
BInputServerDevice::EnqueueMessage(BMessage *message)
|
||||||
{
|
{
|
||||||
/* status_t err;
|
|
||||||
|
|
||||||
ssize_t length = message->FlattenedSize();
|
|
||||||
char* buffer = new char[length];
|
|
||||||
if ((err = message->Flatten(buffer,length)) < 0) {
|
|
||||||
} else {
|
|
||||||
if((write_port(mEventPort, 0, buffer, length)) < 0) {
|
|
||||||
|
|
||||||
}else {
|
|
||||||
free(buffer);
|
|
||||||
err = B_OK;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return err;
|
|
||||||
*/
|
|
||||||
return ((InputServer*)be_app)->EnqueueDeviceMessage(message);
|
return ((InputServer*)be_app)->EnqueueDeviceMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,8 @@
|
|||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#include "InputServerFilter.h"
|
#include <InputServerFilter.h>
|
||||||
|
#include "InputServer.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method: BInputServerFilter::BInputServerFilter()
|
* Method: BInputServerFilter::BInputServerFilter()
|
||||||
@@ -40,6 +41,7 @@
|
|||||||
*/
|
*/
|
||||||
BInputServerFilter::BInputServerFilter()
|
BInputServerFilter::BInputServerFilter()
|
||||||
{
|
{
|
||||||
|
CALLED();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -49,6 +51,7 @@ BInputServerFilter::BInputServerFilter()
|
|||||||
*/
|
*/
|
||||||
BInputServerFilter::~BInputServerFilter()
|
BInputServerFilter::~BInputServerFilter()
|
||||||
{
|
{
|
||||||
|
CALLED();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -59,6 +62,7 @@ BInputServerFilter::~BInputServerFilter()
|
|||||||
status_t
|
status_t
|
||||||
BInputServerFilter::InitCheck()
|
BInputServerFilter::InitCheck()
|
||||||
{
|
{
|
||||||
|
CALLED();
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,6 +75,7 @@ filter_result
|
|||||||
BInputServerFilter::Filter(BMessage *message,
|
BInputServerFilter::Filter(BMessage *message,
|
||||||
BList *outList)
|
BList *outList)
|
||||||
{
|
{
|
||||||
|
CALLED();
|
||||||
return B_DISPATCH_MESSAGE;
|
return B_DISPATCH_MESSAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user