Just enough to get wasm.exe to not crash prompting for the Any key.
authorRyan C. Gordon <icculus@icculus.org>
Thu, 27 Oct 2016 03:17:23 -0400
changeset 67 8bcb1be36798
parent 66 f57c9b6d10ee
child 68 703acbf2086b
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
native/kbdcalls.h
native/os2types.h
--- a/native/kbdcalls.c	Thu Oct 27 02:26:20 2016 -0400
+++ b/native/kbdcalls.c	Thu Oct 27 03:17:23 2016 -0400
@@ -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 ...
--- a/native/kbdcalls.h	Thu Oct 27 02:26:20 2016 -0400
+++ b/native/kbdcalls.h	Thu Oct 27 03:17:23 2016 -0400
@@ -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
--- a/native/os2types.h	Thu Oct 27 02:26:20 2016 -0400
+++ b/native/os2types.h	Thu Oct 27 03:17:23 2016 -0400
@@ -66,6 +66,7 @@
 typedef HANDLE PID, *PPID;
 typedef HANDLE TID, *PTID;
 typedef SHANDLE HVIO, *PHVIO;
+typedef SHANDLE HKBD, *PHKBD;
 typedef PCHAR PSZ;
 
 typedef int (APIENTRY *PFN)(void);