What is the "hardware type ID" in keylayout xml file?

265 views
Skip to first unread message

Ulf Dahlén

unread,
Sep 10, 2017, 6:42:44 AM9/10/17
to Ukelele Users

In a ".keylayout" file there are <layout> elements where you can specify a "mapSet" and "modifierMap" for a range of keyboard types. Apples Technical Note TN2056 describes the XML file structure, but not what a "keyboard type hardware ID" actually is. They say: 

Apple will map new keyboard hardware IDs to one of the existing ones, so it is usually sufficient to copy and paste the entire element from an existing keyboard layout.

Great, but I really would like to understand what this ID is.

At first look it seems like ID 0 through 17 are ANSI keyboards, but when I look at the key layout for European layouts (which are usually ISO keyboards) I find ID 0 and 1, so I guess the IDs are not related to ANSI/ISO/JIS.

Is there a list somewhere with these hardware IDs? Is it one of the properties you can access via HID functions?


John Brownie

unread,
Sep 10, 2017, 5:32:26 PM9/10/17
to ukelel...@googlegroups.com
Hi Ulf,
10 September 2017 at 20:42
Great, but I really would like to understand what this ID is.

At first look it seems like ID 0 through 17 are ANSI keyboards, but when I look at the key layout for European layouts (which are usually ISO keyboards) I find ID 0 and 1, so I guess the IDs are not related to ANSI/ISO/JIS.

Is there a list somewhere with these hardware IDs? Is it one of the properties you can access via HID functions?

The keyboard ID is what is reported back to the system when certain system calls are made. Historically, these were 'gestalt' calls, but currently it uses Quartz Events, calling CGEventSourceGetKeyboardType. I'm not sure that you can get at it in any other way, and I'm not clear on what you mean by the HID functions.

The list goes back a long way, and is defined in gestalt.h, and I also have a few definitions of my own. Here is a compilation:

/*
    To obtain information about the connected keyboard(s), one should
    use the ADB Manager API.  See Technical Note OV16 for details.
*/
enum {
  gestaltKeyboardType           = 'kbd ', /* keyboard type */
  gestaltMacKbd                 = 1,
  gestaltMacAndPad              = 2,
  gestaltMacPlusKbd             = 3,    /* OBSOLETE: This pre-ADB keyboard is not supported by any Mac OS X hardware and this value now means gestaltUnknownThirdPartyKbd */
  gestaltUnknownThirdPartyKbd   = 3,    /* Unknown 3rd party keyboard. */
  gestaltExtADBKbd              = 4,
  gestaltStdADBKbd              = 5,
  gestaltPrtblADBKbd            = 6,
  gestaltPrtblISOKbd            = 7,
  gestaltStdISOADBKbd           = 8,
  gestaltExtISOADBKbd           = 9,
  gestaltADBKbdII               = 10,
  gestaltADBISOKbdII            = 11,
  gestaltPwrBookADBKbd          = 12,
  gestaltPwrBookISOADBKbd       = 13,
  gestaltAppleAdjustKeypad      = 14,
  gestaltAppleAdjustADBKbd      = 15,
  gestaltAppleAdjustISOKbd      = 16,
  gestaltJapanAdjustADBKbd      = 17,   /* Japan Adjustable Keyboard */
  gestaltPwrBkExtISOKbd         = 20,   /* PowerBook Extended International Keyboard with function keys */
  gestaltPwrBkExtJISKbd         = 21,   /* PowerBook Extended Japanese Keyboard with function keys      */
  gestaltPwrBkExtADBKbd         = 24,   /* PowerBook Extended Domestic Keyboard with function keys      */
  gestaltPS2Keyboard            = 27,   /* PS2 keyboard */
  gestaltPwrBkSubDomKbd         = 28,   /* PowerBook Subnote Domestic Keyboard with function keys w/  inverted T  */
  gestaltPwrBkSubISOKbd         = 29,   /* PowerBook Subnote International Keyboard with function keys w/  inverted T     */
  gestaltPwrBkSubJISKbd         = 30,   /* PowerBook Subnote Japanese Keyboard with function keys w/ inverted T    */
  gestaltPortableUSBANSIKbd     = 37,   /* Powerbook USB-based internal keyboard, ANSI layout */
  gestaltPortableUSBISOKbd      = 38,   /* Powerbook USB-based internal keyboard, ISO layout */
  gestaltPortableUSBJISKbd      = 39,   /* Powerbook USB-based internal keyboard, JIS layout */
  gestaltThirdPartyANSIKbd      = 40,   /* Third party keyboard, ANSI layout.  Returned in Mac OS X Tiger and later. */
  gestaltThirdPartyISOKbd       = 41,   /* Third party keyboard, ISO layout. Returned in Mac OS X Tiger and later. */
  gestaltThirdPartyJISKbd       = 42,   /* Third party keyboard, JIS layout. Returned in Mac OS X Tiger and later. */
  gestaltPwrBkEKDomKbd          = 195,  /* (0xC3) PowerBook Domestic Keyboard with Embedded Keypad, function keys & inverted T    */
  gestaltPwrBkEKISOKbd          = 196,  /* (0xC4) PowerBook International Keyboard with Embedded Keypad, function keys & inverted T   */
  gestaltPwrBkEKJISKbd          = 197,  /* (0xC5) PowerBook Japanese Keyboard with Embedded Keypad, function keys & inverted T      */
  gestaltUSBCosmoANSIKbd        = 198,  /* (0xC6) original USB Domestic (ANSI) Keyboard */
  gestaltUSBCosmoISOKbd         = 199,  /* (0xC7) original USB International (ISO) Keyboard */
  gestaltUSBCosmoJISKbd         = 200,  /* (0xC8) original USB Japanese (JIS) Keyboard */
  gestaltPwrBk99JISKbd          = 201,  /* (0xC9) '99 PowerBook JIS Keyboard with Embedded Keypad, function keys & inverted T               */
  gestaltUSBAndyANSIKbd         = 204,  /* (0xCC) USB Pro Keyboard Domestic (ANSI) Keyboard                                 */
  gestaltUSBAndyISOKbd          = 205,  /* (0xCD) USB Pro Keyboard International (ISO) Keyboard                               */
  gestaltUSBAndyJISKbd          = 206   /* (0xCE) USB Pro Keyboard Japanese (JIS) Keyboard                                    */
};


enum {
  gestaltPortable2001ANSIKbd    = 202,  /* (0xCA) PowerBook and iBook Domestic (ANSI) Keyboard with 2nd cmd key right & function key moves.     */
  gestaltPortable2001ISOKbd     = 203,  /* (0xCB) PowerBook and iBook International (ISO) Keyboard with 2nd cmd key right & function key moves.   */
  gestaltPortable2001JISKbd     = 207   /* (0xCF) PowerBook and iBook Japanese (JIS) Keyboard with function key moves.                   */
};

enum {
  gestaltUSBProF16ANSIKbd       = 34,   /* (0x22) USB Pro Keyboard w/ F16 key Domestic (ANSI) Keyboard */
  gestaltUSBProF16ISOKbd        = 35,   /* (0x23) USB Pro Keyboard w/ F16 key International (ISO) Keyboard */
  gestaltUSBProF16JISKbd        = 36,   /* (0x24) USB Pro Keyboard w/ F16 key Japanese (JIS) Keyboard */
  gestaltProF16ANSIKbd          = 31,   /* (0x1F) Pro Keyboard w/F16 key Domestic (ANSI) Keyboard */
  gestaltProF16ISOKbd           = 32,   /* (0x20) Pro Keyboard w/F16 key International (ISO) Keyboard */
  gestaltProF16JISKbd           = 33    /* (0x21) Pro Keyboard w/F16 key Japanese (JIS) Keyboard */
};

And from my own header files;

    // Gestalt constants not in 10.4.10

enum {
    kGestaltAppleWirelessANSIKbd = 43,    /* Aluminium Apple Wireless Keyboard */
    kGestaltAppleWirelessISOKbd = 44,
    kGestaltAppleWirelessJISKbd = 45,
    kGestaltAppleANSIKbd = 46,    /* Aluminium Apple Keyboard */
    kGestaltAppleISOKbd = 47,
    kGestaltAppleJISKbd = 48,
    kGestaltMacBookLate2007ANSIkbd = 1202,    /* MacBook (Late 2007) */
    kGestaltMacBookLate2007ISOkbd = 1203,
    kGestaltMacBookLate2007JISkbd = 1207
};

You have to work out what these are by educated guesses where there are no comments, e.g. gestaltPrtblISOKbd refers to the old portable Mac (pre-dating the actual laptop models), with an ISO layout.

John
--
John Brownie
SIL-PNG, Ukarumpa, Eastern Highlands, Papua New Guinea
Mussau-Emira language, New Ireland Province, Papua New Guinea

Ulf Dahlén

unread,
Sep 11, 2017, 7:26:48 AM9/11/17
to Ukelele Users
John Brownie:

The keyboard ID is what is reported back to the system when certain system calls are made. Historically, these were 'gestalt' calls, but currently it uses Quartz Events, calling CGEventSourceGetKeyboardType. I'm not sure that you can get at it in any other way, and I'm not clear on what you mean by the HID functions.


Thank you! This is exactly the information I wanted!
Reply all
Reply to author
Forward
0 new messages