SAFERHANGUP support for win32tty
win32gui support still needs to be developed.
This commit is contained in:
@@ -57,6 +57,11 @@
|
|||||||
|
|
||||||
#ifdef WIN32CON
|
#ifdef WIN32CON
|
||||||
#define PORT_DEBUG /* include ability to debug international keyboard issues */
|
#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
|
#endif
|
||||||
|
|
||||||
/* The following is needed for prototypes of certain functions */
|
/* The following is needed for prototypes of certain functions */
|
||||||
|
|||||||
@@ -224,9 +224,19 @@ int mode;
|
|||||||
int *mod;
|
int *mod;
|
||||||
coord *cc;
|
coord *cc;
|
||||||
{
|
{
|
||||||
|
#if defined(SAFERHANGUP)
|
||||||
|
DWORD dwWait;
|
||||||
|
#endif
|
||||||
int ch;
|
int ch;
|
||||||
boolean valid = 0, done = 0;
|
boolean valid = 0, done = 0;
|
||||||
while (!done) {
|
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);
|
ReadConsoleInput(hConIn,ir,1,count);
|
||||||
if (mode == 0) {
|
if (mode == 0) {
|
||||||
if ((ir->EventType == KEY_EVENT) && ir->Event.KeyEvent.bKeyDown) {
|
if ((ir->EventType == KEY_EVENT) && ir->Event.KeyEvent.bKeyDown) {
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ static char author[] = "The NetHack Development Team";
|
|||||||
|
|
||||||
extern HANDLE hConIn;
|
extern HANDLE hConIn;
|
||||||
extern INPUT_RECORD ir;
|
extern INPUT_RECORD ir;
|
||||||
|
extern struct sinfo program_state;
|
||||||
|
|
||||||
char dllname[512];
|
char dllname[512];
|
||||||
char *shortdllname;
|
char *shortdllname;
|
||||||
|
|
||||||
@@ -256,9 +258,20 @@ int mode;
|
|||||||
int *mod;
|
int *mod;
|
||||||
coord *cc;
|
coord *cc;
|
||||||
{
|
{
|
||||||
|
#if defined(SAFERHANGUP)
|
||||||
|
DWORD dwWait;
|
||||||
|
#endif
|
||||||
int ch;
|
int ch;
|
||||||
boolean valid = 0, done = 0;
|
boolean valid = 0, done = 0;
|
||||||
while (!done) {
|
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);
|
ReadConsoleInput(hConIn,ir,1,count);
|
||||||
if (mode == 0) {
|
if (mode == 0) {
|
||||||
if ((ir->EventType == KEY_EVENT) && ir->Event.KeyEvent.bKeyDown) {
|
if ((ir->EventType == KEY_EVENT) && ir->Event.KeyEvent.bKeyDown) {
|
||||||
|
|||||||
@@ -455,11 +455,17 @@ int *mod;
|
|||||||
boolean numpad;
|
boolean numpad;
|
||||||
coord *cc;
|
coord *cc;
|
||||||
{
|
{
|
||||||
|
#if defined(SAFERHANGUP)
|
||||||
|
DWORD dwWait;
|
||||||
|
#endif
|
||||||
int ch;
|
int ch;
|
||||||
boolean valid = 0, done = 0;
|
boolean valid = 0, done = 0;
|
||||||
while (!done) {
|
while (!done) {
|
||||||
*count = 0;
|
*count = 0;
|
||||||
WaitForSingleObject(hConIn, INFINITE);
|
dwWait = WaitForSingleObject(hConIn, INFINITE);
|
||||||
|
#if defined(SAFERHANGUP)
|
||||||
|
if (dwWait == WAIT_FAILED) return '\033';
|
||||||
|
#endif
|
||||||
PeekConsoleInput(hConIn,ir,1,count);
|
PeekConsoleInput(hConIn,ir,1,count);
|
||||||
if (mode == 0) {
|
if (mode == 0) {
|
||||||
if ((ir->EventType == KEY_EVENT) && ir->Event.KeyEvent.bKeyDown) {
|
if ((ir->EventType == KEY_EVENT) && ir->Event.KeyEvent.bKeyDown) {
|
||||||
|
|||||||
+9
-5
@@ -258,9 +258,9 @@ DWORD ctrltype;
|
|||||||
#ifndef NOSAVEONHANGUP
|
#ifndef NOSAVEONHANGUP
|
||||||
hangup(0);
|
hangup(0);
|
||||||
#endif
|
#endif
|
||||||
#if 0
|
#if defined(SAFERHANGUP)
|
||||||
clearlocks();
|
CloseHandle(hConIn); /* trigger WAIT_FAILED */
|
||||||
terminate(EXIT_FAILURE);
|
return TRUE;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -376,7 +376,9 @@ tgetch()
|
|||||||
int mod;
|
int mod;
|
||||||
coord cc;
|
coord cc;
|
||||||
DWORD count;
|
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
|
int
|
||||||
@@ -386,7 +388,9 @@ int *x, *y, *mod;
|
|||||||
int ch;
|
int ch;
|
||||||
coord cc;
|
coord cc;
|
||||||
DWORD count;
|
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) {
|
if (!ch) {
|
||||||
*x = cc.x;
|
*x = cc.x;
|
||||||
*y = cc.y;
|
*y = cc.y;
|
||||||
|
|||||||
Reference in New Issue
Block a user