Skip to content
Snippets Groups Projects
Commit 6f84fb87 authored by deuce's avatar deuce
Browse files

Support 0xe0 (enhanced keyboard) doorway codes on input.

Add support for the abort key.
parent 16e2739d
No related branches found
No related tags found
No related merge requests found
...@@ -664,7 +664,37 @@ static void ansi_keyparse(void *par) ...@@ -664,7 +664,37 @@ static void ansi_keyparse(void *par)
sem_wait(&got_key); sem_wait(&got_key);
ch=ansi_raw_inch; ch=ansi_raw_inch;
if(gotnull) { if(ch==-2) {
ansi_inch=0x0100;
sem_post(&got_input);
/* Two-byte code, need to post twice times and wait for one to
be received */
sem_wait(&used_input);
sem_wait(&goahead);
sem_post(&got_input);
sem_wait(&used_input);
}
if(gotnull==2) {
// 0xe0 enhanced keyboard key... translate to 0x00 key for now.
ansi_inch=ch<<8; // (ch<<8)|0xe0;
sem_post(&got_input);
/* Two-byte code, need to post twice times and wait for one to
be received */
sem_wait(&used_input);
sem_wait(&goahead);
sem_post(&got_input);
sem_wait(&used_input);
gotnull=0;
continue;
}
if(gotnull==1) {
if(ch==0xe0) {
gotnull=2;
// Need another key... keep looping.
sem_post(&goahead);
continue;
}
ansi_inch=ch<<8; ansi_inch=ch<<8;
sem_post(&got_input); sem_post(&got_input);
/* Two-byte code, need to post twice and wait for one to /* Two-byte code, need to post twice and wait for one to
...@@ -781,7 +811,7 @@ static void ansi_keythread(void *params) ...@@ -781,7 +811,7 @@ static void ansi_keythread(void *params)
sem_getvalue(&got_key,&sval); sem_getvalue(&got_key,&sval);
if(!sval) { if(!sval) {
ansi_raw_inch=ciolib_ansi_readbyte_cb(); ansi_raw_inch=ciolib_ansi_readbyte_cb();
if(ansi_raw_inch >= 0) if(ansi_raw_inch >= 0 || ansi_raw_inch==-2)
sem_post(&got_key); sem_post(&got_key);
else else
SLEEP(1); SLEEP(1);
......
...@@ -404,12 +404,13 @@ CIOLIBEXPORT int CIOLIBCALL ciolib_getche(void) ...@@ -404,12 +404,13 @@ CIOLIBEXPORT int CIOLIBCALL ciolib_getche(void)
else { else {
while(1) { while(1) {
ch=ciolib_getch(); ch=ciolib_getch();
if(ch) { if(ch != 0 && ch != 0xe0) {
ciolib_putch(ch); ciolib_putch(ch);
return(ch); return(ch);
} }
/* Eat extended chars */ /* Eat extended chars - except ESC which is an abort */
ciolib_getch(); if(ciolib_getch()==1)
return(EOF);
} }
} }
} }
...@@ -466,8 +467,10 @@ CIOLIBEXPORT char * CIOLIBCALL ciolib_cgets(char *str) ...@@ -466,8 +467,10 @@ CIOLIBEXPORT char * CIOLIBCALL ciolib_cgets(char *str)
maxlen=*(unsigned char *)str; maxlen=*(unsigned char *)str;
while((ch=ciolib_getch())!='\n' && ch !='\r') { while((ch=ciolib_getch())!='\n' && ch !='\r') {
switch(ch) { switch(ch) {
case 0: /* Skip extended keys */ case 0: /* Skip extended keys */
ciolib_getche(); case 0xe0: /* Skip extended keys */
if(ciolib_getche()==1)
goto early_return;
break; break;
case '\r': /* Skip \r (ToDo: Should this be treated as a \n? */ case '\r': /* Skip \r (ToDo: Should this be treated as a \n? */
break; break;
...@@ -492,6 +495,7 @@ CIOLIBEXPORT char * CIOLIBCALL ciolib_cgets(char *str) ...@@ -492,6 +495,7 @@ CIOLIBEXPORT char * CIOLIBCALL ciolib_cgets(char *str)
break; break;
} }
} }
early_return;
str[len+2]=0; str[len+2]=0;
*((unsigned char *)(str+1))=(unsigned char)len; *((unsigned char *)(str+1))=(unsigned char)len;
ciolib_putch('\r'); ciolib_putch('\r');
...@@ -563,8 +567,10 @@ CIOLIBEXPORT char * CIOLIBCALL ciolib_getpass(const char *prompt) ...@@ -563,8 +567,10 @@ CIOLIBEXPORT char * CIOLIBCALL ciolib_getpass(const char *prompt)
ciolib_cputs((char *)prompt); ciolib_cputs((char *)prompt);
while((ch=ciolib_getch())!='\n') { while((ch=ciolib_getch())!='\n') {
switch(ch) { switch(ch) {
case 0: /* Skip extended keys */ case 0: /* Skip extended keys */
ciolib_getch(); case 0xe0: /* Skip extended keys */
if(ciolib_getch()==1)
goto early_return;
break; break;
case '\r': /* Skip \r (ToDo: Should this be treeated as a \n? */ case '\r': /* Skip \r (ToDo: Should this be treeated as a \n? */
break; break;
...@@ -583,6 +589,7 @@ CIOLIBEXPORT char * CIOLIBCALL ciolib_getpass(const char *prompt) ...@@ -583,6 +589,7 @@ CIOLIBEXPORT char * CIOLIBCALL ciolib_getpass(const char *prompt)
break; break;
} }
} }
early_return:
pass[len]=0; pass[len]=0;
return(pass); return(pass);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment