Sponsored Content
Top Forums UNIX for Advanced & Expert Users Questions about the Linux console keyboard driver / translation tables Post 302606344 by Bill Cosby on Saturday 10th of March 2012 08:23:21 PM
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.
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
All times are GMT -4. The time now is 06:07 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy