LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-07-2020, 05:00 AM   #1
chomwitt
Member
 
Registered: Jul 2020
Location: Hellas
Distribution: Devuan+XFCE
Posts: 53

Rep: Reputation: Disabled
How linux maps keyboard scancodes to kernel keycodes?


In /usr/share/X11/xkb/keycodes/evdev
there is a mapping from :
Quote:
evdev scancodes to something resembling xfree86 keycodes
e.g:
<AC01> = 38;
Trying
Code:
$ sudo xev -event keyboard
state 0x0, keycode 38 (keysym 0x61, a),
and pressing keycap 'A' i do get keycode: 38

But what is <AC01> ? Where can i find what it means?

Also trying to display usb related values (are those called still scancodes)
i get:

Code:
$ sudo evtest /dev/input/by-id/usb-Logitech_USB_Receiver-if01-event-kbd 

Event: time 1601988267.325606, -------------- SYN_REPORT ------------
Event: time 1601988267.453604, type 4 (EV_MSC), code 4 (MSC_SCAN), value 70004
Event: time 1601988267.453604, type 1 (EV_KEY), code 30 (KEY_A), value 0
So usb keyboard sent : (MSC_SCAN), value 70004
linux transforms that keycode to 30? or 38? and that value is used later
from Xserver to map it to keysyms.

But where does that mapping from keyboard sent scancode to linux keycode is happening ?

Last edited by chomwitt; 10-07-2020 at 05:01 AM. Reason: microcorrections
 
Old 10-07-2020, 05:14 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,839

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
probably I would start here: https://wiki.archlinux.org/index.php/Keyboard_input
 
Old 10-07-2020, 11:10 AM   #3
DavidMcCann
LQ Veteran
 
Registered: Jul 2006
Location: London
Distribution: PCLinuxOS, Debian
Posts: 6,140

Rep: Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314
<AC01> means the first key (01) in the third row up (C) of the alphanumeric area (A). So why does it use that?

If you plug a Mac keyboard into a PC using Windows, it doesn't work. That's because Windows expects a keyboard where the first key in the home row has the code 38, but the Mac uses 8. If you plug it into a PC running Linux it does work. Linux doesn't just check that you have a keyboard available somewhere, but it also checks what sort it is. To enable it to use a wide range, it defines the key codes as places on the keyboard in one file (like evdev) and sets the use of the places in another, like /usr/share/X11/xkb/symbols/latin. e.g.
Code:
<AC01> = 38;
key <AC01> {[a, A, ae, AE]};
Once you've loged in it knows what language you're using and can combine the two files (and some others) to make the source code for a keyboard driver, which it then compiles.
Code:
key 38 {[a, A, ae, AE]};
 
  


Reply

Tags
keyboard, scancode



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Avoid Google Maps with GNOME Maps on GNU/Linux LXer Syndicated Linux News 0 04-15-2018 06:33 AM
IR Remote: Keycodes but no scancodes? polemon Linux - Hardware 6 04-11-2013 06:46 PM
[SOLVED] Raw access to keycodes/scancodes from userspace? hda7 Programming 20 03-05-2011 02:38 PM
wxWidgets keycodes to X Keycodes LonelyStar Programming 0 09-23-2007 10:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:46 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration