thefloweringash / iousbhiddriver-descriptor-override

Fix broken USB HID descriptors. Now with Noppoo Choc Mini support!
http://thefloweringash.github.io/iousbhiddriver-descriptor-override
GNU Lesser General Public License v3.0
204 stars 25 forks source link

Does not support Poseidon ZX Illuminated (macOS Catalina 10.15.3) #43

Open SamuelMereau opened 4 years ago

SamuelMereau commented 4 years ago

Originally posted in https://github.com/thefloweringash/iousbhiddriver-descriptor-override/issues/33#issuecomment-655317649

I'm using a Poseidon ZX Illuminated keyboard, and after installing the package, disabling SIP and following the Troubleshooting guide, I haven't had much success, as some keys are still typing a bit wonky. I've had more luck remapping function keys in Karabiner which has worked well so far. Unfortunately, Karabiner can't help since some keys like the Backspace and Spacebar don't appear at all in the Event Viewer.

The kext appears when entering kextstat | grep IOUSBHIDDriverDescriptorOverride, however, it does not appear in ioreg.

Running ioreg -p IOUSB -c IOUSBDevice | grep -e class -e idVendor -e idProduct -e bcdDevice gives this output:

+-o POSEIDON ZX Illuminated@14200000  <class AppleUSBDevice, id 0x100000931, registered, matched, active, busy 0 (4 ms), retain 15>
          "idProduct" = 12292
          "bcdDevice" = 288
          "idVendor" = 9802

...And this isn't found in plutil -p /Library/Extensions/IOUSBHIDDriverDescriptorOverride.kext/Contents/Info.plist.

SamuelMereau commented 4 years ago

Tested every key as well to see where keys are mixed up. Preview of QWERTY, ASDF, etc. text given was typed using the Poseidon ZX Keyboard while the driver was loaded

`1234567890 (hyphen and equals keys unresponsive)
~!@#$%^&*() 

qwe rtyuiop[]\ (e adds space)
QWE RTYUIOP{}| (E also adds space)

asd fghjkl;' (d adds tab, f uses down arrow and g uses up arrow)
ASDFGHJKL:" (D does not tab, F uses shift+down arrow and G uses shift+up arrow)

zxcvbnm,./ (c uses left arrow and b uses right arrow)
ZXCVBNM<>? (C uses shift+left arrow and B uses shift+right arrow)

**Function Keys (without Karabiner)**

f1 --> Responsive
f2 --> Responsive
f3 --> Responsive
f4 --> Responsive, uses both f4 and escape key
f5 --> Responsive, uses both f5 and backspace key
f6 --> Responsive, uses both f6 and hyphen key
f7 --> Responsive, uses both f7 and equals key
f8 --> Responsive
f9 --> Responsive
f10 --> Responsive
f11 --> Responsive (also activates Mac's native fn+f11 function)
f12 --> Responsive

Other Unresponsive keys (without Karabiner):

Spacebar
Backspace
All allocated arrow keys
Tab
Caps Lock
Escape
Fn
thefloweringash commented 4 years ago

There's no descriptor in this project that matches this keyboard. Try running rake scan to generate one, see the readme on Unsupported Devices. Beware that it's been a while since this project saw much attention, it may require some fixing.

SamuelMereau commented 4 years ago

I don't seem to have the scan task in rake... Any guidance as to how to repair this? Bundler doesn't seem to find its own gemfile, so I have to cd into its directory to run anything, same deal for rake.

thefloweringash commented 4 years ago

I don't seem to have the scan task in rake... Any guidance as to how to repair this? Bundler doesn't seem to find its own gemfile, so I have to cd into its directory to run anything, same deal for rake.

I’ve updated the dependencies in the Gemfile.lock. This might help, depending on the failure. rake and bundler pick up the Rakefile and Gemfile from the current directory, you’ll definitely need to run them in the project. It’s been a while since I used homebrew and I think they’ve since made ruby keg only. I don’t know what the easiest way to get ruby is on macOS. Maybe one of rvm, rbenv, or asdf with asdf-ruby? If you have a recommendation I’ll update the readme.

SamuelMereau commented 4 years ago

Ah, that got them working.

Only problem now is that rake scan isn't able to load libusb. I've installed libusb using the given brew command while cd'ed into the source, also in the home directory as well.

$ rake scan
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby scripts/scanner.rb
Traceback (most recent call last):
    1: from scripts/scanner.rb:6:in `<main>'
scripts/scanner.rb:6:in `require': cannot load such file -- libusb (LoadError)
rake aborted!
Command failed with status (1): [/System/Library/Frameworks/Ruby.framework/...]
/Users/SamuelMereau/Desktop/keyboard/iousbhiddriver-descriptor-override-master/Rakefile:15:in `block in <top (required)>'
/Library/Ruby/Gems/2.6.0/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
Tasks: TOP => scan
(See full trace by running task with --trace)
$ brew info libusb
libusb: stable 1.0.23 (bottled), HEAD
Library for USB device access
https://libusb.info/
/usr/local/Cellar/libusb/1.0.23 (26 files, 474.2KB) *
  Poured from bottle on 2020-07-09 at 12:37:30
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/libusb.rb
thefloweringash commented 4 years ago

Oh, that should be

$ bundle exec rake scan
SamuelMereau commented 4 years ago

Still getting a similar error...

$ bundle exec rake scan
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby scripts/scanner.rb
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/universal-darwin19/rbconfig.rb:229: warning: Insecure world writable dir /Library/Ruby/Gems/2.6.0 in PATH, mode 040757
Traceback (most recent call last):
    1: from scripts/scanner.rb:6:in `<main>'
scripts/scanner.rb:6:in `require': cannot load such file -- libusb (LoadError)
rake aborted!
Command failed with status (1): [/System/Library/Frameworks/Ruby.framework/...]
/Users/SamuelMereau/Desktop/keyboard/iousbhiddriver-descriptor-override-master/Rakefile:15:in `block in <top (required)>'
/Library/Ruby/Gems/2.6.0/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
/Library/Ruby/Gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `load'
/Library/Ruby/Gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `kernel_load'
/Library/Ruby/Gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:28:in `run'
/Library/Ruby/Gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:476:in `exec'
/Library/Ruby/Gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/Library/Ruby/Gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/Library/Ruby/Gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor.rb:399:in `dispatch'
/Library/Ruby/Gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:30:in `dispatch'
/Library/Ruby/Gems/2.6.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/base.rb:476:in `start'
/Library/Ruby/Gems/2.6.0/gems/bundler-2.1.4/lib/bundler/cli.rb:24:in `start'
/Library/Ruby/Gems/2.6.0/gems/bundler-2.1.4/exe/bundle:46:in `block in <top (required)>'
/Library/Ruby/Gems/2.6.0/gems/bundler-2.1.4/lib/bundler/friendly_errors.rb:123:in `with_friendly_errors'
/Library/Ruby/Gems/2.6.0/gems/bundler-2.1.4/exe/bundle:34:in `<top (required)>'
/usr/local/bin/bundle:23:in `load'
/usr/local/bin/bundle:23:in `<main>'
Tasks: TOP => scan
(See full trace by running task with --trace)
SamuelMereau commented 4 years ago

I managed to fix the above error in the pull request above. I'm not a ruby dev, so I'm unsure the changes are best practice, so please make sure this fix is worthwhile.

From this change, I got this output:

$ rake scan
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby scripts/scanner.rb
Checking device: #<LIBUSB::Device 20/11 264a:3004 ? POSEIDON ZX Illuminated ? (HID (01,01), HID (00,00))>
Found ambiguity!
Writing details to descriptors/264a-3004-POSEIDON_ZX_Illuminated.yaml

I've attached the zipped .yaml file. 264a-3004-POSEIDON_ZX_Illuminated.yaml.zip

thefloweringash commented 4 years ago

That descriptor does indeed have the overlapping usages that this project solves. Adding that descriptor file to the source tree under descriptors/ should be enough to fix it. If you want to do the honors you're welcome to open a pull request to do so. If not, I can just push it up.

SamuelMereau commented 4 years ago

I put up a pull request to add the .yaml file

https://github.com/thefloweringash/iousbhiddriver-descriptor-override/pull/45

SamuelMereau commented 4 years ago

Awesome, the keyboard is working nicely! Typing this from the keyboard now.

I still had to remap some of the keys using Karabiner, but everything was easily identifiable and remappable with the Event Viewer. I can make a further pull request to change the old Keys4Mac link out to the newer Karabiner one if you wish.

Thanks for all of the help you have offered.

JeremyOsz commented 4 years ago

I am getting the same errors on my Poseidon Z Catalina even after installing the latest release

SamuelMereau commented 4 years ago

@JeremyOsz Read through above the steps that I took to get my keyboard supported. You should just be able to rake scan while your keyboard is plugged in, and will output a .yaml file in the descriptors directory. You can make a pull request with that file

JeremyOsz commented 4 years ago

@SamuelMereau I think my problem is higher up - the kext file is not installing on my system. Interestingly the keyboard works before I log in

When I run kextstat | grep IOUSBHIDDriverDescriptorOverride I get no results.

$ sudo kextutil -v /Library/Extensions/IOUSBHIDDriverDescriptorOverride.kext

Returns:

Defaulting to kernel file '/System/Library/Kernels/kernel' Untrusted kexts are not allowed Kext with invalid signature (-67062) denied: /Library/StagedExtensions/Library/Extensions/F8EC4F6A-8FB3-4D42-9FF1-FA60AFB13D87.kext Bundle (/Library/Extensions/TtEsportsUSBHIDDriver.kext) failed to validate, deleting: /Library/StagedExtensions/Library/Extensions/F8EC4F6A-8FB3-4D42-9FF1-FA60AFB13D87.kext Unable to stage kext (/Library/Extensions/TtEsportsUSBHIDDriver.kext) to secure location. Untrusted kexts are not allowed Kext with invalid signature (-67062) denied: /Library/StagedExtensions/Library/Extensions/FE0BB6F3-E060-4B35-A01F-5C24250C5918.kext Bundle (/Library/Extensions/IOUSBHIDDriverDescriptorOverride.kext) failed to validate, deleting: /Library/StagedExtensions/Library/Extensions/FE0BB6F3-E060-4B35-A01F-5C24250C5918.kext Unable to stage kext (/Library/Extensions/IOUSBHIDDriverDescriptorOverride.kext) to secure location.

SamuelMereau commented 4 years ago

Ah, you need to disable your mac's SIP for kext signing. Follow this link here to know how: https://www.imore.com/how-turn-system-integrity-protection-macos.

However, to make sure your mac isn't susceptible to malware, I highly recommend instead of using csrutil disable, you instead type in csrutil enable --without kext

JeremyOsz commented 4 years ago

What a wild goose chase this has turned out to be. I cannot access Recovery mode because my computer is refurbished from my employer and they have set a firmware password I don't have. Oh well! let's just hope my other keyboard works once it dries out.

callMeBigBen commented 3 years ago

@SamuelMereau Hi Samuel. I also face the same problem on mac os BigSur with Poseidon ZX. Some part of the key just won't work. I searched on google to find this Github issue. I don't have much experience of solving this kind of problem, nor this Github repo. Would you like to share your step-by-step solution? Thank you so much!

SamuelMereau commented 3 years ago

@callMeBigBen Hi, It's been a while since I've looked at this again, so my step-by-step solution is a bit shaky. I haven't upgraded my Mac to Big Sur, so I'm unsure as to whether it works on there. Follow the guide in the README, this should still be sufficient. I've pushed a .yaml file which should fix any issues with the ZX, however if not you will need to run your own rake scan, which the guide outlines how to do.

Installing Karabiner was essential to assign some keys correctly. You can get this here In addition, I did need to make a script which activated the kext driver on startup with Automator:

on run {input, parameters}

    do shell script "sudo kextutil -v /Library/Extensions/IOUSBHIDDriverDescriptorOverride.kext" with administrator privileges

    return input
end run

Save this to your home directory, and add the application to your login items at System Preferences > Users & Groups > Login Items

Let me know how you go. If you still experience trouble, I'd suggest opening a new ticket to outline your specific issue.

callMeBigBen commented 3 years ago

@SamuelMereau I'll follow your approach. Thank you soooooo much for your reply!

xiaokunx commented 3 years ago

Thanks to Samuel's update. I followed the instruction and finally got it work on Mac OS 10.15.7 Catalina (typing this from the ZX keyboard).

After disable the SIP via "csrutil disable" or "csrutil enable --without kext", reboot, and I could see the following diagnostic info showing the Driver is loaded and the keyboard (product ID 12387) is detected.

 ~ plutil -p /Library/Extensions/IOUSBHIDDriverDescriptorOverride.kext/Contents/Info.plist | grep -A 10 0566-3063
    "0566-3063-USB_KeyBoard.yaml-0" => {
      "bcdDevice" => 256
      "bConfigurationValue" => 1
      "bInterfaceNumber" => 0
      "CFBundleIdentifier" => "ryangoulden.driver.IOUSBHIDDriverDescriptorOverride"
      "HIDDefaultBehavior" => ""
      "idProduct" => 12387
      "idVendor" => 1382
      "IOClass" => "IOUSBHIDDriverDescriptorOverride"
      "IOProviderClass" => "IOUSBHostInterface"
      "ReportDescriptorOverride" => {length = 145, bytes = 0x05010906 a1010508 19012903 15002501 ... 02750895 018101c0 }
 ~ ioreg -p IOUSB -c IOUSBDevice | grep -e class -e idVendor -e idProduct -e bcdDevice | grep -C 2 12387
  |   |     "idVendor" = 1060
  |   +-o USB KeyBoard@14440000  <class AppleUSBDevice, id 0x10000142b, registered, matched, active, busy 0 (1 ms), retain 13>
  |   |     "idProduct" = 12387
  |   |     "bcdDevice" = 256
  |   |     "idVendor" = 1382

The most annoying part is actually remapping keys in Karabiner-Elements. The alpha numeric keys works fine, but none of Esc, Tab, Delete, Spacebar key works. The lifesaver here is this website https://w3c.github.io/uievents/tools/key-event-viewer.html that shows the name of the key when pressed. Here is the final mapping that get almost all keys functioning. you could build them by point and click in Karabiner App's "Simple modifications" tab, chose "USC Keyboard (No Manufacture name)" as the Target Device, then click "Add item" to add the following mapping one at a time.

From  Key        ->      To Key
------------------------------
left_alt(equal to `left_option`) -> left_command
delete_or_backsapce              -> hyphen (-)
left_arrow     ->     tab
right_arrow    ->     left_arrow
down_arow      ->     up_arrow
up_arrow       ->     right_arrow
left_command   ->     left_potion
spacebar       ->     down_arrow
tab            ->     spacebar
equal_sign(=)  ->     escape
hyphen(-)      ->     equal_sign(=)
escape         ->     delete_or_backspace
f1             ->     Media Rewind)
f2             ->     play_or_pause
f3             ->     fast_forward
f4             ->     play_or_pause
f5             ->     mute
f6             ->     volume_decrement
f7             ->     volume_increment
f8             ->     mission_control
f9             ->     launchpad
f10            ->     searchlight
f11            ->     brightness_down
f12            ->     brightness_up