From 9963d246e534e5348bc6b83bbb9c161d187cf444 Mon Sep 17 00:00:00 2001 From: Mohamed Gaber Date: Fri, 24 Mar 2023 18:53:22 +0200 Subject: [PATCH] Add no-verify CLI flag (#41) --- Changelog.md | 4 + include/nuphy.hpp | 2 +- lib/nuphy.cpp | 15 ++- package.json | 4 +- res/NuPhy/keycodes.yml | 40 ++++--- src/main.cpp | 13 ++- ui/src/app.css | 6 +- util/usb/annotate_map.rb | 2 +- util/usb/default.annotated.hex | 198 ++++++++++++++++----------------- 9 files changed, 147 insertions(+), 137 deletions(-) diff --git a/Changelog.md b/Changelog.md index b87136c..c930d69 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,7 @@ +# 0.6.7 +- Add a no-verify CLI flag so unsupported keyboards can still dump data. +- Reorder the keycodes for consistency + # 0.6.6 - Fixes a bug where the Del key was not remappable on Air75. - Fixes scancode for Pause/Break key. diff --git a/include/nuphy.hpp b/include/nuphy.hpp index c2df547..2975a6c 100644 --- a/include/nuphy.hpp +++ b/include/nuphy.hpp @@ -62,7 +62,7 @@ class NuPhy { // Abstract virtual std::vector< uint8_t > setKeymapReportHeader(bool mac = false) = 0; - static std::shared_ptr< NuPhy > find(); // Factory Method + static std::shared_ptr< NuPhy > find(bool verify = true); // Factory Method void validateYAMLKeymap( const std::string &yamlString, diff --git a/lib/nuphy.cpp b/lib/nuphy.cpp index 01fa005..aa0c2fe 100644 --- a/lib/nuphy.cpp +++ b/lib/nuphy.cpp @@ -136,9 +136,10 @@ static std::shared_ptr< NuPhy > createKeyboard( std::string name, std::string dataPath, std::string requestPath, - uint16_t firmware + uint16_t firmware, + bool verify = true ) { - if (name == "Air75") { + if (name == "Air75" || !verify) { return std::make_shared< Air75 >(dataPath, requestPath, firmware); } if (name == "NuPhy Halo75") { @@ -154,7 +155,7 @@ static std::shared_ptr< NuPhy > createKeyboard( std::string writeCol = "col05"; std::string dataCol = "col06"; -std::shared_ptr< NuPhy > NuPhy::find() { +std::shared_ptr< NuPhy > NuPhy::find(bool verify) { auto seeker = hid_enumerate(0x05ac, 0x024f); SCOPE_EXIT { hid_free_enumeration(seeker); @@ -204,7 +205,8 @@ std::shared_ptr< NuPhy > NuPhy::find() { productName.value(), dataPath.value(), requestPath.value(), - firmware + firmware, + verify ); if (keyboard == nullptr) { throw unsupported_keyboard(fmt::format( @@ -219,7 +221,7 @@ std::shared_ptr< NuPhy > NuPhy::find() { return nullptr; } #else -std::shared_ptr< NuPhy > NuPhy::find() { +std::shared_ptr< NuPhy > NuPhy::find(bool verify) { std::shared_ptr< NuPhy > keyboard; auto seeker = hid_enumerate(0x05ac, 0x024f); @@ -260,7 +262,8 @@ std::shared_ptr< NuPhy > NuPhy::find() { productName, seeker->path, seeker->path, - seeker->release_number + seeker->release_number, + verify ); if (keyboard == nullptr) { unsupportedDetected = true; diff --git a/package.json b/package.json index 15a388b..6991015 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "nudelta", "author": "Mohamed Gaber ", - "version": "0.6.6", + "version": "0.6.7", "license": "GPL-3.0-or-later", "homepage": "https://github.com/donn/nudelta#readme", "description": "An open-source alternative to the NuPhy Console", @@ -76,4 +76,4 @@ "tabWidth": 4, "quoteProps": "consistent" } -} \ No newline at end of file +} diff --git a/res/NuPhy/keycodes.yml b/res/NuPhy/keycodes.yml index 770311c..c310f88 100644 --- a/res/NuPhy/keycodes.yml +++ b/res/NuPhy/keycodes.yml @@ -28,6 +28,11 @@ tab: 0x2b000000 space: 0x2c000000 backspace: 0x2a000000 +right: 0x4f000000 +left: 0x50000000 +down: 0x51000000 +up: 0x52000000 + esc: 0x29000000 f1: 0x3a000000 f2: 0x3b000000 @@ -41,6 +46,18 @@ f9: 0x42000000 f10: 0x43000000 f11: 0x44000000 f12: 0x45000000 +f13: 0x68000000 +f14: 0x69000000 +f15: 0x6a000000 +f16: 0x6b000000 +f17: 0x6c000000 +f18: 0x6d000000 +f19: 0x6e000000 +f20: 0x6f000000 +f21: 0x70000000 +f22: 0x71000000 +f23: 0x72000000 +f24: 0x73000000 grave: 0x35000000 num1: 0x1e000000 @@ -54,11 +71,6 @@ num8: 0x25000000 num9: 0x26000000 num0: 0x27000000 -right: 0x4f000000 -left: 0x50000000 -down: 0x51000000 -up: 0x52000000 - a: 0x04000000 b: 0x05000000 c: 0x06000000 @@ -127,6 +139,7 @@ forward: 0xb5000004 mute: 0xe2000004 volumedown: 0xea000004 volumeup: 0xe9000004 +voice_command: 0xcf000004 # -- Extra ## Processed On-Keyboard @@ -137,21 +150,6 @@ backlightcolorup: 0x00030012 backlightdown: 0x0002000c backlightup: 0x0001000c -## Special +## Keyboard Specific/Custom fnspace: 0x2f000002 -voice_command: 0xcf000004 search: 0x2000000e - -## Apple-specific extra F keys (useful for keyboard shortcuts/software macros) -f13: 0x68000000 -f14: 0x69000000 -f15: 0x6a000000 -f16: 0x6b000000 -f17: 0x6c000000 -f18: 0x6d000000 -f19: 0x6e000000 -f20: 0x6f000000 -f21: 0x70000000 -f22: 0x71000000 -f23: 0x72000000 -f24: 0x73000000 diff --git a/src/main.cpp b/src/main.cpp index 404fefe..1ed142d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -29,8 +29,8 @@ #define NUDELTA_VERSION "UNKNOWN" #endif -std::shared_ptr< NuPhy > getKeyboard() { - auto keyboard = NuPhy::find(); +std::shared_ptr< NuPhy > getKeyboard(bool verify = true) { + auto keyboard = NuPhy::find(verify); if (keyboard == nullptr) { throw std::runtime_error( "Couldn't find a NuPhy keyboard connected to this device. Make sure it's plugged in via USB." @@ -77,8 +77,9 @@ SSCO_Fn(resetKeymap) { SSCO_Fn(dumpKeymap) { auto mac = opts.options.find("mac") != opts.options.end(); - - auto keyboard = getKeyboard(); + auto verify = opts.options.find("no-verify") == opts.options.end(); + + auto keyboard = getKeyboard(verify); auto keys = keyboard->getKeymap(mac); auto file = opts.options.find("dump-keys")->second; auto filePtr = fopen(file.c_str(), "wb"); @@ -200,6 +201,10 @@ int main(int argc, char *argv[]) { 'M', "Valid only if dump-keys or load-keys are passed: operate on the Mac mode of the keyboard instead of the Win mode.", false}, + Opt{"no-verify", + 'N', + "Valid only if dump-keys is passed: do not verify the keyboard's identity.", + false}, Opt{"dump-keys", 'D', "Dump the keymap to a binary file.", diff --git a/ui/src/app.css b/ui/src/app.css index b95752e..d33f9dc 100644 --- a/ui/src/app.css +++ b/ui/src/app.css @@ -77,12 +77,12 @@ p { .card { display: grid; - background-color: var(--dark-bg); - border-radius: 12.5px; - padding: 10px; grid-auto-columns: minmax(0, 1fr); grid-auto-rows: minmax(0, 1fr); grid-auto-flow: column; + background-color: var(--dark-bg); + border-radius: 12.5px; + padding: 10px; gap: 3.5px; } diff --git a/util/usb/annotate_map.rb b/util/usb/annotate_map.rb index aca60fa..464b337 100644 --- a/util/usb/annotate_map.rb +++ b/util/usb/annotate_map.rb @@ -1,5 +1,5 @@ require "yaml" -scan_codes = File.read("../../res/Air75/keycodes.yml") +scan_codes = File.read("../../res/NuPhy/keycodes.yml") scancode_by_key = YAML.load(scan_codes) key_by_scancode = scancode_by_key.invert diff --git a/util/usb/default.annotated.hex b/util/usb/default.annotated.hex index d7c2cb5..796a05a 100644 --- a/util/usb/default.annotated.hex +++ b/util/usb/default.annotated.hex @@ -21,13 +21,13 @@ 0050 00 00 00 08 -> e 0054 00 00 00 07 -> d 0058 00 00 00 06 -> c -005c 00 00 00 00 +005c 00 00 00 00 -> none 0060 02 00 00 03 0064 02 00 00 10 0068 00 00 00 15 -> r 006c 02 00 00 22 0070 00 00 00 19 -> v -0074 00 00 00 00 +0074 00 00 00 00 -> none 0078 02 00 00 04 007c 00 00 00 22 -> num5 0080 00 00 00 17 -> t @@ -39,13 +39,13 @@ 0098 00 00 00 1c -> y 009c 00 00 00 0b -> h 00a0 00 00 00 11 -> n -00a4 00 00 00 00 +00a4 00 00 00 00 -> none 00a8 02 00 00 06 00ac 00 00 00 24 -> num7 00b0 00 00 00 18 -> u 00b4 00 00 00 0d -> j 00b8 00 00 00 10 -> m -00bc 00 00 00 00 +00bc 00 00 00 00 -> none 00c0 02 00 00 07 00c4 00 00 00 25 -> num8 00c8 00 00 00 0c -> i @@ -57,7 +57,7 @@ 00e0 00 00 00 12 -> o 00e4 00 00 00 0f -> l 00e8 02 00 00 21 -00ec 20 00 00 00 +00ec 20 00 00 00 -> fn 00f0 02 00 00 09 00f4 00 00 00 27 -> num0 00f8 00 00 00 13 -> p @@ -76,16 +76,16 @@ 012c 02 00 00 1c 0130 00 00 00 64 0134 06 00 00 e7 -> rmeta -0138 00 00 00 46 +0138 00 00 00 46 -> sysrq 013c 00 00 00 2a -> backspace 0140 02 00 00 1c 0144 00 00 00 28 -> enter 0148 06 00 00 e5 -> rshift 014c 02 00 00 13 0150 00 00 08 06 -0154 00 00 00 00 -0158 00 00 00 00 -015c 00 00 00 00 +0154 00 00 00 00 -> none +0158 00 00 00 00 -> none +015c 00 00 00 00 -> none 0160 02 00 00 11 0164 02 00 00 12 0168 02 00 00 1d @@ -94,46 +94,46 @@ 0174 00 00 00 4a -> home 0178 00 00 00 4d -> end 017c 02 00 00 14 -0180 00 00 00 00 +0180 00 00 00 00 -> none 0184 00 00 00 4a -> home 0188 00 00 00 4b -> pgup 018c 00 00 00 4e -> pgdn 0190 00 00 00 4d -> end -0194 00 00 00 00 -0198 00 00 00 00 -019c 00 00 00 53 -01a0 00 00 00 5f -01a4 00 00 00 5c -01a8 00 00 00 59 -01ac 00 00 00 62 -01b0 00 00 00 00 -01b4 00 00 00 54 -01b8 00 00 00 60 -01bc 00 00 00 5d -01c0 00 00 00 5a -01c4 00 00 00 00 -01c8 00 00 00 00 -01cc 00 00 00 55 -01d0 00 00 00 61 -01d4 00 00 00 5e -01d8 00 00 00 5b -01dc 00 00 00 63 -01e0 00 00 00 00 -01e4 00 00 00 56 -01e8 00 00 00 57 -01ec 00 00 00 85 -01f0 00 00 00 58 -01f4 00 00 00 00 -01f8 00 00 00 00 -01fc 00 00 00 00 -0200 00 00 00 00 -0204 00 00 00 00 -0208 00 00 00 00 -020c 00 00 00 00 +0194 00 00 00 00 -> none +0198 00 00 00 00 -> none +019c 00 00 00 53 -> numlock +01a0 00 00 00 5f -> numpad7 +01a4 00 00 00 5c -> numpad4 +01a8 00 00 00 59 -> numpad1 +01ac 00 00 00 62 -> numpad0 +01b0 00 00 00 00 -> none +01b4 00 00 00 54 -> numpad_div +01b8 00 00 00 60 -> numpad8 +01bc 00 00 00 5d -> numpad5 +01c0 00 00 00 5a -> numpad2 +01c4 00 00 00 00 -> none +01c8 00 00 00 00 -> none +01cc 00 00 00 55 -> numpad_mul +01d0 00 00 00 61 -> numpad9 +01d4 00 00 00 5e -> numpad6 +01d8 00 00 00 5b -> numpad3 +01dc 00 00 00 63 -> numpad_dot +01e0 00 00 00 00 -> none +01e4 00 00 00 56 -> numpad_sub +01e8 00 00 00 57 -> numpad_add +01ec 00 00 00 85 -> numpad_comma +01f0 00 00 00 58 -> numpad_enter +01f4 00 00 00 00 -> none +01f8 00 00 00 00 -> none +01fc 00 00 00 00 -> none +0200 00 00 00 00 -> none +0204 00 00 00 00 -> none +0208 00 00 00 00 -> none +020c 00 00 00 00 -> none 0210 04 00 00 6f -> brightnessdown 0214 04 00 00 70 -> brightnessup -0218 00 00 00 00 -021c 00 00 00 00 +0218 00 00 00 00 -> none +021c 00 00 00 00 -> none 0220 0c 00 02 00 -> backlightdown 0224 0c 00 01 00 -> backlightup 0228 04 00 00 b6 -> rewind @@ -142,7 +142,7 @@ 0234 04 00 00 e2 -> mute 0238 04 00 00 ea -> volumedown 023c 04 00 00 e9 -> volumeup -0240 00 00 00 00 +0240 00 00 00 00 -> none 0244 00 00 00 1e -> num1 0248 00 00 00 1f -> num2 024c 00 00 00 20 -> num3 @@ -165,19 +165,19 @@ 0290 00 00 00 36 -> comma 0294 00 00 00 37 -> period 0298 00 00 00 09 -> f -029c 00 00 00 00 -02a0 00 00 00 00 -02a4 00 00 00 00 -02a8 00 00 00 00 -02ac 00 00 00 00 -02b0 00 00 00 00 -02b4 00 00 00 00 -02b8 00 00 00 00 -02bc 00 00 00 00 -02c0 00 00 00 00 -02c4 00 00 00 00 -02c8 00 00 00 00 -02cc 00 00 00 00 +029c 00 00 00 00 -> none +02a0 00 00 00 00 -> none +02a4 00 00 00 00 -> none +02a8 00 00 00 00 -> none +02ac 00 00 00 00 -> none +02b0 00 00 00 00 -> none +02b4 00 00 00 00 -> none +02b8 00 00 00 00 -> none +02bc 00 00 00 00 -> none +02c0 00 00 00 00 -> none +02c4 00 00 00 00 -> none +02c8 00 00 00 00 -> none +02cc 00 00 00 00 -> none 02d0 00 00 00 3a -> f1 02d4 00 00 00 3b -> f2 02d8 00 00 00 3c -> f3 @@ -190,7 +190,7 @@ 02f4 00 00 00 43 -> f10 02f8 00 00 00 44 -> f11 02fc 00 00 00 45 -> f12 -0300 00 00 00 00 +0300 00 00 00 00 -> none 0304 0e 00 00 0c 0308 0e 00 00 0d 030c 0e 00 00 0e @@ -213,44 +213,44 @@ 0350 0d 00 02 00 0354 0d 00 01 00 0358 0e 00 00 16 -035c 00 00 00 00 -0360 00 00 00 00 -0364 00 00 00 00 -0368 00 00 00 00 -036c 00 00 00 00 -0370 00 00 00 00 -0374 00 00 00 00 -0378 00 00 00 00 -037c 00 00 00 00 -0380 00 00 00 00 -0384 00 00 00 00 -0388 00 00 00 00 -038c 00 00 00 00 -0390 00 00 00 00 -0394 00 00 00 00 -0398 00 00 00 00 -039c 00 00 00 00 -03a0 00 00 00 00 -03a4 00 00 00 00 -03a8 00 00 00 00 -03ac 00 00 00 00 -03b0 00 00 00 00 -03b4 00 00 00 00 -03b8 00 00 00 00 -03bc 00 00 00 00 -03c0 00 00 00 00 -03c4 00 00 00 00 -03c8 00 00 00 00 -03cc 00 00 00 00 -03d0 00 00 00 00 -03d4 00 00 00 00 -03d8 00 00 00 00 -03dc 00 00 00 00 -03e0 00 00 00 00 -03e4 00 00 00 00 -03e8 00 00 00 00 -03ec 00 00 00 00 -03f0 00 00 00 00 -03f4 00 00 00 00 -03f8 00 00 00 00 -03fc 00 00 00 00 +035c 00 00 00 00 -> none +0360 00 00 00 00 -> none +0364 00 00 00 00 -> none +0368 00 00 00 00 -> none +036c 00 00 00 00 -> none +0370 00 00 00 00 -> none +0374 00 00 00 00 -> none +0378 00 00 00 00 -> none +037c 00 00 00 00 -> none +0380 00 00 00 00 -> none +0384 00 00 00 00 -> none +0388 00 00 00 00 -> none +038c 00 00 00 00 -> none +0390 00 00 00 00 -> none +0394 00 00 00 00 -> none +0398 00 00 00 00 -> none +039c 00 00 00 00 -> none +03a0 00 00 00 00 -> none +03a4 00 00 00 00 -> none +03a8 00 00 00 00 -> none +03ac 00 00 00 00 -> none +03b0 00 00 00 00 -> none +03b4 00 00 00 00 -> none +03b8 00 00 00 00 -> none +03bc 00 00 00 00 -> none +03c0 00 00 00 00 -> none +03c4 00 00 00 00 -> none +03c8 00 00 00 00 -> none +03cc 00 00 00 00 -> none +03d0 00 00 00 00 -> none +03d4 00 00 00 00 -> none +03d8 00 00 00 00 -> none +03dc 00 00 00 00 -> none +03e0 00 00 00 00 -> none +03e4 00 00 00 00 -> none +03e8 00 00 00 00 -> none +03ec 00 00 00 00 -> none +03f0 00 00 00 00 -> none +03f4 00 00 00 00 -> none +03f8 00 00 00 00 -> none +03fc 00 00 00 00 -> none