// Global variables
// boolean JoystickCalibrated=false; // MDM (GAMERS EDGE) - added\r
// ControlType ControlTypeUsed; // MDM (GAMERS EDGE) - added\r
- boolean Keyboard[NumCodes];\r
- boolean Paused;\r
- char LastASCII;\r
- ScanCode LastScan;\r
+ //boolean Keyboard[NumCodes];\r
+ //boolean Paused;\r
+ //char LastASCII;\r
+ //ScanCode LastScan;\r
\r
//KeyboardDef KbdDefs = {0x1d,0x38,0x47,0x48,0x49,0x4b,0x4d,0x4f,0x50,0x51};\r
- JoystickDef JoyDefs[MaxJoys];\r
- ControlType Controls[MaxPlayers];\r
+ //JoystickDef JoyDefs[MaxJoys];\r
+ //ControlType Controls[MaxPlayers];\r
\r
- dword MouseDownCount;
+ //dword MouseDownCount;
// Internal routines
///////////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////////
void interrupt
-INL_KeyService(void)
+INL_KeyService(inconfig *in)
{
static boolean special;
byte k,c;
if (k == 0xe0) // Special key prefix
special = true;
else if (k == 0xe1) // Handle Pause key
- Paused = true;
+ in->Paused = true;
else
{
if (k & 0x80) // Break code
// DEBUG - handle special keys: ctl-alt-delete, print scrn
- Keyboard[k] = false;
+ in->Keyboard[k] = false;
}
else // Make code
{
- LastCode = CurCode;
- CurCode = LastScan = k;
- Keyboard[k] = true;
+ in->LastCode = in->CurCode;
+ in->CurCode = in->LastScan = k;
+ in->Keyboard[k] = true;
if (special)
c = SpecialNames[k];
{
if (k == sc_CapsLock)
{
- CapsLock ^= true;
+ in->CapsLock ^= true;
// DEBUG - make caps lock light work
}
- if (Keyboard[sc_LShift] || Keyboard[sc_RShift]) // If shifted
+ if (in->Keyboard[sc_LShift] || in->Keyboard[sc_RShift]) // If shifted
{
c = ShiftNames[k];
- if ((c >= 'A') && (c <= 'Z') && CapsLock)
+ if ((c >= 'A') && (c <= 'Z') && in->CapsLock)
c += 'a' - 'A';
}
else
{
c = ASCIINames[k];
- if ((c >= 'a') && (c <= 'z') && CapsLock)
+ if ((c >= 'a') && (c <= 'z') && in->CapsLock)
c -= 'a' - 'A';
}
}
if (c)
- LastASCII = c;
+ in->LastASCII = c;
}
special = false;
if (INL_KeyHook && !special)
INL_KeyHook();
#ifdef TESTKEYIN
- printf("%c %x %u\n", c, k, Keyboard[k]);
+ printf("%c %x %u\n", c, k, in->Keyboard[k]);
#endif
outp(0x20,0x20);
}
//
///////////////////////////////////////////////////////////////////////////
static void
-INL_GetJoyDelta(word joy,int *dx,int *dy,boolean adaptive)
+INL_GetJoyDelta(word joy,int *dx,int *dy,boolean adaptive, inconfig *in)
{
word x,y;
dword time;
static dword lasttime;
IN_GetJoyAbs(joy,&x,&y);
- def = JoyDefs + joy;
+ def = in->JoyDefs + joy;
if (x < def->threshMinX)
{
//
///////////////////////////////////////////////////////////////////////////
static void
-INL_StartKbd(void)
+INL_StartKbd(inconfig *in)
{
INL_KeyHook = 0; // Clear key hook
- IN_ClearKeysDown();
+ IN_ClearKeysDown(in);
OldKeyVect = _dos_getvect(KeyInt);
_dos_setvect(KeyInt,INL_KeyService);
// INL_SetJoyScale() - Sets up scaling values for the specified joystick
//
static void
-INL_SetJoyScale(word joy)
+INL_SetJoyScale(word joy, inconfig *in)
{
JoystickDef *def;
- def = &JoyDefs[joy];
+ def = &(in->JoyDefs[joy]);
def->joyMultXL = JoyScaleMax / (def->threshMinX - def->joyMinX);
def->joyMultXH = JoyScaleMax / (def->joyMaxX - def->threshMaxX);
def->joyMultYL = JoyScaleMax / (def->threshMinY - def->joyMinY);
//
///////////////////////////////////////////////////////////////////////////
void
-IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy)
+IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy, inconfig *in)
{
word d,r;
JoystickDef *def;
- def = &JoyDefs[joy];
+ def = &(in->JoyDefs[joy]);
def->joyMinX = minx;
def->joyMaxX = maxx;
def->threshMinY = ((r / 2) - d) + miny;
def->threshMaxY = ((r / 2) + d) + miny;
- INL_SetJoyScale(joy);
+ INL_SetJoyScale(joy, in);
}
///////////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////////
static boolean
-INL_StartJoy(word joy)
+INL_StartJoy(word joy, inconfig *in)
{
word x,y;
return(false);
else
{
- IN_SetupJoy(joy,0,x * 2,0,y * 2);
+ IN_SetupJoy(joy,0,x * 2,0,y * 2, in);
return(true);
}
}
//
///////////////////////////////////////////////////////////////////////////
static void
-INL_ShutJoy(word joy)
+INL_ShutJoy(word joy, inconfig *in)
{
- JoysPresent[joy] = false;
+ in->JoysPresent[joy] = false;
}
// Public routines
//
///////////////////////////////////////////////////////////////////////////
void
-IN_Startup(void)
+IN_Startup(inconfig *in)
{
boolean checkjoys,checkmouse;
word i;
- if (IN_Started)
+ if (in->IN_Started)
return;
checkjoys = true;
}
}
- INL_StartKbd();
- MousePresent = checkmouse? INL_StartMouse() : false;
+ INL_StartKbd(in);
+ in->MousePresent = checkmouse? INL_StartMouse() : false;
for (i = 0;i < MaxJoys;i++)
- JoysPresent[i] = checkjoys? INL_StartJoy(i) : false;
+ in->JoysPresent[i] = checkjoys? INL_StartJoy(i, in) : false;
- IN_Started = true;
+ in->IN_Started = true;
}
///////////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////////
void
-IN_Default(boolean gotit,ControlType in)
+IN_Default(boolean gotit,player_t *player,ControlType nt, inconfig *in)
{
if
(
(!gotit)
- || ((in == ctrl_Joystick1) && !JoysPresent[0])
- || ((in == ctrl_Joystick2) && !JoysPresent[1])
- || ((in == ctrl_Mouse) && !MousePresent)
+ || ((nt == ctrl_Joystick1) && !in->JoysPresent[0])
+ || ((nt == ctrl_Joystick2) && !in->JoysPresent[1])
+ || ((nt == ctrl_Mouse) && !in->MousePresent)
+ || ((nt == ctrl_Joypad1) && !in->JoyPadPresent[0])
+ || ((nt == ctrl_Joypad2) && !in->JoyPadPresent[1])
)
- in = ctrl_Keyboard1;
- IN_SetControlType(0,in);
+ nt = ctrl_Keyboard1;
+ IN_SetControlType(0,player,nt);
}
///////////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////////
void
-IN_Shutdown(void)
+IN_Shutdown(inconfig *in)
{
word i;
- if (!IN_Started)
+ if (!in->IN_Started)
return;
INL_ShutMouse();
for (i = 0;i < MaxJoys;i++)
- INL_ShutJoy(i);
+ INL_ShutJoy(i, in);
INL_ShutKbd();
- IN_Started = false;
+ in->IN_Started = false;
}
///////////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////////
void
-IN_ClearKeysDown(void)
+IN_ClearKeysDown(inconfig *in)
{
int i;
- LastScan = sc_None;
- LastASCII = key_None;
- memset (Keyboard,0,sizeof(Keyboard));
+ in->LastScan = sc_None;
+ in->LastASCII = key_None;
+ memset (in->Keyboard,0,sizeof(in->Keyboard));
}
///////////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////////
void
-IN_ReadControl(int player,CursorInfo *info)
+IN_ReadControl(int playnum,player_t *player)
{
boolean realdelta;
byte dbyte;
else
{
#endif
- switch (type = Controls[player])
+ switch (type = player[playnum]->Controls)
{
case ctrl_Keyboard1:
case ctrl_Keyboard2:
- def = &KbdDefs[type - ctrl_Keyboard];
+ def = player[playnum]->KbdDefs[type - ctrl_Keyboard];
/* if (Keyboard[def->upleft])
mx = motion_Left,my = motion_Up;
dy = my * 127;
}
- info->x = dx;
- info->xaxis = mx;
- info->y = dy;
- info->yaxis = my;
- info->button0 = buttons & (1 << 0);
- info->button1 = buttons & (1 << 1);
- info->button2 = buttons & (1 << 2);
- info->button3 = buttons & (1 << 3);
- info->dir = DirTable[((my + 1) * 3) + (mx + 1)];
+ player[playnum]->info.x = dx;
+ player[playnum]->info.xaxis = mx;
+ player[playnum]->info.y = dy;
+ player[playnum]->info.yaxis = my;
+ player[playnum]->info.button0 = buttons & (1 << 0);
+ player[playnum]->info.button1 = buttons & (1 << 1);
+ player[playnum]->info.button2 = buttons & (1 << 2);
+ player[playnum]->info.button3 = buttons & (1 << 3);
+ player[playnum]->info.dir = DirTable[((my + 1) * 3) + (mx + 1)];
#if DEMO0
if (DemoMode == demo_Record)
//
///////////////////////////////////////////////////////////////////////////
void
-IN_SetControlType(int player,ControlType type)
+IN_SetControlType(word playnum,player_t *player,ControlType type)
{
// DEBUG - check that requested type is present?
- Controls[player] = type;
+ player[playnum]->Controls = type;
}
#if DEMO0
\r
#define MaxPlayers 4\r
#define MaxKbds 2\r
-#define MaxJoys 2\r
+#define MaxJoys 2
+#define MaxPads 2\r
#define NumCodes 128\r
\r
typedef byte ScanCode;\r
typedef enum {\r
dir_North,//dir_NorthEast,\r
dir_East,//dir_SouthEast,\r
- dir_South,//dir_SouthWest,\r
- dir_West,//dir_NorthWest,\r
+ dir_South,//dir_Soutinest,\r
+ dir_West,//dir_Nortinest,\r
dir_None\r
} Direction;\r
typedef struct {\r
joyMultXL,joyMultYL,\r
joyMultXH,joyMultYH;\r
} JoystickDef;
+typedef struct
+{
+ boolean w;\r
+} JoypadDef;
+
+typedef struct
+{
+ CursorInfo info;
+ ControlType Controls;
+} player_t;
-/*typedef struct
+typedef struct
{
- CursorInfo;
-} ControlInfo;*/\r
+ boolean MousePresent;\r
+ boolean JoysPresent[MaxJoys];\r
+ boolean JoyPadPresent[MaxPads];
+ boolean Keyboard[NumCodes];\r
+ boolean Paused;\r
+ char LastASCII;\r
+ ScanCode LastScan;
+
+ boolean IN_Started;\r
+ boolean CapsLock;\r
+ ScanCode CurCode,LastCode;
+
+ KeyboardDef KbdDefs[MaxKbds];
+ JoystickDef JoyDefs[MaxJoys];
+ JoypadDef JoypadDefs[MaxPads];
+} inconfig;
+\r
/*\r
=============================================================================\r
\r
//\r
// configuration variables\r
//\r
-static boolean MousePresent;\r
-static boolean JoysPresent[MaxJoys];\r
-static boolean JoyPadPresent;\r
+//static boolean MousePresent;\r
+//static boolean JoysPresent[MaxJoys];\r
+//static boolean JoyPadPresent[MaxPads];\r
\r
// Global variables\r
// extern boolean JoystickCalibrated; // MDM (GAMERS EDGE) - added\r
// extern ControlType ControlTypeUsed; // MDM (GAMERS EDGE) - added\r
\r
- extern boolean Keyboard[NumCodes];\r
- extern boolean Paused;\r
- extern char LastASCII;\r
- extern ScanCode LastScan;\r
+ //extern boolean Keyboard[NumCodes];\r
+ //extern boolean Paused;\r
+ //extern char LastASCII;\r
+ //extern ScanCode LastScan;\r
\r
//extern KeyboardDef KbdDefs[];
- static KeyboardDef KbdDefs[MaxKbds] = {0x1d,0x38,0x47,0x48,0x49,0x4b,0x4d,0x4f,0x50,0x51};\r
- extern JoystickDef JoyDefs[MaxJoys];\r
- extern ControlType Controls[MaxPlayers];\r
+ //static KeyboardDef KbdDefs[MaxKbds] = {0x1d,0x38,0x47,0x48,0x49,0x4b,0x4d,0x4f,0x50,0x51};\r
+ //extern JoystickDef JoyDefs[MaxJoys];\r
+ //extern ControlType Controls[MaxPlayers];\r
\r
- extern dword MouseDownCount;\r
+ //extern dword MouseDownCount;\r
\r
#ifdef DEMO0\r
static Demo DemoMode = demo_Off;\r
"Down","Left","Right",""\r
};
\r
-static boolean IN_Started;\r
-static boolean CapsLock;\r
-static ScanCode CurCode,LastCode;\r
-\r
static Direction DirTable[] = // Quick lookup for total direction\r
{\r
- //dir_NorthWest,\r
+ //dir_Nortinest,\r
dir_North,\r
//dir_NorthEast,\r
dir_West, dir_None, dir_East,\r
- //dir_SouthWest,\r
+ //dir_Soutinest,\r
dir_South//,dir_SouthEast\r
};\r
\r
#define IN_ClearKey(code) {Keyboard[code] = false; if (code == LastScan) LastScan = sc_None;}\r
// Internal routines
-void interrupt INL_KeyService(void);
+void interrupt INL_KeyService(inconfig *in);
void Mouse(int x);
//static void INL_GetMouseDelta(int *x,int *y);
//static word INL_GetMouseButtons(void);
//static boolean INL_StartMouse(void);
//static void INL_ShutMouse(void);
//static void INL_SetJoyScale(word joy);
-void IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy);
+void IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy, inconfig *in);
//static boolean INL_StartJoy(word joy);
//static void INL_ShutJoy(word joy);
-void IN_Startup(void);
-void IN_Default(boolean gotit,ControlType in);
-void IN_Shutdown(void);
+void IN_Startup(inconfig *in);
+void IN_Default(boolean gotit,player_t *player,ControlType nt, inconfig *in);
+void IN_Shutdown(inconfig *in);
void IN_SetKeyHook(void (*hook)());
-void IN_ClearKeysDown(void);
+void IN_ClearKeysDown(inconfig *in);
//static void INL_AdjustCursor(CursorInfo *info,word buttons,int dx,int dy);
void IN_ReadCursor(CursorInfo *info);
-void IN_ReadControl(int player,CursorInfo *info);
-void IN_SetControlType(int player,ControlType type);
+void IN_ReadControl(int playnum,player_t *player);
+void IN_SetControlType(word playnum,player_t *player,ControlType type);
#if DEMO0
boolean IN_StartDemoRecord(word bufsize);
void IN_StartDemoPlayback(byte /*__segment*/ *buffer,word bufsize);
void IN_Ack(void);
boolean IN_IsUserInput(void);
boolean IN_UserInput(dword delay,boolean clear);
-
\r
/*extern void IN_Startup(void),IN_Shutdown(void),\r
IN_Default(boolean gotit,ControlType in),\r
extern ScanCode IN_WaitForKey(void);\r
extern word IN_GetJoyButtonsDB(word joy);*/\r
\r
-\r
-void interrupt INL_KeyService(void);\r
boolean IN_qb(byte kee);\r
#endif\r