Further minor MACT cleanups

git-svn-id: https://svn.eduke32.com/eduke32@3200 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2012-11-17 16:48:11 +00:00
parent bbbeefc6a1
commit 83ae3a407a
8 changed files with 40 additions and 153 deletions

View file

@ -7069,7 +7069,7 @@ static void G_CheatGetInv(void)
static void end_cheat(void) static void end_cheat(void)
{ {
g_player[myconnectindex].ps->cheat_phase = 0; g_player[myconnectindex].ps->cheat_phase = 0;
KB_FlushKeyBoardQueue(); KB_FlushKeyboardQueue();
} }
static int8_t cheatbuf[MAXCHEATLEN], cheatbuflen; static int8_t cheatbuf[MAXCHEATLEN], cheatbuflen;
@ -7105,7 +7105,7 @@ GAME_STATIC void G_DoCheats(void)
{ {
while (KB_KeyWaiting()) while (KB_KeyWaiting())
{ {
ch = Btolower(KB_Getch()); ch = Btolower(KB_GetCh());
if (!((ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9'))) if (!((ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9')))
{ {
@ -7169,7 +7169,7 @@ FOUNDCHEAT:
case CHEAT_KEYS: case CHEAT_KEYS:
g_player[myconnectindex].ps->got_access = 7; g_player[myconnectindex].ps->got_access = 7;
KB_FlushKeyBoardQueue(); KB_FlushKeyboardQueue();
end_cheat(); end_cheat();
return; return;
@ -7451,7 +7451,7 @@ FOUNDCHEAT:
ud.eog = 1; ud.eog = 1;
g_player[myconnectindex].ps->player_par = 0; g_player[myconnectindex].ps->player_par = 0;
g_player[myconnectindex].ps->gm |= MODE_EOL; g_player[myconnectindex].ps->gm |= MODE_EOL;
KB_FlushKeyBoardQueue(); KB_FlushKeyboardQueue();
return; return;
} }
} }

View file

@ -1741,11 +1741,20 @@ skip_check:
int32_t j = Gv_GetVarX(*insptr++); int32_t j = Gv_GetVarX(*insptr++);
if ((unsigned)i >= MAXQUOTES) if ((unsigned)i >= MAXQUOTES)
{
CON_ERRPRINTF("invalid quote ID %d\n", i); CON_ERRPRINTF("invalid quote ID %d\n", i);
continue;
}
else if ((ScriptQuotes[i] == NULL)) else if ((ScriptQuotes[i] == NULL))
{
CON_ERRPRINTF("null quote %d\n", i); CON_ERRPRINTF("null quote %d\n", i);
continue;
}
else if ((unsigned)f >= NUMGAMEFUNCTIONS) else if ((unsigned)f >= NUMGAMEFUNCTIONS)
{
CON_ERRPRINTF("invalid function %d\n", f); CON_ERRPRINTF("invalid function %d\n", f);
continue;
}
else else
{ {
if (j < 2) if (j < 2)

View file

@ -39,7 +39,7 @@ int32_t I_CheckAllInput(void)
} }
void I_ClearAllInput(void) void I_ClearAllInput(void)
{ {
KB_FlushKeyBoardQueue(); KB_FlushKeyboardQueue();
KB_ClearKeysDown(); KB_ClearKeysDown();
MOUSE_ClearAllButtons(); MOUSE_ClearAllButtons();
JOYSTICK_ClearAllButtons(); JOYSTICK_ClearAllButtons();
@ -55,7 +55,7 @@ int32_t I_CheckInputWaiting(void)
} }
int32_t I_ClearInputWaiting(void) int32_t I_ClearInputWaiting(void)
{ {
KB_FlushKeyBoardQueue(); KB_FlushKeyboardQueue();
KB_ClearKeysDown(); // JBF KB_ClearKeysDown(); // JBF
I_JoystickAdvanceTriggerClear(); I_JoystickAdvanceTriggerClear();
return ( return (
@ -137,7 +137,7 @@ int32_t I_AdvanceTrigger(void)
} }
int32_t I_AdvanceTriggerClear(void) int32_t I_AdvanceTriggerClear(void)
{ {
KB_FlushKeyBoardQueue(); KB_FlushKeyboardQueue();
KB_ClearKeyDown(sc_kpad_Enter); KB_ClearKeyDown(sc_kpad_Enter);
KB_ClearKeyDown(sc_Enter); KB_ClearKeyDown(sc_Enter);
I_JoystickAdvanceTriggerClear(); I_JoystickAdvanceTriggerClear();
@ -155,7 +155,7 @@ int32_t I_ReturnTrigger(void)
} }
int32_t I_ReturnTriggerClear(void) int32_t I_ReturnTriggerClear(void)
{ {
KB_FlushKeyBoardQueue(); KB_FlushKeyboardQueue();
KB_ClearKeyDown(sc_Escape); KB_ClearKeyDown(sc_Escape);
return ( return (
MOUSE_ClearButton(RIGHT_MOUSE) || MOUSE_ClearButton(RIGHT_MOUSE) ||
@ -171,7 +171,7 @@ int32_t I_EscapeTrigger(void)
} }
int32_t I_EscapeTriggerClear(void) int32_t I_EscapeTriggerClear(void)
{ {
KB_FlushKeyBoardQueue(); KB_FlushKeyboardQueue();
KB_ClearKeyDown(sc_Escape); KB_ClearKeyDown(sc_Escape);
return ( return (
I_JoystickEscapeTriggerClear() I_JoystickEscapeTriggerClear()
@ -197,7 +197,7 @@ int32_t I_PanelUp(void)
} }
int32_t I_PanelUpClear(void) int32_t I_PanelUpClear(void)
{ {
KB_FlushKeyBoardQueue(); KB_FlushKeyboardQueue();
KB_ClearKeyDown(sc_LeftArrow); KB_ClearKeyDown(sc_LeftArrow);
KB_ClearKeyDown(sc_kpad_4); KB_ClearKeyDown(sc_kpad_4);
KB_ClearKeyDown(sc_UpArrow); KB_ClearKeyDown(sc_UpArrow);
@ -230,7 +230,7 @@ int32_t I_PanelDown(void)
} }
int32_t I_PanelDownClear(void) int32_t I_PanelDownClear(void)
{ {
KB_FlushKeyBoardQueue(); KB_FlushKeyboardQueue();
KB_ClearKeyDown(sc_RightArrow); KB_ClearKeyDown(sc_RightArrow);
KB_ClearKeyDown(sc_kpad_6); KB_ClearKeyDown(sc_kpad_6);
KB_ClearKeyDown(sc_DownArrow); KB_ClearKeyDown(sc_DownArrow);
@ -257,7 +257,7 @@ int32_t _EnterText(int32_t small,int32_t x,int32_t y,char *t,int32_t dalen,int32
char ch; char ch;
int32_t i; int32_t i;
while ((ch = KB_Getch()) != 0) while ((ch = KB_GetCh()) != 0)
{ {
if (ch == asc_BackSpace) if (ch == asc_BackSpace)
{ {

View file

@ -574,17 +574,15 @@ static void CONTROL_ApplyAxis(int32_t axis, ControlInfo *info, controldevice dev
static void CONTROL_PollDevices(ControlInfo *info) static void CONTROL_PollDevices(ControlInfo *info)
{ {
Bmemcpy(CONTROL_LastMouseAxes, CONTROL_MouseAxes, sizeof(CONTROL_MouseAxes));
Bmemcpy(CONTROL_LastJoyAxes, CONTROL_JoyAxes, sizeof(CONTROL_JoyAxes));
memset(CONTROL_MouseAxes, 0, sizeof(CONTROL_MouseAxes));
memset(CONTROL_JoyAxes, 0, sizeof(CONTROL_JoyAxes));
memset(info, 0, sizeof(ControlInfo)); memset(info, 0, sizeof(ControlInfo));
if (CONTROL_MouseEnabled) if (CONTROL_MouseEnabled)
{ {
int32_t i = MAXMOUSEAXES-1; int32_t i = MAXMOUSEAXES-1;
Bmemcpy(CONTROL_LastMouseAxes, CONTROL_MouseAxes, sizeof(CONTROL_MouseAxes));
memset(CONTROL_MouseAxes, 0, sizeof(CONTROL_MouseAxes));
CONTROL_GetMouseDelta(); CONTROL_GetMouseDelta();
for (; i>=0; i--) for (; i>=0; i--)
{ {
@ -599,6 +597,9 @@ static void CONTROL_PollDevices(ControlInfo *info)
{ {
int32_t i = joynumaxes-1; int32_t i = joynumaxes-1;
Bmemcpy(CONTROL_LastJoyAxes, CONTROL_JoyAxes, sizeof(CONTROL_JoyAxes));
memset(CONTROL_JoyAxes, 0, sizeof(CONTROL_JoyAxes));
for (; i>=0; i--) for (; i>=0; i--)
{ {
CONTROL_JoyAxes[i].analog = joyaxis[i]; CONTROL_JoyAxes[i].analog = joyaxis[i];

View file

@ -148,13 +148,7 @@ extern uint64_t CONTROL_ButtonHeldState;
//*************************************************************************** //***************************************************************************
//void CONTROL_MapKey( int32_t which, kb_scancode key1, kb_scancode key2 ); //void CONTROL_MapKey( int32_t which, kb_scancode key1, kb_scancode key2 );
void CONTROL_MapButton void CONTROL_MapButton(int32_t whichfunction, int32_t whichbutton, int32_t doubleclicked, controldevice device);
(
int32_t whichfunction,
int32_t whichbutton,
int32_t doubleclicked,
controldevice device
);
void CONTROL_DefineFlag( int32_t which, int32_t toggle ); void CONTROL_DefineFlag( int32_t which, int32_t toggle );
int32_t CONTROL_FlagActive( int32_t which ); int32_t CONTROL_FlagActive( int32_t which );
void CONTROL_ClearAssignments( void ); void CONTROL_ClearAssignments( void );
@ -162,43 +156,21 @@ void CONTROL_ClearAssignments( void );
void CONTROL_GetInput( ControlInfo *info ); void CONTROL_GetInput( ControlInfo *info );
void CONTROL_ClearButton( int32_t whichbutton ); void CONTROL_ClearButton( int32_t whichbutton );
extern float CONTROL_MouseSensitivity; extern float CONTROL_MouseSensitivity;
int32_t CONTROL_Startup int32_t CONTROL_Startup(controltype which, int32_t ( *TimeFunction )( void ), int32_t ticspersecond);
(
controltype which,
int32_t ( *TimeFunction )( void ),
int32_t ticspersecond
);
void CONTROL_Shutdown( void ); void CONTROL_Shutdown( void );
void CONTROL_SetDoubleClickDelay(int32_t delay); void CONTROL_SetDoubleClickDelay(int32_t delay);
int32_t CONTROL_GetDoubleClickDelay(void); int32_t CONTROL_GetDoubleClickDelay(void);
void CONTROL_MapAnalogAxis void CONTROL_MapAnalogAxis(int32_t whichaxis, int32_t whichanalog, controldevice device);
( void CONTROL_MapDigitalAxis(int32_t whichaxis, int32_t whichfunction, int32_t direction, controldevice device);
int32_t whichaxis, void CONTROL_SetAnalogAxisScale(int32_t whichaxis, int32_t axisscale, controldevice device);
int32_t whichanalog,
controldevice device
);
void CONTROL_MapDigitalAxis
(
int32_t whichaxis,
int32_t whichfunction,
int32_t direction,
controldevice device
);
void CONTROL_SetAnalogAxisScale
(
int32_t whichaxis,
int32_t axisscale,
controldevice device
);
void CONTROL_PrintKeyMap(void); void CONTROL_PrintKeyMap(void);
void CONTROL_PrintControlFlag(int32_t which); void CONTROL_PrintControlFlag(int32_t which);
void CONTROL_PrintAxes( void ); void CONTROL_PrintAxes( void );
#define MAXBOUNDKEYS 256 #define MAXBOUNDKEYS MAXKEYBOARDSCAN
typedef struct binding { typedef struct binding {
const char *key; const char *key;

View file

@ -37,11 +37,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "keyboard.h" #include "keyboard.h"
#include "control.h" #include "control.h"
kb_scancode KB_LastScan; kb_scancode KB_LastScan;
static int32_t numpad = 0;
// translation table for taking key names to scancodes and back again // translation table for taking key names to scancodes and back again
static struct static struct
{ {
@ -152,79 +149,6 @@ static struct
{ "Delete", 0xd3 }, { "Delete", 0xd3 },
}; };
// translation table for turning scancode into ascii characters
/*
static char sctoasc[2][256] = {
{
// 0 1 2 3 4 5 6 7 8 9 a b c d e f
0, 27, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', 8, 9, // 0x00
'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', 13, 0, 'a', 's', // 0x10
'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'','`', 0, '\\','z', 'x', 'c', 'v', // 0x20
'b', 'n', 'm', ',', '.', '/', 0, '*', 0, ' ', 0, 0, 0, 0, 0, 0, // 0x30
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '-', 0, 0, 0, '+', 0, // 0x40
0, 0, 0, '.', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x50
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x60
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x70
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x80
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, // 0x90
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xa0
0, 0, 0, 0, 0, '/', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xb0
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xc0
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xd0
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xe0
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 // 0xf0
},
{
// 0 1 2 3 4 5 6 7 8 9 a b c d e f
0, 27, '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', 8, 9, // 0x00
'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', 13, 0, 'A', 'S', // 0x10
'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '"', '~', 0, '|', 'Z', 'X', 'C', 'V', // 0x20
'B', 'N', 'M', '<', '>', '?', 0, '*', 0, ' ', 0, 0, 0, 0, 0, 0, // 0x30
0, 0, 0, 0, 0, 0, 0, '7', '8', '9', '-', '4', '5', '6', '+', '1', // 0x40
'2', '3', '0', '.', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x50
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x60
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x70
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x80
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, // 0x90
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xa0
0, 0, 0, 0, 0, '/', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xb0
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xc0
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xd0
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0xe0
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 // 0xf0
}
};
*/
int32_t KB_KeyWaiting(void)
{
return bkbhit();
// return (keyfifoplc != keyfifoend);
}
char KB_Getch(void)
{
/*
uint8_t ch;
char shifted;
if (keyfifoplc == keyfifoend) return 0;
ch = keyfifo[keyfifoplc];
keyfifoplc = ((keyfifoplc+2)&(KEYFIFOSIZ-1));
shifted = ((keystatus[0x2a]!=0)||(keystatus[0x36]!=0));
if (ch >= 0x47 && ch <= 0x52) shifted = numpad;
return sctoasc[shifted][ch];
*/
return (char)bgetchar();
}
void KB_FlushKeyboardQueue(void)
{
//keyfifoplc = keyfifoend = 0;
bflushchars();
}
void KB_ClearKeysDown(void) void KB_ClearKeysDown(void)
{ {
KB_LastScan = 0; KB_LastScan = 0;
@ -253,21 +177,6 @@ kb_scancode KB_StringToScanCode(const char * string)
return 0; return 0;
} }
void KB_TurnKeypadOn(void)
{
numpad = 1;
}
void KB_TurnKeypadOff(void)
{
numpad = 0;
}
int32_t KB_KeypadActive(void)
{
return numpad;
}
static void KB_KeyEvent(int32_t scancode, int32_t keypressed) static void KB_KeyEvent(int32_t scancode, int32_t keypressed)
{ {
if (keypressed) KB_LastScan = scancode; if (keypressed) KB_LastScan = scancode;
@ -275,7 +184,6 @@ static void KB_KeyEvent(int32_t scancode, int32_t keypressed)
void KB_Startup(void) void KB_Startup(void)
{ {
numpad = 0;
setkeypresscallback(KB_KeyEvent); setkeypresscallback(KB_KeyEvent);
} }

View file

@ -80,6 +80,12 @@ extern kb_scancode KB_LastScan;
#define KB_UnBoundKeyPressed( scan ) ( keystatus[ ( scan ) ] != 0 && !CONTROL_KeyBinds[scan].cmdstr) #define KB_UnBoundKeyPressed( scan ) ( keystatus[ ( scan ) ] != 0 && !CONTROL_KeyBinds[scan].cmdstr)
#define KB_GetCh bgetchar
#define KB_KeyWaiting bkbhit
#define KB_FlushKeyboardQueue bflushchars
/* /*
============================================================================= =============================================================================
@ -88,21 +94,12 @@ extern kb_scancode KB_LastScan;
============================================================================= =============================================================================
*/ */
int32_t KB_KeyWaiting( void ); // Checks if a character is waiting in the keyboard queue
char KB_Getch( void ); // Gets the next keypress
void KB_FlushKeyboardQueue( void ); // Empties the keyboard queue of all waiting characters.
void KB_ClearKeysDown( void ); // Clears all keys down flags. void KB_ClearKeysDown( void ); // Clears all keys down flags.
const char * KB_ScanCodeToString( kb_scancode scancode ); // convert scancode into a string const char * KB_ScanCodeToString( kb_scancode scancode ); // convert scancode into a string
kb_scancode KB_StringToScanCode( const char * string ); // convert a string into a scancode kb_scancode KB_StringToScanCode( const char * string ); // convert a string into a scancode
void KB_TurnKeypadOn( void ); // turn the keypad on
void KB_TurnKeypadOff( void ); // turn the keypad off
int32_t KB_KeypadActive( void ); // check whether keypad is active
void KB_Startup( void ); void KB_Startup( void );
void KB_Shutdown( void ); void KB_Shutdown( void );
#define KB_FlushKeyBoardQueue KB_FlushKeyboardQueue
#define KB_GetCh KB_Getch
#ifdef EXTERNC #ifdef EXTERNC
}; };
#endif #endif

View file

@ -2346,7 +2346,7 @@ cheat_for_port_credits2:
else else
{ {
char ch2, ch; char ch2, ch;
ch = KB_Getch(); ch = KB_GetCh();
if (ch > 0 && ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9'))) if (ch > 0 && ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9')))
{ {
if (ch >= 'a') ch -= ('a'-'A'); if (ch >= 'a') ch -= ('a'-'A');