Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Apple Silicon] Failed to write config - hid_error is not implemented yet #37

Open
jklp opened this issue Feb 23, 2023 · 29 comments
Open
Labels
bug Something isn't working 🍎 Silicon Issues related to running Nudelta on Apple Silicon-based macs

Comments

@jklp
Copy link

jklp commented Feb 23, 2023

Hi, just got my brand new Air75 and was looking for a way to remap some of the keys (as Nuphy Console doesn't work on Mac) and found Nudelta!

Plugged it in and looks like something might be broken (saw the same report at #35) but thought I'd open a new ticket as looks like it could be a different issue.

Tried to add as much info as I could - please let me know if you need more - thanks!


Device: Nuphy Air75
Firmware: 0124
Nudelta version: 0.6.6
MacOS: 13.2.1

To replicate:

  • Keyboard is set to "Mac" and "Wired" mode
  • Connect keyboard to USB
  • Switch to Mac mode in Nudelta
  • Re-map any key
  • Click "write"
  • Get the error "Failed to write to keyboard: hid_error is not implemented yet"

Screenshot 2023-02-24 at 7 35 02 am

@n3rdc4ptn
Copy link

Same for me, thanks @jklp for opening the issue.
I have the same Firmware

@donn
Copy link
Owner

donn commented Feb 24, 2023

So this very helpful error message is straight out of one of the dependencies:

https://github.com/libusb/hidapi/blob/88a0f029b7f18fc7b3c3858d652494428b3ebc2e/libusb/hid.c#L1637

Sadly, it's generic enough that it could mean any failure has occurred when writing. So, at this point, I can only ask you to try the same workaround as @czottmann:


@n3rdc4ptn you mentioned this in the other thread:

I will try to debug it a little more in the next days. As I checked the developer tools in electron there seems to be now error.

Posting the error would be very helpful if you could.

@donn donn added the bug Something isn't working label Feb 24, 2023
@jklp
Copy link
Author

jklp commented Feb 24, 2023

@donn Thanks for the fast response - I gave the suggestion above a go (even removed and re-added) and unfortunately still the same error message.

I've got some experience in Electron / JS development - if there's anything I can help with let me know!

@n3rdc4ptn
Copy link

Sorry, i mistyped there. There is no error in the developer tools. I also tried removing and readding the permission but for me that also does not worked.

@donn
Copy link
Owner

donn commented Feb 26, 2023

Yeah, this is weird. I did try it in Ventura and sure enough, Nudelta worked.

Sadly, this is deep in the native component, which means, well... a lot of iteration necessary. I'll have to write a couple scripts then get back to you.

@jklp
Copy link
Author

jklp commented Feb 28, 2023

@donn Hi Donn not sure if this is useful, but I noticed sometimes when I remap a key and the error appears, it actually does perform the remap.

So maybe the error message is throwing regardless if the remapping was successful or not?

@donn
Copy link
Owner

donn commented Mar 2, 2023

Out of curiosity, are you guys on Aarch64 or Intel?

@n3rdc4ptn
Copy link

n3rdc4ptn commented Mar 2, 2023

I am on an M1 Pro. So aarch64.
Apple calls it arm64 when I run arch in my command line.

@donn
Copy link
Owner

donn commented Mar 2, 2023

I'm wondering if it's Apple Silicon-specific is what's going on here.

@n3rdc4ptn
Copy link

n3rdc4ptn commented Mar 2, 2023

Ok, I compiled nudelta cli on my apple silicon (than it is an arm version?) and with the cli I could write my desired config to the Air75. But only for one time and then I needed to restart my mac because otherwise I always got the hid_error.

So it seems like one time loading works and then I need to restart my mac.

> nudelta -M -l keymap.yml
Found NuPhy Air75 at path DevSrvsID:XXXXXXXXXXXXX (Firmware 0124)
Wrote keymap 'keymap.yml' to the keyboard.

> nudelta -M -l keymap.yml
Found NuPhy Air75 at path DevSrvsID:XXXXXXXXXXXXX (Firmware 0124)
[ERROR] Failed to write to keyboard: hid_error is not implemented yet

I censored the DevSrvID so there is a real id.

*** UPDATE ***
The self compiled nudelta CLI is still an Intel Version. So it still can be an Apple Silicon Bug.

❯ file $(which nudelta)
/usr/local/bin/nudelta: Mach-O 64-bit executable x86_64

@jklp
Copy link
Author

jklp commented Mar 2, 2023

Out of curiosity, are you guys on Aarch64 or Intel?

Ah didn't think of that - I'm on a 2021 MacBook Pro 16" with an M1 Pro chip so I guess in this case Aarch64?

I'm same as n3rdc4ptn and running arch I get arm64

@TRomoser
Copy link

TRomoser commented Mar 2, 2023

Hello all. I have a nuphy air75 that I just received and I kept hitting the page up/page dwn buttons when trying to hit backspace. I used nudelta and ran into the same issue as you all. I tried a couple of times without it working, but the last time the error still appeared but it succeeded. The pg up/dwn buttons are now set to none.

Thanks Donn for the quick response.

I am on a 13-in M2 2022 MacBook Pro

@n3rdc4ptn
Copy link

n3rdc4ptn commented Mar 2, 2023

So it seems to be Apple Silicon related.
@donn If you can change the build scripts to support an arm64 build I can test it if you want. Maybe that can already fix that.
I will try it myself, but I am not so experienced with C++ so maybe you can do it faster.

*** UPDATE ***
I compiled it for arm64 now (not sure what I done wrong before). The error still occurs after the first write.
But it seems to be right what @TRomoser and @jklp said. The write works, but the error is displayed.

❯ file $(which nudelta)
/usr/local/bin/nudelta: Mach-O 64-bit executable arm64

❯ nudelta -M -l keymap.yml
Found NuPhy Air75 at path DevSrvsID:4294972322 (Firmware 0124)
Wrote keymap 'keymap.yml' to the keyboard.

❯ nudelta -M -l keymap.yml
Found NuPhy Air75 at path DevSrvsID:4294972322 (Firmware 0124)
[ERROR] Failed to write to keyboard: hid_error is not implemented yet

@donn donn added the 🍎 Silicon Issues related to running Nudelta on Apple Silicon-based macs label Mar 3, 2023
@donn
Copy link
Owner

donn commented Mar 3, 2023

@TRomoser If Nudelta messes up your keyboard, please factory reset by holding Fn + Tab + R. Sorry about that- NuPhy keeps making minor, undocumented hardware revisions and I keep having to chase them down: see #29 for another instance of this :(

@edessure
Copy link

edessure commented Mar 4, 2023

Hello everyone, same here... getting the same "Failed to write to config" as the screenshot above on a MacBook Air M2...

@donn
Copy link
Owner

donn commented Mar 10, 2023

Just so I don't leave you all hanging- the issue is I do not have a Apple Silicon-based Mac to test with and likely won't for the foreseeable future. The best I can try to do is a build universal binary and see if it's just a Rosetta problem but I've been swamped at work. Thank you all for being patient and sorry

@donn donn pinned this issue Mar 10, 2023
@donn donn changed the title Nuphy Air75: Failed to write config - hid_error is not implemented yet [Apple Silicon] Failed to write config - hid_error is not implemented yet Mar 10, 2023
@jklp
Copy link
Author

jklp commented Mar 10, 2023

No worries and correct me if I'm wrong, but I think for now there is a workaround, where users can keep trying to write the config (maybe after a reboot as well) and eventually it'll remap the key (even though the error message is shown).

Could be a good stop gap until the full solution is implemented?

(and thanks again for working on the project - it isn't always easy to find time to maintain something in your spare time!)

@donn
Copy link
Owner

donn commented Apr 20, 2023

Hey- can you try https://github.com/donn/nudelta/releases/tag/0.7.0? It fixes a different issue but it may help somehow

@jklp
Copy link
Author

jklp commented Apr 23, 2023

Hi Donn thanks for looking into this! Unfortunately I tested both 0.7.0 and the latest 0.7.2 but still throws an error (with a different error message this time - see attached)

Couldn't get it to replicate changing the key mappings like last time (i.e. keep trying to write until the config is changed) but if the code is still the same I think it should still work if the user keep persisting with the writes.

Let me know if there's anything else I can do!

Screenshot 2023-04-24 at 7 53 47 am 2

@Wockeez
Copy link

Wockeez commented May 20, 2023

@donn Hi Donn not sure if this is useful, but I noticed sometimes when I remap a key and the error appears, it actually does perform the remap.

So maybe the error message is throwing regardless if the remapping was successful or not?

I confirm it, I also had the same error, but the keys are remapped

@donn
Copy link
Owner

donn commented Aug 28, 2023

So this is weird. With 0.7.4 I enabled universal builds after some agony. With or without Rosetta, I get the same error message @jklp does, and no remap.

My sister lent me her laptop so I could test, but installing Xcode and debugging is a whole other beast, sadly. So turns out Rosetta isn't the issue. :\

@donn
Copy link
Owner

donn commented Nov 26, 2023

Interestingly, running Nudelta as sudo on my M2 work machine runs fine. I can't do any straight up development on for contractual reasons but I can remap my keyboard. So sudo /Applications/nudelta.app/Contents/MacOS/nudelta may actually work if you're brave enough to run code written by me as sudo.

@aimsecond
Copy link

The sudo worked for me! I opened nudelta using sudo /Applications/nudelta.app/Contents/MacOS/nudelta and it worked on my m1 max MBP.

Nudelta release: 0.7.4
MacOS: 13.6.3 (22G436)
Chip: Apple M1 Max
Keyboard: NuPhy Air75 V1 (Firmware 0121)

Thanks!

@funkindy
Copy link

funkindy commented Feb 27, 2024

Hi, i gave nudelta 0.7.4 input monitoring permissions on Sonoma, run it via sudo, but still have permission error on write.

Maybe i am missing something?

  • Nuphy Air 75 V1 (0130)
  • M1 Max MBP
  • Macos 14.1.1

@funkindy
Copy link

Just in case - some warnings from console after sudo execution

2024-02-29 16:26:45.211 nudelta[5561:6888438] WARNING: Secure coding is not enabled for restorable state! Enable secure coding by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState: and returning YES.
objc[5563]: Class WebSwapCGLLayer is implemented in both /System/Library/Frameworks/WebKit.framework/Versions/A/Frameworks/WebCore.framework/Versions/A/Frameworks/libANGLE-shared.dylib (0x2328c5958) and /Applications/nudelta.app/Contents/Frameworks/Electron Framework.framework/Versions/A/Libraries/libGLESv2.dylib (0x10a9d2978). One of the two will be used. Which one is undefined.

@donn
Copy link
Owner

donn commented Feb 29, 2024

@funkindy No clue Alexey, sorry. :( Though these warnings are "normal"- Electron just acts a bit wonky when you run as superuser.

@funkindy
Copy link

@donn thank you for quick answer! Looks like the main difference in my case is major macos version. @aimsecond may i ask, did you try to remap keys on Sonoma (Macos v14+)?

@jklp
Copy link
Author

jklp commented Mar 2, 2024

Hi, I'm on Sonoma 14.2.1 with an M1 MacBook Pro 16" (2021) and managed to get it working.

Need to run it using sudo as recommended by @donn (#37 (comment)) though I still get the error (I just hit "ok" and it goes through).

One thing I noticed is it no longer reads the keyboard config - though is fine as I only remap a few keys which takes a few seconds.

Currently using a Nuphy Air75 (0124) too

@donn
Copy link
Owner

donn commented Sep 14, 2024

@jklp Nudelta never did read a keyboard's current config and show it, which I acknowledge is a limitation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working 🍎 Silicon Issues related to running Nudelta on Apple Silicon-based macs
Projects
None yet
Development

No branches or pull requests

8 participants