Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Multimedia keys in X [solved]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
bitozoid
n00b
n00b


Joined: 20 Apr 2008
Posts: 67

PostPosted: Mon Feb 03, 2014 12:20 pm    Post subject: Multimedia keys in X [solved] Reply with quote

I'm trying to setup some multimedia keys for X: zoomin, zoomout, back and forward. So far I know keycodes higher than 255 won't work under X. However, I can get them to work.

In virtual terminal:
Code:
# showkey --scancodes
kb mode was UNICODE
...
[I get nothing for ZoomIn or ZoomOut press/release]
0xe0 0x6a [Back press]
0xe0 0xea [Back release]
0xe0 0x69 [Forward press]
0xe0 0xe9 [Forward release]

# showkey --keycodes
kb mode was UNICODE
...
keycode 418 press [ZoomIn press]
keycode 418 release [ZoomIn release]
keycode 419 press [ZoomOut press]
keycode 419 release [ZoomOut release]
keycode 158 press [Back press]
keycode 158 release [Back release]
keycode 159 press [Forward press]
keycode 159 release [Forward release]


1) Why aren't there any scancodes for zoomin/zoomout?

Keyboard seems to be detected by udev. I press these for keys for evtest, and I get the same keycodes. Keycode numbers are the same than for /usr/include/linux/input.h.
Code:
# evtest /dev/input/by-id/usb-Microsoft_Natural®_Ergonomic_Keyboard_4000-if01-event-kbd                     
Input driver version is 1.0.1
Input device ID: bus 0x3 vendor 0x45e product 0xdb version 0x111
Input device name: "Microsoft Natural® Ergonomic Keyboard 4000"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 1 (KEY_ESC)
    Event code 2 (KEY_1)
    Event code 3 (KEY_2)
...
    Event code 158 (KEY_BACK)
    Event code 159 (KEY_FORWARD)
...
    Event code 177 (KEY_SCROLLUP)
    Event code 178 (KEY_SCROLLDOWN)
...
    Event code 418 (KEY_ZOOMIN)
    Event code 419 (KEY_ZOOMOUT)
...
    Event code 442 (?)
  Event type 2 (EV_REL)
    Event code 6 (REL_HWHEEL)
  Event type 3 (EV_ABS)
    Event code 32 (ABS_VOLUME)
      Value      0
      Min        0
      Max     1023
  Event type 4 (EV_MSC)
    Event code 4 (MSC_SCAN)
  Event type 20 (EV_REP)
Properties:
Testing ... (interrupt to exit)
Event: time 1391184142.576035, type 4 (EV_MSC), code 4 (MSC_SCAN), value c022d
Event: time 1391184142.576035, type 1 (EV_KEY), code 418 (KEY_ZOOMIN), value 1
Event: time 1391184142.576035, -------------- SYN_REPORT ------------
Event: time 1391184142.736038, type 4 (EV_MSC), code 4 (MSC_SCAN), value c022d
Event: time 1391184142.736038, type 1 (EV_KEY), code 418 (KEY_ZOOMIN), value 0
Event: time 1391184142.736038, -------------- SYN_REPORT ------------
Event: time 1391184143.216021, type 4 (EV_MSC), code 4 (MSC_SCAN), value c022e
Event: time 1391184143.216021, type 1 (EV_KEY), code 419 (KEY_ZOOMOUT), value 1
Event: time 1391184143.216021, -------------- SYN_REPORT ------------
Event: time 1391184143.408027, type 4 (EV_MSC), code 4 (MSC_SCAN), value c022e
Event: time 1391184143.408027, type 1 (EV_KEY), code 419 (KEY_ZOOMOUT), value 0
Event: time 1391184143.408027, -------------- SYN_REPORT ------------
Event: time 1391184144.488012, type 4 (EV_MSC), code 4 (MSC_SCAN), value c0224
Event: time 1391184144.488012, type 1 (EV_KEY), code 158 (KEY_BACK), value 1
Event: time 1391184144.488012, -------------- SYN_REPORT ------------
Event: time 1391184144.616011, type 4 (EV_MSC), code 4 (MSC_SCAN), value c0224
Event: time 1391184144.616011, type 1 (EV_KEY), code 158 (KEY_BACK), value 0
Event: time 1391184144.616011, -------------- SYN_REPORT ------------
Event: time 1391184144.960001, type 4 (EV_MSC), code 4 (MSC_SCAN), value c0225
Event: time 1391184144.960001, type 1 (EV_KEY), code 159 (KEY_FORWARD), value 1
Event: time 1391184144.960001, -------------- SYN_REPORT ------------
Event: time 1391184145.016002, type 4 (EV_MSC), code 4 (MSC_SCAN), value c0225
Event: time 1391184145.016002, type 1 (EV_KEY), code 159 (KEY_FORWARD), value 0
Event: time 1391184145.016002, -------------- SYN_REPORT ------------


I have tried to map theses keys to other keycodes by using /lib/udev/hwdb.d/60-keyboard.hwdb, with no success.

Code:
# Microsoft Natural Ergonomic Keyboard 4000
keyboard:usb:v045Ep00DB*
 KEYBOARD_KEY_c022d=zoomin
 KEYBOARD_KEY_c022e=zoomout


I look for the keyboard in udev database:
Code:
# udevadm info --export-db | grep usb:v045Ep00
E: MODALIAS=usb:v045Ep00DBd0173dc00dsc00dp00ic03isc01ip01in00
E: MODALIAS=usb:v045Ep00DBd0173dc00dsc00dp00ic03isc00ip00in01


2) Aren't they supposed to start with keyboard:usb? Are 60-keyboard.hwdb lines in use for this keyboard?

Lastly, I try xev and test for the keys. I get nothing for ZoomIn/ZoomOut, and next output for Back and Forward.

Code:
...
FocusOut event, serial 32, synthetic NO, window 0x2800001,
    mode NotifyUngrab, detail NotifyPointer

FocusIn event, serial 32, synthetic NO, window 0x2800001,
    mode NotifyUngrab, detail NotifyAncestor

KeymapNotify event, serial 32, synthetic NO, window 0x0,
    keys:  80  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   
           0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   

ButtonPress event, serial 32, synthetic NO, window 0x2800001,
    root 0x250, subw 0x0, time 4061722, (104,75), root:(1584,132),
    state 0x10, button 6, same_screen YES

ButtonRelease event, serial 32, synthetic NO, window 0x2800001,
    root 0x250, subw 0x0, time 4061722, (104,75), root:(1584,132),
    state 0x10, button 6, same_screen YES

ButtonPress event, serial 32, synthetic NO, window 0x2800001,
    root 0x250, subw 0x0, time 4061722, (104,75), root:(1584,132),
    state 0x10, button 6, same_screen YES

ButtonRelease event, serial 32, synthetic NO, window 0x2800001,
    root 0x250, subw 0x0, time 4061722, (104,75), root:(1584,132),
    state 0x10, button 6, same_screen YES

FocusOut event, serial 32, synthetic NO, window 0x2800001,
    mode NotifyGrab, detail NotifyAncestor

FocusOut event, serial 32, synthetic NO, window 0x2800001,
    mode NotifyUngrab, detail NotifyPointer

FocusIn event, serial 32, synthetic NO, window 0x2800001,
    mode NotifyUngrab, detail NotifyAncestor

KeymapNotify event, serial 32, synthetic NO, window 0x0,
    keys:  80  0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   
           0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   

ButtonPress event, serial 32, synthetic NO, window 0x2800001,
    root 0x250, subw 0x0, time 4062666, (104,75), root:(1584,132),
    state 0x10, button 7, same_screen YES

ButtonRelease event, serial 32, synthetic NO, window 0x2800001,
    root 0x250, subw 0x0, time 4062666, (104,75), root:(1584,132),
    state 0x10, button 7, same_screen YES

ButtonPress event, serial 32, synthetic NO, window 0x2800001,
    root 0x250, subw 0x0, time 4062666, (104,75), root:(1584,132),
    state 0x10, button 7, same_screen YES

ButtonRelease event, serial 32, synthetic NO, window 0x2800001,
    root 0x250, subw 0x0, time 4062666, (104,75), root:(1584,132),
    state 0x10, button 7, same_screen YES

MotionNotify event, serial 32, synthetic NO, window 0x2800001,
    root 0x250, subw 0x0, time 4065983, (106,75), root:(1586,132),
    state 0x10, is_hint 0, same_screen YES
...


3) Why do I get ButtonPress instead of KeyPress? How do I get a Keysym?


Last edited by bitozoid on Mon Feb 03, 2014 2:48 pm; edited 1 time in total
Back to top
View user's profile Send private message
bitozoid
n00b
n00b


Joined: 20 Apr 2008
Posts: 67

PostPosted: Mon Feb 03, 2014 2:47 pm    Post subject: Reply with quote

I modified /lib/udev/hwdb.d/60-keyboard.hwdb to:
Code:
 718 # Microsoft Natural Ergonomic Keyboard 4000
 719 keyboard:usb:v045Ep00DB*
 720  KEYBOARD_KEY_c022d=scrollup
 721  KEYBOARD_KEY_c022e=scrolldown
 722  KEYBOARD_KEY_c0224=back
 723  KEYBOARD_KEY_c0225=forward

and updated the hwdb:
Code:
# udevadm hwdb --update


They are still present as buttons in xev, but I can map them as keysyms as XF86ScrollUp, XF86ScrollDown, XF86Back, XF86Forward.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum