Files
haiku-beta6/src/servers/input/InputServerDevice.cpp
T

297 lines
6.6 KiB
C++
Raw Normal View History

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.
/*****************************************************************************/
#include <Autolock.h>
#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()
{
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()
{
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()
{
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)
{
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)
{
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)
{
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)
{
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.
//
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;
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()
InputServer::gInputDeviceList.AddItem(new InputDeviceListItem(this, *device) );
2002-07-18 02:12:24 +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.
//
/*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);
}
}*/
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)
{
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
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)
{
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()
{
}