LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Changing keyboard output in X (https://www.linuxquestions.org/questions/linux-newbie-8/changing-keyboard-output-in-x-656013/)

krisbee 07-15-2008 07:25 PM

Changing keyboard output in X
 
I am building a stand up arcade machine. Buttons on the control panel equal certain keys... however, I would like to change these keys.

I can modify the keymap in X, or use xmodmap.. but, I also have a second usb keyboard attached...

So, if I change "9" to "Enter" using xmodmap, well, that will change it for both keyboards, won't it? Is there another way that you can direct me to make this change without making it global?

Thanks in advance,
Kris

krisbee 07-16-2008 04:54 PM

No ideas? Should I move the post?

JZL240I-U 07-17-2008 03:39 AM

Aren't there multiple sections [keyboard] in xorg.conf allowed?

krisbee 07-17-2008 06:26 AM

Well, I have multiple mice listed (which is correct, I have two pointer devices), but under keyboard, only one is listed, even though both "keyboards" work the same..

It seems that I can define it, but now I have to know what /dev/input/event each one is... how can I determine that. More importantly, how can I lock that in stone with HAL rules...

JZL240I-U 07-17-2008 06:54 AM

Quote:

Originally Posted by krisbee (Post 3217498)
Well, I have multiple mice listed (which is correct, I have two pointer devices), but under keyboard, only one is listed, even though both "keyboards" work the same.

Sometimes it gets actualized when you plug in the second (USB) keyboard. Just have a look then...

Quote:

Originally Posted by krisbee (Post 3217498)
It seems that I can define it, but now I have to know what /dev/input/event each one is... how can I determine that. More importantly, how can I lock that in stone with HAL rules...

You can browse /dev and find it there. It's not cast in iron ;) in HAL but by udev(d):

udev - writing rules
UDEV Customizing - Gentoo Linux Wiki
udev man pages
udev-FAQ

krisbee 07-17-2008 04:22 PM

Quote:

Sometimes it gets auctualized when you plug in the second (USB) keaboard. Just have a look then...
Nope, nothing shows up in my xorg.conf (or in my Mandriva Control Center, either)... but, it just works. So, it looks like I will have to make an entry in xorg.conf, huh ? :)

JZL240I-U 07-18-2008 01:28 AM

Quote:

Originally Posted by krisbee (Post 3218059)
Nope, nothing shows up in my xorg.conf (or in my Mandriva Control Center, either)... but, it just works.

Pity. Is there any xorg.conf~ or xorg.conf.old you might try?

Quote:

Originally Posted by krisbee (Post 3218059)
So, it looks like I will have to make an entry in xorg.conf, huh ? :)

Indeed. That has to be aligned with the udev rule, though.

krisbee 07-20-2008 06:49 PM

So, here is my udev rule (10-keyboardrules under /etc/udev/rules.d)

BUS=="serio", SYSFS{description}=="i8042 Kbd Port", NAME="%k", SYMLINK+="keywiz"

However, this does not make a /dev/keywiz ...it doesn't do anything :(

What am I doing wrong? I have rebooted several times (I know you don't have to, but I did just to make sure)..

The 1st keyboard is always showing up under /dev/input/event0 but the usb keyboard may not always show in the right place, so I would like two normal named /dev entries...

JZL240I-U 07-21-2008 05:22 AM

Good question, but I am wayyy out of my depth here. Perhaps reposting with a new subject as to attract more knowledgeable people with udev experience?

smoked kipper 07-21-2008 12:19 PM

Quote:

Originally Posted by krisbee (Post 3220990)
So, here is my udev rule (10-keyboardrules under /etc/udev/rules.d)

BUS=="serio", SYSFS{description}=="i8042 Kbd Port", NAME="%k", SYMLINK+="keywiz"

However, this does not make a /dev/keywiz ...it doesn't do anything :(

What am I doing wrong? I have rebooted several times (I know you don't have to, but I did just to make sure)..

The 1st keyboard is always showing up under /dev/input/event0 but the usb keyboard may not always show in the right place, so I would like two normal named /dev entries...

I don't think you can reference the serial port in this way, udev can only create symlinks to devices with nodes in /dev, but the keyboard port itself doesn't have its own node, only the device that provides the port does (i.e. the usb keyboard device). Try changing the BUS to usb and matching some line in the SYSFS attributes for the keyboard itself.

Alternatively, you can see your device list in /proc/bus/input/devices. It should be easy enough to parse this to find the event node.

Something like this should do (as you have multiple keyboards, replace "keyboard" with the actual name):

Code:

grep -A6 keyboard /proc/bus/input/devices | sed -n 's/^.*\(event[^ ]\+\)/\1/p'
You'll notice that all keyboards are bound to the kbd handler. If you are writing your own code, you can grab the device using input_device_grab (doesn't seem to be a man page for this, just look in the kernel source, (<src>/drivers/input)), the handlers will be bypassed and the process doing the grabbing will have exclusive access to the device, so you can handle the key events any way you like, though this will bypass X of course.

As for X, having multiple seperate keyboards in X should be possible now, but I haven't looked into it much. You need to use the "kbd" driver instead of the "keyboard" driver (see kbd(4), xorg.conf(5)).

krisbee 07-21-2008 04:24 PM

Quote:

I don't think you can reference the serial port in this way, udev can only create symlinks to devices with nodes in /dev, but the keyboard port itself doesn't have its own node, only the device that provides the port does (i.e. the usb keyboard device). Try changing the BUS to usb and matching some line in the SYSFS attributes for the keyboard itself.

Alternatively, you can see your device list in /proc/bus/input/devices. It should be easy enough to parse this to find the event node.
Part of the problem is that my keyboard is a ps/2 (event0), and the usb keyboard will show up as event4... however, if I unplug it, reboot, it may not.

The first udev rule I was creating was for the ps/2 keyboard, to come up with a constant /dev entry for that one... then I was going to tackle the usb keyboard next. Since I failed with this one, this is as far as I got.

I looked and the udev rule I created was the best SYSFS attribute I found. It does look like the kernel is using the KBD driver...

smoked kipper 07-23-2008 11:06 AM

Quote:

Originally Posted by krisbee (Post 3221956)
Part of the problem is that my keyboard is a ps/2 (event0), and the usb keyboard will show up as event4... however, if I unplug it, reboot, it may not.

The first udev rule I was creating was for the ps/2 keyboard, to come up with a constant /dev entry for that one... then I was going to tackle the usb keyboard next. Since I failed with this one, this is as far as I got.

You probably don't need to worry about the ps/2 keyboard, since presumably this is your main keyboard. Just concetrate on the usb keyboard.

Quote:

I looked and the udev rule I created was the best SYSFS attribute I found.
Are you looking at the USB device? The "serio" device is the wrong thing to look at.

Quote:

It does look like the kernel is using the KBD driver...
I meant the kbd driver in X. The kernel kbd driver is unrelated. The kernel uses the 'kbd' driver/handler for all keyboards. If you want multiple keyboards in X, you need the kbd driver instead of the default "keyboard" driver, which can only handle 1 keyboard.

krisbee 07-23-2008 07:30 PM

Quote:

You probably don't need to worry about the ps/2 keyboard, since presumably this is your main keyboard. Just concetrate on the usb keyboard.
Well, since I need to specify the device in my xorg.conf, I have been concentrating on the ps/2 keyboard. The reason is I need to change the keys of that keyboard to equal something else (ex, the ESC key working from the F key, etc.) The USB keyboard I will need a normal US configuration. I figured once I got the ps/2 keyboard set on a device, I can work from there (or should I just always assume it will be event0?)

smoked kipper 07-25-2008 09:31 AM

Ah, OK. Well, it will probably always be event0 since the ps/2 port is scanned before usb, but it's probably not a good idea to rely on it, so yeah, continue with the configuration. I've meaning to post the udev rules for my usb keyboard, but I keep forgetting. I'll dig them out when I get home.

krisbee 07-27-2008 07:37 PM

Quote:

Originally Posted by smoked kipper (Post 3226075)
I've meaning to post the udev rules for my usb keyboard, but I keep forgetting. I'll dig them out when I get home.

Any luck with your udev rules?


All times are GMT -5. The time now is 10:41 PM.