<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/3.8.1">
</HEAD>
<BODY>
Does somebody know how the  scancode -> keycode translation is done by Xorg?<BR>
<BR>
<BR>
On Thu, 2006-06-01 at 09:12 +0200, Marvin Raaijmakers wrote:<BR>
<BLOCKQUOTE TYPE=CITE>
    <FONT COLOR="#000000">I made this table for the x86. The following translations are done: </FONT>
<PRE>
<FONT COLOR="#000000">|------------------kernel---------------------|-----------X server------------|</FONT>
<FONT COLOR="#000000"> scancode -> kernel keycode -> scancode related to kernel keycode -> X keycode</FONT>
<FONT COLOR="#000000">           |                 |</FONT>
<FONT COLOR="#000000">           V                 V</FONT>
<FONT COLOR="#000000">  +-----------------+ +-------------+</FONT>
<FONT COLOR="#000000">  | table can be    | | Fixed table |</FONT>
<FONT COLOR="#000000">  | modified using  | +-------------+</FONT>
<FONT COLOR="#000000">  | setkeycodes     |</FONT>
<FONT COLOR="#000000">  +-----------------+</FONT>
</PRE>
    <BR>
    <FONT COLOR="#000000">So my table translates a kernel keycode to an X keycode. I do not know how the X server does the scancode to X keycode translation, but if this is done by using a fixed table (or 1:1), then the translation from kernel keycode to X keycode can be done by using a fixed table.</FONT><BR>
    <FONT COLOR="#000000">As you can see the translation from kernel keycode to scancode related to kernel keycode is quite useless, but must be done because xorg only excepts scancodes. So it would be great if there was an input driver for X that wants to receive kernel keycodes (from the evdev driver) and uses them as the X keycodes (so: kernel keycode = X keycode). This is actually the intent of the kernel keycode story in kernel 2.6.</FONT><BR>
    <FONT COLOR="#000000">Note that a kernel keycode is something like a X keysym for a scancode. So no matter what platform (arm, x86, etc) or keyboard connection (USB, PS/2, etc) you are using, the kernel keycode for key 'a' will always be KEY_A.</FONT><BR>
    <BR>
    <FONT COLOR="#000000">- Marvin Raaijmakers</FONT><BR>
    <BR>
    <FONT COLOR="#000000">On Wed, 2006-05-31 at 23:27 -0700, Park Ji Wong wrote: </FONT>
    <BLOCKQUOTE TYPE=CITE>
<PRE>
<FONT COLOR="#000000">Sorry to interrupt here,</FONT>
<FONT COLOR="#000000">But i have a question, the keycode's value differ to each platform(arm, x86)?</FONT>




<FONT COLOR="#000000">2006/5/31, Marvin Raaijmakers <<A HREF="mailto:marvin.nospam@gmail.com">marvin.nospam@gmail.com</A>>:</FONT>
<FONT COLOR="#000000">> If the remote control is connected via USB it will not be possible to</FONT>
<FONT COLOR="#000000">> set keycodes. At the moment I am trying to modify the input drivers to</FONT>
<FONT COLOR="#000000">> make this possible.</FONT>
<FONT COLOR="#000000">> If you can set the kernel keycode, then of course you can get the X</FONT>
<FONT COLOR="#000000">> keycode by using xev. However you may find it easier to use the</FONT>
<FONT COLOR="#000000">> translation table I made:</FONT>
<FONT COLOR="#000000">></FONT>
<FONT COLOR="#000000">> /* Kernel keycode -> X keycode table */</FONT>
<FONT COLOR="#000000">> const unsigned int keycode_table[256] = {</FONT>
<FONT COLOR="#000000">>        0,   9,  10,  11,  12,  13,  14,  15,  16,  17,  18,  19,  20,  21,</FONT>
<FONT COLOR="#000000">> 22,  23,</FONT>
<FONT COLOR="#000000">>       24,  25,  26,  27,  28,  29,  30,  31,  32,  33,  34,  35,  36,  37,</FONT>
<FONT COLOR="#000000">> 38,  39,</FONT>
<FONT COLOR="#000000">>       40,  41,  42,  43,  44,  45,  46,  47,  48,  49,  50,  51,  52,  53,</FONT>
<FONT COLOR="#000000">> 54,  55,</FONT>
<FONT COLOR="#000000">>       56,  57,  58,  59,  60,  61,  62,  63,  64,  65,  66,  67,  68,  69,</FONT>
<FONT COLOR="#000000">> 70,  71,</FONT>
<FONT COLOR="#000000">>       72,  73,  74,  75,  76,  77,  76,  79,  80,  81,  82,  83,  84,  85,</FONT>
<FONT COLOR="#000000">> 86,  87,</FONT>
<FONT COLOR="#000000">>       88,  89,  90,  91, 111,  221, 94,  95,  96, 211, 128, 127, 129, 208,</FONT>
<FONT COLOR="#000000">> 131, 126,</FONT>
<FONT COLOR="#000000">>      108, 109, 112, 111, 113, 181,  97,  98,  99, 100, 102, 103, 104, 105,</FONT>
<FONT COLOR="#000000">> 106, 107,</FONT>
<FONT COLOR="#000000">>      239, 160, 174, 176, 222, 157, 123, 110, 139, 134, 209, 210, 133, 115,</FONT>
<FONT COLOR="#000000">> 116, 117,</FONT>
<FONT COLOR="#000000">>      232, 133, 134, 135, 140, 248, 191, 192, 122, 188, 245, 158, 161, 193,</FONT>
<FONT COLOR="#000000">> 223, 227,</FONT>
<FONT COLOR="#000000">>      198, 199, 200, 147, 159, 151, 178, 201, 146, 203, 166, 236, 230, 235,</FONT>
<FONT COLOR="#000000">> 234, 233,</FONT>
<FONT COLOR="#000000">>      163, 204, 253, 153, 162, 144, 164, 177, 152, 190, 208, 129, 130, 231,</FONT>
<FONT COLOR="#000000">> 209, 210,</FONT>
<FONT COLOR="#000000">>      136, 220, 143, 246, 251, 137, 138, 182, 183, 184,  93, 184, 247, 132,</FONT>
<FONT COLOR="#000000">> 170, 219,</FONT>
<FONT COLOR="#000000">>      249, 205, 207, 149, 150, 154, 155, 167, 168, 169, 171, 172, 173, 165,</FONT>
<FONT COLOR="#000000">> 175, 179,</FONT>
<FONT COLOR="#000000">>      180,   0, 185, 186, 187, 118, 119, 120, 121, 229, 194, 195, 196, 197,</FONT>
<FONT COLOR="#000000">> 148, 202,</FONT>
<FONT COLOR="#000000">>      101, 212, 237, 214, 215, 216, 217, 218, 228, 142, 213, 240, 241, 242,</FONT>
<FONT COLOR="#000000">> 243, 244,</FONT>
<FONT COLOR="#000000">>        0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,</FONT>
<FONT COLOR="#000000">> 0,   0</FONT>
<FONT COLOR="#000000">> };</FONT>
<FONT COLOR="#000000">></FONT>
<FONT COLOR="#000000">> I made this table for my project keyTouch (<A HREF="http://keytouch.sf.net">http://keytouch.sf.net</A>). If</FONT>
<FONT COLOR="#000000">> it is possible to the set keycodes for your remote control, then you can</FONT>
<FONT COLOR="#000000">> even use this program to bind actions to it. KeyTouch assigns kernel</FONT>
<FONT COLOR="#000000">> keycodes to scancodes, translates the kernel keycode to a X keycode and</FONT>
<FONT COLOR="#000000">> executes an action when that keycode is pressed under X. By using the</FONT>
<FONT COLOR="#000000">> keyTouch editor program you can make a so called keyboard file for your</FONT>
<FONT COLOR="#000000">> remote control and import this keyboard file in keyTouch to get working.</FONT>
<FONT COLOR="#000000">></FONT>
<FONT COLOR="#000000">> - Marvin Raaijmakers</FONT>
<FONT COLOR="#000000">></FONT>
<FONT COLOR="#000000">> On Thu, 2006-06-01 at 08:59 +0300, Aivils Stoss wrote:</FONT>
<FONT COLOR="#000000">></FONT>
<FONT COLOR="#000000">> > On Trešdiena, 31. Maijs 2006 20:31, Jeremy Wilkins wrote:</FONT>
<FONT COLOR="#000000">> > > Hi All,</FONT>
<FONT COLOR="#000000">> > ></FONT>
<FONT COLOR="#000000">> > > I've got an ATI remote control, this worked great in older linux 2.6</FONT>
<FONT COLOR="#000000">> > > kernels but the OK button has changed and now maps to linux keycode</FONT>
<FONT COLOR="#000000">> > > 352 (KEY_OK). I've also managed to find the the scancode using</FONT>
<FONT COLOR="#000000">> > > showkeys.</FONT>
<FONT COLOR="#000000">> > ></FONT>
<FONT COLOR="#000000">> > > How do I find the equivalent X keycode? I've tried xev, but this</FONT>
<FONT COLOR="#000000">> > > appears to only work with keycodes up to 255?</FONT>
<FONT COLOR="#000000">> ></FONT>
<FONT COLOR="#000000">> > Linux kernel does not send keycodes > 255 to X. That is kernel limitation.</FONT>
<FONT COLOR="#000000">> > Set another code on OK button.</FONT>
<FONT COLOR="#000000">> ></FONT>
<FONT COLOR="#000000">> > man setkeycodes</FONT>
<FONT COLOR="#000000">> ></FONT>
<FONT COLOR="#000000">> > Aivils Stoss</FONT>
<FONT COLOR="#000000">> > _______________________________________________</FONT>
<FONT COLOR="#000000">> > xorg mailing list</FONT>
<FONT COLOR="#000000">> > <A HREF="mailto:xorg@lists.freedesktop.org">xorg@lists.freedesktop.org</A></FONT>
<FONT COLOR="#000000">> > <A HREF="http://lists.freedesktop.org/mailman/listinfo/xorg">http://lists.freedesktop.org/mailman/listinfo/xorg</A></FONT>
<FONT COLOR="#000000">></FONT>
<FONT COLOR="#000000">></FONT>


</PRE>
    </BLOCKQUOTE>
<PRE>
<FONT COLOR="#000000">_______________________________________________</FONT>
<FONT COLOR="#000000">xorg mailing list</FONT>
<FONT COLOR="#000000"><A HREF="mailto:xorg@lists.freedesktop.org">xorg@lists.freedesktop.org</A></FONT>
<FONT COLOR="#000000"><A HREF="http://lists.freedesktop.org/mailman/listinfo/xorg">http://lists.freedesktop.org/mailman/listinfo/xorg</A></FONT>
</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>