From 411c204ccbad3879ba1edda23ae33d5a1eccff21 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 27 Oct 2016 03:17:23 -0400 Subject: [PATCH] Just enough to get wasm.exe to not crash prompting for the Any key. This lets the program survive if you run it without command line arguments. --- native/kbdcalls.c | 37 +++++++++++++++++++++++++++++++++++-- native/kbdcalls.h | 14 ++++++++++++++ native/os2types.h | 1 + 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/native/kbdcalls.c b/native/kbdcalls.c index 8d715ca..81da8d4 100644 --- a/native/kbdcalls.c +++ b/native/kbdcalls.c @@ -1,7 +1,40 @@ -#include "os2native.h" +#include "os2native16.h" #include "kbdcalls.h" -LX_NATIVE_MODULE_INIT() +APIRET16 KbdCharIn(PKBDKEYINFO pkbci, USHORT fWait, HKBD hkbd) +{ + TRACE_NATIVE("KbdCharIn(%p, %u, %u)", pkbci, fWait, hkbd); + FIXME("this is just enough to survive 'press any key'"); + getchar(); + return NO_ERROR; +} // kbdCharIn + +static APIRET16 bridge16to32_KbdCharIn(uint8 *args) +{ + const HKBD hkbd = *((HKBD *) args); args += 2; + const USHORT fWait = *((USHORT *) args); args += 2; + //PKBDKEYINFO pkbci = (PKBDKEYINFO) GLoaderState->convert1616to32(*((uint32*) args)); //args += 4; + return KbdCharIn(NULL/*FIXMEpkbci*/, fWait, hkbd); +} // bridge16to32_KbdCharIn + +LX_NATIVE_MODULE_16BIT_SUPPORT() + LX_NATIVE_MODULE_16BIT_API(KbdCharIn) +LX_NATIVE_MODULE_16BIT_SUPPORT_END() + +LX_NATIVE_MODULE_DEINIT({ + LX_NATIVE_MODULE_DEINIT_16BIT_SUPPORT(); +}) + +static int initKbdcalls(void) +{ + LX_NATIVE_MODULE_INIT_16BIT_SUPPORT() + LX_NATIVE_INIT_16BIT_BRIDGE(KbdCharIn, 8) + LX_NATIVE_MODULE_INIT_16BIT_SUPPORT_END() + return 1; +} // initViocalls + +LX_NATIVE_MODULE_INIT({ if (!initKbdcalls()) return NULL; }) + LX_NATIVE_EXPORT16(KbdCharIn, 4) LX_NATIVE_MODULE_INIT_END() // end of kbdcalls.c ... diff --git a/native/kbdcalls.h b/native/kbdcalls.h index 82b9a9c..852c3a3 100644 --- a/native/kbdcalls.h +++ b/native/kbdcalls.h @@ -7,6 +7,20 @@ extern "C" { #endif +#pragma pack(push, 2) +typedef struct +{ + UCHAR chChar; + UCHAR chScan; + UCHAR fbStatus; + UCHAR bNlsShift; + USHORT fsState; + ULONG time; +} KBDKEYINFO, *PKBDKEYINFO; +#pragma pack(pop) + +APIRET16 OS2API16 KbdCharIn(PKBDKEYINFO pkbci, USHORT fWait, HKBD hkbd); + #ifdef __cplusplus } #endif diff --git a/native/os2types.h b/native/os2types.h index 62b631e..b2f1121 100644 --- a/native/os2types.h +++ b/native/os2types.h @@ -66,6 +66,7 @@ typedef HANDLE HMTX, *PHMTX; typedef HANDLE PID, *PPID; typedef HANDLE TID, *PTID; typedef SHANDLE HVIO, *PHVIO; +typedef SHANDLE HKBD, *PHKBD; typedef PCHAR PSZ; typedef int (APIENTRY *PFN)(void);