home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Hack-Phreak Scene Programs
/
cleanhpvac.zip
/
cleanhpvac
/
SLOWRUNS.ZIP
/
SLOWSRC.ZIP
/
MAGIC5.H
< prev
next >
Wrap
C/C++ Source or Header
|
1997-09-06
|
10KB
|
302 lines
// defines for the keyboard interface
#define KEYBOARD_INTERRUPT 0x09 // the keyboard interrupt number
#define KEY_BUFFER 0x60 // the port of the keyboard buffer
#define KEY_CONTROL 0x61 // the port of the keyboard controller
#define PIC_PORT 0x20 // the port of the peripheral
// interrupt controller (PIC)
// these are the scan codes for the keys on the keyboard, note they are all
// from 0-127 and hence are the "make" scan codes, 128-255 are for the break
// scan codes and are computed simply by adding 128 to each of the make codes
#define MAKE_ESC 1
#define MAKE_1 2
#define MAKE_2 3
#define MAKE_3 4
#define MAKE_4 5
#define MAKE_5 6
#define MAKE_6 7
#define MAKE_7 8
#define MAKE_8 9
#define MAKE_9 10
#define MAKE_0 11
#define MAKE_MINUS 12
#define MAKE_EQUALS 13
#define MAKE_BKSP 14
#define MAKE_TAB 15
#define MAKE_Q 16
#define MAKE_W 17
#define MAKE_E 18
#define MAKE_R 19
#define MAKE_T 20
#define MAKE_Y 21
#define MAKE_U 22
#define MAKE_I 23
#define MAKE_O 24
#define MAKE_P 25
#define MAKE_LFT_BRACKET 26
#define MAKE_RGT_BRACKET 27
#define MAKE_ENTER 28
#define MAKE_CTRL 29
#define MAKE_A 30
#define MAKE_S 31
#define MAKE_D 32
#define MAKE_F 33
#define MAKE_G 34
#define MAKE_H 35
#define MAKE_J 36
#define MAKE_K 37
#define MAKE_L 38
#define MAKE_SEMI 39
#define MAKE_APOS 40
#define MAKE_TILDE 41
#define MAKE_LEFT_SHIFT 42
#define MAKE_BACK_SLASH 43
#define MAKE_Z 44
#define MAKE_X 45
#define MAKE_C 46
#define MAKE_V 47
#define MAKE_B 48
#define MAKE_N 49
#define MAKE_M 50
#define MAKE_COMMA 51
#define MAKE_PERIOD 52
#define MAKE_FORWARD_SLASH 53
#define MAKE_RIGHT_SHIFT 54
#define MAKE_PRT_SCRN 55
#define MAKE_ALT 56
#define MAKE_SPACE 57
#define MAKE_CAPS_LOCK 58
#define MAKE_F1 59
#define MAKE_F2 60
#define MAKE_F3 61
#define MAKE_F4 62
#define MAKE_F5 63
#define MAKE_F6 64
#define MAKE_F7 65
#define MAKE_F8 66
#define MAKE_F9 67
#define MAKE_F10 68
#define MAKE_F11 87
#define MAKE_F12 88
#define MAKE_NUM_LOCK 69
#define MAKE_SCROLL_LOCK 70
#define MAKE_HOME 71
#define MAKE_UP 72
#define MAKE_PGUP 73
#define MAKE_KEYPAD_MINUS 74
#define MAKE_LEFT 75
#define MAKE_CENTER 76
#define MAKE_RIGHT 77
#define MAKE_KEYPAD_PLUS 78
#define MAKE_END 79
#define MAKE_DOWN 80
#define MAKE_PGDWN 81
#define MAKE_INS 82
#define MAKE_DEL 83
#define BREAK_ESC 129
#define BREAK_1 130
#define BREAK_2 131
#define BREAK_3 132
#define BREAK_4 133
#define BREAK_5 134
#define BREAK_6 135
#define BREAK_7 136
#define BREAK_8 137
#define BREAK_9 138
#define BREAK_0 139
#define BREAK_MINUS 140
#define BREAK_EQUALS 141
#define BREAK_BKSP 142
#define BREAK_TAB 143
#define BREAK_Q 144
#define BREAK_W 145
#define BREAK_E 146
#define BREAK_R 147
#define BREAK_T 148
#define BREAK_Y 149
#define BREAK_U 150
#define BREAK_I 151
#define BREAK_O 152
#define BREAK_P 153
#define BREAK_LFT_BRACKET 154
#define BREAK_RGT_BRACKET 155
#define BREAK_ENTER 156
#define BREAK_CTRL 157
#define BREAK_A 158
#define BREAK_S 159
#define BREAK_D 160
#define BREAK_F 161
#define BREAK_G 162
#define BREAK_H 163
#define BREAK_J 164
#define BREAK_K 165
#define BREAK_L 166
#define BREAK_SEMI 167
#define BREAK_APOS 168
#define BREAK_TILDE 169
#define BREAK_LEFT_SHIFT 170
#define BREAK_BACK_SLASH 171
#define BREAK_Z 172
#define BREAK_X 173
#define BREAK_C 174
#define BREAK_V 175
#define BREAK_B 176
#define BREAK_N 177
#define BREAK_M 178
#define BREAK_COMMA 179
#define BREAK_PERIOD 180
#define BREAK_FORWARD_SLASH 181
#define BREAK_RIGHT_SHIFT 182
#define BREAK_PRT_SCRN 183
#define BREAK_ALT 184
#define BREAK_SPACE 185
#define BREAK_CAPS_LOCK 186
#define BREAK_F1 187
#define BREAK_F2 188
#define BREAK_F3 189
#define BREAK_F4 190
#define BREAK_F5 191
#define BREAK_F6 192
#define BREAK_F7 193
#define BREAK_F8 194
#define BREAK_F9 195
#define BREAK_F10 196
#define BREAK_F11 215
#define BREAK_F12 216
#define BREAK_NUM_LOCK 197
#define BREAK_SCROLL_LOCK 198
#define BREAK_HOME 199
#define BREAK_UP 200
#define BREAK_PGUP 201
#define BREAK_KEYPAD_MINUS 202
#define BREAK_LEFT 203
#define BREAK_CENTER 204
#define BREAK_RIGHT 205
#define BREAK_KEYPAD_PLUS 206
#define BREAK_END 207
#define BREAK_DOWN 208
#define BREAK_PGDWN 209
#define BREAK_INS 210
#define BREAK_DEL 211
// bitmasks for the "shift state"
// note there is a difference between "on" and "down"
#define KEY_UP 0
#define KEY_DOWN 1
#define SHIFT_RIGHT 0x0001 // right shift
#define SHIFT_LEFT 0x0002 // left shift
#define CTRL 0x0004 // control key
#define ALT 0x0008 // alternate key
#define SCROLL_LOCK_ON 0x0010 // the scroll lock is on
#define NUM_LOCK_ON 0x0020 // the numeric lock is on
#define CAPS_LOCK_ON 0x0040 // the capitals lock is on
#define INSERT_MODE 0x0080 // insert or overlay mode
#define CTRL_LEFT 0x0100 // the left control key is pressed
#define ALT_LEFT 0x0200 // the left alternate key is pressed
#define CTRL_RIGHT 0x0400 // the right control key is pressed
#define ALT_RIGHT 0x0800 // the right alternate key is pressed
#define SCROLL_LOCK_DOWN 0x1000 // the scroll lock key is pressed
#define NUM_LOCK_DOWN 0x2000 // the numeric lock key is pressed
#define CAPS_LOCK_DOWN 0x4000 // the capitals lock key is pressed
#define SYS_REG_DOWN 0x8000 // the system request key is pressed
// Joystick stuff
#define JOYPORT 0x201 // joyport is at 201 hex
#define USE_BIOS 0 // command to use BIOS version
#define USE_LOW_LEVEL 1 // command to use our own low level version
#define JOYSTICK_BUTTON_1_1 0x10 // joystick1, button 1
#define JOYSTICK_BUTTON_1_2 0x20 // joystick1, button 2
#define JOYSTICK_BUTTON_2_1 0x40 // joystick2, button 1
#define JOYSTICK_BUTTON_2_2 0x80 // joystick2, button 2
#define JOYSTICK_1 0x01 // joystick 1
#define JOYSTICK_2 0x02 // joystick 2
#define JOYSTICK_1_X 0x01 // joystick 1, x axis
#define JOYSTICK_1_Y 0x02 // joystick 1, y axis
#define JOYSTICK_2_X 0x04 // joystick 2, x axis
#define JOYSTICK_2_Y 0x08 // joystick 2, y axis
// mouse stuff
#define MOUSE_INTERRUPT 0x33 // mouse interrupt handler
#define MOUSE_RESET 0x00 // reset the mouse
#define MOUSE_SHOW 0x01 // show the mouse
#define MOUSE_HIDE 0x02 // hide the mouse
#define MOUSE_POSITION_BUTTONS 0x03 // get buttons and position
#define MOUSE_MOTION_REL 0x0B // query motion counters
// to compute relative motion
#define MOUSE_SET_SENSITIVITY 0x1A // set the sensitivity of mouse
// mouse button bitmasks
#define MOUSE_LEFT_BUTTON 0x01 // left mouse button mask
#define MOUSE_MIDDLE_BUTTON 0x04 // middle mouse button mask
#define MOUSE_RIGHT_BUTTON 0x02 // right mouse button mask
// E X T E R N A L S /////////////////////////////////////////////////////////
extern void (_interrupt _far *Old_Keyboard_ISR)(); // holds old keyboard interrupt handler
extern int raw_scan_code; // the global keyboard scan code
extern int askey_code; // the global keyboard ASCii code
// this holds the keyboard state table which tracks the state of every key
// on the keyboard, if any element is a one then the key is down
extern int keyboard_state[128];
// this tracks the number of keys that are currently pressed, helps
// with keyboard testing logic
extern int keys_active;
// these values hold the maximum, minimum and neutral joystick values for
// both joysticks
extern unsigned int joystick_1_max_x, // maximum deflection of X axis joy 1
joystick_1_max_y, // maximum deflection of Y axis joy 1
joystick_1_min_x, // minimum deflection of X axis joy 1
joystick_1_min_y, // minimum deflection of Y axis joy 1
joystick_1_neutral_x, // neutral or center of X axis joy 1
joystick_1_neutral_y, // neutral or center of Y axis joy 1
joystick_2_max_x, // maximum deflection of X axis joy 2
joystick_2_max_y, // maximum deflection of Y axis joy 2
joystick_2_min_x, // minimum deflection of X axis joy 2
joystick_2_min_y, // minimum deflection of Y axis joy 2
joystick_2_neutral_x, // neutral or center of X axis joy 2
joystick_2_neutral_y; // neutral or center of Y axis joy 2
// P R O T O T Y P E S ////////////////////////////////////////////////////////
// FUNCTION PROTOTYPES //////////////////////
unsigned char Get_Key(void);
unsigned char Get_Scan_Code(void);
unsigned int Get_Shift_State(unsigned int mask);
void Keyboard_Install_Driver(void);
void Keyboard_Remove_Driver(void);
void _interrupt _far Keyboard_Driver(void);
// joystick stuff
unsigned char Joystick_Buttons(unsigned char button);
unsigned int Joystick(unsigned char stick);
unsigned int Joystick_Bios(unsigned char stick);
void Joystick_Calibrate(int stick, int method);
int Joystick_Available(int stick_num);
// mouse stuff
int Mouse_Control(int command, int *x, int *y, int *buttons);