donn / nudelta

Open source NuPhy Console alternative
GNU General Public License v3.0
504 stars 22 forks source link

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

Open jklp opened 1 year ago

jklp commented 1 year ago

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 https://github.com/donn/nudelta/issues/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:

Screenshot 2023-02-24 at 7 35 02 am

n3rdc4ptn commented 1 year ago

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

donn commented 1 year ago

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.

jklp commented 1 year ago

@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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

@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 commented 1 year ago

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

n3rdc4ptn commented 1 year ago

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

donn commented 1 year ago

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

n3rdc4ptn commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

@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 commented 1 year ago

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

donn commented 1 year ago

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

jklp commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

@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 commented 11 months ago

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 commented 8 months ago

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 commented 6 months ago

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 commented 5 months ago

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?

funkindy commented 5 months ago

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 commented 5 months ago

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

funkindy commented 5 months ago

@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 commented 5 months ago

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 (https://github.com/donn/nudelta/issues/37#issuecomment-1826786347) 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