SAFERHANGUP support for win32tty
win32gui support still needs to be developed.
This commit is contained in:
@@ -57,6 +57,11 @@
|
||||
|
||||
#ifdef WIN32CON
|
||||
#define PORT_DEBUG /* include ability to debug international keyboard issues */
|
||||
#define SAFERHANGUP /* Define SAFERHANGUP to delay hangup processing
|
||||
* until the main command loop. 'safer' because it
|
||||
* avoids certain cheats and also avoids losing
|
||||
* objects being thrown when the hangup occurs.
|
||||
*/
|
||||
#endif
|
||||
|
||||
/* The following is needed for prototypes of certain functions */
|
||||
|
||||
@@ -224,9 +224,19 @@ int mode;
|
||||
int *mod;
|
||||
coord *cc;
|
||||
{
|
||||
#if defined(SAFERHANGUP)
|
||||
DWORD dwWait;
|
||||
#endif
|
||||
int ch;
|
||||
boolean valid = 0, done = 0;
|
||||
while (!done) {
|
||||
#if defined(SAFERHANGUP)
|
||||
dwWait = WaitForSingleObjectEx(
|
||||
hConIn, // event object to wait for
|
||||
INFINITE, // waits indefinitely
|
||||
TRUE); // alertable wait enabled
|
||||
if (dwWait == WAIT_FAILED) return '\033';
|
||||
#endif
|
||||
ReadConsoleInput(hConIn,ir,1,count);
|
||||
if (mode == 0) {
|
||||
if ((ir->EventType == KEY_EVENT) && ir->Event.KeyEvent.bKeyDown) {
|
||||
|
||||
@@ -25,6 +25,8 @@ static char author[] = "The NetHack Development Team";
|
||||
|
||||
extern HANDLE hConIn;
|
||||
extern INPUT_RECORD ir;
|
||||
extern struct sinfo program_state;
|
||||
|
||||
char dllname[512];
|
||||
char *shortdllname;
|
||||
|
||||
@@ -256,9 +258,20 @@ int mode;
|
||||
int *mod;
|
||||
coord *cc;
|
||||
{
|
||||
#if defined(SAFERHANGUP)
|
||||
DWORD dwWait;
|
||||
#endif
|
||||
int ch;
|
||||
boolean valid = 0, done = 0;
|
||||
while (!done) {
|
||||
|
||||
#if defined(SAFERHANGUP)
|
||||
dwWait = WaitForSingleObjectEx(
|
||||
hConIn, // event object to wait for
|
||||
INFINITE, // waits indefinitely
|
||||
TRUE); // alertable wait enabled
|
||||
if (dwWait == WAIT_FAILED) return '\033';
|
||||
#endif
|
||||
ReadConsoleInput(hConIn,ir,1,count);
|
||||
if (mode == 0) {
|
||||
if ((ir->EventType == KEY_EVENT) && ir->Event.KeyEvent.bKeyDown) {
|
||||
|
||||
@@ -455,11 +455,17 @@ int *mod;
|
||||
boolean numpad;
|
||||
coord *cc;
|
||||
{
|
||||
#if defined(SAFERHANGUP)
|
||||
DWORD dwWait;
|
||||
#endif
|
||||
int ch;
|
||||
boolean valid = 0, done = 0;
|
||||
while (!done) {
|
||||
*count = 0;
|
||||
WaitForSingleObject(hConIn, INFINITE);
|
||||
dwWait = WaitForSingleObject(hConIn, INFINITE);
|
||||
#if defined(SAFERHANGUP)
|
||||
if (dwWait == WAIT_FAILED) return '\033';
|
||||
#endif
|
||||
PeekConsoleInput(hConIn,ir,1,count);
|
||||
if (mode == 0) {
|
||||
if ((ir->EventType == KEY_EVENT) && ir->Event.KeyEvent.bKeyDown) {
|
||||
|
||||
@@ -258,9 +258,9 @@ DWORD ctrltype;
|
||||
#ifndef NOSAVEONHANGUP
|
||||
hangup(0);
|
||||
#endif
|
||||
#if 0
|
||||
clearlocks();
|
||||
terminate(EXIT_FAILURE);
|
||||
#if defined(SAFERHANGUP)
|
||||
CloseHandle(hConIn); /* trigger WAIT_FAILED */
|
||||
return TRUE;
|
||||
#endif
|
||||
default:
|
||||
return FALSE;
|
||||
@@ -376,7 +376,9 @@ tgetch()
|
||||
int mod;
|
||||
coord cc;
|
||||
DWORD count;
|
||||
return pCheckInput(hConIn, &ir, &count, iflags.num_pad, 0, &mod, &cc);
|
||||
return (program_state.done_hup) ?
|
||||
'\033' :
|
||||
pCheckInput(hConIn, &ir, &count, iflags.num_pad, 0, &mod, &cc);
|
||||
}
|
||||
|
||||
int
|
||||
@@ -386,7 +388,9 @@ int *x, *y, *mod;
|
||||
int ch;
|
||||
coord cc;
|
||||
DWORD count;
|
||||
ch = pCheckInput(hConIn, &ir, &count, iflags.num_pad, 1, mod, &cc);
|
||||
ch = (program_state.done_hup) ?
|
||||
'\033' :
|
||||
pCheckInput(hConIn, &ir, &count, iflags.num_pad, 1, mod, &cc);
|
||||
if (!ch) {
|
||||
*x = cc.x;
|
||||
*y = cc.y;
|
||||
|
||||
Reference in New Issue
Block a user