Add hid_get_path to API resolves #163 #164

Closed
gotnone wants to merge 2 commits from get_path into master
gotnone commented 2020-05-14 16:21:20 -05:00 (Migrated from github.com)

This resolves the ability to get the device path from hid_device pointer issue in #163

Add a new hid_get_path function to the API. This adds a new path member
to the opaque structure of each hid implementation. The path is
dynamically allocated and populated in the respective hid_open_path
functions. The function returns a const char pointer to this path
string.

  • Add path string to each hid_device_ structure in hid.c files
  • Add hid_get_path function to hidapi.h and hid.c files
  • Add init and free code for dev->path to hid.c files
  • Allocate and populate dev->path in hid_open_path in hid.c files
  • Add example of hid_get_path usage in test.c
This resolves the ability to get the device path from hid_device pointer issue in #163 Add a new hid_get_path function to the API. This adds a new path member to the opaque structure of each hid implementation. The path is dynamically allocated and populated in the respective hid_open_path functions. The function returns a const char pointer to this path string. - Add path string to each hid_device_ structure in hid.c files - Add hid_get_path function to hidapi.h and hid.c files - Add init and free code for dev->path to hid.c files - Allocate and populate dev->path in hid_open_path in hid.c files - Add example of hid_get_path usage in test.c
gotnone commented 2020-05-14 16:31:41 -05:00 (Migrated from github.com)

This PR does have a significant caveat:

I don't have the ability to test this on anything other than windows at the moment. The use of char * may not be appropriate on some implementations (I am thinking of linux with UTF-8 capable filesystems). Please let me know if you can test this on other hidapi implementations.

This PR does have a significant caveat: I don't have the ability to test this on anything other than windows at the moment. The use of `char *` may not be appropriate on some implementations (I am thinking of linux with UTF-8 capable filesystems). Please let me know if you can test this on other hidapi implementations.
gotnone commented 2020-05-14 16:58:15 -05:00 (Migrated from github.com)

After getting my hands on a linux machine. I can say that the libusb and hidraw implementations also appear to work correctly. The limitation on this may be the fact that this linux machine was set up to be en_US.UTF-8.

TODO: somehow test on a mac

After getting my hands on a linux machine. I can say that the libusb and hidraw implementations also appear to work correctly. The limitation on this may be the fact that this linux machine was set up to be en_US.UTF-8. TODO: somehow test on a mac
Youw commented 2020-05-14 17:34:39 -05:00 (Migrated from github.com)

What's on to of my mind - replace calloc + strcpy with strdup
I'll check everything closely a bit later

What's on to of my mind - replace `calloc` + `strcpy` with `strdup` I'll check everything closely a bit later
Youw (Migrated from github.com) approved these changes 2020-08-13 11:17:22 -05:00
Youw commented 2020-11-24 05:52:12 -06:00 (Migrated from github.com)

I'm probably going to spend some more time on this.
I think it is possible to postpone initialization of the "path" variable until it is first time called (at least for some backends).

I'm probably going to spend some more time on this. I think it is possible to postpone initialization of the "path" variable until it is first time called (at least for some backends).
Youw commented 2021-07-28 06:51:52 -05:00 (Migrated from github.com)

I haven't forgot about this one, but I remember I wanted to perform some kind of optimisation, at least for one of the platforms, before merging it.

I haven't forgot about this one, but I remember I wanted to perform some kind of optimisation, at least for one of the platforms, before merging it.

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-libusb/hidapi!164
No description provided.