What can I do for use multimedial key with Xvesa???

Using applications, configuring, problems
Post Reply
Message
Author
tone
Posts: 28
Joined: Sun 25 Jul 2010, 22:42

What can I do for use multimedial key with Xvesa???

#1 Post by tone »

Hello! I use puppy 4.3 and logitech ex110 (cordless USB)
If I use puppy with Xorg: if I press "play" key, in xev I see keycode 162. if I press "stop" key, in xev I see keycode 164.
Then I create /root/.Xmodmap and insert this line:
keycode 124 = XF86AudioPlay

in shell I execute:
xmodmap /root/.Xmodmap

in /root/.jwm/jwmrc-personal insert:
<Key key="XF86AudioPlay">root:3</Key>

If I press play key, it open menu (I use play key for open menu for understand the system)
that's OK!

...........but...
If I use puppy with Xvesa, if I press play or stop key, the keycode with xev
is 8 (also rewind and forward) :(

What can I do for use multimedial key with Xvesa???

With "showkey" I see that the keycode of play key is 164
I see getkeycodes, I prove setkeycodes.. but nothing

PS With Xorg I see the use of file and directroy in /etc/X11/

THANKS!!!

tone
Posts: 28
Joined: Sun 25 Jul 2010, 22:42

#2 Post by tone »

I have also Belkin Keypad that has a Mute, down volume, up volume, play, stop, rewind and other keys.
The only ones that are detected with xev (Puppy run with Xvesa) are :
key: mute - keycode: 121
key: - volume - keycode: 122
key: +volume - keycode: 123
Also logitech ex110 keyboard is the same: detect only this multimedia keys!
For this keys, it's ok, but I can't use play, stop, rewind and other multimedia keys! :(

What can I do for detect play, stop,rewind and other multimedia keys with Xvesa???

Thanks!!

tone
Posts: 28
Joined: Sun 25 Jul 2010, 22:42

#3 Post by tone »

XORG
When i wrote:
"keycode 124 = XF86AudioPlay"
it's wrong, because is
"keycode 162 = XF86AudioPlay"

XVesa
If i press all key of keyboard I see that the keycode is minor of 127.
Perhaps Xvesa don't understand keycode greater then 127 and pheraps the keycode of Play, Stop and other multimedia keys are greater then 127 and so It's impossible use this key with Xvesa!! :(

What do you think about???
It's many days then I prove, but ...no results!!! :(
What can I do for detect play, stop,rewind and other multimedia keys with Xvesa???

npierce
Posts: 858
Joined: Tue 29 Dec 2009, 01:40

#4 Post by npierce »

The Xvesa server, being a member of the TinyX family of X servers is designed to be small. So it doesn't have a lot of the features that the full Xorg server does. The full keymap support available in the Xorg server is missing from the Xvesa server.

But that doesn't mean that you are out of luck. You can probably get your keys to work, but it will take a bit of work. Apparently you have already done some of that work by installing a few utilities that probably did not come with your Puppy: showkey, setkeycodes, getkeycodes, and xev.

(For the benefit of others who might like to try this, I should point out what you may have already discovered: If you use BusyBox's showkey and setkeycodes functions you may have problems, since they don't seem to work properly with multi-byte scancodes (at least in BusyBox v1.15.0.svn). You need to use the real utilities.)

When using Xorg instead of Xvesa, the keycodes are loaded from files in the /etc/X11/xkb/ directory tree. (Some of the keycodes -- for keys with single-byte scancodes (mostly for character keys, function keys, and others from the old 83-key or 84-key keyboards of the early 1980's) -- seem to be based upon the keycodes used by the kernel. For these keys it seems that 8 was added to the kernel keycode to define the Xorg keycode. Other keycodes -- like those for navigation and multimedia -- seem to have no relation to the keycodes used by the kernel.)

The original IBM PC keyboard had 83 keys. Each key had a single-byte scancode. There were 127 possible scancodes for a "key-down" event, and 127 possible scancodes for a "key-up" event, which was more than enough. The SysReq key was later added to create the 84-key keyboard; it also got a single-byte scancode (84). When another character key was added (next to the left Shift key) for European keyboards and F11 and F12 were added to the already existing F1 through F10, the new scancodes were also single-byte scancodes for consistency. But when new groups of navigation keys (like the arrow keys) and other special keys were added, someone realized that the day might come when they would run out of single-byte scancodes. So the double-byte scancode was invented and assigned to those keys, using 224 (0xE0) as the first byte to distinguish them from single-byte scancodes. Most new keys, like your Play and Stop buttons, also use double-byte scancodes.

Having a mixture of single-byte and double-byte scancodes complicates things, so the Xorg keyboard driver converts double-byte scancodes into its own set of single-byte keycodes ranging from 8 to 255. The single-byte scancodes are usually converted to keycodes by simply adding 8 to the scancode. The most common double-byte scancodes (Home, Up, PgUp, etc.) are assigned keycodes between 97 and 123, others are converted simply by adding 128 to the second byte. So, your Play button, which has a double-byte scan code with 34 (0x22) for the second byte, has 128 added to it to become 162 (as you reported in your first post). Keycodes from single-byte scancodes that would conflict with keycodes assigned to double-byte scancodes are assigned other values.

If that all sounds rather confusing, that's because it is. The Xvesa keyboard driver, being smaller and simpler, doesn't bother with all of that "if scancode is single-byte then add 8 unless it is 112 or 115 because that would make them conflict with keycodes 120 and 123 which have been assigned to two-byte scancodes" kind of stuff.

The kernel keyboard driver also converts scancodes into its own set of single-byte keycodes in the range of 1 to 247. Since the kernel has already done the work, the Xvesa keyboard driver uses the kernel's keycodes instead of the scancodes. To convert to its own keycodes it simply adds 8 to the keycodes that it gets from the kernel. So, your Mute button, which is given the keycode 113 by the kernel, has 8 added to it to become 121 (as you reported in your second post).

When using Xvesa, all of the keycodes seem to be created by adding 8 to the keycodes used by the kernel. (So some keycodes will be the same as for Xorg, while others will not.)

The problem is that (for unknown reasons) Xvesa seems to be unable to handle kernel keycodes above 127. So when you hit your Play key, Xvesa sees the kernel keycode of 164, doesn't know what to do, throws up its hands, and calls it zero. And after it adds the 8, it ends up with a keycode of 8 which you see when you run xev.

The work-around is to assign a different kernel keycode to it -- an unused keycode below 128.

(I should point-out here that if by some chance you use, for instance, your Play key for an application that runs in the text console, it will no longer work after you assign a different keycode. But if you only use that key in X, there should not be a problem.)

(Also, remember that the following is for use with Xvesa only; this is not the way to do things for Xorg.)

First, you need to find the scancodes of your keys. WARNING: Remember that you must run showkey from the text console, not from a terminal window in X (such as xterm or rxvt). If you try running showkey from X and are lucky, you will simply get an error message; if not it may get stuck in a loop causing you to loose control of your keyboard. So, from the text console, enter this:

Code: Select all

showkey -s
Press your Play key. It will generate two lines, something like this:

Code: Select all

0xe0 0x22
0xe0 0xa2
The first line (in this example, 0xe0 0x22) is the scancode for the keypress. You will need to wait ten seconds for showkey to exit. (Write these numbers down somewhere. After you change the keycodes showkey -s may not report the scancodes correctly. You will need to use the original numbers if you want to change the keycodes again.)

Second, you need to find an unused keycode below 128. I was going to give a long tedious explanation of how to do that using dumpkeys and getkeycodes, but instead I think I will just suggest some codes that should work for you unless you are using a Japanese keyboard: 90, 91, 92, and 93.

Third, using the text console you use setkeycodes to set new keycodes. For instance, my Play/Pause, Stop, Previous-Song, and Next-Song keys report the following double-byte scancodes: 0xe0 0x22, 0xe0 0x24, 0xe0 0x10, and 0xe0 0x19, respectively. To use these scancodes in a form that setkeycodes likes, I drop the "0x" prefix and join the remaining digits. And I set the four keycodes like this:

Code: Select all

setkeycodes e022 90
setkeycodes e024 91
setkeycodes e010 92
setkeycodes e019 93
[EDIT, 2012-Jan-04: Corrected "0e" to "e0" in above paragraph and code.]

Fourth, go back into X (Xvesa) and check the keys with xev. They should no longer be 8, and should all be different. Each should be the sum of 8 + the keycode you set with setkeycodes.

Fifth, create or edit /root/.Xmodmap so that the new keycodes will be assigned to the appropriate symbols. This is the same as you have already done for Xorg, but here you will be using the appropriate Xvesa keycode for each kernel keycode that you found with xev. In my case, I added these lines:

Code: Select all

keycode 98 = XF86AudioPlay XF86AudioPause
keycode 99 = XF86AudioStop
keycode 100 = XF86AudioPrev
keycode 101 = XF86AudioNext
Then run

Code: Select all

xmodmap /root/.Xmodmap
Remember that if you later decide to use Xorg, edit this file to use the proper Xorg keycodes. If you don't you will find that some of your keys will be confused. For instance, the up arrow may think that it is Play.

Sixth, edit /root/.jwm/jwmrc-personal to set the key bindings, just as you would when using Xorg. If you already have set the bindings to work with Xorg, you should not need to change it. You will need to restart JWM after running xmodmap, even if you don't need to change jwmrc-personal.

Seventh, when you have things working right, you will probably want to put the setkeycodes commands from step three in /etc/rc.d/rc.local so that the keycodes will be set whenever you boot. If you later go back to using Xorg, remember to remove those commands from rc.local or those keys won't work in Xorg. (There should be no need to put the xmodmap command anywhere as long as the map file lives at /root/.Xmodmap, since that command should already be in /usr/X11/lib/X11/xinit/xinitrc, which runs whenever X is started.)

Good luck.
Last edited by npierce on Wed 04 Jan 2012, 18:21, edited 1 time in total.

tone
Posts: 28
Joined: Sun 25 Jul 2010, 22:42

#5 Post by tone »

Thank you tor the excelent explanation!
I understand the reason when keycode of "play key" is 8.

For test I use
showkey : BusyBox
setkeycodes : real utility

I use text console (when start puppy select Xorg -> exit or menu-> setup ->xorg -> XorgWizard).
It's ok this text console?

In text console enter

Code: Select all

showkey -s
and I press Play key and the result is

Code: Select all

0xe0 0x22
0xe0 0xa2
then enter:

Code: Select all

setkeycodes 0e22 90 
but there's an error:

Code: Select all

KDSETKEYCODE: invalid argument
failed to set scancode e22 to keycode 90
then I enter:

Code: Select all

setkeycodes e022 90 
and there isn't error

I prove

Code: Select all

showkey -s
and I press Play key. the scancode is the same

I go in Xvesa (write startx in text console), but when I press "Play", in xev, keycode is still 8. I think is not ok, It should be 98 ( 90+8 ) ?

I can't continue the test :(

Many thanks
Bye

npierce
Posts: 858
Joined: Tue 29 Dec 2009, 01:40

#6 Post by npierce »

It has been almost a year since I logged in here. So my apologies for not getting back to you earlier.
tone wrote:I use text console (when start puppy select Xorg -> exit or menu-> setup ->xorg -> XorgWizard).
It's ok this text console?
Yes, it's ok. But I find it easier and less confusing to fully boot into X (in this case Xvesa), then use the function keys to switch back and forth between X and the text console. For instance, in Puppy 4.3.1 and probably others, Ctrl+Alt+F2 will bring you to a text console and Ctrl+Alt+F4 will bring you back to X. Use the left Alt key.
tone wrote:then enter:

Code: Select all

setkeycodes 0e22 90
but there's an error:

Code: Select all

KDSETKEYCODE: invalid argument
failed to set scancode e22 to keycode 90
Yes, sorry about that. I mistakenly transposed the 'e' and the '0'.
tone wrote:then I enter:

Code: Select all

setkeycodes e022 90
and there isn't error
Right. I'm glad you figured it out despite my mistake, and posted the correct code. I'll correct my earlier post for the benefit of anyone else that tries this.
tone wrote:I go in Xvesa (write startx in text console) . . .
Wait. If you got to the text console, as you said, by selecting Xorg and Exit, did running startx cause xorgwizard to run again, allowing you to choose Xvesa? In some cases it does; in other cases it doesn't. If it doesn't it will start Xorg, not Xvesa. Perhaps this is what went wrong? As you know (since you have already succeeded in getting your keys working with Xorg), Xorg expects different keycodes.

To get back into Xvesa you would need to run xorgwizard again, before running startx. Alternatively, you could run startx and then used Menu -> Setup -> Xorg Video Wizard to switch back to Xvesa. Perhaps you did that? If not, this could be why your Play key failed to work as expected.

Anyway, I suggest you try again using the function keys to switch to the text console and back to X. This way you can change keycodes without any need to restart the X server.

Shep
Posts: 878
Joined: Sat 08 Nov 2008, 07:55
Location: Australia

#7 Post by Shep »

npierce wrote:It has been almost a year since I logged in here. So my apologies for not getting back to you earlier.
His profile shows that tone has not logged in for almost a year, too. :?

Post Reply