Skip to content

Commit e05b485

Browse files
committed
feat: enable desktop HIDAPI_DUMMY
1 parent 2e6dfa0 commit e05b485

3 files changed

Lines changed: 53 additions & 25 deletions

File tree

contrib/depends/toolchain.cmake.in

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) # Find programs on host
6969
set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) # Find libs in target
7070
set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) # Find includes in target
7171

72+
add_definitions(-DHIDAPI_DUMMY=ON)
73+
set(HIDAPI_DUMMY ON)
74+
7275
# specify the cross compiler to be used. Darwin uses clang provided by the SDK.
7376
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
7477
if(ARCHITECTURE STREQUAL "aarch64")
@@ -97,15 +100,12 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
97100
SET(BUILD_64 ON)
98101
SET(BREW OFF)
99102
SET(PORT OFF)
100-
SET(CMAKE_OSX_SYSROOT "@prefix@/native/SDK/")
101103
SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.14")
102104
SET(CMAKE_CXX_STANDARD 14)
103105
SET(LLVM_ENABLE_PIC OFF)
104106
SET(LLVM_ENABLE_PIE OFF)
105107
elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
106108
add_definitions(-DUSE_DEVICE_TREZOR=OFF)
107-
add_definitions(-DHIDAPI_DUMMY=ON)
108-
set(HIDAPI_DUMMY ON)
109109
SET(ANDROID TRUE)
110110
if(ARCHITECTURE STREQUAL "armv7a")
111111
SET(CMAKE_ANDROID_ARCH_ABI "armeabi-v7a")
@@ -132,8 +132,6 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
132132
SET(CMAKE_CXX_COMPILER @CXX@)
133133
elseif(CMAKE_SYSTEM_NAME STREQUAL "iOS")
134134
set(USE_DEVICE_TREZOR OFF)
135-
add_definitions(-DHIDAPI_DUMMY=ON)
136-
set(HIDAPI_DUMMY ON)
137135
add_definitions(-DUSE_DEVICE_LEDGER=ON)
138136
SET(CMAKE_C_COMPILER @CC@)
139137
SET(CMAKE_CXX_COMPILER @CXX@)

patches/monero/0006-add-dummy-device-for-ledger.patch

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,38 @@ Subject: [PATCH 06/17] add dummy device for ledger
2222
create mode 100644 src/device/device_io_dummy.hpp
2323

2424
diff --git a/CMakeLists.txt b/CMakeLists.txt
25-
index c73b813d8..5c0f31cb8 100644
25+
index c73b813d8..ce5ef4bab 100644
2626
--- a/CMakeLists.txt
2727
+++ b/CMakeLists.txt
28-
@@ -692,8 +692,12 @@ include_directories(${LMDB_INCLUDE})
28+
@@ -692,16 +692,21 @@ include_directories(${LMDB_INCLUDE})
2929
include_directories(${LIBUNWIND_INCLUDE})
3030
link_directories(${LIBUNWIND_LIBRARY_DIRS})
3131

32+
-# Final setup for hid
33+
-if (HIDAPI_FOUND)
34+
- message(STATUS "Using HIDAPI include dir at ${HIDAPI_INCLUDE_DIR}")
35+
- add_definitions(-DHAVE_HIDAPI)
36+
- include_directories(${HIDAPI_INCLUDE_DIR})
37+
- link_directories(${LIBHIDAPI_LIBRARY_DIRS})
3238
+if (HIDAPI_DUMMY)
3339
+ add_definitions(-DHIDAPI_DUMMY)
34-
+endif()
40+
else()
41+
- message(STATUS "Could not find HIDAPI")
42+
+ # Final setup for hid
43+
+ if (HIDAPI_FOUND)
44+
+ message(STATUS "Using HIDAPI include dir at ${HIDAPI_INCLUDE_DIR}")
45+
+ add_definitions(-DHAVE_HIDAPI)
46+
+ include_directories(${HIDAPI_INCLUDE_DIR})
47+
+ link_directories(${LIBHIDAPI_LIBRARY_DIRS})
48+
+ else()
49+
+ message(STATUS "Could not find HIDAPI")
50+
+ endif()
51+
endif()
52+
3553
+
36-
# Final setup for hid
37-
-if (HIDAPI_FOUND)
38-
+if (HIDAPI_FOUND)
39-
message(STATUS "Using HIDAPI include dir at ${HIDAPI_INCLUDE_DIR}")
40-
add_definitions(-DHAVE_HIDAPI)
41-
include_directories(${HIDAPI_INCLUDE_DIR})
54+
# Trezor support check
55+
include(CheckTrezor)
56+
4257
diff --git a/src/device/CMakeLists.txt b/src/device/CMakeLists.txt
4358
index e4f1159b5..14d398f87 100644
4459
--- a/src/device/CMakeLists.txt

patches/wownero/0008-add-dummy-device-for-ledger.patch

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,38 @@ Subject: [PATCH 08/15] add dummy device for ledger
2121
create mode 100644 src/device/device_io_dummy.hpp
2222

2323
diff --git a/CMakeLists.txt b/CMakeLists.txt
24-
index 88335ee9d..86000f811 100644
24+
index c73b813d8..ce5ef4bab 100644
2525
--- a/CMakeLists.txt
2626
+++ b/CMakeLists.txt
27-
@@ -693,8 +693,12 @@ include_directories(${LMDB_INCLUDE})
27+
@@ -692,16 +692,21 @@ include_directories(${LMDB_INCLUDE})
2828
include_directories(${LIBUNWIND_INCLUDE})
2929
link_directories(${LIBUNWIND_LIBRARY_DIRS})
3030

31+
-# Final setup for hid
32+
-if (HIDAPI_FOUND)
33+
- message(STATUS "Using HIDAPI include dir at ${HIDAPI_INCLUDE_DIR}")
34+
- add_definitions(-DHAVE_HIDAPI)
35+
- include_directories(${HIDAPI_INCLUDE_DIR})
36+
- link_directories(${LIBHIDAPI_LIBRARY_DIRS})
3137
+if (HIDAPI_DUMMY)
3238
+ add_definitions(-DHIDAPI_DUMMY)
33-
+endif()
39+
else()
40+
- message(STATUS "Could not find HIDAPI")
41+
+ # Final setup for hid
42+
+ if (HIDAPI_FOUND)
43+
+ message(STATUS "Using HIDAPI include dir at ${HIDAPI_INCLUDE_DIR}")
44+
+ add_definitions(-DHAVE_HIDAPI)
45+
+ include_directories(${HIDAPI_INCLUDE_DIR})
46+
+ link_directories(${LIBHIDAPI_LIBRARY_DIRS})
47+
+ else()
48+
+ message(STATUS "Could not find HIDAPI")
49+
+ endif()
50+
endif()
51+
3452
+
35-
# Final setup for hid
36-
-if (HIDAPI_FOUND)
37-
+if (HIDAPI_FOUND)
38-
message(STATUS "Using HIDAPI include dir at ${HIDAPI_INCLUDE_DIR}")
39-
add_definitions(-DHAVE_HIDAPI)
40-
include_directories(${HIDAPI_INCLUDE_DIR})
53+
# Trezor support check
54+
include(CheckTrezor)
55+
4156
diff --git a/src/device/CMakeLists.txt b/src/device/CMakeLists.txt
4257
index e4f1159b5..14d398f87 100644
4358
--- a/src/device/CMakeLists.txt
@@ -235,13 +250,13 @@ index 000000000..edb4beea3
235250
+ MDEBUG("exchange(): waitsForDeviceSend");
236251
+ // NOTE: waitsForDeviceSend should be changed by external code
237252
+ while (waitsForDeviceSend) {
238-
+ usleep(1000);
253+
+ std::this_thread::sleep_for(std::chrono::microseconds(1000));
239254
+ MDEBUG("exchange(): waitsForDeviceSend (still)");
240255
+ }
241256
+
242257
+ MDEBUG("exchange(): waitsForDeviceReceive");
243258
+ while (waitsForDeviceReceive) {
244-
+ usleep(1000);
259+
+ std::this_thread::sleep_for(std::chrono::microseconds(1000));
245260
+ MDEBUG("exchange(): waitsForDeviceReceive (still)");
246261
+ }
247262
+

0 commit comments

Comments
 (0)