104 Commits

Author SHA1 Message Date
nastys ecf1b62882 Add Sixaxis init for Monterey 2023-02-09 22:15:08 +01:00
Jake 7b142f45fd Implement hid_write_control, so we can use HidD_SetOutputReport on win, all others are just a wrapper until tested 2023-02-09 22:15:08 +01:00
Steven Michalske f2e2b5b4d4 macOS: Error reporting/hid_error implementation (#314) 2022-10-14 13:25:42 +03:00
Ihor Dutchak 4e63d6dfc3 Introduce HID_API_MAX_REPORT_DESCRIPTOR_SIZE (#452)
- first step is to use HID_API_MAX_REPORT_DESCRIPTOR_SIZE internally;
- port a few improvements from get-descriptor branch early;

Resolves: #384
2022-09-15 13:05:56 +03:00
Dimitriy Ryazantcev 0f2cf886e5 RFC: Add HID bus type in hid_device_info (#308) 2022-09-10 19:18:09 +03:00
Julian Waller 5c9f147a07 Add hid_get_device_info (#432)
- new API function: `struct hid_device_info * hid_get_device_info(hid_device *dev);` to get `hid_device_info` after the device already opened;
- reused existing implementation on Windows and macOS from enumeration routines to have the implementation;
- refactored libusb implementation to have a shared routine for `hid_enumerate` and `hid_get_device_info`;
- refactored hidraw implementation to have a shared routine for `hid_enumerate` and `hid_get_device_info`;

Resolves: #431
Closes: #164
Closes: #163
2022-08-13 19:01:57 +03:00
Ihor Dutchak 52c728acf4 Use propper type for mach_port_t default param
- enable compilation warnings as errors for CI to catch such issues in the future;
- fix Mingw strict compilation warnings;
2022-05-05 14:53:17 +03:00
Ihor Dutchak 2aeb0688fa Don't use deprecated kIOMasterPortDefault (#406)
`kIOMasterPortDefault` is deprecated since macOS 12.0.
One alternative is to use named constant `kIOMainPortDefault` which is not available before macOS 12.0.

Both named constants are just an alias for `NULL`, so it is simpler to use it directly instead.

Fixes: #377
2022-05-02 14:48:12 +03:00
Ihor Dutchak bca404520f Fire v0.12.0 (#398)
- add convenient macros to check HIDAPI version in runtime;
- mark in which version all recent HIAPI API functions where added;
2022-04-23 15:50:41 +03:00
Ihor Dutchak 05f0588220 darwin: add option to open device in non-exclusive mode (#397)
Resolves: #27
Resolves: #344
2022-04-23 14:16:42 +03:00
Frederik Seiffert 1ce31c3594 macos: Add Mac-specific API to get device Location ID (#378) 2022-02-25 10:54:28 +02:00
Frederik Seiffert e08ddcee5f macOS: Fix build warnings (#374) 2022-02-05 17:24:20 +02:00
Ihor Dutchak 6f37897bef Remove stale Windows/macOS example/test 2022-01-29 18:33:15 +02:00
Ihor Dutchak 69dcdc1ff0 Update copyright strings 2022-01-29 18:33:15 +02:00
Ihor Dutchak 4d63a5085a macOS: use IORegistryEntryGetRegistryEntryID to resolve paths (#322)
With some device connection configurations,
the device paths become over 512 bytes (io_string_t max length)
which makes them unusable with current implementation.

Rather than using ServiceRegistry string path, use its ID,
which is uint64_t and easily serializable/deserializable into a string.

Implementation idea by felix.schwarz@iospirit.com
https://github.com/flirc/hidapi/commit/8d251c3854c3b1877509ab07a623dafc8e803db5

Fixes: #127, #236.
2021-08-23 20:58:13 +03:00
Ihor Dutchak f2bb972e7f add CMake build system 2021-07-03 20:38:58 +03:00
Ihor Dutchak 42fa21fff1 drop support of macOS 10.5 and earlier (#121)
- IOHIDDeviceGetService is available since macOS 10.6
2021-06-14 13:30:35 +03:00
Erik OShaughnessy 7620bc7faa Guard against zero length buffers in hid_write (#279) 2021-06-14 04:09:13 +03:00
Jonas Malaco ce606fac8f macOS: check if IOHIDManagerCopyDevices returned a NULL (#209)
Removes a possible cause for a segmentation fault observed in `CFSetGetCount`.

Related: #208 ("Segmentation fault on Mac OS Catalina").
Signed-off-by: Jonas Malaco <jonas@protocubo.io>
2020-11-23 21:03:03 +02:00
Ihor Dutchak a731aae2a3 macOS: fix -Wall -Wextra -pedantic compilation warnings 2020-10-16 13:06:50 +03:00
Ihor Dutchak 8f72236099 add hid_version/hid_version_str API (#192)
- API functions to get runtime version of the library;
- macros to get static/compile-time version of the library;
- VERSION file;
2020-10-14 18:41:08 +03:00
Ihor Dutchak fd53f39f25 macOS: enumerate device with primary usage/usage_page first (#193)
It improves backward compatibility with versions of hidapi, where
usage/usage_pairs didn't emit seaprate hid_devices_info.
2020-10-14 18:37:27 +03:00
Ihor Dutchak cdc473dfe4 Don't leak device handle in macOS 10.10 or newer (#186)
In one of the early versions of macOS, when you try to close the device
with IOHIDDeviceClose() that is being physically disconnected.
Starting with some version of macOS, this crash bug was fixed,
and starting with macSO 10.15 the opposite effect took place:
in some environments crash happens if IOHIDDeviceClose() is _not_ called.

This patch is to keep a workaround for old versions of macOS,
and don't have a leak in new/tested environments.

Fixes: #144.
2020-09-29 14:01:30 +03:00
Pavel Hübner 24a822c80f Fix compilation warning in pedantic mode on macOS
The compiler provided the following warning message:
```
hid.c:830:29: warning: format specifies type 'void *' but the argument has type 'IOHIDDeviceRef' (aka 'struct __IOHIDDevice *') [-Wformat-pedantic]
                sprintf(str, "HIDAPI_%p", dev->device_handle);
                                     ~~   ^~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/secure/_stdio.h:47:56: note: expanded from macro 'sprintf'
  __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
```
2020-03-20 01:43:44 +02:00
Luca Weiss 51bdec7844 Fix manual Makefiles and add CI for them (#131) 2020-01-12 04:09:48 +02:00
0xDP 65d22a9c31 macOS: correct IOKit framework location (#120) 2019-12-07 18:54:07 +02:00
Tod E. Kurt ca1a2d6efa macOS support for multiple usage/usage-pages (#125)
* macOS support for multiple usage/usage-pages
Update of @fengji2006 PR#65, second try

* apply requested changes and test

* handle possible nullptr
2019-12-05 10:53:44 -08:00
Daniel Van Noord 083223e779 Added support for Get Input Report (#59)
- Get Input Report supported on linux/libusb, mac and windows;
- linux/hidraw doesn't support it on kernel level;
2019-11-15 13:55:51 +02:00
Ludovic Rousseau 3cea631d43 macOS: fix Makefile-manual to build hidtest 2019-11-05 14:00:44 +01:00
Ihor Dutchak d64f6c6a16 macOS: send report id conditionally for hid_get_feature_report (#70)
same as in hid_send_feature_report, and Windows/Linux
2019-09-24 13:34:59 +03:00
Josh Junon d8b6588d09 mac: prevent memory leak in hid_open_path() if hid_init() fails 2019-09-24 13:25:23 +03:00
Andrew Eikum 5d9b4cd93c Zero-initialize new hid_device_info structs
This fixes an uninitialized usage_page value leaking from the Linux
backend. It may fix other uninitialized values, too.
2019-07-25 08:08:12 +02:00
Andrew Eikum 93dca80762 Update more repository URLs 2019-07-25 07:57:59 +02:00
Luca Weiss 42dede9db5 mac: Return string in hid_error() 2019-07-15 13:15:46 +03:00
luz.paz f01c4ede50 Misc. typo fixes
Found via `codespell -q 3`
2019-07-14 13:54:55 +02:00
Tod E. Kurt 0ebecbd1f6 fix small casting issue 2019-07-02 23:10:41 -07:00
Iakov 'Jake' Kirilenko e32d3f1266 Initialize local variable with smth meaningful
I prefer explicit INVALID rather than possible compiler warning about uninitialized var sometimes later
2019-06-24 22:55:27 +02:00
iakov 9d569ba8a9 Add missed NULL initialisation to local variable
Co-Authored-By: Ihor Dutchak <ihor.youw@gmail.com>
2019-06-24 22:55:27 +02:00
Iakov Kirilenko 0324a0b0e5 Codestyle conformance: add spaces after type-case 2019-06-24 22:55:27 +02:00
Iakov Kirilenko 7d08fd907d More rigorous & even C++ compatible code for macOS 2019-06-24 22:55:27 +02:00
Iakov Kirilenko 73b9ccb996 Explicit cast from void* to corresponding type
Fix compilation without -fpermissive
2019-06-24 22:55:27 +02:00
Luca Weiss 2f7a7c9948 Rename hid_device* parameters to dev
Previously, the header file used hid_device *device and the
implementations used hid_device *dev. Make this consistent.
2019-06-17 11:32:48 +02:00
Tod E. Kurt 121567d64a Merge pull request #2 from z3ntu/pr_380
mac: Set a valid interface number on hid_device_info for USB HID dev…
2019-06-09 11:54:01 -07:00
Dylan McKay 00e6e4568f mac: Set a valid interface number on hid_device_info for USB HID devices
Previously the interface would never be set on Mac.

This presents a big pain because retrieving interface numbers can be the
only way to distinguish between the interfaces returned by HIDAPI.

This change makes it possible to retrieve interface number from an
hid_device_info on Mac for USB HID devices only.

It is unclear if the macOS IOKit library returns valid interface numbers
for non-HID USB devices. Because of this, I have opted to simply skip
that case - leave it initialised to `-1`.

In the future, we can easily relax this restriction if it turns out
IOKit correctly returns interface number with non-HID USB devices. For
now, this commit brings 90% of the value at 5% of the risk.
2019-06-06 17:31:48 +02:00
Raphaël P. Barazzutti d8336833fc mac: fix behaviour of hid_get_feature_report (was writing on the report id byte) and return value was not right) 2019-06-06 00:23:45 +02:00
Diego Herranz a6a622ffb6 all: Fix a few typos 2016-09-19 23:40:12 -04:00
Brendan Shanks ae15b65ed9 Mac: Disable unused get_location_id()
Disable get_location_id(). It's not used in active code since make_path()
was removed.
2016-09-19 22:13:10 -04:00
Brendan Shanks 474145e766 Mac: Remove unused get_string_property_utf8()
Remove get_string_property_utf8(), it's not used since make_path() was removed
2016-09-19 22:13:10 -04:00
Brendan Shanks 59a076705b Mac: Use IOKit IOService:/ paths for devices
Change hid_enumerate() and hid_open_path() to use IOKit IOService:/
paths to uniquely identify devices, instead of creating a path
(done by the make_path() function).

The path passed to hid_open_path() now must be a valid path to an
IOHIDDevice in the IOService plane, like:
"IOService:/AppleACPIPlatformExpert/PCI0@0/AppleACPIPCI/EHC1@1D,7/
AppleUSBEHCI/PLAYSTATION(R)3
Controller@fd120000/IOUSBInterface@0/IOUSBHIDDriver"
2016-09-19 22:13:03 -04:00
Bei Zhang 2e27f98b3e all: Fix license name
"GNU Public License" does not exist. It is called "GNU General Public
License", "GNU GPL" or simply "GPL".
2013-10-06 17:33:44 -04:00