Running this program in fullscreen mode works fine.
Running it in a VIO window causes the keyboard to be disabled and I need to use the mouse to reboot (CAD also works to initiate a reboot).
Can someone tell me:
1. Are the results (that I noted as strange) correct operation of the OS/2 functions?
2. Is there a way of getting these functions to work as intended (ie switch to binary mode, then switch back to text mode, as the Physical Device Driver Reference documents as supported functionality)?
Note that the switch to binary mode IS successful - even in the VIO windows - and my real (larger) app does work fine (that app doesn't switch back to text mode until termination time though, so I don't see a problem). It's only after it terminates that I have an issue, which is ironic.
Also note that I am aware of the Kbd* functions that could be used instead, but I don't wish to do thunking (including automated compiler thunking) *in my executable*.
If I use the DosDevIOCtl function, my executable is pure 32-bit. What happens in the doscalls.dll I don't care about. At least nominally I have no insight into that, as it is OS/2 internals, and those internals could change overnight. Also I am not interested in using high memory. This isn't a question about high memory. I will be using standard 32-bit DosOpen and standard 32-bit DosDevIOCtl (ordinal 284 in doscalls.dll or equivalent).
Note that I am using ArcaOS 5.0.8.
Code below.
Thanks. Paul.
wcl386 -bt=os2 -l=os2v2 pdptest.c os2386.lib -"option map"
#include <stdio.h>
#define INCL_DOS
#include <os2.h>
int main(void)
{
ULONG kbdfile;
static USHORT fileAttr = 0;
static ULONG newsize = 0;
ULONG action;
static ULONG openMode = OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE;
static ULONG openAction = OPEN_ACTION_OPEN_IF_EXISTS;
ULONG datalen;
ULONG parmlen;
USHORT rc;
BYTE bb;
static BYTE oldbb;
rc = DosOpen((PSZ)"KBD$",
&kbdfile,
&action,
newsize,
fileAttr,
openAction,
openMode,
0);
if (rc != 0)
{
return (-1);
}
parmlen = 0;
datalen = sizeof oldbb;
/* get old input mode */
rc = DosDevIOCtl(kbdfile,
4,
0x71,
NULL,
0,
&parmlen,
&oldbb,
sizeof oldbb,
&datalen);
printf("rc is %d\n", rc);
printf("surprisingly, oldmode is already binary %x\n", (int)oldbb);
printf("surprisingly, we need to set binary mode, even though it is already set\n");
/* set binary mode */
bb = 0x80;
parmlen = sizeof bb;
datalen = 0;
rc = DosDevIOCtl(kbdfile,
4,
0x51,
&bb,
sizeof bb,
&parmlen,
NULL,
0,
&datalen);
printf("rc is %d\n", rc);
printf("restoring old (binary) mode is identical and useless and behavior is same\n");
printf("so setting text mode instead\n");
oldbb = 0;
parmlen = sizeof oldbb;
datalen = 0;
rc = DosDevIOCtl(kbdfile,
4,
0x51,
&oldbb,
sizeof oldbb,
&parmlen,
NULL,
0,
&datalen);
printf("rc is %d\n", rc);
rc = DosClose(kbdfile);
printf("rc is %d\n", rc);
printf("surprisingly, keyboard is now inoperative and you need to use mouse to reboot\n");
return (0);
}