Skip to content

Commit

Permalink
Just enough to get wasm.exe to not crash prompting for the Any key.
Browse files Browse the repository at this point in the history
This lets the program survive if you run it without command line arguments.
  • Loading branch information
icculus committed Oct 27, 2016
1 parent 970cbbc commit 411c204
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
37 changes: 35 additions & 2 deletions 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 ...
Expand Down
14 changes: 14 additions & 0 deletions native/kbdcalls.h
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions native/os2types.h
Expand Up @@ -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);
Expand Down

0 comments on commit 411c204

Please sign in to comment.