Commit Graph

94 Commits

Author SHA1 Message Date
Ihor Dutchak 197ae97445 Merge remote-tracking branch 'origin/master' into cmake-support 2021-05-15 12:31:18 +03:00
jeremyouellet b8837014ef Use Conditional PlatformToolset projects for VS (#261) 2021-05-05 11:48:34 +03:00
Ihor Dutchak 84d7d57b8a Fix MinGW build on Linux/Unix platforms
Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com>
2021-04-15 18:38:41 +03:00
Ihor Dutchak 11021c09c0 Merge branch 'master' into cmake-support 2021-04-10 16:19:57 +03:00
Ihor Dutchak 0ea5e9502f windows: cache write buffer allocated for small user buffers 2021-03-07 13:58:57 +02:00
Mariusz Jaskółka 3cd1742737 Windows: Fix devices enumeration (#235)
Based on
https://github.com/microsoft/Windows-driver-samples/blob/d40232638faaab19de557e70a3ee938da7a35295/hid/hclient/pnp.c#L32

Fixes wrong detection of the class of devices.

Fixes: #234
2021-01-30 15:20:01 +02:00
Ihor Dutchak ad7cc64ee1 Merge remote-tracking branch 'origin/master' into cmake-support 2020-12-27 13:26:49 +02:00
Mornix fb4135c7a8 Windows: ensure buffer passed to HidD_SetFeature is large enough (#224) 2020-12-24 08:13:54 +02:00
Pavol Rusnak fe724003c6 windows: make hid.c non-executable 2020-12-11 21:01:19 +02:00
Ihor Dutchak 443ea8f2e4 Sync with v0.10.1 (master) 2020-11-26 22:51:45 +02:00
Russell Taylor 9828cad691 Windows: fix strict typecast (#206) 2020-11-23 21:12:26 +02:00
Ihor Dutchak 7260981d09 Merge branch 'master' into cmake-support 2020-10-14 19:30:36 +03:00
Ihor Dutchak 2eb8af161f MSVC: fix /W4 /WX compilation (#191) 2020-10-14 18:42:27 +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
Kevin Teynor b1a2628eea Windows: crash bugfix when trying to open device without a serial number (#194) 2020-10-14 18:36:12 +03:00
Ihor Dutchak a2a51cd03b Merge branch 'master' into cmake-support 2020-09-27 19:31:31 +03:00
UweBonnes 8a88108a49 windows/hid.c: Silence some warnings. (#181) 2020-09-27 18:22:45 +03:00
Cristian GLAVANA f7c7f97d09 Windows Handle GetOverlappedResult blocking on read/write (#129)
- Implemented solution from issue signal11/hidapi#88
- Allows read/write frames up to 1000 per second
2020-09-22 15:21:16 +03:00
Ihor Dutchak 053597e953 Merge branch 'master' into cmake-support 2020-09-08 14:33:02 +03:00
Stanley Pinchak ad27b46170 FIX Compiler Warnings on Windows
- cast hidapi supplied size_t parameters to DWORD when calling Windows
  API functions
- cast size_t return variables in `hid_read_timeout` and
  `hid_send_feature_report` to int in order to match hidapi signature.
2020-08-13 19:12:07 +03:00
Ihor Dutchak 7246840450 add CMake export package installation 2020-07-20 01:13:45 +03:00
Ihor Dutchak a7e4285eb5 add .pc generation for CMake build 2020-07-06 00:29:56 +03:00
Ihor Dutchak 095831f03f CMake: add Darwin build
refactor build system a bit
2020-05-26 22:34:36 +03:00
Ihor Dutchak 1bfcadc672 CMake: add Windows build 2020-05-26 20:24:34 +03:00
Jonas Malaco 2dd94af2ea Move local variable declaration to the beginning of the function
Older versions of MSVC (for example when using Visual Studio 10) don't
yet support variable declaration in the middle of blocks:

hidapi\windows\hid.c(845) : error C2275: 'BOOL' : illegal use of this type as an expression
        C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include\windef.h(153) : see declaration of 'BOOL'

Move the declaration of res to the beginning of the function.  Like in
hid_get_feature_report, only res is moved, essentially ignoring the #if
0 block (or assuming it will never be enabled).
2020-02-09 15:15:43 +02:00
Luca Weiss 51bdec7844 Fix manual Makefiles and add CI for them (#131) 2020-01-12 04:09:48 +02: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 faaf22cba2 Windows: fix build of hidtest 2019-11-05 14:00:44 +01:00
Josep Maria Antolín Segura dd16e7c16f Fix uninitialized strings on Windows (#109)
Fix for unusual cases where the hardware does not return the name and the string is not initialized at all.
2019-10-28 16:23:24 +02:00
Andrew Eikum 93dca80762 Update more repository URLs 2019-07-25 07:57:59 +02:00
Luca Weiss 065d46ab27 Add Windows (msbuild & cygwin) CI (#37)
* Upgrade Windows projects to VS2015
* add MSVC x64 configuration
2019-07-17 20:14:38 +03:00
Niklas Hambüchen 1515eb2c16 windows: Allow hid_error(NULL) 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
Thomas Petazzoni d98c408ed3 hidtest: don't use a C++ source file, since it's pure C
This allows to build the test program with toolchains that don't have
C++ support.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2019-06-25 15:09:11 +03:00
Kubicz, Filip c4f86a7d85 windows: Fix undeclared variable name in register_error()
Signed-off-by: Kubicz, Filip <Filip.Kubicz@nordicsemi.no>
2019-06-18 13:14:47 +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
Kubicz, Filip 76d4ffd853 Windows: enumerate simple devices
Right now, in hid_open it is checked if the connected devices have
"HIDClass" driver name. This is true for composite devices, but some
simple HID devices only have "Mouse" or "Keyboard" driver name.

One of devices that cannot be opened is Dell MS116t, but any mouse which
is not part of composite device can be affected.

With this change, one can enumerate and open these devices.

Signed-off-by: Kubicz, Filip <filip.kubicz@nordicsemi.no>
2019-06-07 08:33:25 +02:00
Sean Cross f7ee9ccd4e windows: retry open_device() without r/w if it fails
Modern Windows implementations don't allow opening HID devices in
READ/WRITE mode if they are claimed by the system.  Examples of such
devices include keyboards and mice.

However, these devices can be opened without READ/WRITE permissions, in
order to allow sending and receiving feature reports.

If open_device() fails, retry without requesting READ/WRITE permissions.

This inverts the logic of the parameter to open_device().

It is a refactor of #44 by @pqu.

Signed-off-by: Sean Cross <sean@xobs.io>
2019-06-05 09:38:14 +02:00
Diego Herranz a6a622ffb6 all: Fix a few typos 2016-09-19 23:40:12 -04:00
Austin Mullins 901512e88b windows: Set maximum buffer for USB strings to 0xFFF wide characters
Limit the size of the buffer passed to hid_get_manufacturer_string(),
hid_get_product_string(), and hid_get_serial_number_string() because
calling the underlying win32 functions with larger buffers causes them
to fail.
2016-09-19 23:31:39 -04:00
Alan Ott b5b2e1779b windows: Always open with sharing enabled
In the past, there was desire to make hid_open() open devices
exclusively, preventing devices from being opened more than once.
Unfortunately, recent versions of Windows have made this largely
impossible for many devices, as it appears that Windows itself is
holding certain HID devices open or preventing them from being
opened in exclusive mode.

This patch will always open devices in SHARED mode on Windows.
2016-03-03 10:54:51 -05:00
Alan Ott 54eb31dc16 windows: Return the correct length from hid_get_feature_report()
The Windows DeviceIoControl() doesn't account for the report ID byte.

Reported-by: Petr Stehlík <pstehlik@sophics.cz>
2014-08-18 11:17:13 -04:00
Mark A. Tsuchida 171a521b91 windows: Limit hid_read() return value to buffer length
hid_read() and hid_read_timeout() now return the number of bytes copied,
instead of the number of bytes returned by GetOverlappekdResult() (which is
the maximum report size for the device).  This limits the return value to
the requested length (buffer size), matching the behavior on other
platforms.
2014-07-22 17:35:56 -04:00
Scott Talbert 627f3aa478 windows: Set the OS report buffer size to 64 reports
Resolves issues with dropped input reports when receiving a large amount
of data.
2014-07-22 16:53:23 -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
Alan Ott 776ec62dfc windows: Fix leak of event handle on open_device() failure
Create a new free_hid_device() function which takes care of all the
resources in hid_device which may need to be freed/released.

Reported-by: Johan Lindh <johan@linkdata.se>
2013-04-23 13:56:06 -04:00
Ludovic Rousseau ec24f93100 all: make hid_enumerate() able to match any vendor or any product
Passing product_id=0 will match any product of a given vendor.  This patch
makes it also possible to use vendor_id=0 to match any vendor for a given
product id.

Windows code added to Ludovic's patch by Alan Ott.
2012-11-27 22:12:35 -05:00
Nikolaj Løbner Sheller 0ed94093c8 windows: replace magic number 2 with sizeof(wchar_t)
Changed for readability, as I think this is what was intended by
the author.
2012-11-26 20:30:09 -05:00
Justin R. Cutler b5b15d0d83 windows: mingw: minor gcc -pedantic warning fixes 2012-11-26 20:00:48 -05:00
Justin R. Cutler 69a91a8f6c All: Convert C99 comments (//) into C89 comments (/* */) 2012-11-26 18:49:51 -05:00