I have written a program that gets input from a usb second keyboard (actually a barcode scanner). The problem is that if another window is active the data is input there rather than in my program. Could someone give me advice on what I'm doing wrong?
#include <stdio.h>
#include <string.h>
int main(int argc, char * argv[]){
FILE * fp_in;
char * data;
fp_in = fopen("/dev/input/by-id/usb-04d9_1400-event-kbd","r");
if(fp_in == NULL){
fprintf(stderr,"Failed to open input by id\n");
}
fp_in = fopen("/dev/input/by-path/pci-0000:00:1d.1-usb-0:2:1.0-event-kbd","r");
if(fp_in == NULL){
fprintf(stderr,"Failed to open input by path\n");
return 1;
}
while(1){
fscanf(fp_in,data,"%s");
fprintf(stderr,"%s",data);
}
return 0;
}
thanks
If I may be so bold as to rephrase the question on Confuzzled's behalf:
How can I write a program under Linux that attaches itself to an input device, in this case a barcode scanner, so that the input does not go to the program that has the keyboard focus?