#include "src/lib/16_in.h"
+/*\r
+=============================================================================\r
+\r
+ GLOBAL VARIABLES\r
+\r
+=============================================================================\r
+*/
+struct inconfig
+{
+ boolean MousePresent;\r
+ boolean JoysPresent[MaxJoys];\r
+ boolean JoyPadPresent[MaxPads];
+ boolean Keyboard[NumCodes];\r
+ boolean Paused;\r
+ char LastASCII;\r
+ ScanCode LastScan;
+
+ KeyboardDef KbdDefs[MaxKbds];// = {0x1d,0x38,/*0x47,*/0x48,/*0x49,*/0x4b,0x4d,/*0x4f,*/0x50/*,0x51*/};
+ JoystickDef JoyDefs[MaxJoys];
+ JoypadDef JoypadDefs[MaxPads];
+} inpu;
+
+//struct inconfig in;
+
+//inpu.KbdDefs = {0x1d,0x38,/*0x47,*/0x48,/*0x49,*/0x4b,0x4d,/*0x4f,*/0x50/*,0x51*/};
+
/*\r
=============================================================================\r
\r
\r
=============================================================================\r
*/
+
#ifdef __cplusplus /* Function must be declared C style */
extern "C" {
-#endif\r
+#endif
+\r
+static struct instat {
+ boolean IN_Started;\r
+ boolean CapsLock;\r
+ ScanCode CurCode,LastCode;
+} inst;
+\r
+static void (*INL_KeyHook)(void);
+static void interrupt (*OldKeyVect)(void);
+static char *ParmStringsIN[] = {"nojoys","nomouse",nil};
+\r
static byte far ASCIINames[] = // Unshifted ASCII for scan codes\r
{\r
// 0 1 2 3 4 5 6 7 8 9 A B C D E F\r
dir_West, dir_None, dir_East,\r
//dir_Soutinest,\r
dir_South//,dir_SouthEast\r
- };\r
-
-static boolean IN_Started;\r
-static boolean CapsLock;\r
-static ScanCode CurCode,LastCode;
-\r
-static void (*INL_KeyHook)(void);
-static void interrupt (*OldKeyVect)(void);
-static char *ParmStringsIN[] = {"nojoys","nomouse",nil};
+ };
#ifdef __cplusplus
}
#endif
//
///////////////////////////////////////////////////////////////////////////
void interrupt
-INL_KeyService(inconfig *in)
+INL_KeyService()
{
static boolean special;
byte k,c;
if (k == 0xe0) // Special key prefix
special = true;
else if (k == 0xe1) // Handle Pause key
- in->Paused = true;
+ inpu.Paused = true;
else
{
if (k & 0x80) // Break code
// DEBUG - handle special keys: ctl-alt-delete, print scrn
- in->Keyboard[k] = false;
+ inpu.Keyboard[k] = false;
}
else // Make code
{
- LastCode = CurCode;
- CurCode = in->LastScan = k;
- in->Keyboard[k] = true;
+ inst.LastCode = inst.CurCode;
+ inst.CurCode = inpu.LastScan = k;
+ inpu.Keyboard[k] = true;
if (special)
c = SpecialNames[k];
{
if (k == sc_CapsLock)
{
- CapsLock ^= true;
+ inst.CapsLock ^= true;
// DEBUG - make caps lock light work
}
- if (in->Keyboard[sc_LShift] || in->Keyboard[sc_RShift]) // If shifted
+ if (inpu.Keyboard[sc_LShift] || inpu.Keyboard[sc_RShift]) // If shifted
{
c = ShiftNames[k];
- if ((c >= 'A') && (c <= 'Z') && CapsLock)
+ if ((c >= 'A') && (c <= 'Z') && inst.CapsLock)
c += 'a' - 'A';
}
else
{
c = ASCIINames[k];
- if ((c >= 'a') && (c <= 'z') && CapsLock)
+ if ((c >= 'a') && (c <= 'z') && inst.CapsLock)
c -= 'a' - 'A';
}
}
if (c)
- in->LastASCII = c;
+ inpu.LastASCII = c;
}
special = false;
if (INL_KeyHook && !special)
INL_KeyHook();
#ifdef TESTKEYIN
- printf("%c %x %u\n", c, k, in->Keyboard[k]);
+ printf("%c %x %u\n", c, k, inpu.Keyboard[k]);
#endif
outp(0x20,0x20);
}
//
///////////////////////////////////////////////////////////////////////////
static void
-INL_GetJoyDelta(word joy,int *dx,int *dy,boolean adaptive, inconfig *in)
+INL_GetJoyDelta(word joy,int *dx,int *dy,boolean adaptive)
{
word x,y;
dword time;
static dword lasttime;
IN_GetJoyAbs(joy,&x,&y);
- def = in->JoyDefs + joy;
+ def = inpu.JoyDefs + joy;
if (x < def->threshMinX)
{
//
///////////////////////////////////////////////////////////////////////////
static void
-INL_StartKbd(inconfig *in)
+INL_StartKbd()
{
INL_KeyHook = 0; // Clear key hook
- IN_ClearKeysDown(in);
+ IN_ClearKeysDown();
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, inconfig *in)
+INL_SetJoyScale(word joy)
{
JoystickDef *def;
- def = &(in->JoyDefs[joy]);
+ def = &(inpu.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, inconfig *in)
+IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy)
{
word d,r;
JoystickDef *def;
- def = &(in->JoyDefs[joy]);
+ def = &(inpu.JoyDefs[joy]);
def->joyMinX = minx;
def->joyMaxX = maxx;
def->threshMinY = ((r / 2) - d) + miny;
def->threshMaxY = ((r / 2) + d) + miny;
- INL_SetJoyScale(joy, in);
+ INL_SetJoyScale(joy);
}
///////////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////////
static boolean
-INL_StartJoy(word joy, inconfig *in)
+INL_StartJoy(word joy)
{
word x,y;
return(false);
else
{
- IN_SetupJoy(joy,0,x * 2,0,y * 2, in);
+ IN_SetupJoy(joy,0,x * 2,0,y * 2);
return(true);
}
}
//
///////////////////////////////////////////////////////////////////////////
static void
-INL_ShutJoy(word joy, inconfig *in)
+INL_ShutJoy(word joy)
{
- in->JoysPresent[joy] = false;
+ inpu.JoysPresent[joy] = false;
}
// Public routines
// IN_Startup() - Starts up the Input Mgr
//
///////////////////////////////////////////////////////////////////////////
-boolean
-IN_Startup(inconfig *in)
+void
+IN_Startup()
{
boolean checkjoys,checkmouse;
word i;
- if (IN_Started)
- {
- return false;
- }
+ if (inst.IN_Started)
+ return;
checkjoys = true;
checkmouse = true;
}
}
- INL_StartKbd(in);
- in->MousePresent = checkmouse? INL_StartMouse() : false;
+ INL_StartKbd();
+ inpu.MousePresent = checkmouse? INL_StartMouse() : false;
for (i = 0;i < MaxJoys;i++)
- in->JoysPresent[i] = checkjoys? INL_StartJoy(i, in) : false;
+ inpu.JoysPresent[i] = checkjoys? INL_StartJoy(i) : false;
- IN_Started = true;
- return true;
+ inst.IN_Started = true;
}
///////////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////////
void
-IN_Default(boolean gotit,player_t *player,ControlType nt, inconfig *in)
+IN_Default(boolean gotit,player_t *player,ControlType nt)
{
if
(
(!gotit)
- || ((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])
+ || ((nt == ctrl_Joystick1) && !inpu.JoysPresent[0])
+ || ((nt == ctrl_Joystick2) && !inpu.JoysPresent[1])
+ || ((nt == ctrl_Mouse) && !inpu.MousePresent)
+ || ((nt == ctrl_Joypad1) && !inpu.JoyPadPresent[0])
+ || ((nt == ctrl_Joypad2) && !inpu.JoyPadPresent[1])
)
nt = ctrl_Keyboard1;
IN_SetControlType(0,player,nt);
// IN_Shutdown() - Shuts down the Input Mgr
//
///////////////////////////////////////////////////////////////////////////
-boolean
-IN_Shutdown(inconfig *in)
+void
+IN_Shutdown()
{
word i;
- if (!IN_Started)
- {
- return false;
- }
+ if (!inst.IN_Started)
+ return;
INL_ShutMouse();
for (i = 0;i < MaxJoys;i++)
- INL_ShutJoy(i, in);
+ INL_ShutJoy(i);
INL_ShutKbd();
- IN_Started = false;
- return true;
+ inst.IN_Started = false;
}
///////////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////////
void
-IN_ClearKeysDown(inconfig *in)
+IN_ClearKeysDown()
{
int i;
- in->LastScan = sc_None;
- in->LastASCII = key_None;
- memset (in->Keyboard,0,sizeof(in->Keyboard));
+ inpu.LastScan = sc_None;
+ inpu.LastASCII = key_None;
+ memset (inpu.Keyboard,0,sizeof(inpu.Keyboard));
}
///////////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////////
void
-IN_ReadCursor(CursorInfo *info, inconfig *in)
+IN_ReadCursor(CursorInfo *info)
{
word i,
buttons;
info->x = info->y = 0;
info->button0 = info->button1 = false;
- if (in->MousePresent)
+ if (inpu.MousePresent)
{
buttons = INL_GetMouseButtons();
INL_GetMouseDelta(&dx,&dy);
for (i = 0;i < MaxJoys;i++)
{
- if (!in->JoysPresent[i])
+ if (!inpu.JoysPresent[i])
continue;
buttons = INL_GetJoyButtons(i);
- INL_GetJoyDelta(i,&dx,&dy,true, in);
+ INL_GetJoyDelta(i,&dx,&dy,true);
dx /= 64;
dy /= 64;
INL_AdjustCursor(info,buttons,dx,dy);
//
///////////////////////////////////////////////////////////////////////////
void
-IN_ReadControl(int playnum,player_t *player, inconfig *in)
+IN_ReadControl(int playnum,player_t *player)
{
boolean realdelta;
byte dbyte;
{
case ctrl_Keyboard1:
case ctrl_Keyboard2:
- def = &(in->KbdDefs[type - ctrl_Keyboard]);
+ def = &(inpu.KbdDefs[type - ctrl_Keyboard]);
/* if (Keyboard[def->upleft])
mx = motion_Left,my = motion_Up;
else if (Keyboard[def->downright])
mx = motion_Right,my = motion_Down;*/
- if (in->Keyboard[def->up])
+ if (inpu.Keyboard[def->up])
my = motion_Up;
- else if (in->Keyboard[def->down])
+ else if (inpu.Keyboard[def->down])
my = motion_Down;
- if (in->Keyboard[def->left])
+ if (inpu.Keyboard[def->left])
mx = motion_Left;
- else if (in->Keyboard[def->right])
+ else if (inpu.Keyboard[def->right])
mx = motion_Right;
- if (in->Keyboard[def->button0])
+ if (inpu.Keyboard[def->button0])
buttons += 1 << 0;
- if (in->Keyboard[def->button1])
+ if (inpu.Keyboard[def->button1])
buttons += 1 << 1;
realdelta = false;
break;
case ctrl_Joystick1:
case ctrl_Joystick2:
- INL_GetJoyDelta(type - ctrl_Joystick,&dx,&dy,false, in);
+ INL_GetJoyDelta(type - ctrl_Joystick,&dx,&dy,false);
buttons = INL_GetJoyButtons(type - ctrl_Joystick);
realdelta = true;
break;
//
///////////////////////////////////////////////////////////////////////////
ScanCode
-IN_WaitForKey(inconfig *in)
+IN_WaitForKey()
{
ScanCode result;
- while (!(result = in->LastScan))
+ while (!(result = inpu.LastScan))
;
- in->LastScan = 0;
+ inpu.LastScan = 0;
return(result);
}
//
///////////////////////////////////////////////////////////////////////////
char
-IN_WaitForASCII(inconfig *in)
+IN_WaitForASCII()
{
char result;
- while (!(result = in->LastASCII))
+ while (!(result = inpu.LastASCII))
;
- in->LastASCII = '\0';
+ inpu.LastASCII = '\0';
return(result);
}
//
///////////////////////////////////////////////////////////////////////////
void
-IN_AckBack(inconfig *in)
+IN_AckBack()
{
word i;
- while (!in->LastScan)
+ while (!inpu.LastScan)
{
- if (in->MousePresent)
+ if (inpu.MousePresent)
{
if (INL_GetMouseButtons())
{
for (i = 0;i < MaxJoys;i++)
{
- if (in->JoysPresent[i])
+ if (inpu.JoysPresent[i])
{
if (IN_GetJoyButtonsDB(i))
{
}
}
- IN_ClearKey(in->LastScan, in);
- in->LastScan = sc_None;
+ IN_ClearKey(inpu.LastScan);
+ inpu.LastScan = sc_None;
}
///////////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////////
void
-IN_Ack(inconfig *in)
+IN_Ack()
{
word i;
- IN_ClearKey(in->LastScan, in);
- in->LastScan = sc_None;
+ IN_ClearKey(inpu.LastScan);
+ inpu.LastScan = sc_None;
- if (in->MousePresent)
+ if (inpu.MousePresent)
while (INL_GetMouseButtons())
;
for (i = 0;i < MaxJoys;i++)
- if (in->JoysPresent[i])
+ if (inpu.JoysPresent[i])
while (IN_GetJoyButtonsDB(i))
;
- IN_AckBack(in);
+ IN_AckBack();
}
///////////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////////
boolean
-IN_IsUserInput(inconfig *in)
+IN_IsUserInput()
{
boolean result;
word i;
- result = in->LastScan;
+ result = inpu.LastScan;
- if (in->MousePresent)
+ if (inpu.MousePresent)
if (INL_GetMouseButtons())
result = true;
for (i = 0;i < MaxJoys;i++)
- if (in->JoysPresent[i])
+ if (inpu.JoysPresent[i])
if (INL_GetJoyButtons(i))
result = true;
//
///////////////////////////////////////////////////////////////////////////
boolean
-IN_UserInput(dword delay,boolean clear, inconfig *in)
+IN_UserInput(dword delay,boolean clear)
{
dword TimeCount = *clockdw;
dword lasttime;
lasttime = TimeCount;
do
{
- if (IN_IsUserInput(in))
+ if (IN_IsUserInput())
{
if (clear)
- IN_AckBack(in);
+ IN_AckBack();
return(true);
}
} while (TimeCount - lasttime < delay);
return(false);
}
-boolean IN_KeyDown(byte code, inconfig *in)
+boolean IN_KeyDown(byte code)
{
- return in->Keyboard[(code)];
+ return inpu.Keyboard[code];
}
\r
-void IN_ClearKey(byte code, inconfig *in)
+void IN_ClearKey(byte code)
{
- in->Keyboard[code] = false;
- if(code == in->LastScan)
- in->LastScan = sc_None;
+ inpu.Keyboard[code] = false;
+ if(code == inpu.LastScan)
+ inpu.LastScan = sc_None;
}
+
+boolean IN_qb(byte kee)
+{
+ printf("%u\n", inpu.Keyboard[kee]);
+ if(inpu.Keyboard[kee]==true) return 1;
+ else return 0;
+}
ControlType Controls;
} player_t;
-typedef struct
-{
- boolean MousePresent;\r
- boolean JoysPresent[MaxJoys];\r
- boolean JoyPadPresent[MaxPads];
- boolean Keyboard[NumCodes];\r
- boolean Paused;\r
- char LastASCII;\r
- ScanCode LastScan;
-
- KeyboardDef KbdDefs[MaxKbds];
- JoystickDef JoyDefs[MaxJoys];
- JoypadDef JoypadDefs[MaxPads];
-} inconfig;
-
#ifdef DEMO0\r
static Demo DemoMode = demo_Off;\r
static byte /*_seg*/ *DemoBuffer;\r
static word DemoOffset,DemoSize;\r
#endif\r
-\r
+
+//extern struct inconfig in;
extern dword far* clockdw;\r
\r
// Internal routines
-void interrupt INL_KeyService(inconfig *in);
-void Mouse(int x);
+extern void interrupt INL_KeyService();
+extern void Mouse(int x);
//static void INL_GetMouseDelta(int *x,int *y);
//static word INL_GetMouseButtons(void);
-void IN_GetJoyAbs(word joy,word *xp,word *yp);
+extern void IN_GetJoyAbs(word joy,word *xp,word *yp);
//static void INL_GetJoyDelta(word joy,int *dx,int *dy,boolean adaptive);
//static word INL_GetJoyButtons(word joy);
-word IN_GetJoyButtonsDB(word joy);
+extern word IN_GetJoyButtonsDB(word joy);
//static void INL_StartKbd(void);
//static void INL_ShutKbd(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, inconfig *in);
+extern void IN_SetupJoy(word joy,word minx,word maxx,word miny,word maxy);
//static boolean INL_StartJoy(word joy);
//static void INL_ShutJoy(word joy);
-boolean IN_Startup(inconfig *in);
-void IN_Default(boolean gotit,player_t *player,ControlType nt, inconfig *in);
-boolean IN_Shutdown(inconfig *in);
-void IN_SetKeyHook(void (*hook)());
-void IN_ClearKeysDown(inconfig *in);
+extern void IN_Startup();
+extern void IN_Default(boolean gotit,player_t *player,ControlType nt);
+extern void IN_Shutdown();
+extern void IN_SetKeyHook(void (*hook)());
+extern void IN_ClearKeysDown();
//static void INL_AdjustCursor(CursorInfo *info,word buttons,int dx,int dy);
-void IN_ReadCursor(CursorInfo *info, inconfig *in);
-void IN_ReadControl(int playnum,player_t *player, inconfig *in);
-void IN_SetControlType(word playnum,player_t *player,ControlType type);
+extern void IN_ReadCursor(CursorInfo *info);
+extern void IN_ReadControl(int playnum,player_t *player);
+extern 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_StopDemo(void);
-void IN_FreeDemoBuffer(void);
+extern boolean IN_StartDemoRecord(word bufsize);
+extern void IN_StartDemoPlayback(byte /*__segment*/ *buffer,word bufsize);
+extern void IN_StopDemo(void);
+extern void IN_FreeDemoBuffer(void);
#endif
-byte *IN_GetScanName(ScanCode scan);
-ScanCode IN_WaitForKey(inconfig *in);
-char IN_WaitForASCII(inconfig *in);
-void IN_AckBack(inconfig *in);
-void IN_Ack(inconfig *in);
-boolean IN_IsUserInput(inconfig *in);
-boolean IN_UserInput(dword delay,boolean clear, inconfig *in);
-boolean IN_KeyDown(byte code, inconfig *in);
-void IN_ClearKey(byte code, inconfig *in);
+extern byte *IN_GetScanName(ScanCode scan);
+extern ScanCode IN_WaitForKey();
+extern char IN_WaitForASCII();
+extern void IN_AckBack();
+extern void IN_Ack();
+extern boolean IN_IsUserInput();
+extern boolean IN_UserInput(dword delay,boolean clear);
+extern boolean IN_KeyDown(byte code);
+extern void IN_ClearKey(byte code);
+extern boolean IN_qb(byte kee);
\r
#endif\r