2002-07-18 02:12:24 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
// OpenBeOS InputServer
|
|
|
|
|
//
|
|
|
|
|
// Version: [0.0.5] [Development Stage]
|
|
|
|
|
//
|
|
|
|
|
// [Description]
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// This application and all source files used in its construction, except
|
|
|
|
|
// where noted, are licensed under the MIT License, and have been written
|
|
|
|
|
// and are:
|
|
|
|
|
//
|
|
|
|
|
// Copyright (c) 2002 OpenBeOS Project
|
|
|
|
|
//
|
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
// copy of this software and associated documentation files (the "Software"),
|
|
|
|
|
// to deal in the Software without restriction, including without limitation
|
|
|
|
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
|
// and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
|
// Software is furnished to do so, subject to the following conditions:
|
|
|
|
|
//
|
|
|
|
|
// The above copyright notice and this permission notice shall be included
|
|
|
|
|
// in all copies or substantial portions of the Software.
|
|
|
|
|
//
|
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
|
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
|
// DEALINGS IN THE SOFTWARE.
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2004-08-23 21:50:09 +00:00
|
|
|
#include <Autolock.h>
|
2004-08-19 22:09:27 +00:00
|
|
|
#include <InputServerDevice.h>
|
2002-07-18 02:12:24 +00:00
|
|
|
#include "InputServer.h"
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2002-07-18 02:12:24 +00:00
|
|
|
/**
|
2002-07-09 12:24:59 +00:00
|
|
|
* Method: BInputServerDevice::BInputServerDevice()
|
|
|
|
|
* Descr:
|
|
|
|
|
*/
|
|
|
|
|
BInputServerDevice::BInputServerDevice()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-07-18 02:12:24 +00:00
|
|
|
/**
|
2002-07-09 12:24:59 +00:00
|
|
|
* Method: BInputServerDevice::~BInputServerDevice()
|
|
|
|
|
* Descr:
|
|
|
|
|
*/
|
|
|
|
|
BInputServerDevice::~BInputServerDevice()
|
|
|
|
|
{
|
2004-08-23 21:50:09 +00:00
|
|
|
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();
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-07-18 02:12:24 +00:00
|
|
|
/**
|
2002-07-09 12:24:59 +00:00
|
|
|
* Method: BInputServerDevice::InitCheck()
|
|
|
|
|
* Descr:
|
|
|
|
|
*/
|
|
|
|
|
status_t
|
|
|
|
|
BInputServerDevice::InitCheck()
|
|
|
|
|
{
|
2004-07-29 12:42:14 +00:00
|
|
|
return B_OK;
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-07-18 02:12:24 +00:00
|
|
|
/**
|
2002-07-09 12:24:59 +00:00
|
|
|
* Method: BInputServerDevice::SystemShuttingDown()
|
|
|
|
|
* Descr:
|
|
|
|
|
*/
|
|
|
|
|
status_t
|
|
|
|
|
BInputServerDevice::SystemShuttingDown()
|
|
|
|
|
{
|
2004-07-29 12:42:14 +00:00
|
|
|
return B_OK;
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-07-18 02:12:24 +00:00
|
|
|
/**
|
2002-07-09 12:24:59 +00:00
|
|
|
* Method: BInputServerDevice::Start()
|
|
|
|
|
* Descr:
|
|
|
|
|
*/
|
|
|
|
|
status_t
|
|
|
|
|
BInputServerDevice::Start(const char *device,
|
|
|
|
|
void *cookie)
|
|
|
|
|
{
|
2004-07-29 12:42:14 +00:00
|
|
|
return B_OK;
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-07-18 02:12:24 +00:00
|
|
|
/**
|
2002-07-09 12:24:59 +00:00
|
|
|
* Method: BInputServerDevice::Stop()
|
|
|
|
|
* Descr:
|
|
|
|
|
*/
|
|
|
|
|
status_t
|
|
|
|
|
BInputServerDevice::Stop(const char *device,
|
|
|
|
|
void *cookie)
|
|
|
|
|
{
|
2004-07-29 12:42:14 +00:00
|
|
|
return B_OK;
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-07-18 02:12:24 +00:00
|
|
|
/**
|
2002-07-09 12:24:59 +00:00
|
|
|
* Method: BInputServerDevice::Control()
|
|
|
|
|
* Descr:
|
|
|
|
|
*/
|
|
|
|
|
status_t
|
|
|
|
|
BInputServerDevice::Control(const char *device,
|
|
|
|
|
void *cookie,
|
|
|
|
|
uint32 code,
|
|
|
|
|
BMessage *message)
|
|
|
|
|
{
|
2004-07-29 12:42:14 +00:00
|
|
|
return B_OK;
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-07-18 02:12:24 +00:00
|
|
|
/**
|
2002-07-09 12:24:59 +00:00
|
|
|
* Method: BInputServerDevice::RegisterDevices()
|
|
|
|
|
* Descr:
|
|
|
|
|
*/
|
|
|
|
|
status_t
|
|
|
|
|
BInputServerDevice::RegisterDevices(input_device_ref **devices)
|
|
|
|
|
{
|
2004-08-23 21:50:09 +00:00
|
|
|
CALLED();
|
|
|
|
|
|
2002-07-18 02:12:24 +00:00
|
|
|
// Lock this section of code so that access to the device list
|
|
|
|
|
// is serialized. Be sure to release the lock before exitting.
|
|
|
|
|
//
|
2004-08-23 21:50:09 +00:00
|
|
|
BAutolock lock(InputServer::gInputDeviceListLocker);
|
|
|
|
|
|
|
|
|
|
//bool has_pointing_device = false;
|
|
|
|
|
//bool has_keyboard_device = false;
|
2002-07-18 02:12:24 +00:00
|
|
|
|
|
|
|
|
input_device_ref *device = NULL;
|
2004-08-23 21:50:09 +00:00
|
|
|
for (int i = 0; NULL != (device = devices[i]); i++) {
|
2002-07-18 02:12:24 +00:00
|
|
|
// :TODO: Check to make sure that each device is valid and
|
|
|
|
|
// that it is not already registered.
|
|
|
|
|
// getDeviceIndex()
|
|
|
|
|
|
2004-08-23 21:50:09 +00:00
|
|
|
InputServer::gInputDeviceList.AddItem(new InputDeviceListItem(this, *device) );
|
2002-07-18 02:12:24 +00:00
|
|
|
|
2004-08-23 21:50:09 +00:00
|
|
|
//has_pointing_device = has_pointing_device || (device->type == B_POINTING_DEVICE);
|
|
|
|
|
//has_keyboard_device = has_keyboard_device || (device->type == B_KEYBOARD_DEVICE);
|
2002-07-18 02:12:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If the InputServer event loop is running, signal the InputServer
|
|
|
|
|
// to start all devices of the type managed by this InputServerDevice.
|
|
|
|
|
//
|
2004-08-23 21:50:09 +00:00
|
|
|
/*if (InputServer::EventLoopRunning() )
|
2002-07-18 02:12:24 +00:00
|
|
|
{
|
|
|
|
|
if (has_pointing_device)
|
|
|
|
|
{
|
|
|
|
|
InputServer::StartStopDevices(NULL, B_POINTING_DEVICE, true);
|
|
|
|
|
}
|
|
|
|
|
if (has_keyboard_device)
|
|
|
|
|
{
|
|
|
|
|
InputServer::StartStopDevices(NULL, B_KEYBOARD_DEVICE, true);
|
|
|
|
|
}
|
2004-08-23 21:50:09 +00:00
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
InputServer::StartStopDevices(this, true);
|
2002-07-18 02:12:24 +00:00
|
|
|
|
|
|
|
|
return B_OK;
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-07-18 02:12:24 +00:00
|
|
|
/**
|
2002-07-09 12:24:59 +00:00
|
|
|
* Method: BInputServerDevice::UnregisterDevices()
|
|
|
|
|
* Descr:
|
|
|
|
|
*/
|
|
|
|
|
status_t
|
|
|
|
|
BInputServerDevice::UnregisterDevices(input_device_ref **devices)
|
|
|
|
|
{
|
2004-08-23 21:50:09 +00:00
|
|
|
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);
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2004-08-23 21:50:09 +00:00
|
|
|
input_device_ref *device = NULL;
|
|
|
|
|
for (int i = 0; NULL != (device = devices[i]); i++) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return B_OK;
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-07-18 02:12:24 +00:00
|
|
|
/**
|
2002-07-09 12:24:59 +00:00
|
|
|
* Method: BInputServerDevice::EnqueueMessage()
|
|
|
|
|
* Descr:
|
|
|
|
|
*/
|
|
|
|
|
status_t
|
|
|
|
|
BInputServerDevice::EnqueueMessage(BMessage *message)
|
|
|
|
|
{
|
2004-08-19 22:09:27 +00:00
|
|
|
return ((InputServer*)be_app)->EnqueueDeviceMessage(message);
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-07-18 02:12:24 +00:00
|
|
|
/**
|
2002-07-09 12:24:59 +00:00
|
|
|
* Method: BInputServerDevice::StartMonitoringDevice()
|
|
|
|
|
* Descr:
|
|
|
|
|
*/
|
|
|
|
|
status_t
|
|
|
|
|
BInputServerDevice::StartMonitoringDevice(const char *device)
|
|
|
|
|
{
|
2004-08-26 14:04:22 +00:00
|
|
|
CALLED();
|
|
|
|
|
PRINT(("StartMonitoringDevice %s\n", device));
|
|
|
|
|
|
|
|
|
|
status_t status = B_OK;
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2004-08-26 14:04:22 +00:00
|
|
|
return status;
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-07-18 02:12:24 +00:00
|
|
|
/**
|
2002-07-09 12:24:59 +00:00
|
|
|
* Method: BInputServerDevice::StopMonitoringDevice()
|
|
|
|
|
* Descr:
|
|
|
|
|
*/
|
|
|
|
|
status_t
|
|
|
|
|
BInputServerDevice::StopMonitoringDevice(const char *device)
|
|
|
|
|
{
|
2004-08-26 14:04:22 +00:00
|
|
|
CALLED();
|
|
|
|
|
status_t status = B_OK;
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2004-08-26 14:04:22 +00:00
|
|
|
return status;
|
2002-07-09 12:24:59 +00:00
|
|
|
}
|
|
|
|
|
|
2002-07-18 02:12:24 +00:00
|
|
|
/**
|
|
|
|
|
///////////////////////// Below this line is reserved functions /////////////////////////////
|
|
|
|
|
*/
|
|
|
|
|
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2002-07-18 02:12:24 +00:00
|
|
|
/**
|
2002-07-09 12:24:59 +00:00
|
|
|
* Method: BInputServerDevice::_ReservedInputServerDevice1()
|
|
|
|
|
* Descr:
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
BInputServerDevice::_ReservedInputServerDevice1()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-07-18 02:12:24 +00:00
|
|
|
/**
|
2002-07-09 12:24:59 +00:00
|
|
|
* Method: BInputServerDevice::_ReservedInputServerDevice2()
|
|
|
|
|
* Descr:
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
BInputServerDevice::_ReservedInputServerDevice2()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-07-18 02:12:24 +00:00
|
|
|
/**
|
2002-07-09 12:24:59 +00:00
|
|
|
* Method: BInputServerDevice::_ReservedInputServerDevice3()
|
|
|
|
|
* Descr:
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
BInputServerDevice::_ReservedInputServerDevice3()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-07-18 02:12:24 +00:00
|
|
|
/**
|
2002-07-09 12:24:59 +00:00
|
|
|
* Method: BInputServerDevice::_ReservedInputServerDevice4()
|
|
|
|
|
* Descr:
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
BInputServerDevice::_ReservedInputServerDevice4()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|