468,537 Members | 1,994 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,537 developers. It's quick & easy.

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

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

Jul 19 '05 #1
1 5310
Keeper <ke****@iosys.no-ip.org> writes:
Newsgroups: alt.perl,comp.lang.perl,comp.lang.perl.misc,comp.l ang.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\\
Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Michael J Whitmore | last post: by
2 posts views Thread by Keeper | last post: by
1 post views Thread by Keeper | last post: by
reply views Thread by Mythran | last post: by
3 posts views Thread by John Dalberg | last post: by
18 posts views Thread by eliss.carmine | last post: by
3 posts views Thread by =?Utf-8?B?cHJvZ2dlcg==?= | last post: by
2 posts views Thread by Brice Rebsamen | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.