Jump to content

Simulate input/Keyboard: Difference between revisions

Line 331:
Perl on linux can do this for PseudoTerminals (ptys) and Terminals (ttys) using [http://www.kernel.org/doc/man-pages/online/pages/man4/tty_ioctl.4.html IOCTL TIOCSTI]. The same can be done with C or any other language that can use IOCTL either natively or via [http://en.wikipedia.org/wiki/Foreign_function_interface FFI] such as [http://en.wikipedia.org/wiki/Java_Native_Interface JNI] or [http://en.wikipedia.org/wiki/Java_Native_Access JNA].
 
 
How to get the correct value for TIOCSTI is discussed [http://www.perlmonks.org/?node_id=10920 (here)].
 
Target may be externally created, but process must be able to open tty/pty for writing.
 
<lang perl>$target = "/dev/pts/51";
### How to get the correct value for $TIOCSTI is discussed [here : http://www.perlmonks.org/?node_id=10920 (here)].
$TIOCSTI = 0x5412 ;
open(TTY,">$target") or die "cannot open $target" ;
54

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.