Rewritten input code, from slayne
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@515 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
0.2:
|
||||
- Rewritten input code (better and adds joystick/pad support), from slayne
|
||||
- Biadapt scaling for pure mode, from fOSSiL
|
||||
- Saving user data in "%APPDATA%/Application Data" on windows - SvdB
|
||||
- Melnorme comm fix, from TD.
|
||||
|
||||
@@ -117,20 +117,6 @@ TFB_ProcessEvents ()
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
//Still testing this... Should fix sticky input soon...
|
||||
/*
|
||||
{
|
||||
Uint8* Temp;
|
||||
|
||||
SDL_PumpEvents ();
|
||||
Temp = SDL_GetKeyState (NULL);
|
||||
for(a = 0; a < 512; a++)
|
||||
{
|
||||
KeyboardDown[a] = Temp[a];
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,28 +48,23 @@ typedef enum
|
||||
|
||||
#define SK_LF_SHIFT ((UNICODE)139)
|
||||
#define SK_RT_SHIFT ((UNICODE)140)
|
||||
#define SK_CTL ((UNICODE)141)
|
||||
#define SK_ALT ((UNICODE)142)
|
||||
#define SK_LF_CTL ((UNICODE)141)
|
||||
#define SK_RT_CTL ((UNICODE)142)
|
||||
#define SK_LF_ALT ((UNICODE)143)
|
||||
#define SK_RT_ALT ((UNICODE)144)
|
||||
|
||||
#define KEY_DOWN ((BYTE)(1 << 0))
|
||||
#define KEY_UP ((BYTE)(1 << 1))
|
||||
#define LF_SHIFT_DOWN ((BYTE)(1 << 2))
|
||||
#define RT_SHIFT_DOWN ((BYTE)(1 << 3))
|
||||
#define CTL_DOWN ((BYTE)(1 << 4))
|
||||
#define ALT_DOWN ((BYTE)(1 << 5))
|
||||
|
||||
#define SK_F1 ((UNICODE)143)
|
||||
#define SK_F2 ((UNICODE)144)
|
||||
#define SK_F3 ((UNICODE)145)
|
||||
#define SK_F4 ((UNICODE)146)
|
||||
#define SK_F5 ((UNICODE)147)
|
||||
#define SK_F6 ((UNICODE)148)
|
||||
#define SK_F7 ((UNICODE)149)
|
||||
#define SK_F8 ((UNICODE)150)
|
||||
#define SK_F9 ((UNICODE)151)
|
||||
#define SK_F10 ((UNICODE)152)
|
||||
#define SK_F11 ((UNICODE)153)
|
||||
#define SK_F12 ((UNICODE)154)
|
||||
#define SK_F1 ((UNICODE)145)
|
||||
#define SK_F2 ((UNICODE)146)
|
||||
#define SK_F3 ((UNICODE)147)
|
||||
#define SK_F4 ((UNICODE)148)
|
||||
#define SK_F5 ((UNICODE)149)
|
||||
#define SK_F6 ((UNICODE)150)
|
||||
#define SK_F7 ((UNICODE)151)
|
||||
#define SK_F8 ((UNICODE)152)
|
||||
#define SK_F9 ((UNICODE)153)
|
||||
#define SK_F10 ((UNICODE)154)
|
||||
#define SK_F11 ((UNICODE)155)
|
||||
#define SK_F12 ((UNICODE)156)
|
||||
|
||||
#define DEVTYPE_MASK 0x03
|
||||
#define GetInputUNICODE(is) (LOWORD (is))
|
||||
@@ -92,14 +87,16 @@ typedef enum
|
||||
#define DEVICE_LEFTSHIFT ((INPUT_STATE)1 << 24)
|
||||
#define DEVICE_RIGHTSHIFT ((INPUT_STATE)1 << 25)
|
||||
|
||||
extern BOOLEAN InitInput (UNICODE PauseKey, UNICODE ExitKey, BOOLEAN
|
||||
(*PauseFunc) (void));
|
||||
extern BOOLEAN InitInput (BOOLEAN (*PauseFunc) (void), UNICODE Pause,
|
||||
UNICODE Exit, UNICODE Abort);
|
||||
extern BOOLEAN UninitInput (void);
|
||||
extern INPUT_DEVICE CreateSerialKeyboardDevice (void);
|
||||
extern INPUT_DEVICE CreateJoystickKeyboardDevice (UNICODE lfkey, UNICODE
|
||||
rtkey, UNICODE topkey, UNICODE botkey, UNICODE but1key, UNICODE
|
||||
but2key, UNICODE but3key, UNICODE shift1key, UNICODE shift2key);
|
||||
extern INPUT_DEVICE CreateJoystickDevice (COUNT port);
|
||||
extern INPUT_DEVICE CreateJoystickKeyboardDevice (UWORD lfkey, UWORD
|
||||
rtkey, UWORD topkey, UWORD botkey, UWORD but1key, UWORD
|
||||
but2key, UWORD but3key, 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);
|
||||
extern INPUT_DEVICE CreateInternalDevice (INPUT_STATE (*input_func)
|
||||
(INPUT_REF InputRef, INPUT_STATE InputState));
|
||||
extern BOOLEAN DestroyInputDevice (INPUT_DEVICE InputDevice);
|
||||
@@ -109,15 +106,43 @@ extern INPUT_STATE GetInputState (INPUT_REF InputRef);
|
||||
extern INPUT_STATE AnyButtonPress (BOOLEAN DetectSpecial);
|
||||
|
||||
extern void FlushInput (void);
|
||||
extern int KeyDown (UNICODE which_scan);
|
||||
extern BOOLEAN KeyDown (UNICODE which_scan);
|
||||
extern UNICODE GetUnicodeKey (void);
|
||||
extern UNICODE KBDToUNICODE (UNICODE which_key);
|
||||
extern UNICODE KeyHit (void);
|
||||
extern BYTE GetKeyState (UNICODE key);
|
||||
extern UNICODE KBDToUNICODE (UWORD which_key);
|
||||
|
||||
/*
|
||||
* Not used right now
|
||||
extern BOOLEAN FindMouse (void);
|
||||
extern void MoveMouse (SWORD x, SWORD y);
|
||||
extern BYTE LocateMouse (PSWORD px, PSWORD py);
|
||||
*/
|
||||
|
||||
/*
|
||||
* joystick_buttons format
|
||||
* Bit 15 - (0) - Button
|
||||
* (1) - Axis
|
||||
* Bit 14 - (0) - positive (n/a for buttons)
|
||||
* (1) - negative (use chord for buttons)
|
||||
* Bit 0-7 - button / axis number
|
||||
* Bit 8-13 - chorded button
|
||||
*/
|
||||
#define JOYAXISMASK 0x8000
|
||||
/* axis number, sign */
|
||||
#define JOYAXIS(a,s) (0x8000 | (s < 0 ? 0x4000 : 0 ) | (a & 0xFF))
|
||||
#define JOYBUTTON(b) ((UWORD)(b & 0xFF))
|
||||
#define JOYCHORD(b1,b2) ((UWORD)(0x4000 | (b1 & 0xFF) | ((b2 & 0x3F) << 8)))
|
||||
#define JOYISAXIS(v) (v & JOYAXISMASK)
|
||||
#define JOYISCHORD(v) (v & 0x4000)
|
||||
#define JOYGETVALUE(v) (v & 0xFF)
|
||||
#define JOYGETSIGN(v) ((v & 0x4000) ? -1 : 1)
|
||||
#define JOYGETCHORD(v) ((v & 0x3F00) >> 8)
|
||||
|
||||
#define KEYCHORD(k1, k2) ((UWORD) ((k1 & 0xFF) << 8) | (k2 & 0xFF))
|
||||
#define KEYGETCHORD(v) ((v & 0xFF00) >> 8)
|
||||
#define KEYISCHORD(v) (v & 0xFF00)
|
||||
#define KEYGETKEY(v) (v & 0xFF)
|
||||
|
||||
extern UNICODE PauseKey, ExitKey, AbortKey;
|
||||
|
||||
#endif /* _INPLIB_H */
|
||||
|
||||
|
||||
@@ -21,15 +21,33 @@
|
||||
|
||||
#include "inplib.h"
|
||||
|
||||
#define NUM_INPUTS 16
|
||||
#define NUM_INPUTS 9
|
||||
/*
|
||||
* Inputs
|
||||
* 0 - Left
|
||||
* 1 - Right
|
||||
* 2 - Up
|
||||
* 3 - Down
|
||||
* 4 - Button 1
|
||||
* 5 - Button 2
|
||||
* 6 - Button 3
|
||||
* 7 - Left shift
|
||||
* 8 - Right shift
|
||||
*/
|
||||
|
||||
typedef struct inp_dev
|
||||
{
|
||||
INPUT_DEVICE ThisDevice;
|
||||
union
|
||||
{
|
||||
UNICODE key_equivalent[NUM_INPUTS];
|
||||
COUNT joystick_port;
|
||||
UWORD key_equivalent[NUM_INPUTS];
|
||||
struct
|
||||
{
|
||||
BYTE joystick_port;
|
||||
UWORD joystick_threshold;
|
||||
/* See inplib.h for description of this field */
|
||||
UWORD joystick_buttons[NUM_INPUTS];
|
||||
} joystick_info;
|
||||
} device;
|
||||
INPUT_STATE (*input_func) (INPUT_REF InputRef, INPUT_STATE
|
||||
InputState);
|
||||
@@ -51,17 +69,29 @@ typedef PBYTE BYTEPTR;
|
||||
#define SetInputDeviceHandle(i,h) \
|
||||
((INPUT_DESCPTR)(i))->ThisDevice = (h)
|
||||
#define SetInputDeviceKeyEquivalents(i,l,r,t,b,b1,b2,b3,s1,s2) \
|
||||
(((INPUT_DESCPTR)(i))->device.key_equivalent[0] = KBDToUNICODE (l), \
|
||||
((INPUT_DESCPTR)(i))->device.key_equivalent[1] = KBDToUNICODE (r), \
|
||||
((INPUT_DESCPTR)(i))->device.key_equivalent[2] = KBDToUNICODE (t), \
|
||||
((INPUT_DESCPTR)(i))->device.key_equivalent[3] = KBDToUNICODE (b), \
|
||||
((INPUT_DESCPTR)(i))->device.key_equivalent[4] = KBDToUNICODE (b1), \
|
||||
((INPUT_DESCPTR)(i))->device.key_equivalent[5] = KBDToUNICODE (b2), \
|
||||
((INPUT_DESCPTR)(i))->device.key_equivalent[6] = KBDToUNICODE (b3), \
|
||||
((INPUT_DESCPTR)(i))->device.key_equivalent[7] = KBDToUNICODE (s1), \
|
||||
((INPUT_DESCPTR)(i))->device.key_equivalent[8] = KBDToUNICODE (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), \
|
||||
((INPUT_DESCPTR)(i))->device.key_equivalent[3] = (b), \
|
||||
((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.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, \
|
||||
((INPUT_DESCPTR)(i))->device.joystick_info.joystick_buttons[3] = b, \
|
||||
((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)
|
||||
#define SetInputDeviceJoystickPort(i,p) \
|
||||
((INPUT_DESCPTR)(i))->device.joystick_port = (p)
|
||||
((INPUT_DESCPTR)(i))->device.joystick_info.joystick_port = (p)
|
||||
#define SetInputDeviceJoystickThreshold(i,t) \
|
||||
((INPUT_DESCPTR)(i))->device.joystick_info.joystick_threshold = (t)
|
||||
#define SetInputDeviceInputFunc(i,f) \
|
||||
((INPUT_DESCPTR)(i))->input_func = (f)
|
||||
|
||||
@@ -69,8 +99,12 @@ typedef PBYTE BYTEPTR;
|
||||
((INPUT_DESCPTR)(i))->ThisDevice
|
||||
#define GetInputDeviceKeyEquivalentPtr(i) \
|
||||
((INPUT_DESCPTR)(i))->device.key_equivalent
|
||||
#define GetInputDeviceJoystickButtonPtr(i) \
|
||||
((INPUT_DESCPTR)(i))->device.joystick_info.joystick_buttons
|
||||
#define GetInputDeviceJoystickPort(i) \
|
||||
((INPUT_DESCPTR)(i))->device.joystick_port
|
||||
((INPUT_DESCPTR)(i))->device.joystick_info.joystick_port
|
||||
#define GetInputDeviceJoystickThreshold(i) \
|
||||
((INPUT_DESCPTR)(i))->device.joystick_info.joystick_threshold
|
||||
#define GetInputDeviceInputFunc(i) \
|
||||
((INPUT_DESCPTR)(i))->input_func
|
||||
|
||||
|
||||
@@ -47,9 +47,9 @@ CreateSerialKeyboardDevice (void)
|
||||
}
|
||||
|
||||
INPUT_DEVICE
|
||||
CreateJoystickKeyboardDevice (UNICODE lfkey, UNICODE rtkey, UNICODE
|
||||
topkey, UNICODE botkey, UNICODE but1key, UNICODE but2key, UNICODE
|
||||
but3key, UNICODE shift1key, UNICODE shift2key)
|
||||
CreateJoystickKeyboardDevice (UWORD lfkey, UWORD rtkey, UWORD
|
||||
topkey, UWORD botkey, UWORD but1key, UWORD but2key, UWORD
|
||||
but3key, UWORD shift1key, UWORD shift2key)
|
||||
{
|
||||
INPUT_DEVICE InputDevice;
|
||||
|
||||
@@ -80,7 +80,9 @@ CreateJoystickKeyboardDevice (UNICODE lfkey, UNICODE rtkey, UNICODE
|
||||
}
|
||||
|
||||
INPUT_DEVICE
|
||||
CreateJoystickDevice (COUNT port)
|
||||
CreateJoystickDevice (COUNT port, UWORD threshold, UWORD left, UWORD right,
|
||||
UWORD top, UWORD bottom, UWORD but1, UWORD but2, UWORD but3, UWORD s1,
|
||||
UWORD s2)
|
||||
{
|
||||
INPUT_DEVICE InputDevice;
|
||||
|
||||
@@ -101,6 +103,9 @@ CreateJoystickDevice (COUNT port)
|
||||
SetInputDeviceHandle (InputPtr, InputDevice);
|
||||
SetInputDeviceInputFunc (InputPtr, _get_joystick_state);
|
||||
SetInputDeviceJoystickPort (InputPtr, port);
|
||||
SetInputDeviceJoystickButtons (InputPtr, left, right, top, bottom,
|
||||
but1, but2, but3, s1, s2);
|
||||
SetInputDeviceJoystickThreshold(InputPtr, threshold);
|
||||
|
||||
UnlockInputDevice (InputDevice);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -19,18 +19,8 @@
|
||||
#ifndef INPUT_H
|
||||
#define INPUT_H
|
||||
|
||||
extern Uint8 KeyboardDown[512];
|
||||
|
||||
extern SDLKey ControlA;
|
||||
extern SDLKey ControlB;
|
||||
extern SDLKey ControlC;
|
||||
extern SDLKey ControlX;
|
||||
extern SDLKey ControlStart;
|
||||
extern SDLKey ControlLeftShift;
|
||||
extern SDLKey ControlRightShift;
|
||||
|
||||
Uint16 GetUNICODEKey ();
|
||||
void FlushInput ();
|
||||
UNICODE GetUNICODEKey (void);
|
||||
void FlushInput (void);
|
||||
void ProcessKeyboardEvent (const SDL_Event *Event);
|
||||
void ProcessJoystickEvent (const SDL_Event *Event);
|
||||
|
||||
|
||||
+204
-35
@@ -48,39 +48,218 @@ Semaphore GraphicsSem;
|
||||
CondVar RenderingCond;
|
||||
STRING GameStrings;
|
||||
|
||||
static UWORD ParseKeyString(char* line)
|
||||
{
|
||||
char key[16];
|
||||
char* index = strchr(line+1, '"');
|
||||
if (index == NULL)
|
||||
return 0;
|
||||
memset(key, 0, sizeof(key));
|
||||
strncpy(key, line+1, index - (line + 1));
|
||||
if (strchr(key, ',') != NULL && strlen(key) != 1)
|
||||
{
|
||||
// We have a chorded key!
|
||||
UWORD k1, k2;
|
||||
char l[16];
|
||||
char* comma = line;
|
||||
memset(l, 0, sizeof(l));
|
||||
while (strchr(comma + 1, ',') != NULL)
|
||||
comma = strchr(comma + 1, ',');
|
||||
strncpy(l, line, comma - line);
|
||||
strcat(l, "\"");
|
||||
k1 = ParseKeyString(l);
|
||||
memset(l, 0, sizeof(l));
|
||||
l[0] = '"';
|
||||
strncpy(l + 1, comma + 1, index - (comma + 1));
|
||||
strcat(l, "\"");
|
||||
k2 = ParseKeyString(l);
|
||||
return KEYCHORD(k1, k2);
|
||||
}
|
||||
|
||||
if (!strcmp(key, "Left"))
|
||||
return SK_LF_ARROW;
|
||||
else if (!strcmp(key, "Right"))
|
||||
return SK_RT_ARROW;
|
||||
else if (!strcmp(key, "Up"))
|
||||
return SK_UP_ARROW;
|
||||
else if (!strcmp(key, "Down"))
|
||||
return SK_DN_ARROW;
|
||||
else if (!strcmp(key, "RCtrl"))
|
||||
return SK_RT_CTL;
|
||||
else if (!strcmp(key, "LCtrl"))
|
||||
return SK_LF_CTL;
|
||||
else if (!strcmp(key, "RAlt"))
|
||||
return SK_RT_ALT;
|
||||
else if (!strcmp(key, "LAlt"))
|
||||
return SK_LF_ALT;
|
||||
else if (!strcmp(key, "LShift"))
|
||||
return SK_LF_SHIFT;
|
||||
else if (!strcmp(key, "RShift"))
|
||||
return SK_RT_SHIFT;
|
||||
else if (!strcmp(key, "Enter"))
|
||||
return '\n';
|
||||
else if (!strcmp(key, "F1"))
|
||||
return SK_F1;
|
||||
else if (!strcmp(key, "F2"))
|
||||
return SK_F2;
|
||||
else if (!strcmp(key, "F3"))
|
||||
return SK_F3;
|
||||
else if (!strcmp(key, "F4"))
|
||||
return SK_F4;
|
||||
else if (!strcmp(key, "F5"))
|
||||
return SK_F5;
|
||||
else if (!strcmp(key, "F6"))
|
||||
return SK_F6;
|
||||
else if (!strcmp(key, "F7"))
|
||||
return SK_F7;
|
||||
else if (!strcmp(key, "F8"))
|
||||
return SK_F8;
|
||||
else if (!strcmp(key, "F9"))
|
||||
return SK_F9;
|
||||
else if (!strcmp(key, "F10"))
|
||||
return SK_F10;
|
||||
else if (!strcmp(key, "F11"))
|
||||
return SK_F11;
|
||||
else if (!strcmp(key, "F12"))
|
||||
return SK_F12;
|
||||
else if (!strcmp(key, "KP+"))
|
||||
return SK_KEYPAD_PLUS;
|
||||
else if (!strcmp(key, "KP-"))
|
||||
return SK_KEYPAD_MINUS;
|
||||
else
|
||||
return key[0];
|
||||
}
|
||||
|
||||
static MEM_HANDLE
|
||||
LoadKeyConfig (FILE *fp, DWORD length)
|
||||
{
|
||||
COUNT i;
|
||||
BYTE buf[38], *pbuf;
|
||||
UWORD buf[18];
|
||||
int p;
|
||||
int i;
|
||||
char line[256];
|
||||
extern BOOLEAN PauseGame (void);
|
||||
|
||||
ReadResFile (buf, 1, sizeof (buf), fp);
|
||||
UNICODE specialKeys[3];
|
||||
|
||||
// new temporary melee keys 2002/11/22
|
||||
// mapped as left, right, thrust, ?, ?, fire, special, ?, ?
|
||||
KeyboardInput[0] = CaptureInputDevice
|
||||
(
|
||||
CreateJoystickKeyboardDevice (SK_LF_ARROW, SK_RT_ARROW, SK_UP_ARROW, 0, 0, SK_RT_SHIFT, SK_CTL, 0, 0x1b)
|
||||
);
|
||||
KeyboardInput[1] = CaptureInputDevice
|
||||
(
|
||||
CreateJoystickKeyboardDevice ('s', 'f', 'e', 0, 0, 'q', 'a', 0, 0x1b)
|
||||
);
|
||||
|
||||
// old melee key code
|
||||
/*for (i = 0, pbuf = buf; i < NUM_PLAYERS; ++i, pbuf += 10)
|
||||
// Look for pause, exit, abort keys
|
||||
for (i = 0; i < 3; ++i)
|
||||
{
|
||||
KeyboardInput[i] = CaptureInputDevice (
|
||||
CreateJoystickKeyboardDevice (
|
||||
pbuf[2], pbuf[4], pbuf[6], 0,
|
||||
0, pbuf[8], pbuf[0],
|
||||
0, 0x1b
|
||||
)
|
||||
for (;;)
|
||||
{
|
||||
if (feof(fp) || ferror(fp))
|
||||
break;
|
||||
fgets(line, 256, fp);
|
||||
if (line[0] != '#')
|
||||
break;
|
||||
}
|
||||
if (line[0] == '"')
|
||||
{
|
||||
specialKeys[i] = (UNICODE)(ParseKeyString(line) & 0xFF);
|
||||
fprintf(stderr, "Special %i = %i\n", i, specialKeys[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// For each of two players
|
||||
for (p = 0; p < 2; ++p)
|
||||
{
|
||||
int joyN = -1;
|
||||
int joyThresh = 0;
|
||||
memset(buf, 0xFF, sizeof(buf));
|
||||
// Read in 9 inputs
|
||||
for (i = 0; i < 9; ++i)
|
||||
{
|
||||
// Look for valid lines
|
||||
for (;;)
|
||||
{
|
||||
if (feof(fp) || ferror(fp))
|
||||
break;
|
||||
fgets(line, 256, fp);
|
||||
|
||||
if (line[0] != '#')
|
||||
break;
|
||||
}
|
||||
// line now contains what should be a valid line
|
||||
if (strstr(line, "<Joyport") != NULL)
|
||||
{
|
||||
joyN = atoi(line + 8);
|
||||
joyThresh = atoi(strchr(line, '-') + 10);
|
||||
--i;
|
||||
continue;
|
||||
}
|
||||
else if (line[0] == '"')
|
||||
{
|
||||
char joy[16];
|
||||
char* index;
|
||||
memset(joy, 0, sizeof(joy));
|
||||
index = strchr(line+1, '"');
|
||||
if (index != NULL)
|
||||
index = strchr(index+1, '<');
|
||||
if (index != NULL)
|
||||
{
|
||||
char* index2 = strchr(index+1, '>');
|
||||
if (index2 != NULL)
|
||||
strncpy(joy, index+1, index2 - (index + 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
joy[0] = 0;
|
||||
}
|
||||
buf[i] = ParseKeyString (line);
|
||||
fprintf(stderr, "Player %i, key %i = %i\n", p, i, buf[i]);
|
||||
if (joy[0] != 0)
|
||||
{
|
||||
char type;
|
||||
if (strchr(joy, '-') != NULL)
|
||||
type = *(strchr(joy, '-') + 1);
|
||||
else
|
||||
type = 0;
|
||||
|
||||
if (type == 'A')
|
||||
{
|
||||
int axis = atoi(strchr(joy, '-') + 2);
|
||||
char sign = joy[strlen(joy)-1];
|
||||
int s;
|
||||
if (sign == '+')
|
||||
s = 1;
|
||||
else if (sign == '-')
|
||||
s = -1;
|
||||
else
|
||||
s = 1;
|
||||
buf[9 + i] = JOYAXIS(axis, s);
|
||||
}
|
||||
else if (type == 'B')
|
||||
{
|
||||
int button = atoi(strchr(joy, '-') + 2);
|
||||
buf[9 + i] = JOYBUTTON(button);
|
||||
}
|
||||
else if (type == 'C')
|
||||
{
|
||||
int b1 = atoi(strchr(joy, '-') + 2);
|
||||
int b2 = atoi(strchr(joy, ',') + 1);
|
||||
buf[9 + i] = JOYCHORD(b1, b2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
KeyboardInput[p] = CaptureInputDevice (
|
||||
CreateJoystickKeyboardDevice(buf[0], buf[1], buf[2], buf[3], buf[4],
|
||||
buf[5], buf[6], buf[7], buf[8])
|
||||
);
|
||||
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])
|
||||
);
|
||||
|
||||
}*/
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
JoystickInput[p] = 0;
|
||||
}
|
||||
}
|
||||
ArrowInput = KeyboardInput[0];
|
||||
(void) length; /* Satisfying compiler (unused parameter) */
|
||||
InitInput(PauseGame, specialKeys[0], specialKeys[1], specialKeys[2]);
|
||||
return (NULL_HANDLE);
|
||||
}
|
||||
|
||||
@@ -88,18 +267,8 @@ static void
|
||||
InitPlayerInput (void)
|
||||
{
|
||||
INPUT_DEVICE InputDevice;
|
||||
extern BOOLEAN PauseGame (void);
|
||||
|
||||
InitInput (SK_F1, SK_F10, PauseGame);
|
||||
|
||||
JoystickInput[0] = CaptureInputDevice (CreateJoystickDevice (0));
|
||||
JoystickInput[1] = CaptureInputDevice (CreateJoystickDevice (1));
|
||||
|
||||
SerialInput = CaptureInputDevice (CreateSerialKeyboardDevice ());
|
||||
ArrowInput = CaptureInputDevice (CreateJoystickKeyboardDevice (
|
||||
SK_LF_ARROW, SK_RT_ARROW, SK_UP_ARROW, SK_DN_ARROW,
|
||||
'\n', ' ', 0x1b, SK_KEYPAD_MINUS, SK_KEYPAD_PLUS
|
||||
));
|
||||
|
||||
InputDevice = CreateInternalDevice (game_input);
|
||||
NormalInput = CaptureInputDevice (InputDevice);
|
||||
|
||||
@@ -181,16 +181,13 @@ PauseGame (void)
|
||||
FlushGraphics ();
|
||||
//SetSemaphore (GraphicsSem);
|
||||
|
||||
{
|
||||
BYTE scan;
|
||||
|
||||
scan = KBDToUNICODE (SK_F1);
|
||||
while (KeyDown (scan))
|
||||
TaskSwitch ();
|
||||
}
|
||||
while (KeyDown (PauseKey))
|
||||
TaskSwitch ();
|
||||
|
||||
FlushInput ();
|
||||
while (KeyHit () != SK_F1)
|
||||
|
||||
// Wait for the pause key to be pressed again
|
||||
while (!KeyDown (PauseKey))
|
||||
TaskSwitch ();
|
||||
|
||||
s.frame = F;
|
||||
|
||||
Reference in New Issue
Block a user