keyboard.4 revision 423
1168054Sflz.Dd April 7, 1993 2168054Sflz.Dt KEYBOARD 4 3168266Sgabor.Os FreeBSD 4168266Sgabor.Sh NAME 5168266Sgabor.Nm keyboard 6168266Sgabor.Nd pc keyboard interface 7168266Sgabor.Sh DESCRIPTION 8168266Sgabor 9168266SgaborThe PC keyboard is use as the console character input device. The keyboard 10168266Sgaboris owned by the current virtual console. 11168054SflzTo switch between the virtual consoles use the sequence 12168054Sflz.Ar ALT+Fn 13168064Sflz, which means hold down ALT and press one of the function keys. The 14168064Sflzvirtual console with the same number as the function key is then 15168064Sflzselected as the current virtual console, and given exclusive use of 16168064Sflzthe keyboard and display. 17168064Sflz 18168064SflzThe console allows entering values that are not physically 19168064Sflzpresent on the keyboard via a special keysequence. 20168064SflzTo use this facility press and hold down ALT, 21168064Sflzthen enter a decimal number from 0-255 via the numerical keypad, then 22168064Sflzrelease ALT. The entered value is then used as the ASCII value for one 23168064Sflzcharacter. This way it is possible to enter any ASCII value. 24168064SflzThe keyboard is configurable to suit the individual user and the different 25168064Sflznational layout. 26168064Sflz 27168054SflzThe keys on the keyboard can have any of the following functions: 28168054Sflz 29168064Sflz Normal key - Enter the ASCII value associated with the key. 30168054Sflz 31168188Sgabor Function key - Enter a string of ASCII values. 32168188Sgabor 33168188Sgabor Switch Key - Switch virtual console. 34168263Sru 35168194Simp Modifier Key - Change the meaning of another key. 36168188Sgabor 37168188Sgabor 38168188SgaborThe keyboard is seen as a number of keys numbered from 1 to n. This 39168188Sgabornumber is often referred to as the "scancode" for a given key. The number 40168188Sgaborof the key is transmitted as an 8 bit char with bit 7 as 0 when a key is 41168188Sgaborpressed, and the number with bit 7 as 1 when released. This makes it 42168188Sgaborpossible to make the mapping of the keys fully configurable. 43168188Sgabor 44168202SumeThe meaning of every key is programmable via the PIO_KEYMAP ioctl call, that 45168188Sgabortakes a structure keymap_t as argument. The layout of this structure is as 46168188Sgaborfollows: 47168202Sume.Pp 48168188Sgabor.Bd -literal -offset indent 49168127Sdwmalone struct keymap { 50168054Sflz u_short n_keys; 51168054Sflz struct key_t { 52168054Sflz u_char map[NUM_STATES]; 53168054Sflz u_char spcl; 54168215Sache u_char flgs; 55168149Simp } key[NUM_KEYS]; 56168149Simp }; 57168179Sgabor.Ed 58168083Sjkim.Pp 59168123SnetchildThe field n_keys tells the system how many keydefinitions (scancodes) 60168080Smlaierfollows. Each scancode is then specified in the key_t substructure. 61168195Sbenno 62168131SbmahEach scancode can be translated to any of 8 different values, depending 63168183Sgaboron the shift, control, and alt state. These eight possibilities is 64168080Smlaierrepresented by the map array, as shown below: 65168150Srwatson 66168270Sbrooks alt 67168149Simp scan cntrl alt alt cntrl 68168150Srwatson code base shift cntrl shift alt shift cntrl shift 69168263Sru map[n] 0 1 2 3 4 5 6 7 70168054Sflz ---- ------------------------------------------------------ 71168183Sgabor 0x1E 'a' 'A' 0x01 0x01 'a' 'A' 0x01 0x01 72168060Sdds 73168108SrafanThis is the default mapping for the key labelled 'A' wich normally has 74168083Sjkimscancode 0x1E. The eight states is as shown, giving the 'A' key its 75168153Simpnormal behavior. 76168080SmlaierThe spcl field is used to give the key "special" treatment, and is 77168149Simpinterpreted as follows. 78168127SdwmaloneEach bit correspond to one of the states above. If the bit is 0 the 79168263Srukey emits the number defined in the corresponding map[] entry. 80168180SrwatsonIf the bit is 1 the key is "special". This means it does not emit 81168149Simpanything, instead it changes the "state". That means it is a shift, 82168127Sdwmalonecontrol, alt, lock, switch-screen, function-key or no-op key. 83168054SflzThe bitmap is backwards ie. 7 for base, 6 for shift etc. 84168183Sgabor 85168150SrwatsonThe flgs field defines if the key should react on caps-lock (1), 86168195Sbennonum-lock (2), both (3) or ignore both (0). 87168081Sle 88168154SgshapiroThe mapkbd utility is used to load such a description into/outof 89168127Sdwmalonethe kernel at runtime. This make it possible to change the key 90168144Simpassignments at runtime, or more important to get (GIO_KEYMAP ioctl) 91168183Sgaborthe exact key meanings from the kernel (fx. used by the X server). 92168080Smlaier 93168150SrwatsonThe function keys can be programmed using the PIO_STRMAP ioctl call. 94168153Simp 95168083SjkimThis ioctl takes a argument of the type fkeyarg_t: 96168111Smatteo.Bd -literal -offset indent 97168149Simp struct fkeyarg { 98168151Sphk u_short keynum; 99168149Simp char keydef[MAXFK]; 100168180Srwatson char flen; 101168150Srwatson }; 102168081Sle.Ed 103168180Srwatson.Pp 104168167SphilipThe field keynum defines which function key that is programmed. 105168142SrwatsonThe array keydef should contain the new string to be used (MAXFK long), 106168263Sruand the length should be entered in flen. 107168143Smjacob 108168080SmlaierThe GIO_STRMAP ioctl call works in a semilar manner, execpt it returns 109168149Simpthe current setting of keynum. 110168130Sdelphij 111168123SnetchildThe function keys are numbered like this: 112168171Sphilip.Bd -literal -offset indent 113168097Sle F1-F12 key 1 - 12 114168149Simp Shift F1-F12 key 13 - 24 115168127Sdwmalone Ctrl F1-F12 key 25 - 36 116168183Sgabor Ctrl+shift F1-F12 key 37 - 48 117168111Smatteo 118168151Sphk Home key 49 119168183Sgabor Up arrow key 50 120168101Sandre Page Up key 51 121168108Srafan (keypad) - key 52 122168149Simp Left arrow key 53 123168149Simp (keypad) 5 key 54 124168149Simp Right arrow key 55 125168140Srwatson (keypad) + key 56 126168118Srse End key 57 127168263Sru Down arrow key 58 128168140Srwatson Page down key 59 129168080Smlaier Insert key 60 130168149Simp.Ed 131168081Sle.Pp 132168167Sphilip.Sh AUTHOR 133168149Simp S_ren Schmidt 134168115Ssimon Email: (baukno@login.dkuug.dk -or- sos@kmd-ac.dk) 135168263Sru