bin/pc: Mark non-returning function as void
[haiku.git] / src / servers / input / InputServerDevice.cpp
blob4e6aefedaa442a7c935a54fb1448cb2f0ab95032
1 /*
2 * Copyright 2002-2008, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
4 */
7 #include <InputServerDevice.h>
9 #include <new>
11 #include <Directory.h>
12 #include <Path.h>
14 #include "InputServer.h"
17 DeviceAddOn::DeviceAddOn(BInputServerDevice *device)
19 fDevice(device)
24 DeviceAddOn::~DeviceAddOn()
26 while (const char* path = fMonitoredPaths.PathAt(0)) {
27 gInputServer->AddOnManager()->StopMonitoringDevice(this, path);
32 bool
33 DeviceAddOn::HasPath(const char* path) const
35 return fMonitoredPaths.HasPath(path);
39 status_t
40 DeviceAddOn::AddPath(const char* path)
42 return fMonitoredPaths.AddPath(path);
46 status_t
47 DeviceAddOn::RemovePath(const char* path)
49 return fMonitoredPaths.RemovePath(path);
53 int32
54 DeviceAddOn::CountPaths() const
56 return fMonitoredPaths.CountPaths();
60 // #pragma mark -
63 BInputServerDevice::BInputServerDevice()
65 fOwner = new(std::nothrow) DeviceAddOn(this);
69 BInputServerDevice::~BInputServerDevice()
71 CALLED();
73 gInputServer->UnregisterDevices(*this);
74 delete fOwner;
78 status_t
79 BInputServerDevice::InitCheck()
81 if (fOwner == NULL)
82 return B_NO_MEMORY;
83 return B_OK;
87 status_t
88 BInputServerDevice::SystemShuttingDown()
90 return B_OK;
94 status_t
95 BInputServerDevice::Start(const char* device, void* cookie)
97 return B_OK;
101 status_t
102 BInputServerDevice::Stop(const char* device, void* cookie)
104 return B_OK;
108 status_t
109 BInputServerDevice::Control(const char* device, void* cookie,
110 uint32 code, BMessage* message)
112 return B_OK;
116 status_t
117 BInputServerDevice::RegisterDevices(input_device_ref** devices)
119 CALLED();
120 return gInputServer->RegisterDevices(*this, devices);
124 status_t
125 BInputServerDevice::UnregisterDevices(input_device_ref** devices)
127 CALLED();
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);
134 status_t
135 BInputServerDevice::EnqueueMessage(BMessage* message)
137 return gInputServer->EnqueueDeviceMessage(message);
141 status_t
142 BInputServerDevice::StartMonitoringDevice(const char* device)
144 CALLED();
145 PRINT(("StartMonitoringDevice %s\n", device));
147 return gInputServer->AddOnManager()->StartMonitoringDevice(fOwner, device);
151 status_t
152 BInputServerDevice::StopMonitoringDevice(const char* device)
154 return gInputServer->AddOnManager()->StopMonitoringDevice(fOwner, device);
158 status_t
159 BInputServerDevice::AddDevices(const char* path)
161 BDirectory directory;
162 status_t status = directory.SetTo(path);
163 if (status != B_OK)
164 return status;
166 BEntry entry;
167 while (directory.GetNextEntry(&entry) == B_OK) {
168 BPath entryPath(&entry);
170 if (entry.IsDirectory()) {
171 AddDevices(entryPath.Path());
172 } else {
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);
181 return B_OK;
185 void BInputServerDevice::_ReservedInputServerDevice1() {}
186 void BInputServerDevice::_ReservedInputServerDevice2() {}
187 void BInputServerDevice::_ReservedInputServerDevice3() {}
188 void BInputServerDevice::_ReservedInputServerDevice4() {}