Questions about the Linux console keyboard driver / translation tables


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Questions about the Linux console keyboard driver / translation tables
# 1  
Old 03-10-2012
Questions about the Linux console keyboard driver / translation tables

Hi there,

I am trying to understand the logic of the Linux keyboard driver, I am not sure if this is the right place to ask, but I don't know where else I could.

Btw. I am talking about an unicode console here.

1.) The Linux kernel (currently) can take 256 translation tables (keymaps), I figured that if I have 8 Mod-Keys and I can press two at the same time, then this makes 256 possible modifications.
E.g. the value of my keycode of the button 'a' is 0x0b61 (small letter a) in table 0 and 0x0b41 (capital letter A) in table 1, so is it true that table 1 is for shift pressed keycodes?
If so, then why is shift (KG_SHIFT in linux/keyboard.h) set to 0, and how do I compute the modifications, meaning how do I know what e.g. index 231 represents?

2.) As seen above, the value for 'a' is actually 0x0b61 instead of 0x0061, if b indicates a type (here KT_LOCK) why isn't it 0xfb61, because I thought that only values above 0xf000 represent typed values, and the values below are simply unicode values.
The values above are read via the KDGKBENT ioctl, are these values read differently then written?
E.g. would I only type 0xfb61 when using the KDSKBENT ioctl?

I hope anyone can help me out a little,
thank you very much in advance,
regards,
Bill
# 2  
Old 03-10-2012
The first thing we need to see what is going on, please post the output of
Code:
locale

from the console. This affects what you're talking about in a big way. "unicode" may be one of several things, so we are all on the same code page.
# 3  
Old 03-10-2012
Quote:
Originally Posted by jim mcnamara
The first thing we need to see what is going on, please post the output of
Code:
locale

from the console. This affects what you're talking about in a big way. "unicode" may be one of several things, so we are all on the same code page.
Hm, I am talking about kernel system calls, I didn't think the locale is involved here.
With "unicode" I mean one of the 4 states for the console after
Code:
man 4 console_ioctl

which are:
Code:
K_RAW
K_XLATE
K_MEDIUMRAW
K_UNICODE

You can set these with the
Code:
ioctl KDSKBMODE

Unicode just means that the kernel console driver will handle characters as two bytes long (unsigned short).

The values I am talking about I acquired through the KDGKBENT ioctl, like this:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <linux/keyboard.h>
#include <sys/ioctl.h>
#include <sys/kd.h>

int
main(int argc, char **argv) {
  struct kbentry ke;
  
  ke.kb_table = (unsigned char)atoi(argv[1]);
  ke.kb_index = (unsigned char)atoi(argv[2]);
  ioclt(0, KDGKBENT, &ke);
  printf("keycode %u = %04x\n", ke.kb_index, ke.kb_value);
  return 0;
}

If you compile this program and invoke it with the first parameter as one of the above mentioned 256 keymap tables, and the second parameter as your keycode, it will print the corresponding value.
You can use showkey(1) to get a keycode from your keyboard (it doesn't work while in X I assume)

E.g. When I press 'a' during showkey(1) I get the keycode 40, if I then invoke my program like
Code:
./a.out 0 40

I get
Code:
keycode 40 = 0b61

Where 0061 would be the utf-8 (and ascii) representation of 'a', if I use 1 instead of 0 I get 0b41, where 0041 would be capital letter 'A'

This should all be independent of the locale, it depends on the defined keymap(5)

Now I am wondering what the 0x0b is doing there, it could be the KT_LOCK function (defined in linux/keyboard.h), but then I am wondering why it is not 0xfb, because functions need to be greater than 0xf000, or so I thought.

I hope you are seeing where I am getting at, my in- and output on the console is jut fine, I am only wondering about the internals.

Regarding this, this is the most interesting link I have found so far: (The part I am interested in starts at section: "Key maps in the kernel")
h**p://gunnarwrobel.de/wiki/Linux-and-the-keyboard.html


But for what it's worth, here my locale output:
Code:
LANG=de_DE.utf8
LC_CTYPE="de_DE.utf8"
LC_NUMERIC="de_DE.utf8"
LC_TIME="de_DE.utf8"
LC_COLLATE="de_DE.utf8"
LC_MONETARY="de_DE.utf8"
LC_MESSAGES="de_DE.utf8"
LC_PAPER="de_DE.utf8"
LC_NAME="de_DE.utf8"
LC_ADDRESS="de_DE.utf8"
LC_TELEPHONE="de_DE.utf8"
LC_MEASUREMENT="de_DE.utf8"
LC_IDENTIFICATION="de_DE.utf8"
LC_ALL=

regards.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Debian

Debian Etch - install us-keyboard driver

Hi, i'm using a debian-4.0r1 on an old subnet machine. I have to extend it with an other keyboard . What i have is a DVD of etch 4.0r7. How can i install and load the keyboard-driver for the us-keyboard? Can anybody please give me a hint how to do that? Thanks in advance (0 Replies)
Discussion started by: IMPe
0 Replies

2. Solaris

Solaris LDOM not accepting keyboard input at console

Ran into this issue today and wanted to share how I fixed it as there is not a lot a lot of info online on this issue. We upgraded our NetApp controllers to Ontap 9 and reboot all our iSCSI attached LDOMs after. One of the LDOM did not come up cleanly and it would not accept any keyboard inputs... (0 Replies)
Discussion started by: ncherukuri
0 Replies

3. HP-UX

CDE Login on console won't use keyboard

Hi all, I'm installing a HP r2660 machine with HP-UX 11.23 (this version fixed by customer's product) and I've troubles using the VGA console as workstation display. At first it worked just as TEXT console, then I fixed /etc/dt/config/Xservers and now I've the CDE prompt for login. ... (5 Replies)
Discussion started by: larry100
5 Replies

4. Hardware

Difference between platform driver,codec driver and Machine driver

In general terms what are the differences platform driver,codec driver and Machine driver? (1 Reply)
Discussion started by: rupeshkp728
1 Replies

5. Programming

Access keyboard driver

(USING FEDORA 16) I am using following command: cat `pwd`/pci-0000:00:1d.0-usb-0:1.3:1.0-event-kbd to access the keyboard driver to make a key logger ,but what i am getting is just some hash code ,please help me decrypt it. Thanks. (1 Reply)
Discussion started by: jayeshsharma52
1 Replies

6. UNIX for Dummies Questions & Answers

Windows to Linux remote console using VNC brings up blank console screen with only mouse pointer

:confused:Hi This was installed on the Linux box a few weeks back by a guy that no longer works for us. All worked fine until last week. Now when we connect its just a blank screen with no icons. I get a whole bunch of errors when starting the service too: Tue Feb 23 14:29:45 2010 ... (1 Reply)
Discussion started by: wbdevilliers
1 Replies

7. UNIX for Advanced & Expert Users

How to write a keyboard driver?

How to write a keyboard driver with interrupt driven? the platform is ARM and the interface is SRAMC with I/O mapped. What should my handler and read fucntions contains? and I want to know how to map the memory by using the ioremap() function? when exactly we have to use mmap()can you please help... (0 Replies)
Discussion started by: rkkcorleone
0 Replies

8. UNIX for Dummies Questions & Answers

Need Book for Linux Basics and Linux device driver.

hai friend, I am new to Linux, i need a book for Linux basic and Linux device driver .. plz send the book name and author(Easy to learn and mostly used by programmers) and also send the link if it is available in Net... Thank you. ... (0 Replies)
Discussion started by: sundar.lsr
0 Replies

9. UNIX for Dummies Questions & Answers

need help getting console driver number(index)

Well, i have a little problem here. I am given device "console" of symbolical type. I do need to get its driver's number (index ?) Your help would be greatly appreciated thx, axujet (1 Reply)
Discussion started by: axujet
1 Replies

10. UNIX for Dummies Questions & Answers

Linux 7.2, Keyboard Problem!

I recently tried to install Linux 7.2 on my home PC (Compaq), and it did not recognise my keyboard. I could not proceed with the installation as I could not type anything. I installed 6.2 and it worked fine???????????. I was wondering if anybody has encountered this problem (very frustrating). ... (4 Replies)
Discussion started by: camerja1
4 Replies
Login or Register to Ask a Question