2 * Copyright 2002-2008, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
7 #include <InputServerDevice.h>
11 #include <Directory.h>
14 #include "InputServer.h"
17 DeviceAddOn::DeviceAddOn(BInputServerDevice
*device
)
24 DeviceAddOn::~DeviceAddOn()
26 while (const char* path
= fMonitoredPaths
.PathAt(0)) {
27 gInputServer
->AddOnManager()->StopMonitoringDevice(this, path
);
33 DeviceAddOn::HasPath(const char* path
) const
35 return fMonitoredPaths
.HasPath(path
);
40 DeviceAddOn::AddPath(const char* path
)
42 return fMonitoredPaths
.AddPath(path
);
47 DeviceAddOn::RemovePath(const char* path
)
49 return fMonitoredPaths
.RemovePath(path
);
54 DeviceAddOn::CountPaths() const
56 return fMonitoredPaths
.CountPaths();
63 BInputServerDevice::BInputServerDevice()
65 fOwner
= new(std::nothrow
) DeviceAddOn(this);
69 BInputServerDevice::~BInputServerDevice()
73 gInputServer
->UnregisterDevices(*this);
79 BInputServerDevice::InitCheck()
88 BInputServerDevice::SystemShuttingDown()
95 BInputServerDevice::Start(const char* device
, void* cookie
)
102 BInputServerDevice::Stop(const char* device
, void* cookie
)
109 BInputServerDevice::Control(const char* device
, void* cookie
,
110 uint32 code
, BMessage
* message
)
117 BInputServerDevice::RegisterDevices(input_device_ref
** devices
)
120 return gInputServer
->RegisterDevices(*this, devices
);
125 BInputServerDevice::UnregisterDevices(input_device_ref
** devices
)
128 // TODO: is this function supposed to remove devices that do not belong to this object?
129 // (at least that's what the previous implementation allowed for)
130 return gInputServer
->UnregisterDevices(*this, devices
);
135 BInputServerDevice::EnqueueMessage(BMessage
* message
)
137 return gInputServer
->EnqueueDeviceMessage(message
);
142 BInputServerDevice::StartMonitoringDevice(const char* device
)
145 PRINT(("StartMonitoringDevice %s\n", device
));
147 return gInputServer
->AddOnManager()->StartMonitoringDevice(fOwner
, device
);
152 BInputServerDevice::StopMonitoringDevice(const char* device
)
154 return gInputServer
->AddOnManager()->StopMonitoringDevice(fOwner
, device
);
159 BInputServerDevice::AddDevices(const char* path
)
161 BDirectory directory
;
162 status_t status
= directory
.SetTo(path
);
167 while (directory
.GetNextEntry(&entry
) == B_OK
) {
168 BPath
entryPath(&entry
);
170 if (entry
.IsDirectory()) {
171 AddDevices(entryPath
.Path());
173 BMessage
added(B_NODE_MONITOR
);
174 added
.AddInt32("opcode", B_ENTRY_CREATED
);
175 added
.AddString("path", entryPath
.Path());
177 Control(NULL
, NULL
, B_INPUT_DEVICE_ADDED
, &added
);
185 void BInputServerDevice::_ReservedInputServerDevice1() {}
186 void BInputServerDevice::_ReservedInputServerDevice2() {}
187 void BInputServerDevice::_ReservedInputServerDevice3() {}
188 void BInputServerDevice::_ReservedInputServerDevice4() {}