haiku/src/servers/input/InputServerDevice.cpp
Stefano Ceccherini d246d9be88 Some old changes I forgot to commit... BInputServerDevice::InitCheck()
now checks if the fOwner allocation went fine (and returns B_NO_MEMORY 
in case it didn't). Since it can fail, inherited classes should call it 
as well (I modified MouseInputDevice's and KeyboardInputDevice's 
versions for now)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23106 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-12-10 21:20:25 +00:00

114 lines
2.0 KiB
C++

/*
* Copyright 2002-2007, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#include "InputServer.h"
#include <InputServerDevice.h>
#include <new>
BInputServerDevice::BInputServerDevice()
{
fOwner = new (std::nothrow) _BDeviceAddOn_(this);
}
BInputServerDevice::~BInputServerDevice()
{
CALLED();
gInputServer->UnregisterDevices(*this);
delete fOwner;
}
status_t
BInputServerDevice::InitCheck()
{
if (fOwner == NULL)
return B_NO_MEMORY;
return B_OK;
}
status_t
BInputServerDevice::SystemShuttingDown()
{
return B_OK;
}
status_t
BInputServerDevice::Start(const char* device, void* cookie)
{
return B_OK;
}
status_t
BInputServerDevice::Stop(const char* device, void* cookie)
{
return B_OK;
}
status_t
BInputServerDevice::Control(const char* device, void* cookie,
uint32 code, BMessage* message)
{
return B_OK;
}
status_t
BInputServerDevice::RegisterDevices(input_device_ref** devices)
{
CALLED();
return gInputServer->RegisterDevices(*this, devices);
}
status_t
BInputServerDevice::UnregisterDevices(input_device_ref** devices)
{
CALLED();
// TODO: is this function supposed to remove devices that do not belong to this object?
// (at least that's what the previous implementation allowed for)
return gInputServer->UnregisterDevices(*this, devices);
}
status_t
BInputServerDevice::EnqueueMessage(BMessage* message)
{
return gInputServer->EnqueueDeviceMessage(message);
}
status_t
BInputServerDevice::StartMonitoringDevice(const char* device)
{
CALLED();
PRINT(("StartMonitoringDevice %s\n", device));
return InputServer::gDeviceManager.StartMonitoringDevice(fOwner, device);
}
status_t
BInputServerDevice::StopMonitoringDevice(const char* device)
{
CALLED();
return InputServer::gDeviceManager.StopMonitoringDevice(fOwner, device);
}
void BInputServerDevice::_ReservedInputServerDevice1() {}
void BInputServerDevice::_ReservedInputServerDevice2() {}
void BInputServerDevice::_ReservedInputServerDevice3() {}
void BInputServerDevice::_ReservedInputServerDevice4() {}