I have a PS2 barcode scanner connected via patch cord to the PS2 port
which is shared with the keyboard. I am trying to read the barcode scanner
keycodes from /dev/input/event0 via a read call shown in the fragment below,
then translate the keycodes to something useful.
# code 1
if ((read_status = read (fd, ev, event_size * 64)) < event_size)
{ perror("read()"); exit(1);}
else{
for (i=0; i<read_status/event_size; i++)
{
fprintf(fp, " Time sec:%ld usec:%ld Type:%d Code:%d Value:%d
Char:%s
\n",ev[i].time.tv_sec,ev[i].time.tv_usec,ev[i].type,ev[i].code,
ev[i].value,keycode[ev[i].code]);
}
Here is the problem: when I capture the barcode scanner the keycodes
repeat in an
unpredictable pattern, unlike keyboard keycodes which are exact repeats. If
have focus
on a terminal, the barcode scanner keycodes show up on terminal correctly.
So apparently there are some basic gaps in my knowledge of how
/dev/input/eventX is supposed to behave. Any thoughts would be appreciated.
Sorry for the long post
(some more notes are at the end) and I hope my mailer does not munch lines.
#fragment of barcode scanner keycodes that show up in a term with focus
3~ which translates to <alt> <f10>
#fragment of barcode scanner keycodes captured by code 1
Time sec:1171769624 usec:924265 Type:4 Code:4 Value:56 Char:3
Time sec:1171769624 usec:924277 Type:1 Code:56 Value:1 Char:<alt>
Time sec:1171769624 usec:924281 Type:0 Code:0 Value:0 Char:
Time sec:1171769624 usec:927977 Type:4 Code:4 Value:68 Char:3
Time sec:1171769624 usec:927983 Type:1 Code:68 Value:1 Char:<f10>
Time sec:1171769624 usec:927987 Type:0 Code:0 Value:0 Char:
Time sec:1171769624 usec:933494 Type:4 Code:4 Value:68 Char:3
Time sec:1171769624 usec:933505 Type:1 Code:68 Value:0 Char:<f10>
Time sec:1171769624 usec:933509 Type:0 Code:0 Value:0 Char:
Time sec:1171769624 usec:938986 Type:4 Code:4 Value:56 Char:3
Time sec:1171769624 usec:938991 Type:1 Code:56 Value:0 Char:<alt>
Time sec:1171769624 usec:938995 Type:0 Code:0 Value:0 Char:
#fragment of keyboard keycodes captured by code 1 when I type "lin"
Time sec:1171841171 usec:401248 Type:4 Code:4 Value:38 Char:3
Time sec:1171841171 usec:401259 Type:1 Code:38 Value:1 Char:l
Time sec:1171841171 usec:401263 Type:0 Code:0 Value:0 Char:
Time sec:1171841171 usec:534801 Type:4 Code:4 Value:38 Char:3
Time sec:1171841171 usec:534812 Type:1 Code:38 Value:0 Char:l
Time sec:1171841171 usec:534816 Type:0 Code:0 Value:0 Char:
Time sec:1171841171 usec:707949 Type:4 Code:4 Value:23 Char:3
Time sec:1171841171 usec:707962 Type:1 Code:23 Value:1 Char:i
Time sec:1171841171 usec:707966 Type:0 Code:0 Value:0 Char:
Time sec:1171841171 usec:847474 Type:4 Code:4 Value:23 Char:3
Time sec:1171841171 usec:847485 Type:1 Code:23 Value:0 Char:i
Time sec:1171841171 usec:847489 Type:0 Code:0 Value:0 Char:
Time sec:1171841172 usec:100230 Type:4 Code:4 Value:49 Char:3
Time sec:1171841172 usec:100242 Type:1 Code:49 Value:1 Char:n
Time sec:1171841172 usec:100246 Type:0 Code:0 Value:0 Char:
Time sec:1171841172 usec:227808 Type:4 Code:4 Value:49 Char:3
Time sec:1171841172 usec:227820 Type:1 Code:49 Value:0 Char:n
Time sec:1171841172 usec:227824 Type:0 Code:0 Value:0 Char:
Notes
1. Kernel Version: Linux kubuntu 2.6.15-28-386 #1 PREEMPT
2. I make sure I do not touch the keyboard when I am using the scanner
3. I have made half hearted attempts at changing repeat rates,delay
as shown in code 2 fragment below has not helped much, AFAIK the
related IOCTLs were not implemented in the above kernel, since then
they have been.
# code 2
ev[0].type = EV_REP;
ev[0].code = REP_DELAY;
ev[0].value = 1000;
if ( (output_status = write(fd, &ev[0], sizeof(struct input_event))) <0)
{perror("write()"); exit(1);}
_________________________________________________________________
http://homepage.msn.com/zune?icid=hmetagline
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ