Commit Graph

32 Commits

Author SHA1 Message Date
Alan Ott 7a8194b03b Disconnection fixes on Mac. 2011-10-04 17:03:50 -04:00
Alan Ott be40902624 Fix for hid_read*() hanging after device disconenct on Mac.
Send a pthread_cond_broadcast() when a device gets disconnected and
wake up any waiting threads.
2011-10-04 15:54:13 -04:00
Alan Ott 51c18081bf Switch mac/hid.c to use threads.
The previous mac/hid.c implementation was kind of problematic. It worked
fine on 10.5, but on 10.7 I have gotten reports of really weird stuff
happening, such as the report callback being called with invalid context
data.

The problem was, the callback's don't get removed from the callback list
when you call IOHIDDeviceClose() in 10.7 like they used to.  This means that
the report callback must be unregistered at hid_close() time.  Further the
unregister will not work unless you pass _exactly_ the same parameters into
IOHIDDeviceRegisterInputReportCallback() that were passed in the first time
(with the exception of the function being NULL).  Thanks Apple for your
stellar documentation and commitment to backwards compatibility.

Further, with the previous implementation, the OS only seemed to buffer
up 4 reports in between calls to CFRunLoopRun*(), causing the potential
for reports to get lost. The new method, being on a separate thread,
will now buffer up to a configurable 30 reports.
2011-10-04 11:04:27 -04:00
Alan Ott 0075338395 Add hid_init() and hid_exit() to Mac. 2011-09-13 02:37:13 +08:00
signal11 4f284dc2ec Check for NULL device on enumeration on Mac.
On Mac, hid_enumerate can crash if the device is unplugged during enumeration.

From: Richard Bateman (Taxilian) <taxilian@gmail.com>
2011-08-08 21:42:04 -04:00
Alan Ott 781efae694 hid_read_timeout() (Mac)
Add hid_read_timeout() to mac.
2011-08-08 21:01:45 -04:00
Richard Bateman d94f682c70 Fixed possible mac when unplugging a device during enumeration 2011-06-24 15:21:40 -06:00
Alan Ott 3290860713 Change interface field to interface_number in hid_device_info struct.
Change field named interface to interface_number because Visual Studio uses
interface as a keyword for managed C++.
2011-01-18 23:00:59 -05:00
Alan Ott a93cdfbeac Add the interface number to hid_device_info on Linux/libusb implementation.
The interface number is added to the hid_device_info struct. Since the
Linux/libusb implementation can't put the Usage and Usage Page in the
hid_device_info struct because it requires detaching the kernel driver, the
interface number is added instead so that users with composite HID devices
can differentiate between the interfaces on the device.
2011-01-18 22:52:06 -05:00
Bastaan Veelo ba51d59a4e hid_device_info with bcdDevice release number. 2011-01-18 18:38:35 -05:00
Bastaan Veelo b04545e118 Fill in the Usage Page and Usage values on Mac. 2011-01-14 18:54:38 -05:00
Alan Ott 02b5007fc4 Made the Mac implementation robust to disconnects and re-connects while a device has an open handle. 2010-12-21 00:55:04 -05:00
Alan Ott cc41195b5c Fixed a 64-bit issue. The code in the Apple docs doesn't work for 64-bit. On 64-bit systems long is 64-bits, but on 32-bit systems it's 32-bits. The function get_long_property() was changed to be get_int_property(), and references to long were changed to int32_t.
Thanks to Ulf Soderberg and Ludovic Rossuau for pointing out this problem.
2010-12-08 13:32:31 -07:00
Alan Ott ec376aea5e Make sure the string properties are null-terminated. 2010-11-07 16:17:33 -05:00
Ludovic Rousseau e08ae577ca Failsafe clean rule
If the files to remove are not present the clean rule should not fail.
The clean rule is now idempotent.

Signed-off-by: Alan Ott <alan@signal11.us>
2010-10-13 17:01:08 -04:00
Ludovic Rousseau 93affcd658 Also remove $(CPPOBJS) in the clean rule
Signed-off-by: Alan Ott <alan@signal11.us>
2010-10-13 16:52:28 -04:00
Ludovic Rousseau 0dcd42f957 Fix warning: no previous prototype for ‘hid_report_callback’
Local functions should be declared as static

Signed-off-by: Alan Ott <alan@signal11.us>
2010-10-13 16:51:44 -04:00
Ludovic Rousseau a377ee4b1b Fix function declaration isn’t a prototype
Functions with no arguments should use void

hid.c:51: warning: function declaration isn’t a prototype
hid.c:210: warning: function declaration isn’t a prototype

Signed-off-by: Alan Ott <alan@signal11.us>
2010-10-13 16:51:13 -04:00
Ludovic Rousseau 306f3f7978 Do not overwrite CFLAGS
The user should be able to add options to CFLAGS

Signed-off-by: Alan Ott <alan@signal11.us>
2010-10-13 16:50:29 -04:00
Alan Ott 09cb41aada Additional licenses. HIDAPI is now GPLv3, BSD, or the original license,
at the discretion of the user. This should provide maximum flexibility and
freedom.
2010-09-13 11:15:24 -04:00
Alan Ott c5993b749e Fixed Warnings. 2010-08-21 13:26:57 -04:00
Alan Ott 17c4c9251c Changed hid_error() to return const. 2010-08-21 13:22:03 -04:00
Alan Ott f53f5fb0f8 Changed hid_get_feature_report() to return the number of bytes actually read on Windows. This involved changing the implementation to use DeviceIoControl() rather than HidD_GetFeature().
Changed it on Mac as well to return the same. The Linux implementation already did this.
2010-08-14 14:12:43 -04:00
Alan Ott 65331407a7 Made the hid_error() return wchar_t* so we can get translated error messages. 2010-08-10 14:58:59 -04:00
Alan Ott 3c19a45952 Implemented the following for Mac OS X:
hid_get_manufacturer_string()
	hid_get_product_string()
	hid_get_serial_number_string()
2010-07-28 21:30:09 -04:00
Alan Ott d2c01f9000 Updated .gitignore to include generated files on Unix. 2010-07-28 20:57:46 -04:00
Alan Ott 228ec0cc25 Merge branch 'master' of github.com:signal11/hidapi 2010-07-28 20:54:01 -04:00
Alan Ott 306e3a6058 Updated to the new API. 2010-07-28 20:53:21 -04:00
Alan Ott da1ab35011 Fixed up the header comments. 2010-07-28 20:32:41 -04:00
Alan Ott ca717d8553 Made hid_read() thread-safe on Mac. 2010-07-07 21:01:46 -04:00
Alan Ott 044ddb1295 Added support for Feature Reports to OSX version. 2010-07-05 23:26:18 -04:00
Alan Ott fc29fa93c9 Initial cut at a Mac OS X version. Not fully complete, but functional for read/write open and close. 2010-07-05 22:48:23 -04:00