device: fixed Ledger Nano S device selection

This commit is contained in:
xiphon 2018-10-18 04:37:30 +00:00
parent 5c85da5a73
commit 825d836f9f
2 changed files with 6 additions and 6 deletions

View file

@ -72,7 +72,7 @@ namespace hw {
this->connect(p->vid, p->pid, p->interface_number, p->usage_page, p->interface_OR_page); this->connect(p->vid, p->pid, p->interface_number, p->usage_page, p->interface_OR_page);
} }
void device_io_hid::connect(unsigned int vid, unsigned int pid, unsigned int interface_number, unsigned int usage_page, bool interface_OR_page ) { void device_io_hid::connect(unsigned int vid, unsigned int pid, int interface_number, unsigned short usage_page, bool interface_OR_page ) {
hid_device_info *hwdev_info, *hwdev_info_list; hid_device_info *hwdev_info, *hwdev_info_list;
hid_device *hwdev; hid_device *hwdev;
@ -83,8 +83,8 @@ namespace hw {
hwdev = NULL; hwdev = NULL;
hwdev_info = hwdev_info_list; hwdev_info = hwdev_info_list;
while (hwdev_info) { while (hwdev_info) {
if ((interface_OR_page && ((usage_page == 0xffa0) || (interface_number == 0))) || if ((interface_OR_page && ((hwdev_info->usage_page == usage_page) || (hwdev_info->interface_number == interface_number))) ||
((usage_page == 0xffa0) && (interface_number == 0)) ) { ((hwdev_info->usage_page == usage_page) && (hwdev_info->interface_number == interface_number))) {
MDEBUG("HID Device found: " << safe_hid_path(hwdev_info)); MDEBUG("HID Device found: " << safe_hid_path(hwdev_info));
hwdev = hid_open_path(hwdev_info->path); hwdev = hid_open_path(hwdev_info->path);
break; break;

View file

@ -52,8 +52,8 @@ namespace hw {
struct hid_conn_params { struct hid_conn_params {
unsigned int vid; unsigned int vid;
unsigned int pid; unsigned int pid;
unsigned int interface_number; int interface_number;
unsigned int usage_page; unsigned short usage_page;
bool interface_OR_page ; bool interface_OR_page ;
}; };
@ -100,7 +100,7 @@ namespace hw {
void init(); void init();
void connect(void *params); void connect(void *params);
void connect(unsigned int vid, unsigned int pid, unsigned int interface_number, unsigned int usage_page, bool interface_OR_page ); void connect(unsigned int vid, unsigned int pid, int interface_number, unsigned short usage_page, bool interface_OR_page );
bool connected() const; bool connected() const;
int exchange(unsigned char *command, unsigned int cmd_len, unsigned char *response, unsigned int max_resp_len); int exchange(unsigned char *command, unsigned int cmd_len, unsigned char *response, unsigned int max_resp_len);
void disconnect(); void disconnect();