Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DosDevIOCtl keyboard function problem

10 views
Skip to first unread message

Eric Veldhuyzen

unread,
Jun 4, 1995, 3:00:00 AM6/4/95
to
Hi,

I am trying to get the keyboard mode, but DosDevIOCtl gives me an
errorcode 22 (Bad Command?). Could sombody please explain to me what's
wrong? Here is a fragment of what I was trying to do:

#define INCL_DOSDEVICES
#define INCL_DOSDEVIOCTL
#include <os2.h>

#define STDIN 0x00000000
#define STDOUT 0x00000001
#define STDERR 0x00000002

int main ()
{
APIRET rc;
ULONG ParmLengthInOut = 0,
DataLengthInOut = 0;

BYTE KeyboardMode;

if ((rc = DosDevIOCtl (STDIN, IOCTL_KEYBOARD, KBD_GETINPUTMODE,
(PVOID) & KeyboardMode, sizeof (BYTE), &ParmLengthInOut,
NULL, 0, NULL)) != 0) {
printf ("DosDevIOCtl GetInputMode failed with rc = %ld.\n", rc);
return (rc);
}
}

BTW, I am using EMX gcc.

--
Eric Veldhuyzen TEAM OS/2
Eric.Ve...@si.hhs.nl CIS: [100010,3051]
Er...@terra.xs4all.nl PGP-KeyID: 0xFB64FCB3
************ FIGHT to keep your right to PRIVACY. Use PGP! ************

deb@ibm

unread,
Jun 6, 1995, 3:00:00 AM6/6/95
to

You need to open the keyboard device, not use standard input. So add:

rc = DosOpen( "KBD$ ", &hKbd, &ulAction, 0L, 4L, 1L, 0x40L, NULL );

to your code and then pass hKbd into DosDevIOCtl instead of STDIN if rc is
equal to NO_ERROR...

Eric Veldhuyzen

unread,
Jun 8, 1995, 3:00:00 AM6/8/95
to
In article <D9rHt...@bocanews.bocaraton.ibm.com>, <deb@ibm> wrote:
>
>You need to open the keyboard device, not use standard input. So add:
>
> rc = DosOpen( "KBD$ ", &hKbd, &ulAction, 0L, 4L, 1L, 0x40L, NULL );
>
>to your code and then pass hKbd into DosDevIOCtl instead of STDIN if rc is
>equal to NO_ERROR...

Thanks, but I think I need more than this, since now my program
gives me the message "The parameter is incorrect" (rc = 87).

#define INCL_DOSDEVICES
#define INCL_DOSDEVIOCTL
#define INCL_DOSMISC
#include <os2.h>

int main ()
{
APIRET rc;
ULONG ParmLengthInOut = 0,

Action,
MsgLength,
bytesWritten;
UCHAR Msg[100];
BYTE KeyboardMode;
HFILE KeyboardHandle;

if ((rc = DosOpen ("KBD$", &KeyboardHandle, &Action, 0L,
FILE_NORMAL, FILE_OPEN | OPEN_ACTION_FAIL_IF_NEW,
OPEN_ACCESS_READONLY | OPEN_SHARE_DENYREADNONE, NULL)) != 0) {
DosGetMessage (NULL, 0, Msg, sizeof (Msg), rc, "OSO001.MSG", &MsgLength);
DosWrite (1, Msg, MsgLength, &bytesWritten);
return (rc);
}
if ((rc = DosDevIOCtl (KeyboardHandle, IOCTL_KEYBOARD, KBD_GETINPUTMODE,


(PVOID) & KeyboardMode, sizeof (BYTE), &ParmLengthInOut,
NULL, 0, NULL)) != 0) {

DosGetMessage (NULL, 0, Msg, sizeof (Msg), rc, "OSO001.MSG", &MsgLength);
DosWrite (1, Msg, MsgLength, &bytesWritten);
return (rc);
}
return (0);
}

Please mail me too, because my newsfeed is very unstable lately. I
don't want to miss any replies.

deb@ibm

unread,
Jun 12, 1995, 3:00:00 AM6/12/95
to

The name of the device driver is space-sensitive, so you need to include
the four blanks in the string as I did (there wasn't a typo or a spastic
finger at fault). Make sure to pass in "KBD$ ", not "KBD$"...

Lafaix Martin

unread,
Jun 12, 1995, 3:00:00 AM6/12/95
to
In article <DA2HC...@bocanews.bocaraton.ibm.com>, deb@ibm writes:
|> In <2fd63742....@terra.xs4all.nl>, er...@terra.xs4all.nl (Eric Veldhuyzen) writes:
|> >In article <D9rHt...@bocanews.bocaraton.ibm.com>, <deb@ibm> wrote:
|> >>
|> >>You need to open the keyboard device, not use standard input. So add:
|> >>
|> >> rc = DosOpen( "KBD$ ", &hKbd, &ulAction, 0L, 4L, 1L, 0x40L, NULL );
|> >>
|> >>to your code and then pass hKbd into DosDevIOCtl instead of STDIN if rc is
|> >>equal to NO_ERROR...
|> >
|> >Thanks, but I think I need more than this, since now my program
|> >gives me the message "The parameter is incorrect" (rc = 87).
|>
|> The name of the device driver is space-sensitive, so you need to include
|> the four blanks in the string as I did (there wasn't a typo or a spastic
|> finger at fault). Make sure to pass in "KBD$ ", not "KBD$"...
|>
|>

Hum, I respectfuly beg to differ :-)

In fact, I think the tricky part is that you have to use the
OPEN_SHARE_DENYNONE flag to get it to work. The following code
works just fine (at least with Warp):

rc = DosOpen("KBD$",

&hf,
&ulAction,
0L,
0,
FILE_OPEN,
OPEN_ACCESS_READONLY|OPEN_SHARE_DENYNONE,
0);

Hope this helps...

Martin.
--
laf...@mimosa.unice.fr
Team OS/2

Simon Bowring

unread,
Jun 13, 1995, 3:00:00 AM6/13/95
to
In article <DA2HC...@bocanews.bocaraton.ibm.com>, deb@ibm wrote:

> >>
> >> rc = DosOpen( "KBD$ ", &hKbd, &ulAction, 0L, 4L, 1L, 0x40L, NULL );
>

> The name of the device driver is space-sensitive, so you need to include
> the four blanks in the string as I did (there wasn't a typo or a spastic
> finger at fault). Make sure to pass in "KBD$ ", not "KBD$"...

I'm 95% sure this is not true! I am certain that it is not true for
other character mode device drivers in general, and it is certainly
not true for the clock$, com port and lpt device drivers, as well as all
the character mode drivers I have written.

The name in a device driver's header is space padded to 8 characters,
but there is *NO* requirement for this to be reflected in the
DosOpen() call.

Try "copy kbd$ con", type a few characters followed by CTRL-Z (End of File)
and press enter (this is not proof, since CMD.EXE could have coded a special
case for the keyboard driver, but it is evidence).

Regards

Simon Bowring


Eric Veldhuyzen

unread,
Jun 18, 1995, 3:00:00 AM6/18/95
to
In article <DA2HC...@bocanews.bocaraton.ibm.com>, <deb@ibm> wrote:
>In <2fd63742....@terra.xs4all.nl>, er...@terra.xs4all.nl (Eric Veldhuyzen) writes:
>>In article <D9rHt...@bocanews.bocaraton.ibm.com>, <deb@ibm> wrote:
>>>
>>>You need to open the keyboard device, not use standard input. So add:
>>>
>>> rc = DosOpen( "KBD$ ", &hKbd, &ulAction, 0L, 4L, 1L, 0x40L, NULL );
>>>
>>>to your code and then pass hKbd into DosDevIOCtl instead of STDIN if rc is
>>>equal to NO_ERROR...
>>
>>Thanks, but I think I need more than this, since now my program
>>gives me the message "The parameter is incorrect" (rc = 87).
>>
>>#define INCL_DOSDEVICES
>>#define INCL_DOSDEVIOCTL
>>#define INCL_DOSMISC
>>#include <os2.h>
>>
>>int main ()
>>{
>> APIRET rc;
>> ULONG ParmLengthInOut = 0,
>> Action,
>> MsgLength,
>> bytesWritten;
>> UCHAR Msg[100];
>> BYTE KeyboardMode;
>> HFILE KeyboardHandle;
>>
>> if ((rc = DosOpen ("KBD$", &KeyboardHandle, &Action, 0L,
>> FILE_NORMAL, FILE_OPEN | OPEN_ACTION_FAIL_IF_NEW,
>> OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE, NULL)) != 0) {

>> DosGetMessage (NULL, 0, Msg, sizeof (Msg), rc, "OSO001.MSG", &MsgLength);
>> DosWrite (1, Msg, MsgLength, &bytesWritten);
>> return (rc);
>> }
>> if ((rc = DosDevIOCtl (KeyboardHandle, IOCTL_KEYBOARD, KBD_GETINPUTMODE,
>> (PVOID) & KeyboardMode, sizeof (BYTE), &ParmLengthInOut,
>> NULL, 0, NULL)) != 0) {
>> DosGetMessage (NULL, 0, Msg, sizeof (Msg), rc, "OSO001.MSG", &MsgLength);
>> DosWrite (1, Msg, MsgLength, &bytesWritten);
>> return (rc);
>> }
>> return (0);
>>}
>>
>The name of the device driver is space-sensitive, so you need to include
>the four blanks in the string as I did (there wasn't a typo or a spastic
>finger at fault). Make sure to pass in "KBD$ ", not "KBD$"...

I tried both "KBD$" and "KBD$ ", but it doesn't matter. It still
gives me the error that the parameter is incorrect. The open call
works just fine BTW.

kos...@cft.philips.nl

unread,
Jun 20, 1995, 3:00:00 AM6/20/95
to

The KBD_GETINPUTMODE function needs data packet, not a parameter packet!

Try the call this way:

if ((rc = DosDevIOCtl (KeyboardHandle, IOCTL_KEYBOARD, KBD_GETINPUTMODE,

NULL, 0, NULL,
(PVOID) & KeyboardMode, sizeof (BYTE), &ParmLengthInOut)) != 0) {

>>> DosGetMessage (NULL, 0, Msg, sizeof (Msg), rc, "OSO001.MSG", &MsgLength);
>>> DosWrite (1, Msg, MsgLength, &bytesWritten);
>>> return (rc);
>>> }
>>> return (0);
>>>}
>>>
>>The name of the device driver is space-sensitive, so you need to include
>>the four blanks in the string as I did (there wasn't a typo or a spastic
>>finger at fault). Make sure to pass in "KBD$ ", not "KBD$"...
>
>I tried both "KBD$" and "KBD$ ", but it doesn't matter. It still
>gives me the error that the parameter is incorrect. The open call
>works just fine BTW.
>
>--
>Eric Veldhuyzen TEAM OS/2
>Eric.Ve...@si.hhs.nl CIS: [100010,3051]
>Er...@terra.xs4all.nl PGP-KeyID: 0xFB64FCB3
> ************ FIGHT to keep your right to PRIVACY. Use PGP! ************


==========================================================================
Han Koster Nederlandse Philips Bedrijven BV
Internet: kos...@cft.philips.nl Centre for Manufacturing Technology
DECnet: NLZCL::KOSTER Eindhoven
Tel: (...)31 40 736647 The Netherlands
==========================================================================

Eric Veldhuyzen

unread,
Jun 23, 1995, 3:00:00 AM6/23/95
to
In article <3s6a3f$o...@phcoms4.seri.philips.nl>,

<kos...@cft.philips.nl> wrote:
>
>The KBD_GETINPUTMODE function needs data packet, not a parameter packet!
>
>Try the call this way:
>
> if ((rc = DosDevIOCtl (KeyboardHandle, IOCTL_KEYBOARD, KBD_GETINPUTMODE,
> NULL, 0, NULL,
> (PVOID) & KeyboardMode, sizeof (BYTE), &ParmLengthInOut)) != 0) {

Are you sure about this? My documentation says something else:

> Query Input Mode - Function 71h
>
> Description - Category 04h, Function 71h
>
>This function returns the input mode.
>
> Mode - Category 04h, Function 71h
>
> Mode
> A 1-byte field containing one of the following values:
> Bit 1xxxxxx1 Shift report
> Bit 0xxxxxx0 ASCII mode
> Bit 1xxxxxxx BINARY mode
>
> Parameter Packet Format - Category 04h, Function 71h
>
>ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄż
>łField Length ł
>ĂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´
>łMode BYTE ł
>ŔÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄŮ
>
> Data Packet Format - Category 04h, Function 71h
>
>None.
>
> Returns - Category 04h, Function 71h
>
>None.
>
> Remarks - Category 04h, Function 71h
>
>This request is used to obtain the input mode of the session of the currently
>active process. The input mode can be set with Function 51h. The input mode
>is meaningful for Ctrl+C, Ctrl+P, Ctrl+S, Ctrl+Break, Ctrl+ScrollLock, and
>Ctrl+PrtSc processing only.

0 new messages