Skip to content

Commit

Permalink
Fix Alternate-ID Bug, Handle Mixup Affecting Windows (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
donn authored Jun 30, 2023
1 parent 6af21c3 commit 840b60f
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 28 deletions.
5 changes: 5 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 0.7.3
- Fix USB handle mixup affecting Windows builds
- Fix GUI bug with remapping alternate IDs
- Update all underlying dependencies

# 0.7.2
- Fix internal indices for `n`, `o`, and `u`.
- Add annotated hex dumps for more keyboards for future RE work
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM centos:centos7
# Dependencies
ENV INST yum install -y --setopt=skip_missing_names_on_install=False
RUN $INST https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm centos-release-scl
RUN $INST autoconf devtoolset-11 ninja-build kernel-headers perl-core python36 python36-pip bzip2
RUN $INST autoconf devtoolset-11 kernel-headers perl-core python36 python36-pip bzip2

# Environment Configuration
ENV CC=/opt/rh/devtoolset-11/root/usr/bin/gcc \
Expand All @@ -30,4 +30,4 @@ WORKDIR /nudelta
COPY . .
RUN yarn
RUN yarn build
RUN cp -r /nudelta/dist/*.AppImage /nudelta.AppImage
RUN cp -r /nudelta/dist/*.AppImage /nudelta.AppImage
19 changes: 5 additions & 14 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,34 +43,25 @@ Contributions are super appreciated for all of these.

### Build Requirements
* C++17 Compiler
* Clang recommended for macOS/Linux
* MSVC recommended for Windows
* Cmake
* Node 14+ with Yarn

## Build (GUI)
## Build

```sh
git clone https://github.com/donn/nudelta
cd nudelta
git submodule update --init --recursive
rm -rf build
yarn
yarn build
yarn build-native # CLI / Library
yarn build # GUI
```

The Linux AppImage will be found under ./dist, and the Mac app will be found under ./dist/mac.

## Build (CLI)
```sh
git clone https://github.com/donn/nudelta
cd nudelta
git submodule update --init --recursive
mkdir build
cd build
cmake ..
make -j$(nproc)
sudo make install
```

## Using the CLI

You will need to use **sudo** on Linux. On macOS, you will need to grant Input Monitoring permissions to whichever Terminal host you're using to run Nudelta, likely Terminal.app.
Expand Down
7 changes: 3 additions & 4 deletions lib/nuphy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ void set_report(NuPhy::Handles handles, uint8_t *data, size_t dataSize) {
if (!hidAccess.value()) {
throw std::runtime_error(hidAccessFailureMessage);
}
auto bytesWritten =
hid_send_feature_report(handles.request, data, dataSize);
auto bytesWritten = hid_send_feature_report(handles.data, data, dataSize);
if (bytesWritten < 0) {
auto errorString = fmt::format(
"Failed to write to keyboard: {}",
Expand Down Expand Up @@ -172,7 +171,7 @@ std::string represent_hid_struct(hid_device_info *info) {
// path
// - So far, I've identified col06 as the one for keymap data, col05 for
// requests
std::string writeCol = "col05";
std::string requestCol = "col05";
std::string dataCol = "col06";

std::shared_ptr< NuPhy > NuPhy::find(bool verify) {
Expand All @@ -197,7 +196,7 @@ std::shared_ptr< NuPhy > NuPhy::find(bool verify) {
for (auto it = path.begin(); it != path.end(); it++) {
*it = char(std::tolower(*it));
}
if (path.find(writeCol) != -1) {
if (path.find(requestCol) != -1) {
if (requestPath.has_value()) {
throw std::runtime_error(
"Multiple keyboards with the same product ID found! Please ensure only one keyboard is plugged in.\n"
Expand Down
3 changes: 2 additions & 1 deletion 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.7.2",
"version": "0.7.3",
"license": "GPL-3.0-or-later",
"homepage": "https://github.com/donn/nudelta#readme",
"description": "An open-source alternative to the NuPhy Console",
Expand All @@ -15,6 +15,7 @@
"build-native": "node util/build-native.js",
"build-ui": "rollup -c",
"watch": "nodemon --ext .js,.mjs,.cjs,.css --ignore ui/app-dist/ --exec sh -c \"yarn build-ui && electron .\"",
"watch-win": "nodemon --ext .js,.mjs,.cjs,.css --ignore ui/app-dist/ --exec cmd /c \"yarn build-ui && electron .\"",
"format": "prettier --write . && clang-format -i include/*.hpp lib/*.cpp src/*.cpp",
"lint": "prettier --check . && clang-format --dry-run --Werror include/*.hpp lib/*.cpp src/*.cpp"
},
Expand Down
2 changes: 1 addition & 1 deletion submodules/fmt
Submodule fmt updated 68 files
+8 −0 .github/dependabot.yml
+3 −2 .github/pull_request_template.md
+30 −0 .github/workflows/cifuzz.yml
+9 −1 .github/workflows/doc.yml
+30 −13 .github/workflows/linux.yml
+17 −2 .github/workflows/macos.yml
+12 −4 .github/workflows/windows.yml
+97 −41 CMakeLists.txt
+438 −1 ChangeLog.rst
+1 −1 LICENSE.rst
+33 −25 README.rst
+185 −140 doc/api.rst
+5 −6 doc/build.py
+134 −8 doc/syntax.rst
+1 −1 include/fmt/args.h
+481 −281 include/fmt/chrono.h
+18 −37 include/fmt/color.h
+23 −23 include/fmt/compile.h
+705 −1,129 include/fmt/core.h
+91 −152 include/fmt/format-inl.h
+998 −754 include/fmt/format.h
+44 −71 include/fmt/os.h
+22 −50 include/fmt/ostream.h
+201 −174 include/fmt/printf.h
+155 −145 include/fmt/ranges.h
+217 −24 include/fmt/std.h
+62 −33 include/fmt/xchar.h
+40 −29 src/fmt.cc
+1 −5 src/format.cc
+99 −62 src/os.cc
+3 −3 support/Vagrantfile
+0 −1 support/bazel/.bazelrc
+1 −1 support/bazel/.bazelversion
+2 −2 support/bazel/BUILD.bazel
+5 −4 support/bazel/README.md
+1 −1 support/build.gradle
+0 −54 support/cmake/cxx14.cmake
+15 −3 test/CMakeLists.txt
+1 −1 test/add-subdirectory-test/CMakeLists.txt
+1 −1 test/args-test.cc
+383 −23 test/chrono-test.cc
+2 −2 test/compile-error-test/CMakeLists.txt
+1 −0 test/compile-fp-test.cc
+7 −8 test/compile-test.cc
+111 −231 test/core-test.cc
+2 −0 test/enforce-checks-test.cc
+1 −1 test/find-package-test/CMakeLists.txt
+27 −91 test/format-impl-test.cc
+274 −325 test/format-test.cc
+1 −1 test/fuzzing/CMakeLists.txt
+2 −0 test/gtest-extra-test.cc
+1 −6 test/gtest-extra.h
+1 −7 test/gtest/CMakeLists.txt
+1 −1 test/gtest/gmock-gtest-all.cc
+2 −2 test/mock-allocator.h
+36 −88 test/module-test.cc
+15 −56 test/os-test.cc
+16 −47 test/ostream-test.cc
+1 −7 test/posix-mock-test.cc
+0 −2 test/posix-mock.h
+13 −37 test/printf-test.cc
+108 −35 test/ranges-test.cc
+1 −1 test/scan-test.cc
+16 −11 test/scan.h
+1 −1 test/static-export-test/CMakeLists.txt
+158 −16 test/std-test.cc
+2 −6 test/util.h
+118 −55 test/xchar-test.cc
2 changes: 1 addition & 1 deletion submodules/hidapi
Submodule hidapi updated 117 files
2 changes: 1 addition & 1 deletion submodules/yaml-cpp
7 changes: 3 additions & 4 deletions ui/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ function redrawKeyboard() {
}

function drawOptionArray(e, remap, key, alt, column, row) {
let id = key.id;
let id = alt ? key.altID : key.id;
let defaultMapping = alt ? key.altDefaultMapping : key.defaultMapping;
let defaultModifiers = alt ? key.altDefaultModifiers : key.defaultModifiers;

Expand Down Expand Up @@ -451,7 +451,7 @@ function setsEqual(lhs, rhs) {
*/
function updateKeymap(event) {
let remap = window.config.getRemap(window.mode);
console.log("load", JSON.stringify(remap));
console.log("Before: ", JSON.stringify(remap));
let key = window.currentKey;

let currentRemap = remap[key.id] ?? {};
Expand Down Expand Up @@ -483,7 +483,6 @@ function updateKeymap(event) {

if (key.altID) {
let currentRemap = remap[key.altID] ?? {};

let incomingID = g("#keycode-selector-alt").value;
let incomingModifiers = new Set();
let defaultModifiers = new Set(key.altDefaultModifiers);
Expand All @@ -509,7 +508,7 @@ function updateKeymap(event) {
remap[key.altID] = currentRemap;
}
}
console.log("save", JSON.stringify(remap));
console.log("After: ", JSON.stringify(remap));
window.config.setRemap(window.mode, remap);
}

Expand Down

0 comments on commit 840b60f

Please sign in to comment.