Commit 22bc541d authored by deuce's avatar deuce
Browse files

Allow input from X.

This may actually work now.
parent 0c72ed10
......@@ -27,6 +27,7 @@ void initciowrap(int mode)
cio_api.gettextinfo=x_gettextinfo;
cio_api.setcursortype=x_setcursortype;
cio_api.clreol=x_clreol;
cio_api.getch=x_getch;
return;
}
fprintf(stderr,"X init failed\n");
......@@ -49,4 +50,5 @@ void initciowrap(int mode)
cio_api.gettextinfo=curs_gettextinfo;
cio_api.setcursortype=curs_setcursortype;
cio_api.clreol=curs_clreol;
cio_api.getch=getch;
}
......@@ -74,6 +74,7 @@ typedef struct {
void (*setcursortype)(int);
void (*textbackground) (int);
void (*textcolor) (int);
int (*getch) (void);
} cioapi_t;
extern cioapi_t cio_api;
......@@ -95,6 +96,8 @@ extern cioapi_t cio_api;
#define _setcursortype(a) cio_api.setcursortype(a)
#define textbackground(a) cio_api.textbackground(a)
#define textcolor(a) cio_api.textcolor(a)
#undef getch
#define getch() cio_api.getch()
#endif
......
......@@ -346,12 +346,14 @@ mouse_t mouse_status;
void tty_pause()
{
#ifdef DISABLED
sigset_t set;
sigprocmask(0, 0, &set);
sigdelset(&set, SIGIO);
sigdelset(&set, SIGALRM);
sigsuspend(&set);
#endif
}
volatile int poll_cnt = 0;
......@@ -958,7 +960,9 @@ video_async_event(int sig)
{
int int9 = 0;
#ifdef DISABLED
for (;;) {
#endif
int x;
fd_set fdset;
XEvent ev;
......@@ -1005,7 +1009,9 @@ video_async_event(int sig)
}
break;
}
#ifdef DISABLED
}
#endif
}
/* Resize the window, using information from 'vga_status[]'. This function is
......@@ -1354,6 +1360,9 @@ console_init()
if(timer_init())
return(-1);
sigemptyset(&sigset);
sigaddset(&sigset, SIGIO);
sigaddset(&sigset, SIGALRM);
sigprocmask(SIG_UNBLOCK, &sigset, 0);
return(0);
}
......@@ -1456,6 +1465,8 @@ tty_peek(int flag)
int
tty_kbhit(void)
{
video_async_event(0);
if(!nextchar && KbdEmpty())
return(0);
return(1);
......
/* $Id$ */
#define CIO_KEY_HOME 0x47 << 8
#define CIO_KEY_UP 72 << 8
#define CIO_KEY_END 0x4f << 8
#define CIO_KEY_DOWN 80 << 8
#define CIO_KEY_F(x) (0x3a+x) << 8
#define CIO_KEY_IC 0x52 << 8
#define CIO_KEY_DC 0x53 << 8
#define CIO_KEY_LEFT 0x4b << 8
#define CIO_KEY_RIGHT 0x4d << 8
#define CIO_KEY_PPAGE 0x49 << 8
#define CIO_KEY_NPAGE 0x51 << 8
#define CIO_KEY_BACKSPACE 0xff01 /* Windows never differentiates between a
* backspace keypress and the backspace
* char
*/
#define CIO_KEY_MOUSE 0xff02
#ifndef KEY_HOME
#define KEY_HOME 0x47 << 8
#endif
......
......@@ -237,7 +237,78 @@ int inkey()
#else
#define inkey() getch()
int inkey()
{
int c;
c=getch();
if(!c)
c=(getch()<<8);
switch(c) {
case CIO_KEY_HOME:
c=KEY_HOME;
break;
case CIO_KEY_UP:
c=KEY_UP;
break;
case CIO_KEY_END:
c=KEY_END;
break;
case CIO_KEY_DOWN:
c=KEY_DOWN;
break;
case CIO_KEY_F(1):
c=KEY_F(1);
break;
case CIO_KEY_F(2):
c=KEY_F(2);
break;
case CIO_KEY_F(3):
c=KEY_F(3);
break;
case CIO_KEY_F(4):
c=KEY_F(4);
break;
case CIO_KEY_F(5):
c=KEY_F(5);
break;
case CIO_KEY_F(6):
c=KEY_F(6);
break;
case CIO_KEY_F(7):
c=KEY_F(7);
break;
case CIO_KEY_F(8):
c=KEY_F(8);
break;
case CIO_KEY_F(9):
c=KEY_F(9);
break;
case CIO_KEY_F(10):
c=KEY_F(10);
break;
case CIO_KEY_IC:
c=KEY_IC;
break;
case CIO_KEY_DC:
c=KEY_DC;
break;
case CIO_KEY_LEFT:
c=KEY_LEFT;
break;
case CIO_KEY_RIGHT:
c=KEY_RIGHT;
break;
case CIO_KEY_PPAGE:
c=KEY_PPAGE;
break;
case CIO_KEY_NPAGE:
c=KEY_NPAGE;
break;
}
return(c);
}
#endif
......
......@@ -43,7 +43,6 @@ int x_gettext(int sx, int sy, int ex, int ey, unsigned char *fill)
int x,y;
unsigned char *out;
WORD sch;
printf("gettext\n");
out=fill;
for(y=sy-1;y<ey;y++) {
......@@ -210,3 +209,8 @@ void x_clreol(void)
for(x=CursCol0;x<DpyCols;x++)
vmem[CursRow0*DpyCols+x]=x_curr_attr;
}
int x_getch(void)
{
return(tty_read(0));
}
......@@ -24,6 +24,7 @@ void x_setcursortype(int type);
void x_textbackground(int colour);
void x_textcolor(int colour);
void x_clreol(void);
int x_getch(void);
#ifdef __cplusplus
}
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment