[comp.sys.atari.st] Program to turn KeyClick On/Off

david@looking.UUCP (03/27/87)

*** REPLACE THIS LINE WITH YOUR MESSAGE ***

Someone was asking how to turn key click on/off within a program.
(I believe it was Warren Long, who didn't want key click sounds to
 interrupt the other sounds generated by SpaceWars).

Well here is a simple program to do it.  It is pretty much self-
explanatory.

--------------------cut here----------------cut here--------------------
#include <stdio.h>
#include <osbind.h>

/* CLICK Modes */
#define C_TOGGLE	0
#define C_SET		1
#define C_RESET		2

/* System Variable 'Conterm' is a byte */
#define CONTERM		(*((char *)0x484))

/* Declare the meaning of the bits */
#define CLICK_BIT	1	/* Key click on/off */
#define REPEAT_BIT	2	/* Key repeat on/off */
#define BELL_BIT	4	/* Bell at <ctrl-G> on/off */
#define KBSHIFT_BIT	8	/* Return KBShift from Cconin in
				 * bits 24-31 on/off
				 */

main( argc, argv )
int argc;
char *argv[];
{
	int old_val, new_val;
	int mode;
	long save_ssp;

	/* Get the option.  If no option, toggle click setting */
	if( argc < 2 )
		mode = C_TOGGLE;
	else if ( strcmp( argv[1], "on" ) == 0 )
		mode = C_SET;
	else if ( strcmp( argv[1], "off" ) == 0 )
		mode = C_RESET;
	else {
		printf( "Unknown option '%s'\n", argv[1] );
		exit(1);
	}

	/* Enter Supervisor mode */
	save_ssp = Super( 0L );

	/* Get old value of CONTERM byte */
	old_val = CONTERM;

	switch( mode ) {
		case C_TOGGLE:
			new_val = old_val ^ CLICK_BIT;
			break;
		case C_SET:
			new_val = old_val | CLICK_BIT;
			break;
		case C_RESET:
			new_val = old_val & ~CLICK_BIT;
			break;
	}

	/* Set the new value */
	CONTERM = new_val;

	/* Exit out of supervisor mode */
	Super( save_ssp );
}

-------------cut here--------------------cut here-------------------------

David Rowley
Looking Glass Software
Waterloo, Ontario
...utzoo!watmath!looking!david