Skip to content

Commit

Permalink
Add no-verify CLI flag (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
donn authored Mar 24, 2023
1 parent 1c15be8 commit 9963d24
Show file tree
Hide file tree
Showing 9 changed files with 147 additions and 137 deletions.
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion include/nuphy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
15 changes: 9 additions & 6 deletions lib/nuphy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand All @@ -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);
Expand Down Expand Up @@ -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(
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "nudelta",
"author": "Mohamed Gaber <me@donn.website>",
"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",
Expand Down Expand Up @@ -76,4 +76,4 @@
"tabWidth": 4,
"quoteProps": "consistent"
}
}
}
40 changes: 19 additions & 21 deletions res/NuPhy/keycodes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ tab: 0x2b000000
space: 0x2c000000
backspace: 0x2a000000

right: 0x4f000000
left: 0x50000000
down: 0x51000000
up: 0x52000000

esc: 0x29000000
f1: 0x3a000000
f2: 0x3b000000
Expand All @@ -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
Expand All @@ -54,11 +71,6 @@ num8: 0x25000000
num9: 0x26000000
num0: 0x27000000

right: 0x4f000000
left: 0x50000000
down: 0x51000000
up: 0x52000000

a: 0x04000000
b: 0x05000000
c: 0x06000000
Expand Down Expand Up @@ -127,6 +139,7 @@ forward: 0xb5000004
mute: 0xe2000004
volumedown: 0xea000004
volumeup: 0xe9000004
voice_command: 0xcf000004

# -- Extra
## Processed On-Keyboard
Expand All @@ -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
13 changes: 9 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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.",
Expand Down
6 changes: 3 additions & 3 deletions ui/src/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion util/usb/annotate_map.rb
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Loading

0 comments on commit 9963d24

Please sign in to comment.