aboutsummaryrefslogtreecommitdiff
path: root/src/device/device_io_hid.cpp
diff options
context:
space:
mode:
authorselsta <selsta@sent.at>2019-01-09 09:20:53 +0100
committerselsta <selsta@sent.at>2019-01-09 15:45:06 +0100
commit6c060e6aaa26cd7e0161f075b52f093769195cd2 (patch)
treec1765920dae7f3f440e01a1fa518a1531f1f2e15 /src/device/device_io_hid.cpp
parentMerge pull request #5045 (diff)
downloadmonero-6c060e6aaa26cd7e0161f075b52f093769195cd2.tar.xz
device: proper handling of user input
(1) If the user denies something on the Ledger, a proper error message is now shown. (2) Ledger doesn't time out anymore while waiting on user input. (3) Lower the timeout to 2 seconds, this is enough for normal Ledger <-> System communication.
Diffstat (limited to '')
-rw-r--r--src/device/device_io_hid.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/device/device_io_hid.cpp b/src/device/device_io_hid.cpp
index 1aadfb9ea..36c7a241b 100644
--- a/src/device/device_io_hid.cpp
+++ b/src/device/device_io_hid.cpp
@@ -148,7 +148,7 @@ namespace hw {
return this->usb_device != NULL;
}
- int device_io_hid::exchange(unsigned char *command, unsigned int cmd_len, unsigned char *response, unsigned int max_resp_len) {
+ int device_io_hid::exchange(unsigned char *command, unsigned int cmd_len, unsigned char *response, unsigned int max_resp_len, bool user_input) {
unsigned char buffer[400];
unsigned char padding_buffer[MAX_BLOCK+1];
unsigned int result;
@@ -177,7 +177,11 @@ namespace hw {
//get first response
memset(buffer, 0, sizeof(buffer));
- hid_ret = hid_read_timeout(this->usb_device, buffer, MAX_BLOCK, this->timeout);
+ if (!user_input) {
+ hid_ret = hid_read_timeout(this->usb_device, buffer, MAX_BLOCK, this->timeout);
+ } else {
+ hid_ret = hid_read(this->usb_device, buffer, MAX_BLOCK);
+ }
ASSERT_X(hid_ret>=0, "Unable to read hidapi response. Error "+std::to_string(result)+": "+ safe_hid_error(this->usb_device));
result = (unsigned int)hid_ret;
io_hid_log(1, buffer, result);