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

Discussion in 'Perl' started by Keeper, Nov 11, 2003.

  1. Keeper

    Keeper Guest

    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
     
    Keeper, Nov 11, 2003
    #1
    1. Advertisements

  2. Keeper <-ip.org> writes:

    > 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\\
     
    Brian McCauley, Nov 11, 2003
    #2
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Keeper
    Replies:
    2
    Views:
    1,372
    Jack Klein
    Nov 12, 2003
  2. Keeper
    Replies:
    1
    Views:
    407
    Jack Klein
    Nov 12, 2003
  3. Keeper

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

    Keeper, Nov 11, 2003, in forum: C Programming
    Replies:
    1
    Views:
    635
    Jack Klein
    Nov 12, 2003
  4. Keeper

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

    Keeper, Nov 11, 2003, in forum: C Programming
    Replies:
    1
    Views:
    422
    Jack Klein
    Nov 12, 2003
  5. Michael J Whitmore

    Simulate Mouse/Keyboard to stop Screen Saver

    Michael J Whitmore, Nov 6, 2003, in forum: Python
    Replies:
    1
    Views:
    1,661
    Dave Brueck
    Nov 6, 2003
  6. Ron Peterson

    /dev/urandom vs. /dev/random

    Ron Peterson, Jan 7, 2005, in forum: C Programming
    Replies:
    21
    Views:
    2,066
    Keith Thompson
    Jan 13, 2005
  7. AC
    Replies:
    0
    Views:
    348
  8. DaGeek247

    Simulate Keyboard keypress Delay

    DaGeek247, Feb 13, 2013, in forum: Python
    Replies:
    2
    Views:
    322
    88888 Dihedral
    Feb 14, 2013
Loading...