[comp.sys.mac] KMAPs and KCHRs

ranson@crcge1.UUCP (D. Ranson CNET) (10/13/87)

(Before you ask: Yes, I have read TechNote 160)
 How are KMAP ressource REALLY used in System4.1? On a SE, I have found that
KMAP ID 1 in the System file is actually used (You can easily swap 2 keys),
but the Keyboard DA apparently assume a default KMAP.
On a Plus, KMAPs seem to have no effect at all. You can boot from a System4.1
without any KMAP in it! Are KMAPs only for ADB keyboards? Why this limitation?
I suppose the right KMAP is chosen at boot time by comparing some sort of
keyboard ID to the ressource ID. Any info on that?
We French Mac-ers are particularly interested in KMAPs because of a bug in
the "physical mapping" of our keyboards. The raw codes for the keys < and `
have been swapped between the Plus and the ADB keyboards. Only KMAPs can cure
that if you want a universal System file (Currently, the recommended System
file for a Plus in France is 3.2).
    Daniel Ranson
    ...!seismo!mcvax!inria!{crcge1 or cnetlu}!ranson

tecot@apple.UUCP (Ed Tecot) (10/19/87)

In article <3022@crcge1.UUCP> ranson@crcge1.UUCP (D. Ranson CNET) writes:
>
>(Before you ask: Yes, I have read TechNote 160)

Good.  Please note that the following information describes System 4.1 and
later ONLY.

> How are KMAP ressource REALLY used in System4.1? On a SE, I have found that
>KMAP ID 1 in the System file is actually used (You can easily swap 2 keys),
>but the Keyboard DA apparently assume a default KMAP.
>On a Plus, KMAPs seem to have no effect at all. You can boot from a System4.1
>without any KMAP in it! Are KMAPs only for ADB keyboards? Why this limitation?
>I suppose the right KMAP is chosen at boot time by comparing some sort of
>keyboard ID to the ressource ID. Any info on that?

The KMAP is used to convert the raw keycodes from any ADB keyboard to the
"Virtual" keycode set which is defined to be a superset of the MacPlus
keyboard codes, thus eliminating the need for a KMAP for non-ADB machines.
The code checks for a KMAP that matches the handler ID of the keyboard in
question and uses it.  If one is not found, it uses KMAP 0 (found in ROM).
The code was not extended to the MacPlus for several reasons:
1) The code and space required for the KMAP would cramp an already overcrowded
	system heap.
2) It would break just about any upgrade (Radius, Prodigy, GCC)
3) It is really not necessary (see below)

>We French Mac-ers are particularly interested in KMAPs because of a bug in
>the "physical mapping" of our keyboards. The raw codes for the keys < and `
>have been swapped between the Plus and the ADB keyboards. Only KMAPs can cure
>that if you want a universal System file (Currently, the recommended System
>file for a Plus in France is 3.2).

You don't want to modify the KMAP since KMAPs are not meant to be localized.
They are intended to be universal across all systems for a particular
keyboard.  KCHRs are, on the other hand localizable.  However, I do understand
your problem and realize that fixing the KCHR would not solve your problem.
Never fear, though; even as we speak, the problem is being fixed, I recommend
that you contact your local Apple Sales office.

						_emt

cheveign@ircam.UUCP (Alain de Cheveigne) (10/21/87)

Some time ago I reconfigured the keyboard layout to use a character 
set (ECMA 8-bit standard) that combines latin and greek within the
same 8-bit code set.  Given this set, I wanted a normal greek typewriter
layout, with latin accessible via the option key (or vice-versa).

I found the keyboard maps in system ressource INIT0  (INIT1 for the
number pad).  If you open INIT0 with resedit and browse through the
data, you come accross a series of codes starting with 61 73 64 66...
(71 73 64 66... for a french keyboard) corresponding to keys a s d f...
These codes are in the order of the key numbers in IM vol I-250 and
IV-250.

If your system was configured for the US, there should be 6 such series,
one each for:
	normal (lower-case)
	SHIFT
	SHIFT-LOCK
	OPTION
	OPTION-SHIFT
	OPTION-SHIFT-LOCK
If your system was configured for another country or reconfigured
using "localizer", you will find a total of 12 series.  The extra
6 are for the "international" keyboard (one extra key) that used to
be available for the 128 and 512.

The keyboard routine is actually more than just a lookup, because
for a few characters (diacriticals) the routine waits for the next 
character and eventually substitutes a compound character.  That
is defined elsewhere in INIT0, and occurs as far as I could tell 
after the initial mapping.  The Keyboard DA reflects, as it should,
the final result of the mapping.

For the greek layout, I just pasted new values into INIT0 
using resedit.  To make things nice and general, I even cannibalized
Localizer (calling it "Greekalizer") to swap a greek keyboard into any
system for any Mac for any country.  Along came the SE with it's new
KMAP and KCHR ressources and messed my efforts up...

It seems that with systems 4.0 up the system can look in three places
for the keyboard layout, so you have to modify all three for a 
"universal" fix.  Occasionally, it slips at start-up and you get
the wrong layout.


This information is based on guesses and trial.  Please correct me
where I'm wrong.  I'd appreciate the same info for SE and IIs (ie: 
where is that darn table).  Also, does anyone have an opinion on
a DA (?) called "MacKeymeleon" that  reconfigures keyboards?

please mail to:
	alain@inria!ircam!urubu.uunet