Fixing USB Keyboard Type

From Pterodactylus
Revision as of 09:36, 26 February 2024 by Bombe (talk | contribs) (Where the fuck did I get that JSON listing from?! Anyway, show XML export.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

First, export the current keyboard settings:

# defaults export /Library/Preferences/com.apple.keyboardtype - > keyboardtype

Then, find USB vendor and product ID of your keyboard:

# lsusb
Bus 000 Device 001: ID 0bda:2172 Realtek Semiconductor Corp. BillBoard Device  Serial: 00000000000000000
Bus 001 Device 001: ID 2109:0822 VIA Labs, Inc. USB3.1 Hub  Serial: 000000001
Bus 001 Device 003: ID 05e3:0626 Genesys Logic, Inc. USB3.1 Hub
Bus 001 Device 004: ID 0b95:1790 ASIX Electronics Corporation AX88179A  Serial: 00000000000001
Bus 001 Device 006: ID 2537:1081 2537 NS1081  Serial: 0123456789ABCDE
Bus 001 Device 002: ID 2109:2822 VIA Labs, Inc. USB2.0 Hub  Serial: 000000001
Bus 001 Device 008: ID 0bda:8152 Realtek Semiconductor Corp. USB 10/100 LAN  Serial: 00E04C36001A
Bus 001 Device 007: ID 14cd:8601 MOAI ELECTRONICS CORPORATION USB 2.0 Hub
Bus 001 Device 009: ID 05e3:0610 Genesys Logic, Inc. USB2.1 Hub
Bus 001 Device 012: ID 25a7:fa61 25a7 2.4G Receiver
Bus 001 Device 011: ID 04d9:a1dd Holtek Semiconductor, Inc. USB-HID Keyboard
Bus 001 Device 010: ID 0bda:0567 Realtek Semiconductor Corp. WEB CAMERA M9 Pro  Serial: 200901010001
Bus 001 Device 005: ID 291a:8388 291a Anker USB-C Hub Device  Serial: 0000000000000001
Bus 000 Device 000: ID 0bda:2172 Realtek Semiconductor Corp. USB 3.1 Bus
Bus 000 Device 000: ID 2109:0822 VIA Labs, Inc. USB 3.1 Bus

The keyboard is the USB device 04d9:a1dd. Convert the two IDs to decimal numbers; the product ID is 41437, and the vendor ID is 1241.

Now, open the keyboardtype file, and look for entry that has your product and vendor ID in decimal:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>keyboardtype</key>
        <dict>
                <key>34053-16700-0</key>
                <integer>41</integer>
                <key>400-9610-0</key>
                <integer>41</integer>
                <key>41437-1241-0</key>
                <integer>41</integer>
                <key>50475-1133-0</key>
                <integer>41</integer>
                <key>64097-9639-0</key>
                <integer>41</integer>
        </dict>
</dict>
</plist>

The number represents the type of keyboard (41 is ISO). Change the number to the type you want the keyboard to be.

Import the changed file back:

# sudo defaults import /Library/Preferences/com.apple.keyboardtype - < keyboardtype

Now unplug the keyboard and plug it back in.