LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 04-07-2011, 01:06 PM   #1
tias42
LQ Newbie
 
Registered: Apr 2011
Posts: 3

Rep: Reputation: 0
Problem re-mapping non-standard keys to modifier keys


I'm running Debian (Squeeze) and I have a toshiba portege m700. It has five buttons on the front just under the screen, which are the only ones accessible when you flip the screen over into tablet mode. One of them is for rotating the screen, and another is for switching to external display. I want to remap the remaining three to control, alt and super so that I can use shortcuts with the stylus.

The problem is, when I used showkey to find out the key codes, I found out that each button generates more than one key code:

Button 1:
key 126 press >> super_r, although this is distinct from the actual super key (125)
key 7 press >> 6
key 7 release
key 126 release

Button 2: (you can guess what this button was supposed to be for)
key 29 press >> control_L
key 56 press >> alt_L
key 111 press >> delete
key 111 release
key 56 release
key 29 release

Button 3:
key 125 press >> super_r, the same as keyboard super
key 45 press >> x
key 45 release
key 125 release

As far as I can tell both the key codes and scan codes for most of these are identical to the keys whose outputs they match. I don't know a way to remap all of these to a single keypress, and needless to say I don't want to lose keys like 6 or x. I've tried simply making the key combination a shortcut for what I want, but as I want modifier keys, the extra keypresses making up the shortcut interfere. Possibly it would help to write some sort of script to ignore the rest of the key events - after which I could just remap the first one to what I want, but I lack the expertise to do something like that myself.

Any help would be greatly appreciated. I've spent a fruitless day trawling the world wide interwebs to no avail, and it would be really good to get it working.
 
Old 04-08-2011, 09:50 AM   #2
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,017

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
Is the coding for the keys any clearer if you use xev to grab the codes?
I could not get showkey to work, and this is from man showkey
Code:
2.6 KERNELS
       In 2.6 kernels key codes lie in the range 1-255, instead of 1-127.  Key codes larger than 127 are returned as three bytes
       of  which  the  low  order  7  bits are: zero, bits 13-7, and bits 6-0 of the key code.  The high order bits are: 0/1 for
       make/break, 1, 1.

       In 2.6 kernels raw mode, or scancode mode, is not very raw at all.  Scan codes are first translated  to  key  codes,  and
       when  scancodes  are  desired,  the  key codes are translated back. Various transformations are involved, and there is no
       guarantee at all that the final result corresponds to what the keyboard hardware did send. So, if you want  to  know  the
       scan  codes sent by various keys it is better to boot a 2.4 kernel. Since 2.6.9 there also is the boot option atkbd.soft‐
       raw=0 that tells the 2.6 kernel to return the actual scan codes.
 
Old 04-09-2011, 12:41 AM   #3
tias42
LQ Newbie
 
Registered: Apr 2011
Posts: 3

Original Poster
Rep: Reputation: 0
I tried it with xev, with results along a similar line. Here's what I got:

Code:
Button 1

KeyPress event, serial 32, synthetic NO, window 0x6a00001,
    root 0x112, subw 0x0, time 1044571, (703,-16), root:(709,466),
    state 0x0, keycode 134 (keysym 0xffec, Super_R), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 35, synthetic NO, window 0x6a00001,
    root 0x112, subw 0x0, time 1044572, (703,-16), root:(709,466),
    state 0x40, keycode 15 (keysym 0x36, 6), same_screen YES,
    XLookupString gives 1 bytes: (36) "6"
    XmbLookupString gives 1 bytes: (36) "6"
    XFilterEvent returns: False

KeyRelease event, serial 35, synthetic NO, window 0x6a00001,
    root 0x112, subw 0x0, time 1044730, (703,-16), root:(709,466),
    state 0x40, keycode 15 (keysym 0x36, 6), same_screen YES,
    XLookupString gives 1 bytes: (36) "6"
    XFilterEvent returns: False

KeyRelease event, serial 35, synthetic NO, window 0x6a00001,
    root 0x112, subw 0x0, time 1044733, (703,-16), root:(709,466),
    state 0x40, keycode 134 (keysym 0xffec, Super_R), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

Button 2

KeyPress event, serial 35, synthetic NO, window 0x6a00001,
    root 0x112, subw 0x0, time 1060093, (703,-16), root:(709,466),
    state 0x0, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 35, synthetic NO, window 0x6a00001,
    root 0x112, subw 0x0, time 1060095, (703,-16), root:(709,466),
    state 0x4, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 35, synthetic NO, window 0x6a00001,
    root 0x112, subw 0x0, time 1060099, (703,-16), root:(709,466),
    state 0xc, keycode 119 (keysym 0xffff, Delete), same_screen YES,
    XLookupString gives 1 bytes: (7f) ""
    XmbLookupString gives 1 bytes: (7f) ""
    XFilterEvent returns: False

KeyRelease event, serial 35, synthetic NO, window 0x6a00001,
    root 0x112, subw 0x0, time 1060255, (703,-16), root:(709,466),
    state 0xc, keycode 119 (keysym 0xffff, Delete), same_screen YES,
    XLookupString gives 1 bytes: (7f) ""
    XFilterEvent returns: False

KeyRelease event, serial 35, synthetic NO, window 0x6a00001,
    root 0x112, subw 0x0, time 1060257, (703,-16), root:(709,466),
    state 0xc, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 35, synthetic NO, window 0x6a00001,
    root 0x112, subw 0x0, time 1060261, (703,-16), root:(709,466),
    state 0x4, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

Button 3

KeyPress event, serial 35, synthetic NO, window 0x6a00001,
    root 0x112, subw 0x0, time 1069481, (703,-16), root:(709,466),
    state 0x0, keycode 133 (keysym 0xffeb, Super_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 35, synthetic NO, window 0x6a00001,
    root 0x112, subw 0x0, time 1069482, (703,-16), root:(709,466),
    state 0x40, keycode 53 (keysym 0x78, x), same_screen YES,
    XLookupString gives 1 bytes: (78) "x"
    XmbLookupString gives 1 bytes: (78) "x"
    XFilterEvent returns: False

KeyRelease event, serial 35, synthetic NO, window 0x6a00001,
    root 0x112, subw 0x0, time 1069486, (703,-16), root:(709,466),
    state 0x40, keycode 53 (keysym 0x78, x), same_screen YES,
    XLookupString gives 1 bytes: (78) "x"
    XFilterEvent returns: False

KeyRelease event, serial 35, synthetic NO, window 0x6a00001,
    root 0x112, subw 0x0, time 1069493, (703,-16), root:(709,466),
    state 0x40, keycode 133 (keysym 0xffeb, Super_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False


And for reference:


super key

KeyPress event, serial 35, synthetic NO, window 0x6a00001,
    root 0x112, subw 0x0, time 1074698, (703,-16), root:(709,466),
    state 0x0, keycode 133 (keysym 0xffeb, Super_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 35, synthetic NO, window 0x6a00001,
    root 0x112, subw 0x0, time 1074760, (703,-16), root:(709,466),
    state 0x40, keycode 133 (keysym 0xffeb, Super_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

6 key

KeyPress event, serial 35, synthetic NO, window 0x6a00001,
    root 0x112, subw 0x0, time 1053566, (703,-16), root:(709,466),
    state 0x0, keycode 15 (keysym 0x36, 6), same_screen YES,
    XLookupString gives 1 bytes: (36) "6"
    XmbLookupString gives 1 bytes: (36) "6"
    XFilterEvent returns: False

KeyRelease event, serial 35, synthetic NO, window 0x6a00001,
    root 0x112, subw 0x0, time 1053647, (703,-16), root:(709,466),
    state 0x0, keycode 15 (keysym 0x36, 6), same_screen YES,
    XLookupString gives 1 bytes: (36) "6"
    XFilterEvent returns: False

alt key

KeyPress event, serial 35, synthetic NO, window 0x6a00001,
    root 0x112, subw 0x0, time 1064655, (703,-16), root:(709,466),
    state 0x0, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 35, synthetic NO, window 0x6a00001,
    root 0x112, subw 0x0, time 1064715, (703,-16), root:(709,466),
    state 0x8, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

delete key

KeyPress event, serial 35, synthetic NO, window 0x6a00001,
    root 0x112, subw 0x0, time 1065572, (703,-16), root:(709,466),
    state 0x0, keycode 119 (keysym 0xffff, Delete), same_screen YES,
    XLookupString gives 1 bytes: (7f) ""
    XmbLookupString gives 1 bytes: (7f) ""
    XFilterEvent returns: False

KeyRelease event, serial 35, synthetic NO, window 0x6a00001,
    root 0x112, subw 0x0, time 1065673, (703,-16), root:(709,466),
    state 0x0, keycode 119 (keysym 0xffff, Delete), same_screen YES,
    XLookupString gives 1 bytes: (7f) ""
    XFilterEvent returns: False

control key

KeyPress event, serial 35, synthetic NO, window 0x6a00001,
    root 0x112, subw 0x0, time 1064072, (703,-16), root:(709,466),
    state 0x0, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 35, synthetic NO, window 0x6a00001,
    root 0x112, subw 0x0, time 1064153, (703,-16), root:(709,466),
    state 0x4, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

x key

KeyPress event, serial 35, synthetic NO, window 0x6a00001,
    root 0x112, subw 0x0, time 1072429, (703,-16), root:(709,466),
    state 0x0, keycode 53 (keysym 0x78, x), same_screen YES,
    XLookupString gives 1 bytes: (78) "x"
    XmbLookupString gives 1 bytes: (78) "x"
    XFilterEvent returns: False

KeyRelease event, serial 35, synthetic NO, window 0x6a00001,
    root 0x112, subw 0x0, time 1072511, (703,-16), root:(709,466),
    state 0x0, keycode 53 (keysym 0x78, x), same_screen YES,
    XLookupString gives 1 bytes: (78) "x"
    XFilterEvent returns: False

I just noticed that button 1 is right super, not left super, but it's still the only one with a unique ID. And my main problem is still that they are generating more than one key press.
 
Old 04-09-2011, 01:49 AM   #4
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,017

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
xev is reporting the same behaviour. Those are strange keys.
Does this change if you add the option atkbd.soft‐raw=0 to your kernel boot line?
 
Old 04-09-2011, 05:03 AM   #5
tias42
LQ Newbie
 
Registered: Apr 2011
Posts: 3

Original Poster
Rep: Reputation: 0
No, it's the same. I'm pretty sure it's just lazy design of the laptop, rather than weird settings.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
mouse keys as modifier keys (ctrl & alt) belda Linux - Desktop 3 06-25-2009 10:37 AM
Using winkey et al as modifier / compose keys noranthon Linux - Newbie 6 03-15-2007 11:14 AM
mapping non standard keyboard keys gravesb Linux - Hardware 13 08-31-2005 07:16 PM
xfce4 modifier keys question acidream Linux - General 3 10-11-2004 03:17 PM
Using modifier keys for special characters kpfeiffer Linux - Newbie 5 10-19-2002 04:25 AM


All times are GMT -5. The time now is 07:58 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration