TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: David Muir
from: Bruce Hoyt
date: 1996-02-28 09:04:40
subject: All keys for KbdCharIn

-=> Quoting David Muir to All <=-

 DM> okay.. simple question. KbdCharIn() and KbdPeek() do not recognize

 DM> the  following three characters as input from the keyboard..

 DM> CTRL-P

 DM> CTRL-S

 DM> CTRL-T

 DM> What can I do to intercept the pressing of these three control

 DM> keys (in  addition to all other combinations of course)?



I assumed that setting binary mode using DosDevIOCtl category 4 function 0x51

would work but I get an error 0x16 which is Unknown_Command. Here's my code:

----------------------------------------------------------------------------

/* Test for disabling keyboard Ctrl-C using emx 9.0a

	and os2.h and os2386.lib from DEVCON 7 Toolkit.



	I need to disable Ctrl-C for my OS/2 Native Forth Interpreter.

	Documentation in Control Program Guide and Reference is sparce

	but I assume that the DosDevIOCtl category 4, function 0x51 does

	what I want. But I can't get it to work. When I call it,

	I get error 0x16 which is Unknown Command. This happens both

	in a window and in full screen mode. Why?

*/



#define INCL_KBD

#define INCL_DOSDEVICES

#define INCL_DOSDEVIOCTL



#include 

#include 



KBDKEYINFO chardata;



ULONG getkey (void) {

	APIRET rc;



	rc = KbdCharIn(&chardata, 0, 0);

	if (rc != 0) {

		printf("KbdCharIn error = %x\n", rc);

	}

	return (chardata.chChar + (chardata.chScan<<8));

}



/* DosDevIOCtl(hDevice, category, function,

	pParams, cbParmLenMax, pcbParmLen,

	pData, cbDataLenMax, pcbDataLen)

*/



UCHAR parm = 0x80;		/* set binary mode */

ULONG parmlen;			/* return length of parameter block here */



void set_binary_mode(void) {

	APIRET rc;



	rc = DosDevIOCtl( (HFILE)0, 4, 0x51, &parm, 1, &parmlen, NULL, 0, NULL);

	if (rc != 0) {

		/* Why do I get error 0x16 = Unknown_Command here? */

		printf("DosDevIOCtl error = %x\n", rc);

	}

}



main () {

	set_binary_mode();

	for(;;) {

		printf("Key pressed = %x\n", getkey());

	}

}

----------------------------------------------------------------------------



Bruce



--- Blue Wave v2.12 OS/2 [NR]

* Origin: Snoopy's OS/2 BBS (3:772/380)
SEEN-BY: 50/99 78/0 620/243 622/407 623/630 632/339 640/705 690/347 711/409
SEEN-BY: 711/410 413 430 808 809 934 955 712/515 713/888 770/115 771/1320
SEEN-BY: 772/1 20 135 350 380 774/605 800/1 7877/2809
@PATH: 772/380 20 711/955 808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.