libusb 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +8 -2
- data/Gemfile +2 -0
- data/History.md +12 -0
- data/README.md +25 -14
- data/Rakefile +64 -109
- data/appveyor.yml +23 -0
- data/ext/extconf.rb +10 -12
- data/ext/libusb_recipe.rb +29 -0
- data/lib/libusb/call.rb +14 -11
- data/lib/libusb/compat.rb +9 -9
- data/lib/libusb/context.rb +16 -1
- data/lib/libusb/dependencies.rb +7 -0
- data/lib/libusb/dev_handle.rb +13 -3
- data/lib/libusb/eventmachine.rb +4 -4
- data/lib/libusb/transfer.rb +71 -10
- data/lib/libusb/version_gem.rb +1 -1
- data/libusb.gemspec +7 -5
- data/ports/archives/libusb-1.0.21.tar.bz2 +0 -0
- data/test/test_libusb_bulk_stream_transfer.rb +1 -1
- data/test/test_libusb_descriptors.rb +4 -4
- data/test/test_libusb_event_machine.rb +7 -7
- data/test/test_libusb_hotplug.rb +15 -3
- data/test/test_libusb_iso_transfer.rb +1 -1
- data/test/test_libusb_mass_storage.rb +19 -19
- data/test/test_libusb_mass_storage2.rb +1 -1
- data/test/test_libusb_structs.rb +13 -0
- data/test/test_libusb_threads.rb +2 -2
- data/wireshark-usb-sniffer.png +0 -0
- metadata +32 -156
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/ext/libusb-1.0.20/AUTHORS +0 -89
- data/ext/libusb-1.0.20/COPYING +0 -504
- data/ext/libusb-1.0.20/ChangeLog +0 -227
- data/ext/libusb-1.0.20/INSTALL +0 -234
- data/ext/libusb-1.0.20/Makefile.am +0 -28
- data/ext/libusb-1.0.20/Makefile.in +0 -897
- data/ext/libusb-1.0.20/NEWS +0 -2
- data/ext/libusb-1.0.20/PORTING +0 -94
- data/ext/libusb-1.0.20/README +0 -29
- data/ext/libusb-1.0.20/TODO +0 -2
- data/ext/libusb-1.0.20/Xcode/common.xcconfig +0 -49
- data/ext/libusb-1.0.20/Xcode/config.h +0 -28
- data/ext/libusb-1.0.20/Xcode/debug.xcconfig +0 -29
- data/ext/libusb-1.0.20/Xcode/libusb.xcconfig +0 -21
- data/ext/libusb-1.0.20/Xcode/libusb.xcodeproj/project.pbxproj +0 -865
- data/ext/libusb-1.0.20/Xcode/libusb_debug.xcconfig +0 -21
- data/ext/libusb-1.0.20/Xcode/libusb_release.xcconfig +0 -21
- data/ext/libusb-1.0.20/Xcode/release.xcconfig +0 -30
- data/ext/libusb-1.0.20/aclocal.m4 +0 -1193
- data/ext/libusb-1.0.20/android/README +0 -114
- data/ext/libusb-1.0.20/android/config.h +0 -81
- data/ext/libusb-1.0.20/android/jni/Android.mk +0 -23
- data/ext/libusb-1.0.20/android/jni/Application.mk +0 -24
- data/ext/libusb-1.0.20/android/jni/examples.mk +0 -134
- data/ext/libusb-1.0.20/android/jni/libusb.mk +0 -54
- data/ext/libusb-1.0.20/android/jni/tests.mk +0 -56
- data/ext/libusb-1.0.20/compile +0 -347
- data/ext/libusb-1.0.20/config.guess +0 -1421
- data/ext/libusb-1.0.20/config.h.in +0 -155
- data/ext/libusb-1.0.20/config.sub +0 -1807
- data/ext/libusb-1.0.20/configure +0 -15466
- data/ext/libusb-1.0.20/configure.ac +0 -326
- data/ext/libusb-1.0.20/depcomp +0 -791
- data/ext/libusb-1.0.20/doc/Makefile.am +0 -9
- data/ext/libusb-1.0.20/doc/Makefile.in +0 -456
- data/ext/libusb-1.0.20/doc/doxygen.cfg.in +0 -2334
- data/ext/libusb-1.0.20/examples/Makefile.am +0 -19
- data/ext/libusb-1.0.20/examples/Makefile.in +0 -713
- data/ext/libusb-1.0.20/examples/dpfp.c +0 -506
- data/ext/libusb-1.0.20/examples/dpfp_threaded.c +0 -549
- data/ext/libusb-1.0.20/examples/ezusb.c +0 -831
- data/ext/libusb-1.0.20/examples/ezusb.h +0 -120
- data/ext/libusb-1.0.20/examples/fxload.c +0 -308
- data/ext/libusb-1.0.20/examples/getopt/getopt.c +0 -1060
- data/ext/libusb-1.0.20/examples/getopt/getopt.h +0 -180
- data/ext/libusb-1.0.20/examples/getopt/getopt1.c +0 -188
- data/ext/libusb-1.0.20/examples/hotplugtest.c +0 -122
- data/ext/libusb-1.0.20/examples/listdevs.c +0 -71
- data/ext/libusb-1.0.20/examples/sam3u_benchmark.c +0 -193
- data/ext/libusb-1.0.20/examples/xusb.c +0 -1130
- data/ext/libusb-1.0.20/install-sh +0 -501
- data/ext/libusb-1.0.20/libusb-1.0.pc.in +0 -11
- data/ext/libusb-1.0.20/libusb/Makefile.am +0 -90
- data/ext/libusb-1.0.20/libusb/Makefile.in +0 -1053
- data/ext/libusb-1.0.20/libusb/core.c +0 -2452
- data/ext/libusb-1.0.20/libusb/descriptor.c +0 -1201
- data/ext/libusb-1.0.20/libusb/hotplug.c +0 -344
- data/ext/libusb-1.0.20/libusb/hotplug.h +0 -90
- data/ext/libusb-1.0.20/libusb/io.c +0 -2760
- data/ext/libusb-1.0.20/libusb/libusb-1.0.def +0 -168
- data/ext/libusb-1.0.20/libusb/libusb-1.0.rc +0 -61
- data/ext/libusb-1.0.20/libusb/libusb.h +0 -1999
- data/ext/libusb-1.0.20/libusb/libusbi.h +0 -1102
- data/ext/libusb-1.0.20/libusb/os/darwin_usb.c +0 -1969
- data/ext/libusb-1.0.20/libusb/os/darwin_usb.h +0 -158
- data/ext/libusb-1.0.20/libusb/os/haiku/Makefile.am +0 -5
- data/ext/libusb-1.0.20/libusb/os/haiku/Makefile.in +0 -810
- data/ext/libusb-1.0.20/libusb/os/haiku/aclocal.m4 +0 -1193
- data/ext/libusb-1.0.20/libusb/os/haiku/compile +0 -347
- data/ext/libusb-1.0.20/libusb/os/haiku/config.guess +0 -1421
- data/ext/libusb-1.0.20/libusb/os/haiku/config.sub +0 -1807
- data/ext/libusb-1.0.20/libusb/os/haiku/configure +0 -17579
- data/ext/libusb-1.0.20/libusb/os/haiku/configure.ac +0 -8
- data/ext/libusb-1.0.20/libusb/os/haiku/depcomp +0 -791
- data/ext/libusb-1.0.20/libusb/os/haiku/haiku_pollfs.cpp +0 -378
- data/ext/libusb-1.0.20/libusb/os/haiku/haiku_usb.h +0 -112
- data/ext/libusb-1.0.20/libusb/os/haiku/haiku_usb_backend.cpp +0 -550
- data/ext/libusb-1.0.20/libusb/os/haiku/haiku_usb_raw.cpp +0 -255
- data/ext/libusb-1.0.20/libusb/os/haiku/haiku_usb_raw.h +0 -180
- data/ext/libusb-1.0.20/libusb/os/haiku/install-sh +0 -501
- data/ext/libusb-1.0.20/libusb/os/haiku/ltmain.sh +0 -9655
- data/ext/libusb-1.0.20/libusb/os/haiku/m4/libtool.m4 +0 -7992
- data/ext/libusb-1.0.20/libusb/os/haiku/m4/ltoptions.m4 +0 -384
- data/ext/libusb-1.0.20/libusb/os/haiku/m4/ltsugar.m4 +0 -123
- data/ext/libusb-1.0.20/libusb/os/haiku/m4/ltversion.m4 +0 -23
- data/ext/libusb-1.0.20/libusb/os/haiku/m4/lt~obsolete.m4 +0 -98
- data/ext/libusb-1.0.20/libusb/os/haiku/missing +0 -215
- data/ext/libusb-1.0.20/libusb/os/linux_netlink.c +0 -369
- data/ext/libusb-1.0.20/libusb/os/linux_udev.c +0 -306
- data/ext/libusb-1.0.20/libusb/os/linux_usbfs.c +0 -2692
- data/ext/libusb-1.0.20/libusb/os/linux_usbfs.h +0 -192
- data/ext/libusb-1.0.20/libusb/os/netbsd_usb.c +0 -674
- data/ext/libusb-1.0.20/libusb/os/openbsd_usb.c +0 -768
- data/ext/libusb-1.0.20/libusb/os/poll_posix.c +0 -53
- data/ext/libusb-1.0.20/libusb/os/poll_posix.h +0 -11
- data/ext/libusb-1.0.20/libusb/os/poll_windows.c +0 -728
- data/ext/libusb-1.0.20/libusb/os/poll_windows.h +0 -131
- data/ext/libusb-1.0.20/libusb/os/threads_posix.c +0 -82
- data/ext/libusb-1.0.20/libusb/os/threads_posix.h +0 -50
- data/ext/libusb-1.0.20/libusb/os/threads_windows.c +0 -214
- data/ext/libusb-1.0.20/libusb/os/threads_windows.h +0 -87
- data/ext/libusb-1.0.20/libusb/os/wince_usb.c +0 -869
- data/ext/libusb-1.0.20/libusb/os/wince_usb.h +0 -131
- data/ext/libusb-1.0.20/libusb/os/windows_common.h +0 -108
- data/ext/libusb-1.0.20/libusb/os/windows_usb.c +0 -4643
- data/ext/libusb-1.0.20/libusb/os/windows_usb.h +0 -973
- data/ext/libusb-1.0.20/libusb/strerror.c +0 -202
- data/ext/libusb-1.0.20/libusb/sync.c +0 -308
- data/ext/libusb-1.0.20/libusb/version.h +0 -18
- data/ext/libusb-1.0.20/libusb/version_nano.h +0 -1
- data/ext/libusb-1.0.20/ltmain.sh +0 -9655
- data/ext/libusb-1.0.20/m4/libtool.m4 +0 -7992
- data/ext/libusb-1.0.20/m4/ltoptions.m4 +0 -384
- data/ext/libusb-1.0.20/m4/ltsugar.m4 +0 -123
- data/ext/libusb-1.0.20/m4/ltversion.m4 +0 -23
- data/ext/libusb-1.0.20/m4/lt~obsolete.m4 +0 -98
- data/ext/libusb-1.0.20/missing +0 -215
- data/ext/libusb-1.0.20/tests/Makefile.am +0 -6
- data/ext/libusb-1.0.20/tests/Makefile.in +0 -596
- data/ext/libusb-1.0.20/tests/libusb_testlib.h +0 -107
- data/ext/libusb-1.0.20/tests/stress.c +0 -160
- data/ext/libusb-1.0.20/tests/testlib.c +0 -277
- metadata.gz.sig +0 -0
@@ -1,378 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright 2007-2008, Haiku Inc. All rights reserved.
|
3
|
-
* Distributed under the terms of the MIT License.
|
4
|
-
*
|
5
|
-
* Authors:
|
6
|
-
* Michael Lotz <mmlr@mlotz.ch>
|
7
|
-
*/
|
8
|
-
|
9
|
-
#include "haiku_usb.h"
|
10
|
-
#include <cstdio>
|
11
|
-
#include <Directory.h>
|
12
|
-
#include <Entry.h>
|
13
|
-
#include <Looper.h>
|
14
|
-
#include <Messenger.h>
|
15
|
-
#include <Node.h>
|
16
|
-
#include <NodeMonitor.h>
|
17
|
-
#include <Path.h>
|
18
|
-
#include <cstring>
|
19
|
-
|
20
|
-
class WatchedEntry {
|
21
|
-
public:
|
22
|
-
WatchedEntry(BMessenger*, entry_ref*);
|
23
|
-
~WatchedEntry();
|
24
|
-
bool EntryCreated(entry_ref* ref);
|
25
|
-
bool EntryRemoved(ino_t node);
|
26
|
-
bool InitCheck();
|
27
|
-
|
28
|
-
private:
|
29
|
-
BMessenger* fMessenger;
|
30
|
-
node_ref fNode;
|
31
|
-
bool fIsDirectory;
|
32
|
-
USBDevice* fDevice;
|
33
|
-
WatchedEntry* fEntries;
|
34
|
-
WatchedEntry* fLink;
|
35
|
-
bool fInitCheck;
|
36
|
-
};
|
37
|
-
|
38
|
-
|
39
|
-
class RosterLooper : public BLooper {
|
40
|
-
public:
|
41
|
-
RosterLooper(USBRoster*);
|
42
|
-
void Stop();
|
43
|
-
virtual void MessageReceived(BMessage*);
|
44
|
-
bool InitCheck();
|
45
|
-
|
46
|
-
private:
|
47
|
-
USBRoster* fRoster;
|
48
|
-
WatchedEntry* fRoot;
|
49
|
-
BMessenger* fMessenger;
|
50
|
-
bool fInitCheck;
|
51
|
-
};
|
52
|
-
|
53
|
-
|
54
|
-
WatchedEntry::WatchedEntry(BMessenger* messenger, entry_ref* ref)
|
55
|
-
: fMessenger(messenger),
|
56
|
-
fIsDirectory(false),
|
57
|
-
fDevice(NULL),
|
58
|
-
fEntries(NULL),
|
59
|
-
fLink(NULL),
|
60
|
-
fInitCheck(false)
|
61
|
-
{
|
62
|
-
BEntry entry(ref);
|
63
|
-
entry.GetNodeRef(&fNode);
|
64
|
-
|
65
|
-
BDirectory directory;
|
66
|
-
if (entry.IsDirectory() && directory.SetTo(ref) >= B_OK) {
|
67
|
-
|
68
|
-
fIsDirectory = true;
|
69
|
-
|
70
|
-
while (directory.GetNextEntry(&entry) >= B_OK) {
|
71
|
-
if (entry.GetRef(ref) < B_OK)
|
72
|
-
continue;
|
73
|
-
|
74
|
-
WatchedEntry* child = new(std::nothrow) WatchedEntry(fMessenger, ref);
|
75
|
-
if (child == NULL)
|
76
|
-
continue;
|
77
|
-
if (child->InitCheck() == false)
|
78
|
-
{
|
79
|
-
delete child;
|
80
|
-
continue;
|
81
|
-
}
|
82
|
-
|
83
|
-
|
84
|
-
child->fLink = fEntries;
|
85
|
-
fEntries = child;
|
86
|
-
}
|
87
|
-
|
88
|
-
watch_node(&fNode, B_WATCH_DIRECTORY, *fMessenger);
|
89
|
-
|
90
|
-
} else {
|
91
|
-
if (strncmp(ref->name, "raw", 3) == 0)
|
92
|
-
return;
|
93
|
-
|
94
|
-
BPath path, parent_path;
|
95
|
-
entry.GetPath(&path);
|
96
|
-
fDevice = new(std::nothrow) USBDevice(path.Path());
|
97
|
-
if (fDevice != NULL && fDevice->InitCheck() == true) {
|
98
|
-
// Add this new device to each active context's device list
|
99
|
-
struct libusb_context *ctx;
|
100
|
-
unsigned long session_id = (unsigned long)&fDevice;
|
101
|
-
|
102
|
-
usbi_mutex_lock(&active_contexts_lock);
|
103
|
-
list_for_each_entry(ctx, &active_contexts_list, list, struct libusb_context) {
|
104
|
-
|
105
|
-
struct libusb_device* dev = usbi_get_device_by_session_id(ctx, session_id);
|
106
|
-
if (dev) {
|
107
|
-
usbi_dbg("using previously allocated device with location %lu", session_id);
|
108
|
-
libusb_unref_device(dev);
|
109
|
-
continue;
|
110
|
-
}
|
111
|
-
usbi_dbg("allocating new device with location %lu" ,session_id);
|
112
|
-
dev = usbi_alloc_device(ctx, session_id);
|
113
|
-
if (!dev) {
|
114
|
-
usbi_dbg("device allocation failed");
|
115
|
-
continue;
|
116
|
-
}
|
117
|
-
*((USBDevice**)dev->os_priv) = fDevice;
|
118
|
-
|
119
|
-
// Calculate pseudo-device-address
|
120
|
-
int addr,tmp;
|
121
|
-
if (strcmp(path.Leaf(), "hub") == 0)
|
122
|
-
{
|
123
|
-
tmp=100; //Random Number
|
124
|
-
}
|
125
|
-
else
|
126
|
-
{
|
127
|
-
sscanf(path.Leaf(), "%d", &tmp);
|
128
|
-
}
|
129
|
-
addr = tmp + 1;
|
130
|
-
path.GetParent(&parent_path);
|
131
|
-
while(strcmp(parent_path.Leaf(),"usb") != 0)
|
132
|
-
{
|
133
|
-
sscanf(parent_path.Leaf(), "%d", &tmp);
|
134
|
-
addr += tmp + 1;
|
135
|
-
parent_path.GetParent(&parent_path);
|
136
|
-
}
|
137
|
-
sscanf(path.Path(), "/dev/bus/usb/%d", &dev->bus_number);
|
138
|
-
(dev->device_address) = addr - (dev->bus_number + 1);
|
139
|
-
|
140
|
-
if(usbi_sanitize_device(dev) < 0)
|
141
|
-
{
|
142
|
-
usbi_dbg("device sanitization failed");
|
143
|
-
libusb_unref_device(dev);
|
144
|
-
continue;
|
145
|
-
}
|
146
|
-
usbi_connect_device(dev);
|
147
|
-
}
|
148
|
-
usbi_mutex_unlock(&active_contexts_lock);
|
149
|
-
} else if (fDevice) {
|
150
|
-
delete fDevice;
|
151
|
-
fDevice = NULL;
|
152
|
-
return;
|
153
|
-
}
|
154
|
-
}
|
155
|
-
fInitCheck = true;
|
156
|
-
}
|
157
|
-
|
158
|
-
|
159
|
-
WatchedEntry::~WatchedEntry()
|
160
|
-
{
|
161
|
-
if (fIsDirectory) {
|
162
|
-
watch_node(&fNode, B_STOP_WATCHING, *fMessenger);
|
163
|
-
|
164
|
-
WatchedEntry* child = fEntries;
|
165
|
-
while (child) {
|
166
|
-
WatchedEntry *next = child->fLink;
|
167
|
-
delete child;
|
168
|
-
child = next;
|
169
|
-
}
|
170
|
-
}
|
171
|
-
|
172
|
-
if (fDevice) {
|
173
|
-
// Remove this device from each active context's device list
|
174
|
-
struct libusb_context *ctx;
|
175
|
-
struct libusb_device *dev;
|
176
|
-
unsigned long session_id = (unsigned long)&fDevice;
|
177
|
-
|
178
|
-
usbi_mutex_lock(&active_contexts_lock);
|
179
|
-
list_for_each_entry(ctx, &active_contexts_list, list, struct libusb_context) {
|
180
|
-
dev = usbi_get_device_by_session_id (ctx, session_id);
|
181
|
-
if (dev != NULL) {
|
182
|
-
usbi_disconnect_device (dev);
|
183
|
-
libusb_unref_device(dev);
|
184
|
-
} else {
|
185
|
-
usbi_dbg("device with location %lu not found", session_id);
|
186
|
-
}
|
187
|
-
}
|
188
|
-
usbi_mutex_static_unlock(&active_contexts_lock);
|
189
|
-
delete fDevice;
|
190
|
-
}
|
191
|
-
}
|
192
|
-
|
193
|
-
|
194
|
-
bool
|
195
|
-
WatchedEntry::EntryCreated(entry_ref *ref)
|
196
|
-
{
|
197
|
-
if (!fIsDirectory)
|
198
|
-
return false;
|
199
|
-
|
200
|
-
if (ref->directory != fNode.node) {
|
201
|
-
WatchedEntry* child = fEntries;
|
202
|
-
while (child) {
|
203
|
-
if (child->EntryCreated(ref))
|
204
|
-
return true;
|
205
|
-
child = child->fLink;
|
206
|
-
}
|
207
|
-
return false;
|
208
|
-
}
|
209
|
-
|
210
|
-
WatchedEntry* child = new(std::nothrow) WatchedEntry(fMessenger, ref);
|
211
|
-
if (child == NULL)
|
212
|
-
return false;
|
213
|
-
child->fLink = fEntries;
|
214
|
-
fEntries = child;
|
215
|
-
return true;
|
216
|
-
}
|
217
|
-
|
218
|
-
|
219
|
-
bool
|
220
|
-
WatchedEntry::EntryRemoved(ino_t node)
|
221
|
-
{
|
222
|
-
if (!fIsDirectory)
|
223
|
-
return false;
|
224
|
-
|
225
|
-
WatchedEntry* child = fEntries;
|
226
|
-
WatchedEntry* lastChild = NULL;
|
227
|
-
while (child) {
|
228
|
-
if (child->fNode.node == node) {
|
229
|
-
if (lastChild)
|
230
|
-
lastChild->fLink = child->fLink;
|
231
|
-
else
|
232
|
-
fEntries = child->fLink;
|
233
|
-
delete child;
|
234
|
-
return true;
|
235
|
-
}
|
236
|
-
|
237
|
-
if (child->EntryRemoved(node))
|
238
|
-
return true;
|
239
|
-
|
240
|
-
lastChild = child;
|
241
|
-
child = child->fLink;
|
242
|
-
}
|
243
|
-
return false;
|
244
|
-
}
|
245
|
-
|
246
|
-
|
247
|
-
bool
|
248
|
-
WatchedEntry::InitCheck()
|
249
|
-
{
|
250
|
-
return fInitCheck;
|
251
|
-
}
|
252
|
-
|
253
|
-
|
254
|
-
RosterLooper::RosterLooper(USBRoster* roster)
|
255
|
-
: BLooper("LibusbRoster Looper"),
|
256
|
-
fRoster(roster),
|
257
|
-
fRoot(NULL),
|
258
|
-
fMessenger(NULL),
|
259
|
-
fInitCheck(false)
|
260
|
-
{
|
261
|
-
BEntry entry("/dev/bus/usb");
|
262
|
-
if (!entry.Exists()) {
|
263
|
-
usbi_err(NULL,"usb_raw not published");
|
264
|
-
return;
|
265
|
-
}
|
266
|
-
|
267
|
-
Run();
|
268
|
-
fMessenger = new(std::nothrow) BMessenger(this);
|
269
|
-
if (fMessenger == NULL)
|
270
|
-
{
|
271
|
-
usbi_err(NULL,"error creating BMessenger object");
|
272
|
-
return;
|
273
|
-
}
|
274
|
-
|
275
|
-
if(Lock()) {
|
276
|
-
entry_ref ref;
|
277
|
-
entry.GetRef(&ref);
|
278
|
-
fRoot = new(std::nothrow) WatchedEntry(fMessenger, &ref);
|
279
|
-
Unlock();
|
280
|
-
if (fRoot == NULL)
|
281
|
-
{
|
282
|
-
return;
|
283
|
-
}
|
284
|
-
if (fRoot->InitCheck() == false)
|
285
|
-
{
|
286
|
-
delete fRoot;
|
287
|
-
return;
|
288
|
-
}
|
289
|
-
}
|
290
|
-
fInitCheck = true;
|
291
|
-
}
|
292
|
-
|
293
|
-
|
294
|
-
void
|
295
|
-
RosterLooper::Stop()
|
296
|
-
{
|
297
|
-
Lock();
|
298
|
-
delete fRoot;
|
299
|
-
delete fMessenger;
|
300
|
-
Quit();
|
301
|
-
}
|
302
|
-
|
303
|
-
|
304
|
-
void
|
305
|
-
RosterLooper::MessageReceived(BMessage *message)
|
306
|
-
{
|
307
|
-
int32 opcode;
|
308
|
-
if (message->FindInt32("opcode", &opcode) < B_OK)
|
309
|
-
return;
|
310
|
-
|
311
|
-
switch (opcode) {
|
312
|
-
case B_ENTRY_CREATED: {
|
313
|
-
dev_t device;
|
314
|
-
ino_t directory;
|
315
|
-
const char* name;
|
316
|
-
if (message->FindInt32("device", &device) < B_OK
|
317
|
-
|| message->FindInt64("directory", &directory) < B_OK
|
318
|
-
|| message->FindString("name", &name) < B_OK)
|
319
|
-
break;
|
320
|
-
|
321
|
-
entry_ref ref(device, directory, name);
|
322
|
-
fRoot->EntryCreated(&ref);
|
323
|
-
break;
|
324
|
-
}
|
325
|
-
case B_ENTRY_REMOVED: {
|
326
|
-
ino_t node;
|
327
|
-
if (message->FindInt64("node", &node) < B_OK)
|
328
|
-
break;
|
329
|
-
fRoot->EntryRemoved(node);
|
330
|
-
break;
|
331
|
-
}
|
332
|
-
}
|
333
|
-
}
|
334
|
-
|
335
|
-
|
336
|
-
bool
|
337
|
-
RosterLooper::InitCheck()
|
338
|
-
{
|
339
|
-
return fInitCheck;
|
340
|
-
}
|
341
|
-
|
342
|
-
|
343
|
-
USBRoster::USBRoster()
|
344
|
-
: fLooper(NULL)
|
345
|
-
{
|
346
|
-
}
|
347
|
-
|
348
|
-
|
349
|
-
USBRoster::~USBRoster()
|
350
|
-
{
|
351
|
-
Stop();
|
352
|
-
}
|
353
|
-
|
354
|
-
|
355
|
-
int
|
356
|
-
USBRoster::Start()
|
357
|
-
{
|
358
|
-
if(fLooper)
|
359
|
-
return LIBUSB_SUCCESS;
|
360
|
-
|
361
|
-
fLooper = new(std::nothrow) RosterLooper(this);
|
362
|
-
if (fLooper == NULL || ((RosterLooper*)fLooper)->InitCheck() == false)
|
363
|
-
return LIBUSB_ERROR_OTHER;
|
364
|
-
return LIBUSB_SUCCESS;
|
365
|
-
}
|
366
|
-
|
367
|
-
|
368
|
-
void
|
369
|
-
USBRoster::Stop()
|
370
|
-
{
|
371
|
-
if(!fLooper)
|
372
|
-
return;
|
373
|
-
|
374
|
-
((RosterLooper *)fLooper)->Stop();
|
375
|
-
fLooper = NULL;
|
376
|
-
}
|
377
|
-
|
378
|
-
|
@@ -1,112 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Haiku Backend for libusb
|
3
|
-
* Copyright © 2014 Akshay Jaggi <akshay1994.leo@gmail.com>
|
4
|
-
*
|
5
|
-
* This library is free software; you can redistribute it and/or
|
6
|
-
* modify it under the terms of the GNU Lesser General Public
|
7
|
-
* License as published by the Free Software Foundation; either
|
8
|
-
* version 2.1 of the License, or (at your option) any later version.
|
9
|
-
*
|
10
|
-
* This library is distributed in the hope that it will be useful,
|
11
|
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
-
* Lesser General Public License for more details.
|
14
|
-
*
|
15
|
-
* You should have received a copy of the GNU Lesser General Public
|
16
|
-
* License along with this library; if not, write to the Free Software
|
17
|
-
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
|
-
*/
|
19
|
-
|
20
|
-
#include <List.h>
|
21
|
-
#include <Locker.h>
|
22
|
-
#include <Autolock.h>
|
23
|
-
#include <USBKit.h>
|
24
|
-
#include <map>
|
25
|
-
#include "libusbi.h"
|
26
|
-
#include "haiku_usb_raw.h"
|
27
|
-
|
28
|
-
using namespace std;
|
29
|
-
|
30
|
-
class USBDevice;
|
31
|
-
class USBDeviceHandle;
|
32
|
-
class USBTransfer;
|
33
|
-
|
34
|
-
class USBDevice {
|
35
|
-
public:
|
36
|
-
USBDevice(const char *);
|
37
|
-
virtual ~USBDevice();
|
38
|
-
const char* Location() const;
|
39
|
-
uint8 CountConfigurations() const;
|
40
|
-
const usb_device_descriptor* Descriptor() const;
|
41
|
-
const usb_configuration_descriptor* ConfigurationDescriptor(uint32) const;
|
42
|
-
const usb_configuration_descriptor* ActiveConfiguration() const;
|
43
|
-
uint8 EndpointToIndex(uint8) const;
|
44
|
-
uint8 EndpointToInterface(uint8) const;
|
45
|
-
int ClaimInterface(int);
|
46
|
-
int ReleaseInterface(int);
|
47
|
-
int CheckInterfacesFree(int);
|
48
|
-
int SetActiveConfiguration(int);
|
49
|
-
int ActiveConfigurationIndex() const;
|
50
|
-
bool InitCheck();
|
51
|
-
private:
|
52
|
-
int Initialise();
|
53
|
-
unsigned int fClaimedInterfaces; // Max Interfaces can be 32. Using a bitmask
|
54
|
-
usb_device_descriptor fDeviceDescriptor;
|
55
|
-
unsigned char** fConfigurationDescriptors;
|
56
|
-
int fActiveConfiguration;
|
57
|
-
char* fPath;
|
58
|
-
map<uint8,uint8> fConfigToIndex;
|
59
|
-
map<uint8,uint8>* fEndpointToIndex;
|
60
|
-
map<uint8,uint8>* fEndpointToInterface;
|
61
|
-
bool fInitCheck;
|
62
|
-
};
|
63
|
-
|
64
|
-
class USBDeviceHandle {
|
65
|
-
public:
|
66
|
-
USBDeviceHandle(USBDevice* dev);
|
67
|
-
virtual ~USBDeviceHandle();
|
68
|
-
int ClaimInterface(int);
|
69
|
-
int ReleaseInterface(int);
|
70
|
-
int SetConfiguration(int);
|
71
|
-
int SetAltSetting(int,int);
|
72
|
-
status_t SubmitTransfer(struct usbi_transfer*);
|
73
|
-
status_t CancelTransfer(USBTransfer*);
|
74
|
-
bool InitCheck();
|
75
|
-
private:
|
76
|
-
int fRawFD;
|
77
|
-
static status_t TransfersThread(void *);
|
78
|
-
void TransfersWorker();
|
79
|
-
USBDevice* fUSBDevice;
|
80
|
-
unsigned int fClaimedInterfaces;
|
81
|
-
BList fTransfers;
|
82
|
-
BLocker fTransfersLock;
|
83
|
-
sem_id fTransfersSem;
|
84
|
-
thread_id fTransfersThread;
|
85
|
-
bool fInitCheck;
|
86
|
-
};
|
87
|
-
|
88
|
-
class USBTransfer {
|
89
|
-
public:
|
90
|
-
USBTransfer(struct usbi_transfer*,USBDevice*);
|
91
|
-
virtual ~USBTransfer();
|
92
|
-
void Do(int);
|
93
|
-
struct usbi_transfer* UsbiTransfer();
|
94
|
-
void SetCancelled();
|
95
|
-
bool IsCancelled();
|
96
|
-
private:
|
97
|
-
struct usbi_transfer* fUsbiTransfer;
|
98
|
-
struct libusb_transfer* fLibusbTransfer;
|
99
|
-
USBDevice* fUSBDevice;
|
100
|
-
BLocker fStatusLock;
|
101
|
-
bool fCancelled;
|
102
|
-
};
|
103
|
-
|
104
|
-
class USBRoster {
|
105
|
-
public:
|
106
|
-
USBRoster();
|
107
|
-
virtual ~USBRoster();
|
108
|
-
int Start();
|
109
|
-
void Stop();
|
110
|
-
private:
|
111
|
-
void* fLooper;
|
112
|
-
};
|