Read 1 of 2 keyboards connected


 
Thread Tools Search this Thread
Top Forums Programming Read 1 of 2 keyboards connected
# 1  
Old 09-03-2016
Linux Read 1 of 2 keyboards connected

Hi all experts in linux and programming!

I want to make work the following setup:
2 usb keyboards connected to a normal x86
One keyboard working as usual in xorg, but I need that the other one doesn't send anything to xorg but instead I want to process its keystrokes with some kind of background process.

How can it be done? Smilie
# 2  
Old 09-04-2016
Quote:
Originally Posted by SerKan
2 usb keyboards connected to a normal x86
One keyboard working as usual in xorg, but I need that the other one doesn't send anything to xorg but instead I want to process its keystrokes with some kind of background process.
First a bit of theory: you communicate with a UNIX system by using a "tty": a "terminal" consisting of a keyboard and a screen, usually connected via a serial line.

If you connect to a UNIX system over a network you use a so-called "terminal emulator program" (many times "xterm", but that is not the only one) to emulate such a terminal and its serial connection is emulated via the network connection.

There is a special form of a tty, which is called console. This is not connected via the standard serial line but directly attached to the computer. Perhaps the local screen attached to your VGA-card and the (first) keyboard form this console.

Now, after that much theory, to your specific question: this might work, but not necessarily with a USB-attached keyboard and definitely not with a background process. Background processes are part of a process hierarchy, headed by some foreground process: this is usually the shell from which you initiated the background process, typically by issuing the command:

Code:
$ /path/to/command -someoptions &

Since the shell you typed that in was already connected to some tty (the one which keyboard you used to type it, probably the console) the background process inherited this connection. You can cut it off from this (by using the nohup command) but per default itis attached to the one you used to call it. Furthermore, a single USB-attached keyboard is not a terminal.

I hope this helps.

bakunin
This User Gave Thanks to bakunin For This Post:
# 3  
Old 09-05-2016
There are devices such as bar code readers that can be connected to act like a keyboard. So - in principle, I guess your request should be doable, while I don't have a solution at hand.
Does it make sense to connect a keyboard without a screen enabling people control over what they typed in?
# 4  
Old 09-05-2016
Before attempting ANYTHING that hits the hardware hard, read up on any protocols required for the USB ports, plus how they work and this includes the keyboard and mouse for those ports too. KB and mouse use USB version 1.1, [1.0?], minimum and do not require I/O speeds greater than about 1.5Mbs data rate.

In Linux flavours, or at least most, there are __accessable__ devices that can be read from and/or written to. I have no idea if this is true of professional UNIX tools however. The protocol for the keyboards being sent and received can be read easily using basic code in differing languages but not necessarily sync'd at all. The data being sent by the KB has many bytes in it in binary form; the same goes for the pointing device,(mouse).

Writing to a USB port via one of these devices is not the same animal however.

Unless you have at least studied how this/these __serial__ interfaces work be careful as they are __effectively__ in __parallel__. As bakunin has implied these could be allocated tty[?] device names in the UNIX domain but can be COM[?], usually COM1 and COM2 for KB and mouse respectively, in the Windows domain, but I have no idea what they are in the Apple OSX !0.7.x and above domain, perhaps also tty[?]. The Linux domains could be special devices and/or tty[?].

IMO it is certainly not an easy task for a novice to intercept a second KB's I/O and redirect from its main duty as user input on any machine in question.

(I would like to be proven wrong however.)

Bazza.
# 5  
Old 09-05-2016
I can't say anything about Linux, but in FreeBSD it would not be really hard.

You just have to tell devd (and possibly Xorg) to ignore that specific keyboard. If can do that, you are free to read /dev/ukbd0 (or ukbd1) as you please. What you get from there might be ascii or scancodes, or you might be able to choose.

It should be similar in Linux, devd is called udev there, I think.

Juha
This User Gave Thanks to Juha Nurmela For This Post:
# 6  
Old 09-05-2016
Here is a snapshot of reading KB event6 in Ubuntu 16.04 64 bit...
It is in /dev/input/ ...
As I quoted in most Linux flavours reading is easy, understanding the protocol is NOT!
As you can see with this snapshot of the 'Ubuntu Terminal', to run it from the '/dev/input/' directory requires 'sudo'...
sudo cat event6
Note there were only 3 keys pressed and 1 combination of keys...
Now see how difficult it is to monitor any KB knowing its device, just think how difficult it is if you have disabled said KB and required data from it.
Read 1 of 2 keyboards connected-ubuntu-1604-64jpg
# 7  
Old 09-05-2016
Okay, I was assuming too much.

Juha
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. IP Networking

Connected to IANA anyway, why?

May someone can answer this. Anytime I ignite my laptop to go online I see via etherape that I am connected to IANA as shown below. Is my provider redirecting me there, the cable under the sea, what is the reason for this? This happened with a pretty normal desktop PC, as well with my ancient... (2 Replies)
Discussion started by: 1in10
2 Replies

2. OS X (Apple)

How to see connected macs through terminal?

Been a while since I've been here; I have my iMac and MBpro connected via firewire, and they can see each other when I open the finder windows. But I'd like to be able to 'see' each computer on the other via the terminal application; and I can't see them right now. I can transfer files via the... (0 Replies)
Discussion started by: Straitsfan
0 Replies

3. UNIX for Dummies Questions & Answers

Ftp showing connected only

hi, good morning. Anyone can help me out. A trying to ftp from server A to server B. from server A to B its working fine but from server B to A, its only showing connected only: finap7 #ftp 10.10.10.210 Connected to 10.10.10.210. I refresh the inetd but nothing is happening. Please... (1 Reply)
Discussion started by: kamaldev
1 Replies

4. UNIX for Dummies Questions & Answers

Non Internet connected distribution

Hi all I've been a Debian user since solidly since about 1997 so I'm fairly experienced Linux user as a whole but unfortunately the monoculture has hit be hard recently. I'm working off a Laptop a lot of the time which spends up to 2-4 weeks without an Internet connection. A few weeks ago it... (1 Reply)
Discussion started by: pointyhat
1 Replies

5. IP Networking

Am I Connected?

Be Gentle folks, I am a baby OpenSuSe 11.2 user :-) In windows Vista, there is a world in the systray when you are Internet connected and not just local. I have searched all over for a .RPM for the Network Manager or another packeg in Suse that can show me the same thing or something close. ... (0 Replies)
Discussion started by: donmaxwelliii
0 Replies

6. AIX

How do I know to which storage I am connected

Hello everyone. We have a environment where we have DS8K storage and ES800 storage, the way to check to which storage the box is connected is using the LUN ID I get frm " pcmpath query device " command. for ex: 75CXX - DS8K storage 26860 - ES 800 Storage I was told to check... (4 Replies)
Discussion started by: nivaspIND
4 Replies

7. UNIX for Advanced & Expert Users

linux connected to as400

we have a as400 5rev4 and want to use a rhel server to use as a file server. We exported a drive on the rhel box and then mounted it on the as400. We can see the top directory in our mounted as400 directory but when we attempt access subdirectories we get a no matching object error. When we open... (2 Replies)
Discussion started by: javagair
2 Replies

8. IP Networking

check whether connected to network

hi... can anyone pls suggest a few methods to check whether a computer is connected to any network, using the terminal, not GUI. thanks eskay (1 Reply)
Discussion started by: eskay_karthik
1 Replies

9. Programming

Connected or not connected !

Hello ! I've got a question . I really don't het this point. Let's supose that I have a client connected to a server. I want the server IMEDIATLY know if the client is diconnected . How can I realize this ? :mad: Amd I'm just curios about one thing. I have a server and multiple clients... (3 Replies)
Discussion started by: !_30
3 Replies

10. AIX

How can I get Information about who is connected???

Hello, I'm new here and I come from Germany. At our AIX-ORACLE-System someone has deleted one important file and we'd like to find out who did this, next time. Is there any command to find out who is connected? I'm not trying to find out if it's root, etc., I'd like to get the DNS-Name or... (3 Replies)
Discussion started by: Huch
3 Replies
Login or Register to Ask a Question