cons2 non-us keymap

From: Joerg Wittenberger <joerg.wittenberger_at_nospam.org>
Date: Tue Dec 27 1994 - 09:20:24 PST

Hi,

in-head translation of keyboards are a nightmare.
I modified the cons2 server slightly to support non-us keyboards.

I don't think the monolith way of file stored mappings is needed for
c/s systems. It isn't hard to recompile a small server.

For that reason I only modified the makefile to support a LANG
variable, changed the state machine in isr.c to recognize the extra
shift key (alt graphics), and moved the language dependend mapping
tables out of isr.c into LANG-dependend files (mapus.c and mapde.c
kinda file stored mappings). I'm not sure whether this approach
disturbs US people or not because I don't know about the behavior of
the right alt key on these keyboards. Maybe we need a generalized
isr.c.

I don't have experiences in creating diff files suitable for patch.
But I don't feel like learning it yet. The following patch did it's
job on the makefile and isr.c for me but not for map??.c so I'll
append them.

Have fun.

---------- patch for makefile and isr.c------------
diff -c cons2.old/isr.c cons2/isr.c
*** cons2.old/isr.c Tue Dec 27 17:19:58 1994
--- cons2/isr.c Tue Dec 27 17:42:03 1994
***************
*** 8,38 ****
  
  static int shift = 0, /* Count # shift keys down */
          alt = 0, /* ...alt keys */
          ctl = 0, /* ...ctl keys */
          capstoggle = 0, /* For toggling effect of CAPS */
          numtoggle = 0, /* ...NUM lock */
          isE0 = 0; /* Prefix for extended keys (FN1, etc.) */
  
! /* Map scan codes to ASCII, one table for normal, one for shifted */
! static char normal[] = {
! 0,033,'1','2','3','4','5','6','7','8','9','0','-','=','\b','\t',
! 'q','w','e','r','t','y','u','i','o','p','[',']',015,0x80,
! 'a','s','d','f','g','h','j','k','l',';',047,0140,0x80,
! 0134,'z','x','c','v','b','n','m',',','.','/',0x80,
! '*',0x80,' ',0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
! 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
! 0x80,0x80,0x80,'0',0177
! };
! static char shifted[] = {
! 0,033,'!','@','#','$','%','^','&','*','(',')','_','+','\b','\t',
! 'Q','W','E','R','T','Y','U','I','O','P','{','}',015,0x80,
! 'A','S','D','F','G','H','J','K','L',':',042,'~',0x80,
! '|','Z','X','C','V','B','N','M','<','>','?',0x80,
! '*',0x80,' ',0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
! 0x80,0x80,0x80,0x80,'7','8','9',0x80,'4','5','6',0x80,
! '1','2','3','0',177
! };
  
  /*
   * key_event()
   * Process a key event
--- 8,22 ----
  
  static int shift = 0, /* Count # shift keys down */
          alt = 0, /* ...alt keys */
+ altgr = 0, /* ...altgr key */
          ctl = 0, /* ...ctl keys */
          capstoggle = 0, /* For toggling effect of CAPS */
          numtoggle = 0, /* ...NUM lock */
          isE0 = 0; /* Prefix for extended keys (FN1, etc.) */
  
! extern char normal[],shifted[],altgrmap[];
  
+ static char* keymap=normal;
  /*
   * key_event()
   * Process a key event
***************
*** 48,62 ****
          /*
           * Look up in right table for current state
           */
           if (capstoggle) {
- ch = normal[c];
                   if ((ch >= 'a') && (ch <= 'z')) {
! ch = shift ? normal[c] : shifted[c];
! } else {
! ch = shift ? shifted[c] : normal[c];
                   }
- } else {
- ch = shift ? shifted[c] : normal[c];
          }
  
          /*
--- 32,44 ----
          /*
           * Look up in right table for current state
           */
+ ch = keymap[c];
           if (capstoggle) {
                   if ((ch >= 'a') && (ch <= 'z')) {
! ch -= 'a'-'A';
! } else if ((ch >= 'A') && (ch <= 'Z')) {
! ch += 'a'-'A';
                   }
          }
  
          /*
***************
*** 227,236 ****
--- 209,220 ----
          case 0x36: /* Shift key down */
          case 0x2a:
                  shift = 1;
+ keymap = shifted;
                  break;
          case 0xb6: /* Shift key up */
          case 0xaa:
                  shift = 0;
+ keymap = normal;
                  break;
          case 0xe0: /* Prefix for "left side" */
                   isE0 = 1;
***************
*** 242,251 ****
                  ctl = 0;
                  break;
          case 0x38: /* Alt key down */
! alt = 1;
                  break;
          case 0xb8: /* Alt key up */
! alt = 0;
                  break;
          case 0x3a: /* Ignore cap/num down; they might repeat */
          case 0x45:
--- 226,245 ----
                  ctl = 0;
                  break;
          case 0x38: /* Alt key down */
! if(!isE0) {
! alt = 1;
! } else {
! altgr = 1;
! keymap = altgrmap;
! }
                  break;
          case 0xb8: /* Alt key up */
! if(!isE0) {
! alt = 0;
! } else {
! altgr = 0;
! keymap = shift ? shifted : normal;
! }
                  break;
          case 0x3a: /* Ignore cap/num down; they might repeat */
          case 0x45:
diff -c cons2.old/makefile cons2/makefile
*** cons2.old/makefile Tue Dec 27 17:19:14 1994
--- cons2/makefile Tue Dec 27 17:39:47 1994
***************
*** 1,9 ****
  CC= gcc
  LD= ld
  INCS= -I../../../include
  CFLAGS= -Wall -DDEBUG $(INCS) -O
  LDFLAGS= -L../../../libc
! OBJS= main.o cons.o stat.o isr.o rw.o
  LIBS= -lusr -lc_s
  
  .c.o:
--- 1,12 ----
+ # Edit LANG as you need. currently supported: us de
+ LANG=us
+ #
  CC= gcc
  LD= ld
  INCS= -I../../../include
  CFLAGS= -Wall -DDEBUG $(INCS) -O
  LDFLAGS= -L../../../libc
! OBJS= main.o cons.o stat.o isr.o rw.o map$(LANG).o
  LIBS= -lusr -lc_s
  
  .c.o:
Only in cons2: mapde.c
Only in cons2: mapus.c
------------ mapus.c --------------
/* Map scan codes to ASCII, one table for normal, one for shifted */
char normal[] = {
  0,033,'1','2','3','4','5','6','7','8','9','0','-','=','\b','\t',
'q','w','e','r','t','y','u','i','o','p','[',']',015,0x80,
'a','s','d','f','g','h','j','k','l',';',047,0140,0x80,
0134,'z','x','c','v','b','n','m',',','.','/',0x80,
'*',0x80,' ',0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
0x80,0x80,0x80,'0',0177
};
char shifted[] = {
  0,033,'!','@','#','$','%','^','&','*','(',')','_','+','\b','\t',
'Q','W','E','R','T','Y','U','I','O','P','{','}',015,0x80,
'A','S','D','F','G','H','J','K','L',':',042,'~',0x80,
'|','Z','X','C','V','B','N','M','<','>','?',0x80,
'*',0x80,' ',0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
0x80,0x80,0x80,0x80,'7','8','9',0x80,'4','5','6',0x80,
'1','2','3','0',177
};

char altgrmap[] = {
  0,033,'!','@','#','$','%','^','&','*','(',')','_','+','\b','\t',
'Q','W','E','R','T','Y','U','I','O','P','{','}',015,0x80,
'A','S','D','F','G','H','J','K','L',':',042,'~',0x80,
'|','Z','X','C','V','B','N','M','<','>','?',0x80,
'*',0x80,' ',0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
0x80,0x80,0x80,0x80,'7','8','9',0x80,'4','5','6',0x80,
'1','2','3','0',177
};
---------------- mapde.c ----------------
/* Map scan codes to ASCII, one table for normal, one for shifted */
char normal[] = {
  0, 033,'1','2','3','4','5','6','7','8','9','0','\337',047,'\b','\t',
'q','w','e','r','t','z','u','i','o','p','\374','+',015,0x80,
'a','s','d','f','g','h','j','k','l','\366','\344','^',0x80,
'#','y','x','c','v','b','n','m',',','.','-',0x80,
'*',0x80,' ',0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
0x80,0x80,0x80,0x80,0x80,0x80,0x80,'-',0x80,0x80,0x80,'+',
0x80,0x80,0x80,'0',0177,0x80,0x80,'<'
};

char shifted[] = {
 0, 033, '!', '"', '\247', '$', '%', '&','/','(',')','=', '?',0140,'\b','\t',
'Q','W','E','R','T','Z','U','I','O','P','\334','*',015,0x80,
'A','S','D','F','G','H','J','K','L','\326','\304','>',047,
047,'Y','X','C','V','B','N','M',';',':','_','>',
'*',0x80,' ',0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
0x80,0x80,0x80,0x80,'7','8','9',0x80,'4','5','6',0x80,
'1','2','3','0',0177,0x80,0x80,'>'
};

char altgrmap[] = {
  0,033,'!','\262','\263','$','%','^','{','[',']','}','\134',0x80,'\b','\t',
'@','W','E','R','T','Y','U','I','O','P','{','~',015,0x80,
'A','S','D','F','G','H','J','K','L',':',042,'~',0x80,
'|','Z','X','C','V','B','N','M','<','>','?',0x80,
'*',0x80,' ',0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
0x80,0x80,0x80,0x80,'7','8','9',0x80,'4','5','6',0x80,
'1','2','3','0',177,0x80,0x80,'|'
};

-----------------------------------------------------------------------------
Joerg Wittenberger | email: joerg.wittenberger@inf.tu-dresden.de
Rietzstr. 32b |
01139 Dresden |
Germany | PGP: D4 B2 DA AE C3 02 50 9C 45 3E AD 99 C1 1A 8E F8

WWW: <a href=http://www.inf.tu-dresden.de:~jw6/top.html> (click here) </a>
Received on Wed Dec 28 01:45:49 1994

This archive was generated by hypermail 2.1.8 : Thu Sep 22 2005 - 15:12:11 PDT