Na�ve Keymap

Greetings,

The 'keymaps' structure seems to boil down to something like this:

=======================================================
#include <stdio.h>

const int map = 3;
enum language {english, greek, russian};

const int keysym = 8;
enum modifier {normal=0x0, shift=0x1, alt=0x2 , ctrl=0x4};

const int keycode = 120;
// keys are not enumerated.

int keymap[map][keycode][keysym]; //<---- KEYMAP

int main(int argc, char *argv[])
{
  keymap[english][30][normal]     = 'a';
  keymap[english][30][shift]      = 'A';
  keymap[english][30][alt]        = 0x1b61;  // "\eA"
  keymap[english][30][alt+shift]  = '?';
  keymap[english][30][ctrl]       = 0x01;    // SOH
  keymap[english][30][ctrl+shift] = '?';
  keymap[english][30][ctrl+alt]   = '?';
  keymap[english][30][ctrl+alt+shift] = '?';

  keymap[english][47][normal] = 'v';
  keymap[english][47][shift]  = 'V';

  keymap[greek][30][normal] = 0x03b1; //&#945;
  keymap[greek][30][shift]  = 0x0391; //&#913;

  keymap[greek][47][normal] = '&#969;';
  keymap[greek][47][shift]  = '&#937;';

  printf("%C\n", keymap[greek][47][normal]);
  return 0;
}
=======================================================

(My Windows 98 keyboard drivers (i.e. keymaps) don't work in Dev-4 and the
printf() doesn't work on my system.)

1) Can I assume anything about the integer value of wchar_t?

I just took the number from the Unicode chart. If I can't, I'll just write some
utf-8 conversion routines myself, and out-'put' them to a byte stream.

2) The composed characters will not be part of the array (of course), but they
/will/ be part of the map. The scanner (function) will map composed keycode
sequences to Unicode (=wide) characters.

I'm guessing that there are submaps for individual languages, but I'm beginning
to get the impression that keymaps was not intended for that. The few examples
I've seen seem to use (globally defined) compose sequences and modifier key
combinations to enter "unusual" characters. In other words, there is only a
single 'map' (and that map is used by all instances of the console) and that
'map' covers all language characters.

(Incidentally, it looks to me like there is such a thing as a graphical
console, called a "GUI console", so X /can/ share the real console with
text-mode VCs.

I thought I saw that VTs (sometimes called VCs) are represented by device
files.

Consoles are (terminal) emulation programs, and should run as application
programs. If the console were part of the kernel, it's API would have to be
exposed using ioctl() on the device file, only the API would be very large.

I'm still Googling...)

3) The KEYMAPS configuration language is aweful, but I see what you mean. It is
similar to a multi-dimensional array initialization, only you're using keycodes
to identify the rows (and save space). Keysyms are known positionally, and can
be omitted.
 
Say, why are the keycodes given numerically? Who knows a '30' from a '47'?

Plausible answer: Because not all keyboards are printed with latin characters,
stupid. So, a Greek keyboard key would not be called 'V', but '&#937;'.

Signed,

Elvis Presley,
King of Rock and Roll
Duke of Earl, etc. etc. etc.




        
                
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail 

--
Linux-UTF8:   i18n of Linux on all levels
Archive:      http://mail.nl.linux.org/linux-utf8/

Reply via email to