LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (http://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   Mapping Multimedia Keyboard - Need more help (http://www.linuxquestions.org/questions/linux-hardware-18/mapping-multimedia-keyboard-need-more-help-260049/)

apachedude 11-28-2004 02:01 AM

Mapping Multimedia Keyboard - Need more help
 
I just picked up a Logitech Cordless Internet Pro (should be the samething as Logitech Cordless Desktop Pro) today. I've read several HOWTOs on how to map keys, but they make no sense to me.
I'm running SuSE 9.1 with KDE 3.2. There are two things I'd like to do: 1) map the Win button to pop up the KDE "start menu" and 2) assign the multimedia buttons to work appropriately. The multimedia buttons on my keyboard are media (which I would like execute xmms, Juk, Kaffeine, or the like), play/pause (which obviously resumes or pauses playback from that player), mute (turn off master volume), volume (changes master volume in increments), favorites (I'd leave this blank), email (map to Thunderbird), and www (to Firefox).
So far, all I know how to do is use xev to find the keycode to those buttons. I've also tried making a .Xmodmap script in my home directory. Where do I begin?

apachedude 11-28-2004 04:47 AM

I did some tinkering by myself using xev. It turned out that Microsoft Natural Keyboard Pro OEM better described the keys. I managed to map favorites, email, and www as I desired. However, how do I tell the master volume (KAmix?) from the command line to adjust the volume? I know from reading other sites that GNOME uses aumix-minimal with various switches. But I have no idea how to run a shell command to lower the volume in KDE.

apachedude 11-28-2004 05:16 PM

I have almost everything working now, except for the single Win key to pop up the Start Menu. Just in case anyone else wants to know how I did this:
I changed my Logitech's keyboard layout to Microsoft Natural Keyboard Pro OEM, which actually fits the keys better.
I then opened KHotKeys. I mapped www (XF86HomePage) to "firefox", email (XF86Mail) to "thunderbird", favorites (XF86Fav) to "konqueror file:'~'", volume to "amixer set Master 1+" and "1-" respectively, mute to "amixer set Master toggle", and play/pause to "xmms -t". I left media alone for now because I have no reason to use it.

Again, if anyone knows how to map the Win key to pop up the start menu (a single-key shortcut, not a two-key combo), please let me know!

hazza 12-06-2004 05:22 AM

One way to map the Win key to open the launch menu involves using xmodmap to define the symbol for it to F13. You can do this in ~/.Xmodmap:

Code:

!~/.Xmodmap
!
keycode 115 = F13

Then you just have to go into Keyboard Shortcuts in Control Center and then define "Popup Launch Menu" to the left Win key. Somehow in Mandrake 10 the Win keys popup the launch menu and the audio multimedia keys use hooks into kmix to change the volume. I looked into the dcop hooks in kamix to and didn't find anything there. Hopefully the developer of kamix will expose dcop hooks to at least allow the master volume level changed using something like khotkeys [edit: it looks like the latest version of kamix might have the required hooks].

apachedude 12-06-2004 02:32 PM

Hazaa, thanks for the help, but I had tried this previous. What still happens is that I open Keyboard Shortcuts in the KDE menu, and when I press the left Win button (keycode 115), it still flashes "Win+" for a split second, clearly expecting a two-key combo. Then because I let go without pressing a second key, it goes away from the screen.

ColBond 12-06-2004 05:05 PM

Been following this thread because I've been trying to do a similar thing with my LX700. I'm curios how you can map a button to just a random button combination. Like I want the zoom keys to send Ctrl+ and Ctrl-. and the forward and back to do Alt left and Alt right.

Thanks
Matt W

hazza 12-06-2004 10:16 PM

Quote:

when I press the left Win button (keycode 115), it still flashes "Win+" for a split second, clearly expecting a two-key combo.
It looks like even though xmodmap is configured to define keycode 115 (Win key) as F13 it is being overriden elsewhere. It might just be that you have to select your keyboard layout in /etc/X11/XF86Config and leave "Enable keyboard layouts" under Keyboard Layout in the Control Center unchecked. This means that you have to find the keyboard section in /etc/X11/XF86Config and set the model in there.

eg

Code:

Section "InputDevice"
  Driver      "Keyboard"
  Identifier  "Keyboard[0]"
  Option      "Protocol" "Standard"
  Option      "XkbLayout" "us"
  Option      "XkbModel" "logidak"
  Option      "XkbRules" "xfree86"
EndSection

You will have to change the XkbModel option to that of your keyboard. The list of model names and keyboard descriptions is in /etc/X11/xkb/rules/xfree86.lst. So mine can be found by doing something like:

Code:

$ grep "Logitech Deluxe Access Keyboard" /etc/X11/xkb/rules/xfree86.lst
  logidak      Logitech Deluxe Access Keyboard

Then restart X and check if the left Win key has been defined as F13 as per ~/.Xmodmap.

hazza 12-07-2004 12:19 AM

Quote:

Been following this thread because I've been trying to do a similar thing with my LX700. I'm curios how you can map a button to just a random button combination. Like I want the zoom keys to send Ctrl+ and Ctrl-. and the forward and back to do Alt left and Alt right.

Thanks
Matt W
I haven't actually defined any of the multimedia keys to multiple key combinations myself. My suggestion would be first to find out what the keycode the keys you mentioned generate when you press them by using xev.

An extract from the output of xev when I press Messenger multimedia key on my Logitech Access Keyboard is:


KeyRelease event, serial 28, synthetic NO, window 0x3600001,
root 0x38, subw 0x0, time 8852489, (833,-215), root:(838,434),
state 0x0, keycode 236 (keysym 0x0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes: ""


The part to look for is a keycode that has no symbol assigned to it. You can then use xmodmap to define the keys:

! ~/.Xmodmap
!
keycode xxx = XF86ZoomIn
keycode xxx = XF86ZoomOut
keycode xxx = XF86Back
keycode xxx = XF86Forward

Fill in the the blanks with the keycode that xev shows when you press those keys. You might note in the above post about how loading a keyboard layout in KDE will override any settings made with xmodmap.

Once you have the those keys defined it then becomes a matter of getting defining your application shortkey keys to them. In KDE there's an Application Shortcuts tab under Keyboard Shortcuts. I remember that GNOME had an equivalent place to change the settings. I can't remember if you can define an second alternative for the same action in GNOME though.

It might also be worthwhile creating a keyboard layout for your LX700 (Logitech Cordless Desktop LX700 I presume). I could come up with a template of a patch to add the layout but first I'd need a decent photo of the keyboard in which I can actually see and read the description under each multimedia key.

ColBond 12-07-2004 12:02 PM

If that's not too much work/trouble, it would be really great. My AIM is ColBondMW, other ways of getting ahold of me are in my profile.

maorc 12-08-2004 08:45 PM

xev not responding to multimedia buttons
 
I use the Microsoft Multimedia Natural Keyboard, and I too try to assign the multimedia buttons to work appropriately.
With xev I can only see some of the buttons responding, and when I switch between different Keyboard Layouts, I get different buttons responding.
How can I make all buttons work?

I am sure that it is worthwhile creating a Keyboard Layout for the this keyboard because it is one of the most popular natural keyboards in the market.

Thanks,
Maor

hazza 12-09-2004 05:03 AM

Quote:

I use the Microsoft Multimedia Natural Keyboard, and I too try to assign the multimedia buttons to work appropriately.
With xev I can only see some of the buttons responding, and when I switch between different Keyboard Layouts, I get different buttons responding.
How can I make all buttons work?

I am sure that it is worthwhile creating a Keyboard Layout for the this keyboard because it is one of the most popular natural keyboards in the market.

Thanks,
Maor
This is what a patch I created to add one of my keyboards to SUSE 9.1 looks like:
Code:

--- xkb/rules/xfree86.orig        2004-08-23 17:07:00.000000000 +0930
+++ xkb/rules/xfree86        2004-12-09 18:52:35.925979920 +1030
@@ -113,6 +113,7 @@
              rapidaccess rapidaccess2 rapidaccess2a \
              ltcd logiaccess logicdp logicdpa logicink logiciink \
              logiinkse logiinkseusb logiik itouch \
+              logidak \
              mx1998 mx2500 mx2750 \
              microsoftinet microsoftpro microsoftprooem microsoftprose \
              microsoftoffice microsoftmult \
--- xkb/rules/xfree86.lst.orig        2004-04-06 11:38:40.000000000 +0930
+++ xkb/rules/xfree86.lst        2004-10-29 15:21:33.271871456 +0930
@@ -74,6 +74,7 @@
  logiaccess        Logitech Access Keyboard
  logicink        Logitech Internet Navigator Keyboard
  logiciink        Logitech iTouch Internet Navigator Keyboard
+  logidak        Logitech Deluxe Access Keyboard
  logiinkse        Logitech iTouch Internet Navigator Keyboard SE
  logiinkseusb        Logitech iTouch Internet Navigator Keyboard SE (USB)
  logiik        Logitech Internet Keyboard
--- xkb/symbols/inet.orig        2004-04-06 11:38:39.000000000 +0930
+++ xkb/symbols/inet        2004-10-29 15:29:15.649579360 +0930
@@ -1220,6 +1220,15 @@
    key <I16>        {        [ XF86ScrollClick        ]        };
 };
 
+partial alphanumeric_keys
+xkb_symbols "logidak" {
+    name[Group1]= "Logitech Deluxe Access Keyboard";
+
+    key <I32>  {      [ XF86WWW              ]      };
+    key <I6C>  {      [ XF86Mail              ]      };
+    key <I65>  {      [ XF86Search            ]      };
+};
+
 partial alphanumeric_keys
 xkb_symbols "logiinkse" {
    name[Group1]= "Logitech iTouch Internet Navigator Keyboard SE";
--- xkb/symbols.dir.orig        2004-08-23 17:07:35.000000000 +0930
+++ xkb/symbols.dir        2004-10-29 15:16:55.952030480 +0930
@@ -544,6 +544,7 @@
 --p----- a------- inet(logicdpa)
 --p----- a------- inet(logicink)
 --p----- a------- inet(logiciink)
+--p----- a------- inet(logidak)
 --p----- a------- inet(logiinkse)
 --p----- a------- inet(logiinkseusb)
 --p----- a------- inet(logiik)
@@ -739,6 +740,7 @@
 --p----- a------- inet.fixes(logicdpa)
 --p----- a------- inet.fixes(logicink)
 --p----- a------- inet.fixes(logiciink)
+--p----- a------- inet.fixes(logidak)
 --p----- a------- inet.fixes(logiinkse)
 --p----- a------- inet.fixes(logiinkseusb)
 --p----- a------- inet.fixes(logiik)
@@ -959,6 +961,7 @@
 --p----- a------- inet.xkb-cherryblueb(logicdpa)
 --p----- a------- inet.xkb-cherryblueb(logicink)
 --p----- a------- inet.xkb-cherryblueb(logiciink)
+--p----- a------- inet.xkb-cherryblueb(logidak)
 --p----- a------- inet.xkb-cherryblueb(logiinkse)
 --p----- a------- inet.xkb-cherryblueb(logiinkseusb)
 --p----- a------- inet.xkb-cherryblueb(logiik)

That patch is for the Logitech Deluxe Access Keyboard model. From that you can see that the files modified are:
  • /etc/X11/xkb/rules/xfree86 (file name may be xorg)
  • /etc/X11/xkb/rules/xfree86.lst (file name may be xorg.lst)
  • /etc/X11/xkb/symbols/inet
  • /etc/X11/xkb/symbols.dir

Make a backup copy of each of those files by adding a suffix like ".orig" so when you're done you can create a patch by running "gendiff xkb .orig >xkb-keymodel.patch".

You need to pick a one word model name, which was logidak in my case, and add a line with that in the files where I added a line. The main part of mapping the keycodes the multimedia keys to key symtols is in xkb/symbols/inet.


partial alphanumeric_keys
xkb_symbols "logidak" {
name[Group1]= "Logitech Deluxe Access Keyboard";

key <I32> { [ XF86WWW ] };
key <I6C> { [ XF86Mail ] };
key <I65> { [ XF86Search ] };
};


Change your keyboard layout to "Generic 104-key PC" so the multimedia keys will be easier to spot in xev. The multimedia keys you can map to key symbols will show up with keycodes but without key symbols in xev. For example:

KeyRelease event, serial 28, synthetic NO, window 0x3400001,
root 0x38, subw 0x0, time 34880040, (557,384), root:(562,410),
state 0x0, keycode 236 (keysym 0x0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes: ""


For keycodes above 128 you can convert them to "I" key numbers by subtracting 128 and then converting the answer to hexadecimal:


I_number = keycode - 128
= 236 - 128
= 108 (0x6C)


On my logidak keyboard the key that generated that keycode was the Mail multimedia key so I chose to map it to XF86Mail. I found key symbols that match the multimedia keys by searching through xkb/symbols/inet. When you've finished all the changes make a patch by doing the following in /etc/X11:

Code:

# gendiff xkb .orig
That way next time you upgrade X you can reapply the patch and won't lose the new keyboard layout you've created.

maorc 12-09-2004 09:21 PM

Cool. I got half the buttons to work.
The other half do not do respond in xev on the "Generic 104-key PC" layout. Any idea how to identiry those?

Thanks!

PS. When I am done, is there a place that I can submit my patch, so it would be available on the internet, and on the next version of Suse? (and maybe other distributions)

hazza 12-09-2004 10:37 PM

Quote:

Originally posted by maorc
Cool. I got half the buttons to work.
The other half do not do respond in xev on the "Generic 104-key PC" layout. Any idea how to identiry those?

Thanks!

PS. When I am done, is there a place that I can submit my patch, so it would be available on the internet, and on the next version of Suse? (and maybe other distributions)
My keyboard doesn't have multimedia keys that don't generate key events so I haven't had to deal with that problem yet. That problem does look similar to what's said in Bug 320 - Keymapping for MS natural USB keyboard. My method of mapping the multimedia keys needs keycodes to be reported so you might have to wait until X is patched to report them.

You could submit the patch to add support for the multimedia keys of your keyboard model at freedesktop.org Bugzilla against xorg. With SUSE you could try submitting it through their feedback page.

hazza 12-22-2004 10:17 AM

I've now noticed that under a 2.6.x version of the kernel I have the same problem of multimedia keys not having keycodes. Whenever one of these keys is pressed the kernel prints a message:

Code:

Dec 23 01:33:55 sonic kernel: Count = 1 Count = 1 Count = 1 Count = 1 Count = 1 Count = 1 <4>atkbd.c: Unknown key pressed (translated set 2, code 0x91 on isa0060/serio0).
Dec 23 01:33:55 sonic kernel: atkbd.c: Use 'setkeycodes e011 <keycode>' to make it known.
Dec 23 01:33:55 sonic kernel: atkbd.c: Unknown key released (translated set 2, code 0x91 on isa0060/serio0).
Dec 23 01:33:55 sonic kernel: atkbd.c: Use 'setkeycodes e011 <keycode>' to make it known.

The message suggests using setkeycodes to map the scancode listed to a keycode but I haven't had any success with it yet.

TheVisionary 12-24-2004 03:25 AM

Hello,

I am also trying to setup a media USB keyboard and found that some keys don't show anything.
Maybe this info can help:
http://www.tcnj.edu/~tolboom2/globlink_rf88.html

Although I have the same keyboard, I am such a newbe I don't even know what to with this :-(


All times are GMT -5. The time now is 09:06 PM.