Read 1 of 2 keyboards connected


 
Thread Tools Search this Thread
Top Forums Programming Read 1 of 2 keyboards connected
# 8  
Old 09-05-2016
Quote:
Originally Posted by wisecracker
Note there were only 3 keys pressed and 1 combination of keys...
If i remember correctly the original PC keyboard was built on the Intel MCS-48 microcontroller, namely the 8042, all PC hardware still reflects that. The mcirocontroller sends so-called "make-" and "break-codes" to the main computer, which basically reflect pressing and releasing a key. Scancodes tell which key exactly was pressed (at this level is i.e. possible to separate the left from the right SHIFT key being pressed, etc.)

In the original design (but i have long since stopped to update my PC hardware knowledge) it used not only the BIOS-interrupt 09h, it also controlled the A20 gate, which was done because of a bug in the 80286 design (it couldn't get back from protected to real mode without a reboot).

I hope this helps.

bakunin
# 9  
Old 09-06-2016
Quote:
Originally Posted by bakunin
If i remember correctly the original PC keyboard was built on the Intel MCS-48 microcontroller, namely the 8042, all PC hardware still reflects that. The mcirocontroller sends so-called "make-" and "break-codes" to the main computer, which basically reflect pressing and releasing a key. Scancodes tell which key exactly was pressed (at this level is i.e. possible to separate the left from the right SHIFT key being pressed, etc.)

In the original design (but i have long since stopped to update my PC hardware knowledge) it used not only the BIOS-interrupt 09h, it also controlled the A20 gate, which was done because of a bug in the 80286 design (it couldn't get back from protected to real mode without a reboot).

I hope this helps.

bakunin
See here:-
Usb_kb-io.
However we are not talking BIOS interrupts which are immaterial in this thread but HID USB protocols, disabling a USB port to re-enable it again, but, redirected to a background process. Not as easy task for the big guns let alone amateurs like me.
# 10  
Old 09-18-2016
Many thanks to all of you!
Now. I think you are overthinking the things.

Someone told something about a barcode scan reader and he got it -That is exactly my case.

I have my normal keyboard and also I have this barcode reader that enter text like a keyboard.

What I want is to read the text from the scanner in asynchronous mode and avoid this one mess with the real keyboard input that I want to let work as usual.

Why this thing has to be so complicated?
I don't think we have to deal with interrupts and all of that. It would need to be done in the unix way, by just reading files.
# 11  
Old 09-19-2016
Quote:
Originally Posted by SerKan
I have my normal keyboard and also I have this barcode reader that enter text like a keyboard.

What I want is to read the text from the scanner in asynchronous mode and avoid this one mess with the real keyboard input that I want to let work as usual.

Why this thing has to be so complicated?
I don't think we have to deal with interrupts and all of that. It would need to be done in the unix way, by just reading files.
Erm, now I am confused.
Your OP -
Quote:
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.
- so now you don't want 2 keyboards but a USB barcode scanner instead!?
The barcode scanner will probably have its own device _name_ inside the '/dev' drawer.
You will still need to know its protocol to extract the relevant data. You will have to research that part yourself.
To see the data coming from the barcode scanner you can start by using cat /dev/barcode_scanner_devicename but this might hang or do nothing as the I/O might just be another section in the '/dev' drawer; see post #6...

As I don't have a barcode scanner to test with then my reply has to be limited.
This User Gave Thanks to wisecracker For This Post:
# 12  
Old 09-20-2016
The barcode scanner works as a keyboard -That is one reason why at first I named them as 2 keyboards.

I can read the scanner/keyboard by "tail" on his /dev/input
The problem is that I want to monitor this input apart in a bakground process and not disturb the working of the normal keyboard in xorg.
# 13  
Old 09-20-2016
I'm fairly sure you can do it, but there's a gotcha -- you'd end up processing raw key codes, not the ASCII you'd get from /dev/input.

My old tablet came with touch screen and wacom tablet screen, and those devices ended up fighting each other all the time so I had to disable one, which I did by 'grabbing' the raw mouse device so the generic /dev/mouse couldn't get it. I suspect keyboard will behave the same. I think you'll need to run the 'grabbing' part as root, perhaps not the rest of it.

Here's a slightly modified version of that code which reads data and prints to standard output:

Code:
/**
 *      grab.c
 *      grabs an evdev device to prevent it from sending events
 *      to /dev/input/mice.
 */
#include <sys/types.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <unistd.h>

#include <linux/input.h>

#include <stdio.h>

int main(int argc, char *argv[])
{
        char buf[512];
        ssize_t bytes;
        int fd;

        if(argc != 2)
        {
                fprintf(stderr, "Syntax:  %s device-to-lock\n", argv[0]);
                return(1);
        }

        fd=open(argv[1], O_RDONLY);
        if(fd < 0)
        {
                perror("Couldn't open");
                return(1);
        }

        if(ioctl(fd, EVIOCGRAB, (void *)1))
        {
                perror("Couldn't grab");
                close(fd);
                return(1);
        }

        while((bytes = read(fd, buf, 512)) > 0)
        {
                write(STDOUT_FILENO, buf, bytes);
        }

        close(fd);
        return(0);
}


Last edited by Corona688; 09-20-2016 at 12:48 PM..
# 14  
Old 09-20-2016
NO! The barcode scanner, as RudiC quoted, "acts LIKE a keyboard". It has a limited ASCII set and uses the KB event, BUT, have you found out whether it has a separate device in the '/dev/' drawer?

Not sure how you are able to read '/dev/input' as this is a directory on Ubuntu 16.04 64 bit
OS. You must be reading the 'event' which is 'event6' on said OS.

With the barcode scanner NOT plugged in do:-
ls /dev > devlist1.txt
Then plug the barcode scanner in, wait a few seconds and do:-
ls /dev > devlist2.txt
Then find the difference between the two...

If so, you could try the 'xinput' command as xinput list keyboard or something similar, assuming the binaries are in the $PATH and disable the barcode scanner and see if that still produces an output at the event handler. If not see if it can be read from its separate driver that you would have found from above. I am sure it is capable of having a separate driver for other possible uses -- BUT -- I have NOT got one so my help IS limited.

If successful you WILL still need to understand the protocol that comes from the barcode scanner, which sould closely follow a subset of that of the keyboard...

Last edited by wisecracker; 09-20-2016 at 01:45 PM.. Reason: Typos.
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