+ return( 1 );
+ };
+
+ /* Set tty and fb devices */
+ p_vout->p_sys->i_tty_dev = 0; /* 0 == /dev/tty0 == current console */
+
+ FBGfxMode( p_vout->p_sys->i_tty_dev );
+
+ /* Set keyboard settings */
+ if (tcgetattr(0, &p_vout->p_sys->old_termios) == -1)
+ {
+ intf_ErrMsg( "intf error: tcgetattr" );
+ }
+
+ if (tcgetattr(0, &new_termios) == -1)
+ {
+ intf_ErrMsg( "intf error: tcgetattr" );
+ }
+
+ /* new_termios.c_lflag &= ~ (ICANON | ISIG);
+ new_termios.c_lflag |= (ECHO | ECHOCTL); */
+ new_termios.c_lflag &= ~ (ICANON);
+ new_termios.c_lflag &= ~(ECHO | ECHOCTL);
+ new_termios.c_iflag = 0;
+ new_termios.c_cc[VMIN] = 1;
+ new_termios.c_cc[VTIME] = 0;
+
+ if (tcsetattr(0, TCSAFLUSH, &new_termios) == -1)
+ {
+ intf_ErrMsg( "intf error: tcsetattr" );
+ }
+
+ ioctl(p_vout->p_sys->i_tty_dev, VT_RELDISP, VT_ACKACQ);
+
+ /* Set-up tty signal handler to be aware of tty changes */
+ memset( &sig_tty, 0, sizeof( sig_tty ) );
+ sig_tty.sa_handler = FBSwitchDisplay;
+ sigemptyset( &sig_tty.sa_mask );
+ if( sigaction( SIGUSR1, &sig_tty, &p_vout->p_sys->sig_usr1 ) ||
+ sigaction( SIGUSR2, &sig_tty, &p_vout->p_sys->sig_usr2 ) )
+ {
+ intf_ErrMsg( "intf error: can't set up signal handler (%s)",
+ strerror(errno) );
+ tcsetattr(0, 0, &p_vout->p_sys->old_termios);
+ FBTextMode( p_vout->p_sys->i_tty_dev );
+ free( p_vout->p_sys );
+ return( 1 );
+ }
+
+ /* Set-up tty according to new signal handler */
+ if( ioctl(p_vout->p_sys->i_tty_dev, VT_GETMODE, &p_vout->p_sys->vt_mode)
+ == -1 )
+ {
+ intf_ErrMsg( "intf error: cant get terminal mode (%s)",
+ strerror(errno) );
+ sigaction( SIGUSR1, &p_vout->p_sys->sig_usr1, NULL );
+ sigaction( SIGUSR2, &p_vout->p_sys->sig_usr2, NULL );
+ tcsetattr(0, 0, &p_vout->p_sys->old_termios);
+ FBTextMode( p_vout->p_sys->i_tty_dev );
+ free( p_vout->p_sys );
+ return( 1 );
+ }
+ memcpy( &vt_mode, &p_vout->p_sys->vt_mode, sizeof( vt_mode ) );
+ vt_mode.mode = VT_PROCESS;
+ vt_mode.waitv = 0;
+ vt_mode.relsig = SIGUSR1;
+ vt_mode.acqsig = SIGUSR2;
+
+ if( ioctl(p_vout->p_sys->i_tty_dev, VT_SETMODE, &vt_mode) == -1 )
+ {
+ intf_ErrMsg( "intf error: can't set terminal mode (%s)",
+ strerror(errno) );
+ sigaction( SIGUSR1, &p_vout->p_sys->sig_usr1, NULL );
+ sigaction( SIGUSR2, &p_vout->p_sys->sig_usr2, NULL );
+ tcsetattr(0, 0, &p_vout->p_sys->old_termios);
+ FBTextMode( p_vout->p_sys->i_tty_dev );
+ free( p_vout->p_sys );