From 224593e70556ab822a91735708c7f12a429ea09f Mon Sep 17 00:00:00 2001 From: ghaushe Date: Wed, 5 Feb 2003 03:52:50 +0000 Subject: [PATCH] Added a 4th button DEVICE_BUTTON4 currently assigned as 'Esc' which executes an emergency-escape (the old chord still works too) git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@678 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/ChangeLog | 1 + sc2/content/starcon.key | 8 ++++++-- sc2/doc/users/manual.txt | 4 +++- sc2/src/sc2code/battle.c | 5 +++-- sc2/src/sc2code/libs/inplib.h | 13 +++++++------ sc2/src/sc2code/libs/input/inpintrn.h | 21 ++++++++++++--------- sc2/src/sc2code/libs/input/input_common.c | 10 +++++----- sc2/src/sc2code/libs/input/sdl/input.c | 2 ++ sc2/src/sc2code/setup.c | 12 +++++++----- 9 files changed, 46 insertions(+), 30 deletions(-) diff --git a/sc2/ChangeLog b/sc2/ChangeLog index 15a5ec5e1..ce862a4a6 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,5 @@ Changes towards version 0.2: +- Added a 4th button to starcon.key 'Esc' now emergency-escapes -PBlue - Biadapt and biadv scalers now work in OpenGL mode too -Mika - Fixed lockup when fastforwarding through orz comm -PBlue - A new windows installer is now in builds/win32_install -PBlue diff --git a/sc2/content/starcon.key b/sc2/content/starcon.key index a72b257b3..da948e478 100644 --- a/sc2/content/starcon.key +++ b/sc2/content/starcon.key @@ -1,7 +1,7 @@ # File format: # Three lines for Pause Key, Exit Key, Abort Key -# 9 lines for player 1, 9 lines for player 2 in the following order: -# Left, Right, Up, Down, Button 1, Button 2, Button 3, +# 10 lines for player 1, 10 lines for player 2 in the following order: +# Left, Right, Up, Down, Button 1, Button 2, Button 3, Button 4, # Left Shift, Right Shift # # Each player's key listing can begin with an optional joystick declaration @@ -42,6 +42,7 @@ "Enter" " " "RCtrl" +"Esc" "LShift" "RShift" # @@ -55,6 +56,7 @@ #"Enter" #" " #"RCtrl" +#"Esc" #"LShift" #"RShift" # @@ -68,6 +70,7 @@ #"Enter" #" " #"RCtrl" +#"Esc" #"LShift" #"RShift" # @@ -82,3 +85,4 @@ "a" "" "" +"" diff --git a/sc2/doc/users/manual.txt b/sc2/doc/users/manual.txt index f2074fd0c..4f70de8d2 100644 --- a/sc2/doc/users/manual.txt +++ b/sc2/doc/users/manual.txt @@ -467,7 +467,9 @@ UP or ENTER: Thrust LEFT and RIGHT: Steer SPACE: Fire Primary Weapon CONTROL: Fire Secondary Weapon -SPACE with RIGHT SHIFT: Emergency Warp Escape +SPACE with RIGHT SHIFT + OR +ESCAPE: Emergency Warp Escape Planet Exploration diff --git a/sc2/src/sc2code/battle.c b/sc2/src/sc2code/battle.c index c0e568be4..5a0e85365 100644 --- a/sc2/src/sc2code/battle.c +++ b/sc2/src/sc2code/battle.c @@ -89,8 +89,9 @@ if ((InputState & DEVICE_BUTTON3) && cur_player == 0 && ((PlayerControl[cur_player] & HUMAN_CONTROL) || (InputState = GetInputState (NormalInput))) - && (InputState & (DEVICE_BUTTON2 | DEVICE_RIGHTSHIFT)) - == (DEVICE_BUTTON2 | DEVICE_RIGHTSHIFT)) + && ((InputState & (DEVICE_BUTTON2 | DEVICE_RIGHTSHIFT)) + == (DEVICE_BUTTON2 | DEVICE_RIGHTSHIFT) + || (InputState & DEVICE_BUTTON4))) { ELEMENTPTR ElementPtr; diff --git a/sc2/src/sc2code/libs/inplib.h b/sc2/src/sc2code/libs/inplib.h index f67265f93..f37e70540 100644 --- a/sc2/src/sc2code/libs/inplib.h +++ b/sc2/src/sc2code/libs/inplib.h @@ -82,10 +82,11 @@ typedef enum #define DEVICE_BUTTON1 ((INPUT_STATE)1 << 19) #define DEVICE_BUTTON2 ((INPUT_STATE)1 << 20) #define DEVICE_BUTTON3 ((INPUT_STATE)1 << 21) -#define DEVICE_PAUSE ((INPUT_STATE)1 << 22) -#define DEVICE_EXIT ((INPUT_STATE)1 << 23) -#define DEVICE_LEFTSHIFT ((INPUT_STATE)1 << 24) -#define DEVICE_RIGHTSHIFT ((INPUT_STATE)1 << 25) +#define DEVICE_BUTTON4 ((INPUT_STATE)1 << 22) +#define DEVICE_PAUSE ((INPUT_STATE)1 << 23) +#define DEVICE_EXIT ((INPUT_STATE)1 << 24) +#define DEVICE_LEFTSHIFT ((INPUT_STATE)1 << 25) +#define DEVICE_RIGHTSHIFT ((INPUT_STATE)1 << 26) extern BOOLEAN InitInput (BOOLEAN (*PauseFunc) (void), UNICODE Pause, UNICODE Exit, UNICODE Abort); @@ -93,10 +94,10 @@ extern BOOLEAN UninitInput (void); extern INPUT_DEVICE CreateSerialKeyboardDevice (void); extern INPUT_DEVICE CreateJoystickKeyboardDevice (UWORD lfkey, UWORD rtkey, UWORD topkey, UWORD botkey, UWORD but1key, UWORD - but2key, UWORD but3key, UWORD shift1key, UWORD shift2key); + but2key, UWORD but3key, UWORD but4key, UWORD shift1key, UWORD shift2key); extern INPUT_DEVICE CreateJoystickDevice (COUNT port, UWORD threshold, UWORD left, UWORD right, UWORD up, UWORD down, - UWORD but1, UWORD but2, UWORD but3, UWORD s1, UWORD s2); + UWORD but1, UWORD but2, UWORD but3, UWORD but4, UWORD s1, UWORD s2); extern INPUT_DEVICE CreateInternalDevice (INPUT_STATE (*input_func) (INPUT_REF InputRef, INPUT_STATE InputState)); extern BOOLEAN DestroyInputDevice (INPUT_DEVICE InputDevice); diff --git a/sc2/src/sc2code/libs/input/inpintrn.h b/sc2/src/sc2code/libs/input/inpintrn.h index 6ffe03413..df94cca03 100644 --- a/sc2/src/sc2code/libs/input/inpintrn.h +++ b/sc2/src/sc2code/libs/input/inpintrn.h @@ -21,7 +21,7 @@ #include "inplib.h" -#define NUM_INPUTS 9 +#define NUM_INPUTS 10 /* * Inputs * 0 - Left @@ -31,8 +31,9 @@ * 4 - Button 1 * 5 - Button 2 * 6 - Button 3 - * 7 - Left shift - * 8 - Right shift + * 7 - Button 4 + * 8 - Left shift + * 9 - Right shift */ typedef struct inp_dev @@ -73,7 +74,7 @@ typedef PBYTE BYTEPTR; #define SetInputDeviceHandle(i,h) \ ((INPUT_DESCPTR)(i))->ThisDevice = (h) -#define SetInputDeviceKeyEquivalents(i,l,r,t,b,b1,b2,b3,s1,s2) \ +#define SetInputDeviceKeyEquivalents(i,l,r,t,b,b1,b2,b3,b4,s1,s2) \ (((INPUT_DESCPTR)(i))->device.key_equivalent[0] = (l), \ ((INPUT_DESCPTR)(i))->device.key_equivalent[1] = (r), \ ((INPUT_DESCPTR)(i))->device.key_equivalent[2] = (t), \ @@ -81,9 +82,10 @@ typedef PBYTE BYTEPTR; ((INPUT_DESCPTR)(i))->device.key_equivalent[4] = (b1), \ ((INPUT_DESCPTR)(i))->device.key_equivalent[5] = (b2), \ ((INPUT_DESCPTR)(i))->device.key_equivalent[6] = (b3), \ - ((INPUT_DESCPTR)(i))->device.key_equivalent[7] = (s1), \ - ((INPUT_DESCPTR)(i))->device.key_equivalent[8] = (s2)) -#define SetInputDeviceJoystickButtons(i,l,r,t,b,b1,b2,b3,s1,s2) \ + ((INPUT_DESCPTR)(i))->device.key_equivalent[7] = (b4), \ + ((INPUT_DESCPTR)(i))->device.key_equivalent[8] = (s1), \ + ((INPUT_DESCPTR)(i))->device.key_equivalent[9] = (s2)) +#define SetInputDeviceJoystickButtons(i,l,r,t,b,b1,b2,b3,b4,s1,s2) \ (((INPUT_DESCPTR)(i))->device.joystick_info.joystick_buttons[0] = l, \ ((INPUT_DESCPTR)(i))->device.joystick_info.joystick_buttons[1] = r, \ ((INPUT_DESCPTR)(i))->device.joystick_info.joystick_buttons[2] = t, \ @@ -91,8 +93,9 @@ typedef PBYTE BYTEPTR; ((INPUT_DESCPTR)(i))->device.joystick_info.joystick_buttons[4] = b1, \ ((INPUT_DESCPTR)(i))->device.joystick_info.joystick_buttons[5] = b2, \ ((INPUT_DESCPTR)(i))->device.joystick_info.joystick_buttons[6] = b3, \ - ((INPUT_DESCPTR)(i))->device.joystick_info.joystick_buttons[7] = s1, \ - ((INPUT_DESCPTR)(i))->device.joystick_info.joystick_buttons[8] = s2) + ((INPUT_DESCPTR)(i))->device.joystick_info.joystick_buttons[7] = b4, \ + ((INPUT_DESCPTR)(i))->device.joystick_info.joystick_buttons[8] = s1, \ + ((INPUT_DESCPTR)(i))->device.joystick_info.joystick_buttons[9] = s2) #define SetInputDeviceJoystickPort(i,p) \ ((INPUT_DESCPTR)(i))->device.joystick_info.joystick_port = (p) #define SetInputDeviceJoystickThreshold(i,t) \ diff --git a/sc2/src/sc2code/libs/input/input_common.c b/sc2/src/sc2code/libs/input/input_common.c index 8d7f415e0..ff2d1b7d5 100644 --- a/sc2/src/sc2code/libs/input/input_common.c +++ b/sc2/src/sc2code/libs/input/input_common.c @@ -49,7 +49,7 @@ CreateSerialKeyboardDevice (void) INPUT_DEVICE CreateJoystickKeyboardDevice (UWORD lfkey, UWORD rtkey, UWORD topkey, UWORD botkey, UWORD but1key, UWORD but2key, UWORD - but3key, UWORD shift1key, UWORD shift2key) + but3key, UWORD but4key, UWORD shift1key, UWORD shift2key) { INPUT_DEVICE InputDevice; @@ -69,7 +69,7 @@ CreateJoystickKeyboardDevice (UWORD lfkey, UWORD rtkey, UWORD SetInputDeviceInputFunc (InputPtr, _get_joystick_keyboard_state); SetInputDeviceKeyEquivalents (InputPtr, lfkey, rtkey, topkey, botkey, - but1key, but2key, but3key, + but1key, but2key, but3key, but4key, shift1key, shift2key); UnlockInputDevice (InputDevice); @@ -81,8 +81,8 @@ CreateJoystickKeyboardDevice (UWORD lfkey, UWORD rtkey, UWORD INPUT_DEVICE CreateJoystickDevice (COUNT port, UWORD threshold, UWORD left, UWORD right, - UWORD top, UWORD bottom, UWORD but1, UWORD but2, UWORD but3, UWORD s1, - UWORD s2) + UWORD top, UWORD bottom, UWORD but1, UWORD but2, UWORD but3, UWORD but4, + UWORD s1, UWORD s2) { INPUT_DEVICE InputDevice; @@ -104,7 +104,7 @@ CreateJoystickDevice (COUNT port, UWORD threshold, UWORD left, UWORD right, SetInputDeviceInputFunc (InputPtr, _get_joystick_state); SetInputDeviceJoystickPort (InputPtr, port); SetInputDeviceJoystickButtons (InputPtr, left, right, top, bottom, - but1, but2, but3, s1, s2); + but1, but2, but3, but4, s1, s2); SetInputDeviceJoystickThreshold(InputPtr, threshold); UnlockInputDevice (InputDevice); diff --git a/sc2/src/sc2code/libs/input/sdl/input.c b/sc2/src/sc2code/libs/input/sdl/input.c index b5d607eec..22a9a68c2 100644 --- a/sc2/src/sc2code/libs/input/sdl/input.c +++ b/sc2/src/sc2code/libs/input/sdl/input.c @@ -469,6 +469,8 @@ _get_joystick_keyboard_state (INPUT_REF InputRef, INPUT_STATE InputState) InputState |= DEVICE_BUTTON2; if (GetKeyboardDown (*KeyEquivalentPtr++)) InputState |= DEVICE_BUTTON3; + if (GetKeyboardDown (*KeyEquivalentPtr++)) + InputState |= DEVICE_BUTTON4; if (GetKeyboardDown (*KeyEquivalentPtr++)) InputState |= DEVICE_LEFTSHIFT; diff --git a/sc2/src/sc2code/setup.c b/sc2/src/sc2code/setup.c index f4a07c1f8..7e74ad6e1 100644 --- a/sc2/src/sc2code/setup.c +++ b/sc2/src/sc2code/setup.c @@ -126,6 +126,8 @@ static UWORD ParseKeyString(char* line) return SK_KEYPAD_PLUS; else if (!strcmp(key, "KP-")) return SK_KEYPAD_MINUS; + else if (!strcmp(key, "Esc")) + return 27; //Escape is stadard ASCII 27 else return key[0]; } @@ -133,7 +135,7 @@ static UWORD ParseKeyString(char* line) static MEM_HANDLE LoadKeyConfig (FILE *fp, DWORD length) { - UWORD buf[18]; + UWORD buf[20]; int p; int i; char line[256]; @@ -166,7 +168,7 @@ LoadKeyConfig (FILE *fp, DWORD length) int joyThresh = 0; memset(buf, 0xFF, sizeof(buf)); // Read in 9 inputs - for (i = 0; i < 9; ++i) + for (i = 0; i < 10; ++i) { // Look for valid lines for (;;) @@ -243,13 +245,13 @@ LoadKeyConfig (FILE *fp, DWORD length) } KeyboardInput[p] = CaptureInputDevice ( CreateJoystickKeyboardDevice(buf[0], buf[1], buf[2], buf[3], buf[4], - buf[5], buf[6], buf[7], buf[8]) + buf[5], buf[6], buf[7], buf[8], buf[9]) ); if (joyN != -1) { JoystickInput[p] = CaptureInputDevice ( - CreateJoystickDevice(joyN, joyThresh, buf[9], buf[10], buf[11], - buf[12], buf[13], buf[14], buf[15], buf[16], buf[17]) + CreateJoystickDevice(joyN, joyThresh, buf[10], buf[11], buf[12], + buf[13], buf[14], buf[15], buf[16], buf[17], buf[18], buf[19]) ); } else