home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / program / keyclick / keyclick.txt
Encoding:
Text File  |  1985-11-19  |  2.0 KB  |  81 lines

  1.  
  2. Someone was asking how to turn key click on/off within a program.
  3. (I believe it was Warren Long, who didn't want key click sounds to
  4.  interrupt the other sounds generated by SpaceWars).
  5.  
  6. Well here is a simple program to do it.  It is pretty much self-
  7. explanatory.
  8.  
  9. --------------------cut here----------------cut here--------------------
  10. #include <stdio.h>
  11. #include <osbind.h>
  12.  
  13. /* CLICK Modes */
  14. #define C_TOGGLE    0
  15. #define C_SET        1
  16. #define C_RESET        2
  17.  
  18. /* System Variable 'Conterm' is a byte */
  19. #define CONTERM        (*((char *)0x484))
  20.  
  21. /* Declare the meaning of the bits */
  22. #define CLICK_BIT    1    /* Key click on/off */
  23. #define REPEAT_BIT    2    /* Key repeat on/off */
  24. #define BELL_BIT    4    /* Bell at <ctrl-G> on/off */
  25. #define KBSHIFT_BIT    8    /* Return KBShift from Cconin in
  26.                  * bits 24-31 on/off
  27.                  */
  28.  
  29. main( argc, argv )
  30. int argc;
  31. char *argv[];
  32. {
  33.     int old_val, new_val;
  34.     int mode;
  35.     long save_ssp;
  36.  
  37.     /* Get the option.  If no option, toggle click setting */
  38.     if( argc < 2 )
  39.         mode = C_TOGGLE;
  40.     else if ( strcmp( argv[1], "on" ) == 0 )
  41.         mode = C_SET;
  42.     else if ( strcmp( argv[1], "off" ) == 0 )
  43.         mode = C_RESET;
  44.     else {
  45.         printf( "Unknown option '%s'\n", argv[1] );
  46.         exit(1);
  47.     }
  48.  
  49.     /* Enter Supervisor mode */
  50.     save_ssp = Super( 0L );
  51.  
  52.     /* Get old value of CONTERM byte */
  53.     old_val = CONTERM;
  54.  
  55.     switch( mode ) {
  56.         case C_TOGGLE:
  57.             new_val = old_val ^ CLICK_BIT;
  58.             break;
  59.         case C_SET:
  60.             new_val = old_val | CLICK_BIT;
  61.             break;
  62.         case C_RESET:
  63.             new_val = old_val & ~CLICK_BIT;
  64.             break;
  65.     }
  66.  
  67.     /* Set the new value */
  68.     CONTERM = new_val;
  69.  
  70.     /* Exit out of supervisor mode */
  71.     Super( save_ssp );
  72. }
  73.  
  74. -------------cut here--------------------cut here-------------------------
  75.  
  76. David Rowley
  77. Looking Glass Software
  78. Waterloo, Ontario
  79. ...utzoo!watmath!looking!david
  80.  
  81.