[PATCH] Ykb keymaps for evdev

Mika Pruikkonen <[email protected]>
Newsgroups gmane.comp.graphics.y.devel
Message-ID <[email protected]>
Hi all,

I finally played around a bit with Y a few weeks ago, and got 
Andrew's patch-148 working. (As a side note, the devel version 
build process is quite picky about autotool versions, it took 
me some time to figure out that a compile error was caused by 
a wrong version of libtool. Changing to 1.5.2 got things working.)

Using patch-148 with fbdev required a few fixes, and I thought
that I'd share them before I forgot completely what they were 
about. You can also find these at the archive 
[email protected]/Y--asuffield--0.2, which is located at 
http://www.hut.fi/~mpruikko/arch/2004. It's a branch of asuffield's 
patch-148, which at the time of writing seems to still be the most 
recent one.

This patch adds support for keymaps for the evdev input module, 
which uses different keycodes than the sdl module. The evdev 
keycodes are defined in include/linux/input.h in the linux kernel 
sources, and the file evdev_basic.ykb in this patch is made by 
looking at that header file and using basic.ykb as a template. It's 
not perfect, and I'm not expecting this to be a long-term solution, 
but something like this is needed at the moment to get keyboard input 
working properly with fbdev.

To use this, you need to make a copy of your ykb layout file, for
example gb.ykb. Make a copy of it, say gb_evdev.ykb, and make two
changes to the copy: 

'include "basic.ykb";' -> 'include "evdev_basic.ykb";', and

'keymap gb' -> 'keymap gb_evdev' (near the end of the file).

This is done for gb, us and jp106 in the patch-1 patchset of my
archive, but the patch below contains only the file evdev_basic.ykb.
After the above, make and install the *.ykm files and change your 
layout in server.conf to gb_evdev, and it should work.

Before ykb (i.e. even in Mark's latest tree) the keycodes were 
converted internally to ones which Y would understand in evdev.c, 
and things worked automagically. My current solution to make copies 
of the top-level .ykb files is really, really ugly, so probably 
something neater should be thought out. Should ykb support using 
different keycodes depending on the loaded input module? Does it 
already? Or shouldn't evdev be used at all?


--- orig/config/keymaps/evdev_basic.ykb
+++ mod/config/keymaps/evdev_basic.ykb
@@ -0,0 +1,290 @@
+# Generated manually from basic.ykb by finding corresponding
+# evdev defines in <linux/input.h>
+
+keycode basic
+{
+  TLDE = 41;
+  AE01 = 2;
+  AE02 = 3;
+  AE03 = 4;
+  AE04 = 5;
+  AE05 = 6;
+  AE06 = 7;
+  AE07 = 8;
+  AE08 = 9;
+  AE09 = 10;
+  AE10 = 11;
+  AE11 = 12;
+  AE12 = 13;
+  backspace = 14;
+
+  BKSL = 43;
+  LSGT = 86;
+
+  tab = 15;
+  AD01 = 16;
+  AD02 = 17;
+  AD03 = 18;
+  AD04 = 19;
+  AD05 = 20;
+  AD06 = 21;
+  AD07 = 22;
+  AD08 = 23;
+  AD09 = 24;
+  AD10 = 25;
+  AD11 = 26;
+  AD12 = 27;
+  return = 28;
+
+  caps_lock = 58;
+  AC01 = 30;
+  AC02 = 31;
+  AC03 = 32;
+  AC04 = 33;
+  AC05 = 34;
+  AC06 = 35;
+  AC07 = 36;
+  AC08 = 37;
+  AC09 = 38;
+  AC10 = 39;
+  AC11 = 40;
+
+  left_shift = 42;
+  AB01 = 44;
+  AB02 = 45;
+  AB03 = 46;
+  AB04 = 47;
+  AB05 = 48;
+  AB06 = 49;
+  AB07 = 50;
+  AB08 = 51;
+  AB09 = 52;
+  AB10 = 53;
+  right_shift = 54;
+
+  left_alt = 56;
+  left_ctrl = 29;
+  space = 57;
+  right_ctrl = 97;
+  right_alt = 100;
+  alt_gr = right_alt;
+  left_windows = 125;
+  right_windows = 126;
+  menu = 127;
+
+  escape = 1;
+  FK01 = 59;
+  FK02 = 60;
+  FK03 = 61;
+  FK04 = 62;
+  FK05 = 63;
+  FK06 = 64;
+  FK07 = 65;
+  FK08 = 66;
+  FK09 = 67;
+  FK10 = 68;
+  FK11 = 87;
+  FK12 = 88;
+
+  sysrq = 99;
+  print_screen = sysrq;
+  scroll_lock = 70;
+  pause = 119;
+  break = pause;
+
+  insert = 110;
+  home = 102;
+  page_up = 104;
+  delete = 111;
+  end = 107;
+  page_down = 109;
+
+  up  =  103;
+  left = 105;
+  down = 108;
+  right = 106;
+
+  numlock = 69;
+  keypad_divide = 98;
+  keypad_multiply = 55;
+  keypad_subtract = 74;
+
+  keypad_7 = 71;
+  keyapd_8 = 72;
+  keypad_9 = 73;
+  keypad_add = 78;
+
+  keypad_4 = 75;
+  keypad_5 = 76;
+  keypad_6 = 77;
+
+  keypad_1 = 79;
+  keypad_2 = 80;
+  keypad_3 = 81;
+  keypad_enter = 96;
+
+  keypad_0 = 82;
+  keypad_delete = 83;
+
+  FK13 = 183;
+  FK14 = 184;
+  FK15 = 185;
+  FK16 = 186;
+  FK17 = 187;
+#  KPDC = 123;
+
+  # Keys that are generated on Japanese keyboards
+
+  # Hankaku_Zenkaku toggle
+  hankaku_zenkaku = 85;
+  # Hiragana_Katakana toggle
+  hiragana_katakana = 93;
+  # backslash/underscore
+#  AB11 = KPDC;
+  # Henkan
+  XFER = 92;
+  # Muhenkan
+  NFER = 94;
+  # Yen
+  AE13 = 124;
+
+  # Keys that are generated on Japanese keyboards and the
+  # ABNT2 Brazillian keyboards
+  AC12 = BKSL;
+}
+
+keycode name basic
+{
+  backspace[*] = "backspace";
+  tab[*] = "tab";
+  return[*] = "return";
+
+  caps_lock[*] = "caps_lock";
+  left_shift[*] = "left_shift";
+  right_shift[*] = "right_shift";
+  left_alt[*] = "left_alt";
+  left_ctrl[*] = "left_ctrl";
+  space[*] = "space";
+  right_ctrl[*] = "right_ctrl";
+  right_alt[*] = "right_alt";
+  left_windows[*] = "left_win";
+  right_windows[*] = "right_win";
+
+  menu[*] = "menu";
+  escape[*] = "escape";
+
+  FK01[*] = "F1";
+  FK02[*] = "F2";
+  FK03[*] = "F3";
+  FK04[*] = "F4";
+  FK05[*] = "F5";
+  FK06[*] = "F6";
+  FK07[*] = "F7";
+  FK08[*] = "F8";
+  FK09[*] = "F9";
+  FK10[*] = "F10";
+  FK11[*] = "F11";
+  FK12[*] = "F12";
+  FK13[*] = "F13";
+  FK14[*] = "F14";
+  FK15[*] = "F15";
+  FK16[*] = "F16";
+  FK17[*] = "F17";
+
+  print_screen[*] = "print_screen";
+  sysrq[*] = "sysrq";
+  scroll_lock[*] = "scroll_lock";
+  pause[*] = "pause";
+  break[*] = "break";
+
+  insert[*] = "insert";
+  home[*] = "home";
+  page_up[*] = "page_up";
+  delete[*] = "delete";
+  end[*] = "end";
+  page_down[*] = "page_down";
+
+  up[*] = "up";
+  left[*] = "left";
+  down[*] = "down";
+  right[*] = "right";
+
+  numlock[*] = "numlock";
+  keypad_divide[*] = "keypad_divide";
+  keypad_multiply[*] = "keypad_multiply";
+  keypad_subtract[*] = "keypad_subtract";
+
+  keypad_7[*] = "keypad_7";
+  keyapd_8[*] = "keypad_8";
+  keypad_9[*] = "keypad_9";
+  keypad_add[*] = "keypad_add";
+
+  keypad_4[*] = "keypad_4";
+  keypad_5[*] = "keypad_5";
+  keypad_6[*] = "keypad_6";
+
+  keypad_1[*] = "keypad_1";
+  keypad_2[*] = "keypad_2";
+  keypad_3[*] = "keypad_3";
+  keypad_enter[*] = "keypad_enter";
+
+  keypad_0[*] = "keypad_0";
+  keypad_delete[*] = "keypad_delete";
+}
+
+modifier basic
+{
+  shift = 0;
+  ctrl = 1;
+  alt = 2;
+  meta = 3;
+  super = 4;
+  hyper = 5;
+  # X calls this Mode_switch
+  altgr = 6;
+}
+
+modifier name basic
+{
+  ctrl = "C";
+  alt = "A";
+  meta = "M";
+  super = "S";
+  hyper = "H";
+  altgr = "Ag";
+}
+
+seq basic_modifiers
+{
+  left_shift[*] setModifiers(shift) restoreState();
+  ^left_shift[*] maskModifiers(!shift) restoreState();
+  right_shift[*] setModifiers(shift) restoreState();
+  ^right_shift[*] maskModifiers(!shift) restoreState();
+
+  caps_lock[/shift] setStickyModifiers(shift);
+  caps_lock[shift] maskStickyModifiers(!shift);
+
+  left_ctrl[*] setModifiers(ctrl) restoreState();
+  ^left_ctrl[*] maskModifiers(!ctrl) restoreState();
+  right_ctrl[*] setModifiers(ctrl) restoreState();
+  ^right_ctrl[*] maskModifiers(!ctrl) restoreState();
+
+  left_alt[*] setModifiers(meta) restoreState();
+  ^left_alt[*] maskModifiers(!meta) restoreState();
+  alt_gr[*] setModifiers(altgr) restoreState();
+  ^alt_gr[*] maskModifiers(!altgr) restoreState();
+
+  left_windows[*] setModifiers(super) restoreState();
+  ^left_windows[*] maskModifiers(!super) restoreState();
+  right_windows[*] setModifiers(super) restoreState();
+  ^right_windows[*] maskModifiers(!super) restoreState();
+}
+
+abstract keymap basic
+{
+  include keycode basic;
+  include keycode name basic;
+  include modifier basic;
+  include modifier name basic;
+  include seq basic_modifiers;
+}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.