On Wed, 5 Jan 2000, Luc Hermans wrote:

> Hi,
> 
> With  'cat /dev/vcs1'  I can dump the screen of the prog 
> running on /dev/tty1.
> 
> Can I send console input to that prog also ?

Try the following:

-----
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>

#include <linux/keyboard.h>
#include <linux/kd.h>

void inskey (unsigned char *string, const char *tty_dev)
{
  int tty_fd;
  long kbmode;

  tty_fd = open (tty_dev, O_RDONLY);
  if (tty_fd_fd == -1) return;

  /* The ultimate goal for this function is to be able to insert characters,
   * as well as arrow key controls, even if the keyboard on the console is
   * in K_RAW mode (as in dosemu particularly).  
   * For instance, at least, the insertion is not performed if in 
   * raw keyboard to prevent garbage results.
   * Keyboard scan codes would have to be sent otherwise.
   */
  ioctl( tty_fd, KDGKBMODE, &kbmode );
  if( kbmode == K_XLATE ) 
    while (*string)
      if (ioctl (tty_fd, TIOCSTI, string++))
        break;

  close (tty_fd);

Then calling inskey( "ls -la\r", "/dev/tty1" ) for example should provide
the expected result on tty1.

Also you might want to use /dev/vcsa1 instead.  See "man vcs".



Nicolas


--
To unsubscribe from this list, send a message to [EMAIL PROTECTED]
with the command "unsubscribe linux-embedded" in the message body.
For more information, see <http://waste.org/mail/linux-embedded>.

Reply via email to