Keyboard KCAP Resources?

24 views
Skip to first unread message

Robert Brost

unread,
Dec 6, 2016, 7:22:52 AM12/6/16
to Ukelele Users
I have a split ergonomic custom keyboard (Ergodox) which I have programmed to the Dvorak keyboard.  I actually only used Ukelele only to attach a custom icon to the keyboard bundle. I have everything working except the image that is displayed by the Keyboard Viewer.

I understand the graphical presentation for the keyboard is stored in a KCAP resource.  I would like to build a custom KCAP resource (or the modern equivalent) so when I call up the Keyboard viewer I see what looks like my split ergonomic keyboard.  Apple used to sell a similar keyboard (I have attached a gif file to show what it looked like.)  If I could get the KCAP resource for that old Apple keyboard, I could modify it to produce the image I need.

Where does Apple hide this KCAP info?  I assume it is somewhere inside the modern keyboard bundle.  Is there source code for what looks like a binary bundle? Is there a compiler to convert the source to the binary form?  

I have loads of all Apple SW on developer DVD's so I probably can find that old keyboard resource.  The problem is injecting this info into a modern keyboard bundle.  Any ideas of how to do this??

For background, here is some info from Inside Macintosh (fond memories):

The key-caps resource (resource type 'KCAP' ) reflects the physical layout of a particular

keyboard and is used by the Key Caps desk accessory. The resource indicates the shapes

and positions of all keys, and defines the virtual key codes that correspond to each

physical key. Key Caps uses this resource to draw a representation of the current

keyboard layout— using the current keyboard-layout resource— for the current

physical keyboard. If you are creating a new keyboard, you can define its physical

layout in a key-caps resource.


For system software versions 7.0 and later, the key-caps resource is located in the System

file. There is one 'KCAP'  resource per physical keyboard on a Macintosh; it belongs to

the Operating System, and not to any script system. The resource ID for each key-caps

resource is equal to the keyboard type of the keyboard it is associated with. See Table C-1

on page C-4 for a list of keyboard types. For ADB keyboards, the ID of the key-caps

resource is the same as the keyboard handler ID.


AppleAdjustableKbd.gif

Sorin Paliga

unread,
Dec 6, 2016, 7:55:33 AM12/6/16
to ukelel...@googlegroups.com
You may associate an icns file to a .keylayout file by labelling it EXACTLY like the keylayout (its internal name). 
Otherwise, if a bundle, choose an icns file. If you have a PNG or JPG file, there are converts to icns files.
--
You received this message because you are subscribed to the Google Groups "Ukelele Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ukelele-user...@googlegroups.com.
To post to this group, send email to ukelel...@googlegroups.com.
Visit this group at https://groups.google.com/group/ukelele-users.
For more options, visit https://groups.google.com/d/optout.
<AppleAdjustableKbd.gif>

Robert Brost

unread,
Dec 6, 2016, 8:32:23 AM12/6/16
to Ukelele Users
Perhaps I was not clear.  When one selects the Keyboard Viewer from the Input Menu, a "live" image of the keyboard displays which changes when keys are pressed.  This is especially useful for pressing the Alt key and seeing a visual representation of the dead keys and how they are mapped.  The generic layout is fine for most keyboards except it does not look much like my Ergodox <https://ergodox-ez.com/> which has two half keyboards and a rather unusual set of large and small keys for use with ones thumbs.  I was hoping to produce the appropriate resource (KCAP) to provide the Keyboard Viewer with the different physical arrangement used by my keyboard (image of my keyboard is attached.)
IMG_5681x2_large.jpg

Sorin Paliga

unread,
Dec 6, 2016, 8:56:55 AM12/6/16
to ukelel...@googlegroups.com
Now it is clear. As far as I know, you cannot change the keyboard viewer, unless you are a programmer and is conversant with such things like the look and feel of apps. 
I have no knowledge of an app or utility, which may do that. But this is a good idea for other developers.
<IMG_5681x2_large.jpg>

John Brownie

unread,
Dec 6, 2016, 10:53:19 AM12/6/16
to ukelel...@googlegroups.com
Robert Brost wrote:
> I understand the graphical presentation for the keyboard is stored in
> a KCAP resource. I would like to build a custom KCAP resource (or the
> modern equivalent) so when I call up the Keyboard viewer I see what
> looks like my split ergonomic keyboard. Apple used to sell a similar
> keyboard (I have attached a gif file to show what it looked like.) If
> I could get the KCAP resource for that old Apple keyboard, I could
> modify it to produce the image I need.
>
> Where does Apple hide this KCAP info? I assume it is somewhere inside
> the modern keyboard bundle. Is there source code for what looks like
> a binary bundle? Is there a compiler to convert the source to the
> binary form?
>
> I have loads of all Apple SW on developer DVD's so I probably can find
> that old keyboard resource. The problem is injecting this info into a
> modern keyboard bundle. Any ideas of how to do this??
The KCAP resources no longer exist on macOS, having been deleted in
Yosemite, I believe. They were still available in March 2015, when I
captured what was available and incorporated the data into Ukelele. If
you look inside the Ukelele.app bundle, you can see the file
KCAPResources.plist inside the Resources directory. If you were to find
a way to get a new KCAP resource data file for what you want, I could
easily add it to that file and have it available in Ukelele. Since it's
a binary file, it's not that easy to create, though.

In older systems, the resources were in /System/Library/Input
Methods/KeyboardViewer.app/Contents/Resources/KeyboardViewer.rsrc. In
Classic, I cannot remember where they were kept, possibly in a system file.

All that said, though, the Apple Adjustable is one of the options in
Ukelele when you choose Keyboard Type… from the View menu. It has the id
15 (gestaltAppleAdjustADBKbd), with 16 and 17 as the ISO and JIS
variants, respectively.

I don't know how the Keyboard Viewer does it, as it doesn't use KCAP
resources, though the file still exists. I suspect that it's some sort
of compiled form rather than a real resource file, since it's in the
data fork, not the resource fork.

Years ago I asked about a modern replacement for KCAP resources, and an
Apple engineer said that there wasn't anything at that point, but that
he would file a request for something. Unfortunately, I never heard
anything further about it, so I don't know what Apple is doing, though
they must have something in place to drive the Keyboard Viewer.

John
--
John Brownie
In Finland on furlough from SIL Papua New Guinea

Gé van Gasteren

unread,
Dec 6, 2016, 11:05:30 AM12/6/16
to ukelel...@googlegroups.com
Hi Robert,

If you wanted a different interface just for comfort, you just got your answer from John.

But if there are really keys missing in your current Keyboard Type view, you can still access and assign them using their Keycode. See 6.5 in the manual which is available from the Ukelele Help menu.

To find out the key code for a certain key, you can open the Inspector window and go to the State tab. Then press the key to see its key code.

Good luck,


--
You received this message because you are subscribed to the Google Groups "Ukelele Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ukelele-users+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages