How to simulate keyboard.../dev/tty0?

K

Keeper

Hi all,

I'm trying to send chars to the current console (currently having cursor
focus) - /dev/tty0 - in my program by:

my $st = 'K'
my $ri = 'L'
my $ng = 'J'
open(TTY, ">/dev/tty0");
ioctl(TTY, &TIOCSTI, $st);
ioctl(TTY, &TIOCSTI, $ri);
ioctl(TTY, &TIOCSTI, $ng);

I'm using redhat 9, kde.
Everything is ok in the linux console (on tty1 chars are sending
properly - KLJ...), but in kde i see strange things (and not only for
those characters):
^[[D- on ttyp1
- on mozilla window
My question is why chars are not properly sending by ioctl call, is
there any additional settings to do (setting termios, keyboard driver?)??

thanks,
Keeper
 
B

Brian McCauley

Keeper said:
Newsgroups: alt.perl,comp.lang.perl,comp.lang.perl.misc,comp.lang.perl.modules

comp.lang.perl does not exist (see FAQ) - please don't start any
threads there. Nobody will see your message there except the clueless
and those of us who periodically visit from comp.lang.perl.misc to
rescue the clueless.

Please don't cross-post alt.perl and comp.lang.perl.* - the people who
hang out in alt.perl tend to do so because they found comp.lang.perl.*
"unfriendly". (Actully, they usually found it to be intollerant of
selfishness). Duping these people into posting to comp.lang.perl
won't make either them or us happy.

By definition comp.lang.perl.misc is for stuff that doesn't have a
more specific home in comp.lang.perl.*. As such it is very rarely
appropriate to cross-post comp.lang.perl.misc and another
comp.lang.perl.* group.
my $st = 'K'
my $ri = 'L'
my $ng = 'J'
open(TTY, ">/dev/tty0");
ioctl(TTY, &TIOCSTI, $st);
ioctl(TTY, &TIOCSTI, $ri);
ioctl(TTY, &TIOCSTI, $ng);

I'm using redhat 9, kde.
Everything is ok in the linux console (on tty1 chars are sending
properly - KLJ...), but in kde i see strange things (and not only for
those characters):
^[[D- on ttyp1
- on mozilla window
My question is why chars are not properly sending by ioctl call, is
there any additional settings to do (setting termios, keyboard
driver?)??

Your question has nothing whatever to do with Perl. Whatever the
answer it would be exactly the same whatever language you used to
issue those ioctl()s.

IIRC the X server puts the tty device into a mode where keys generate
hardware specific scan-codes not ASCII(-like) codes. If you wish to
put keys into the tty keyboard stream that goes to the X server then
you'd need to use scan-codes. There are also mechanisms to inject
events into X but I don't know anything about them.

(Like I say I'm not an expert on this - but then if you are looking
for experts on this you are in the wrong place).

--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,905
Latest member
Kristy_Poole

Latest Threads

Top