Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hidapi-libusb don't reattach kernel driver #110

Closed
mayanksuman opened this issue Oct 26, 2019 · 0 comments · Fixed by #111
Closed

hidapi-libusb don't reattach kernel driver #110

mayanksuman opened this issue Oct 26, 2019 · 0 comments · Fixed by #111
Labels
libusb Related to libusb backend

Comments

@mayanksuman
Copy link
Contributor

mayanksuman commented Oct 26, 2019

For instance in case of following code, the hid device (mouse) freeze after the program exits. Please change the VendorID and ProductID in the code during testing.

#ifdef WIN32
#include <windows.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <hidapi/hidapi.h>

#define MAX_STR 255

int main(int argc, char* argv[])
{
	int res;
	unsigned char buf[65];
	wchar_t wstr[MAX_STR];
	hid_device *handle;
	int i;

	// Initialize the hidapi library
	res = hid_init();

	if (res==0)
		wprintf(L"HID Initialized.\n");

	// Open the device using the VID, PID,
	// and optionally the Serial number.
	handle = hid_open(0x46d, 0xc534, NULL);
	if (handle != NULL)
		wprintf(L"Device Opened with handle %d\n", handle);
	else{
		wprintf(L"Device not Opened.\n", handle);
		exit(1);
	}

	// Read the Manufacturer String
	res = hid_get_manufacturer_string(handle, wstr, MAX_STR);
	wprintf(L"Manufacturer String: %ls\n", wstr);

	// Read the Product String
	res = hid_get_product_string(handle, wstr, MAX_STR);
	wprintf(L"Product String: %ls\n", wstr);

	// Read the Serial Number String
	res = hid_get_serial_number_string(handle, wstr, MAX_STR);
	if(res==0)
		wprintf(L"Serial Number String: (%d) %ls\n", wstr[0], wstr);

	hid_close(handle);

	// Finalize the hidapi library
	res = hid_exit();

	return 0;
}

Compiling the program with -lhdiapi-libusb result in frozen device after program run (no issue found with -lhdiapi-hidraw). Same issue (link) was filed for signal11/hidapi.

@Youw Youw added the libusb Related to libusb backend label Oct 28, 2019
@Youw Youw closed this as completed in #111 Oct 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libusb Related to libusb backend
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants