LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 07-15-2008, 07:25 PM   #1
krisbee
Member
 
Registered: Jan 2006
Posts: 60

Rep: Reputation: 15
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
 
Old 07-16-2008, 04:54 PM   #2
krisbee
Member
 
Registered: Jan 2006
Posts: 60

Original Poster
Rep: Reputation: 15
No ideas? Should I move the post?
 
Old 07-17-2008, 03:39 AM   #3
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 13.1 / 12.3_64-KDE, Ubuntu 14.04, Fedora 20, Mint 17, Chakra
Posts: 3,644

Rep: Reputation: Disabled
Aren't there multiple sections [keyboard] in xorg.conf allowed?
 
Old 07-17-2008, 06:26 AM   #4
krisbee
Member
 
Registered: Jan 2006
Posts: 60

Original Poster
Rep: Reputation: 15
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...
 
Old 07-17-2008, 06:54 AM   #5
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 13.1 / 12.3_64-KDE, Ubuntu 14.04, Fedora 20, Mint 17, Chakra
Posts: 3,644

Rep: Reputation: Disabled
Quote:
Originally Posted by krisbee View Post
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 View Post
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

Last edited by JZL240I-U; 07-18-2008 at 01:25 AM.
 
Old 07-17-2008, 04:22 PM   #6
krisbee
Member
 
Registered: Jan 2006
Posts: 60

Original Poster
Rep: Reputation: 15
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 ?
 
Old 07-18-2008, 01:28 AM   #7
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 13.1 / 12.3_64-KDE, Ubuntu 14.04, Fedora 20, Mint 17, Chakra
Posts: 3,644

Rep: Reputation: Disabled
Quote:
Originally Posted by krisbee View Post
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 View Post
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.
 
Old 07-20-2008, 06:49 PM   #8
krisbee
Member
 
Registered: Jan 2006
Posts: 60

Original Poster
Rep: Reputation: 15
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...

Last edited by krisbee; 07-20-2008 at 07:40 PM.
 
Old 07-21-2008, 05:22 AM   #9
JZL240I-U
Senior Member
 
Registered: Apr 2003
Location: Germany
Distribution: openSuSE 13.1 / 12.3_64-KDE, Ubuntu 14.04, Fedora 20, Mint 17, Chakra
Posts: 3,644

Rep: Reputation: Disabled
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?
 
Old 07-21-2008, 12:19 PM   #10
smoked kipper
Member
 
Registered: May 2008
Location: UK
Distribution: Slackware,Slamd64
Posts: 81

Rep: Reputation: 15
Quote:
Originally Posted by krisbee View Post
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)).

Last edited by smoked kipper; 07-21-2008 at 12:27 PM.
 
Old 07-21-2008, 04:24 PM   #11
krisbee
Member
 
Registered: Jan 2006
Posts: 60

Original Poster
Rep: Reputation: 15
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...
 
Old 07-23-2008, 11:06 AM   #12
smoked kipper
Member
 
Registered: May 2008
Location: UK
Distribution: Slackware,Slamd64
Posts: 81

Rep: Reputation: 15
Quote:
Originally Posted by krisbee View Post
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.
 
Old 07-23-2008, 07:30 PM   #13
krisbee
Member
 
Registered: Jan 2006
Posts: 60

Original Poster
Rep: Reputation: 15
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?)
 
Old 07-25-2008, 09:31 AM   #14
smoked kipper
Member
 
Registered: May 2008
Location: UK
Distribution: Slackware,Slamd64
Posts: 81

Rep: Reputation: 15
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.
 
Old 07-27-2008, 07:37 PM   #15
krisbee
Member
 
Registered: Jan 2006
Posts: 60

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by smoked kipper View Post
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?
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to redirect keyboard as well as output ackzsel Linux - General 2 10-04-2007 09:16 AM
changing uname -r output kesari Red Hat 2 11-04-2004 05:20 AM
Keyboard output buffer Majestros Linux - Hardware 0 07-06-2004 09:01 AM
Changing the output of lspci GT_Onizuka Linux - General 2 04-30-2004 05:50 PM
Changing the color of ls output? exitsfunnel Linux - Newbie 1 02-19-2004 11:20 PM


All times are GMT -5. The time now is 03:43 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