home *** CD-ROM | disk | FTP | other *** search
- /*
- * Keycode and Event Record interpreter for MicroEMACS 3.9e for the
- * Macintosh. This file is built into a separate code-containing
- * resource of type GetC, ID #606. It takes a pointer to an
- * Event Record, and returns an appropriate eight-bit character
- * code, ORed with one of four modifier flags, as below.
- *
- * "This program supports ALL Macintosh keyboards."
- * (But YOU have to supply the key interpreter for YOUR keyboard!)
- *
- */
- #define __SEG__ Liberty
- #ifdef macintosh /* MPW */
- #include <events.h>
- #else /* LSC */
- #include <EventMgr.h>
- #endif
- #define CTRL 0x0100 /* Control flag, or'ed in */
- #define META 0x0200 /* Meta flag, or'ed in */
- #define CTLX 0x0400 /* ^X flag, or'ed in */
- #define SPEC 0x0800 /* special key (function key) */
-
- long main(E)
- EventRecord *E;
-
- {
- unsigned short c;
-
- c = 0;
-
- switch ( (E->message&keyCodeMask)>>8 ){
- /*
- * Extended Keyboard Function Keys.
- */
- case 122:
- c = SPEC | '1'; /* Saratoga "F1" */
- break;
- case 120:
- c = SPEC | '2';
- break;
- case 99:
- c = SPEC | '3';
- break;
- case 118:
- c = SPEC | '4';
- break;
- case 96:
- c = SPEC | '5';
- break;
- case 97:
- c = SPEC | '6';
- break;
- case 98:
- c = SPEC | '7';
- break;
- case 100:
- c = SPEC | '8';
- break;
- case 101:
- c = SPEC | '9';
- break;
- case 109:
- c = SPEC | 'A';
- break;
- case 103:
- c = SPEC | 'B';
- break;
- case 111:
- c = SPEC | 'C';
- break;
- case 105:
- c = SPEC | 'D';
- break;
- case 107:
- c = SPEC | 'E';
- break;
- case 113:
- c = SPEC | 'F'; /* "F15" */
- break;
- /*
- * Special Keys.
- */
- case 121: /* Page Down */
- c = SPEC | 'V';
- break;
- case 116: /* Page Up */
- c = SPEC | 'Z';
- break;
- case 119: /* End */
- c = SPEC | '>';
- break;
- case 115: /* Home */
- c = SPEC | '<';
- break;
- case 114: /* Help */
- c = SPEC | '?';
- break;
- case 117: /* Del */
- return (127);
- default:
- break;
- }
- if (c != 0)return c;
-
- /* Get the character code. */
-
- c = (unsigned short) (E->message & charCodeMask);
- /*
- * Map control characters to their positions. Pre-ADB keyboards
- * use the propeller key for control. Propeller-digit is used to
- * emulate function keys f1 through f10 and F1 through F10.
- * The normal 32 control characters can be generated with the
- * command key, as well as some bogus ones, like ^╢, ^;, and
- * lots others.
- */
- if(E->modifiers & cmdKey){
- if( c <= '9' && c >= '0'){
- return (c | SPEC);
- }
- if ( c == '[' || c == ']' || c == '^' || c == '_' || c == '\\'
- || c <= ' ' || ( c >= 'A' && c <= 'Z')
- || ( c >= 'a' && c <= 'z'))
- c &= 31;
- else c |= CTRL;
- }
- return (c);
- }
-
-