2001-04-15 04:18:22 +00:00
|
|
|
/*
|
|
|
|
in_fbdev.c
|
|
|
|
|
|
|
|
fix this!
|
|
|
|
|
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
2003-01-15 15:31:36 +00:00
|
|
|
|
2005-08-04 15:27:09 +00:00
|
|
|
static __attribute__ ((used)) const char rcsid[] =
|
2003-01-15 15:31:36 +00:00
|
|
|
"$Id$";
|
|
|
|
|
2001-04-15 04:18:22 +00:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <fcntl.h>
|
2001-08-27 01:00:03 +00:00
|
|
|
#include <termios.h>
|
2001-04-15 04:18:22 +00:00
|
|
|
#include <sys/ioctl.h>
|
|
|
|
|
|
|
|
#include "QF/cvar.h"
|
2003-01-06 18:28:13 +00:00
|
|
|
#include "QF/input.h"
|
2001-04-15 04:18:22 +00:00
|
|
|
#include "QF/keys.h"
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static int
|
2001-04-15 04:18:22 +00:00
|
|
|
fd_blocking (int fd, int on)
|
|
|
|
{
|
|
|
|
int x;
|
|
|
|
|
|
|
|
#if defined(_POSIX_SOURCE) || !defined(FIONBIO)
|
2001-08-27 01:00:03 +00:00
|
|
|
# if !defined(O_NONBLOCK)
|
|
|
|
# if defined(O_NDELAY)
|
|
|
|
# define O_NONBLOCK O_NDELAY
|
|
|
|
# endif
|
2001-04-15 04:18:22 +00:00
|
|
|
# endif
|
|
|
|
if ((x = fcntl(fd, F_GETFL, 0)) == -1)
|
|
|
|
return -1;
|
|
|
|
if (on)
|
|
|
|
x &= ~O_NONBLOCK;
|
|
|
|
else
|
|
|
|
x |= O_NONBLOCK;
|
|
|
|
|
|
|
|
return fcntl(fd, F_SETFL, x);
|
|
|
|
#else
|
|
|
|
x = !on;
|
|
|
|
|
|
|
|
return ioctl(fd, FIONBIO, &x);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct termios old_tty, new_tty;
|
|
|
|
static int tty_fd = 0;
|
|
|
|
|
|
|
|
void
|
2001-04-15 08:04:15 +00:00
|
|
|
IN_LL_Init (void)
|
2001-04-15 04:18:22 +00:00
|
|
|
{
|
|
|
|
fd_blocking(0, 0);
|
|
|
|
tcgetattr(tty_fd, &old_tty);
|
|
|
|
new_tty = old_tty;
|
|
|
|
new_tty.c_cc[VMIN] = 1;
|
|
|
|
new_tty.c_cc[VTIME] = 0;
|
|
|
|
new_tty.c_lflag &= ~ICANON;
|
|
|
|
new_tty.c_iflag &= ~IXON;
|
|
|
|
tcsetattr(tty_fd, TCSADRAIN, &new_tty);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-04-15 08:04:15 +00:00
|
|
|
IN_LL_Init_Cvars (void)
|
2001-04-15 04:18:22 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-04-15 08:04:15 +00:00
|
|
|
IN_LL_Shutdown (void)
|
2001-04-15 04:18:22 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-04-08 18:45:12 +00:00
|
|
|
IN_LL_ProcessEvents (void)
|
2001-04-15 04:18:22 +00:00
|
|
|
{
|
|
|
|
int k, down;
|
|
|
|
char buf[4];
|
|
|
|
|
|
|
|
if (read(0, buf, 1) == 1) {
|
|
|
|
k = buf[0];
|
|
|
|
switch (k) {
|
|
|
|
case '\r':
|
|
|
|
case '\n':
|
2001-10-28 04:23:37 +00:00
|
|
|
k = QFK_RETURN;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
case '\033':
|
|
|
|
if (read(0, buf, 2) != 2)
|
|
|
|
break;
|
|
|
|
switch (buf[1]) {
|
|
|
|
case 'A':
|
2001-10-28 04:23:37 +00:00
|
|
|
k = QFK_UP;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
case 'B':
|
2001-10-28 04:23:37 +00:00
|
|
|
k = QFK_DOWN;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
case 'C':
|
2001-10-28 04:23:37 +00:00
|
|
|
k = QFK_RIGHT;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
case 'D':
|
2001-10-28 04:23:37 +00:00
|
|
|
k = QFK_LEFT;
|
2001-04-15 04:18:22 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
down = 1;
|
2001-08-16 22:49:53 +00:00
|
|
|
Key_Event(k, buf[0], down);
|
|
|
|
Key_Event(k, buf[0], !down);
|
2001-04-15 04:18:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-07 03:55:51 +00:00
|
|
|
void
|
|
|
|
IN_LL_Grab_Input (int grab)
|
2001-08-30 20:04:13 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-04-17 15:55:33 +00:00
|
|
|
void
|
|
|
|
IN_LL_ClearStates (void)
|
|
|
|
{
|
|
|
|
}
|