2012-06-03 16:11:22 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 2010 EDuke32 developers and contributors
|
|
|
|
|
|
|
|
This file is part of EDuke32.
|
|
|
|
|
|
|
|
EDuke32 is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License version 2
|
|
|
|
as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2014-07-20 08:55:56 +00:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2012-06-03 16:11:22 +00:00
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include "global.h"
|
|
|
|
#include "game.h"
|
|
|
|
#include "function.h"
|
|
|
|
#include "keyboard.h"
|
|
|
|
#include "mouse.h"
|
|
|
|
#include "joystick.h"
|
|
|
|
#include "control.h"
|
|
|
|
#include "input.h"
|
|
|
|
|
|
|
|
int32_t I_CheckAllInput(void)
|
|
|
|
{
|
|
|
|
return (
|
|
|
|
KB_KeyWaiting() ||
|
|
|
|
MOUSE_GetButtons() ||
|
|
|
|
JOYSTICK_GetButtons()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
void I_ClearAllInput(void)
|
|
|
|
{
|
2012-11-17 16:48:11 +00:00
|
|
|
KB_FlushKeyboardQueue();
|
2012-06-03 16:11:22 +00:00
|
|
|
KB_ClearKeysDown();
|
|
|
|
MOUSE_ClearAllButtons();
|
|
|
|
JOYSTICK_ClearAllButtons();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-16 23:15:49 +00:00
|
|
|
int32_t I_AdvanceTrigger(void)
|
2012-06-03 16:11:22 +00:00
|
|
|
{
|
|
|
|
return (
|
2014-06-16 23:15:49 +00:00
|
|
|
KB_KeyPressed(sc_kpad_Enter) ||
|
|
|
|
KB_KeyPressed(sc_Enter) ||
|
|
|
|
(MOUSE_GetButtons()&LEFT_MOUSE) ||
|
2012-06-03 16:11:22 +00:00
|
|
|
#if defined(GEKKO)
|
|
|
|
(JOYSTICK_GetButtons()&WII_A)
|
|
|
|
#else
|
|
|
|
BUTTON(gamefunc_Open) ||
|
|
|
|
BUTTON(gamefunc_Fire)
|
|
|
|
#endif
|
|
|
|
);
|
|
|
|
}
|
2014-06-16 23:15:49 +00:00
|
|
|
|
|
|
|
void I_AdvanceTriggerClear(void)
|
2012-06-03 16:11:22 +00:00
|
|
|
{
|
2014-06-16 23:15:49 +00:00
|
|
|
KB_FlushKeyboardQueue();
|
|
|
|
KB_ClearKeyDown(sc_kpad_Enter);
|
|
|
|
KB_ClearKeyDown(sc_Enter);
|
|
|
|
MOUSE_ClearButton(LEFT_MOUSE);
|
2012-06-03 16:11:22 +00:00
|
|
|
#if defined(GEKKO)
|
2014-06-16 23:15:49 +00:00
|
|
|
JOYSTICK_ClearButton(WII_A);
|
2012-06-03 16:11:22 +00:00
|
|
|
#else
|
|
|
|
CONTROL_ClearButton(gamefunc_Open);
|
|
|
|
CONTROL_ClearButton(gamefunc_Fire);
|
|
|
|
#endif
|
|
|
|
}
|
2014-06-16 23:15:49 +00:00
|
|
|
|
|
|
|
int32_t I_ReturnTrigger(void)
|
2012-06-03 16:11:22 +00:00
|
|
|
{
|
|
|
|
return (
|
2014-06-16 23:15:49 +00:00
|
|
|
KB_KeyPressed(sc_Escape) ||
|
|
|
|
(MOUSE_GetButtons()&RIGHT_MOUSE) ||
|
2012-06-03 16:11:22 +00:00
|
|
|
BUTTON(gamefunc_Crouch)
|
|
|
|
#if defined(GEKKO)
|
|
|
|
|| (JOYSTICK_GetButtons()&(WII_B|WII_HOME))
|
|
|
|
#endif
|
|
|
|
);
|
|
|
|
}
|
2014-06-16 23:15:49 +00:00
|
|
|
|
|
|
|
void I_ReturnTriggerClear(void)
|
2012-06-03 16:11:22 +00:00
|
|
|
{
|
2014-06-16 23:15:49 +00:00
|
|
|
KB_FlushKeyboardQueue();
|
|
|
|
KB_ClearKeyDown(sc_Escape);
|
|
|
|
MOUSE_ClearButton(RIGHT_MOUSE);
|
2012-06-03 16:11:22 +00:00
|
|
|
CONTROL_ClearButton(gamefunc_Crouch);
|
|
|
|
#if defined(GEKKO)
|
2014-06-16 23:15:49 +00:00
|
|
|
JOYSTICK_ClearButton(WII_B);
|
|
|
|
JOYSTICK_ClearButton(WII_HOME);
|
2012-06-03 16:11:22 +00:00
|
|
|
#endif
|
|
|
|
}
|
2014-06-16 23:15:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
int32_t I_EscapeTrigger(void)
|
2012-06-03 16:11:22 +00:00
|
|
|
{
|
|
|
|
return (
|
2014-06-16 23:15:49 +00:00
|
|
|
KB_KeyPressed(sc_Escape)
|
2012-06-03 16:11:22 +00:00
|
|
|
#if defined(GEKKO)
|
2014-06-16 23:15:49 +00:00
|
|
|
|| (JOYSTICK_GetButtons()&WII_HOME)
|
2012-06-03 16:11:22 +00:00
|
|
|
#endif
|
|
|
|
);
|
|
|
|
}
|
2014-06-16 23:15:49 +00:00
|
|
|
|
|
|
|
void I_EscapeTriggerClear(void)
|
2012-06-03 16:11:22 +00:00
|
|
|
{
|
2014-06-16 23:15:49 +00:00
|
|
|
KB_FlushKeyboardQueue();
|
|
|
|
KB_ClearKeyDown(sc_Escape);
|
2012-06-03 16:11:22 +00:00
|
|
|
#if defined(GEKKO)
|
2014-06-16 23:15:49 +00:00
|
|
|
JOYSTICK_ClearButton(WII_HOME);
|
2012-06-03 16:11:22 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-06-16 23:15:49 +00:00
|
|
|
|
|
|
|
int32_t I_MenuUp(void)
|
2012-06-03 16:11:22 +00:00
|
|
|
{
|
|
|
|
return (
|
2014-06-16 23:15:49 +00:00
|
|
|
KB_KeyPressed(sc_UpArrow) ||
|
|
|
|
KB_KeyPressed(sc_kpad_8) ||
|
|
|
|
(MOUSE_GetButtons()&WHEELUP_MOUSE) ||
|
|
|
|
BUTTON(gamefunc_Move_Forward) ||
|
|
|
|
(JOYSTICK_GetHat(0)&HAT_UP)
|
2012-06-03 16:11:22 +00:00
|
|
|
);
|
|
|
|
}
|
2014-06-16 23:15:49 +00:00
|
|
|
|
|
|
|
void I_MenuUpClear(void)
|
2012-06-03 16:11:22 +00:00
|
|
|
{
|
2014-06-16 23:15:49 +00:00
|
|
|
KB_ClearKeyDown(sc_UpArrow);
|
|
|
|
KB_ClearKeyDown(sc_kpad_8);
|
|
|
|
MOUSE_ClearButton(WHEELUP_MOUSE);
|
|
|
|
CONTROL_ClearButton(gamefunc_Move_Forward);
|
|
|
|
JOYSTICK_ClearHat(0);
|
2012-06-03 16:11:22 +00:00
|
|
|
}
|
2014-06-16 23:15:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
int32_t I_MenuDown(void)
|
2012-06-03 16:11:22 +00:00
|
|
|
{
|
|
|
|
return (
|
2014-06-16 23:15:49 +00:00
|
|
|
KB_KeyPressed(sc_DownArrow) ||
|
|
|
|
KB_KeyPressed(sc_kpad_2) ||
|
|
|
|
(MOUSE_GetButtons()&WHEELDOWN_MOUSE) ||
|
|
|
|
BUTTON(gamefunc_Move_Backward) ||
|
|
|
|
(JOYSTICK_GetHat(0)&HAT_DOWN)
|
2012-06-03 16:11:22 +00:00
|
|
|
);
|
|
|
|
}
|
2014-06-16 23:15:49 +00:00
|
|
|
|
|
|
|
void I_MenuDownClear(void)
|
2012-06-03 16:11:22 +00:00
|
|
|
{
|
2014-06-16 23:15:49 +00:00
|
|
|
KB_ClearKeyDown(sc_DownArrow);
|
|
|
|
KB_ClearKeyDown(sc_kpad_2);
|
|
|
|
KB_ClearKeyDown(sc_PgDn);
|
|
|
|
MOUSE_ClearButton(WHEELDOWN_MOUSE);
|
|
|
|
CONTROL_ClearButton(gamefunc_Move_Backward);
|
|
|
|
JOYSTICK_ClearHat(0);
|
2012-06-03 16:11:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-16 23:15:49 +00:00
|
|
|
int32_t I_MenuLeft(void)
|
2012-06-03 16:11:22 +00:00
|
|
|
{
|
|
|
|
return (
|
|
|
|
KB_KeyPressed(sc_LeftArrow) ||
|
|
|
|
KB_KeyPressed(sc_kpad_4) ||
|
2014-06-16 23:15:49 +00:00
|
|
|
(SHIFTS_IS_PRESSED && KB_KeyPressed(sc_Tab)) ||
|
2012-06-03 16:11:22 +00:00
|
|
|
BUTTON(gamefunc_Turn_Left) ||
|
|
|
|
BUTTON(gamefunc_Strafe_Left) ||
|
2014-06-16 23:15:49 +00:00
|
|
|
(JOYSTICK_GetHat(0)&HAT_LEFT)
|
2012-06-03 16:11:22 +00:00
|
|
|
);
|
|
|
|
}
|
2014-06-16 23:15:49 +00:00
|
|
|
|
|
|
|
void I_MenuLeftClear(void)
|
2012-06-03 16:11:22 +00:00
|
|
|
{
|
|
|
|
KB_ClearKeyDown(sc_LeftArrow);
|
|
|
|
KB_ClearKeyDown(sc_kpad_4);
|
2014-06-16 23:15:49 +00:00
|
|
|
KB_ClearKeyDown(sc_Tab);
|
2012-06-03 16:11:22 +00:00
|
|
|
CONTROL_ClearButton(gamefunc_Turn_Left);
|
|
|
|
CONTROL_ClearButton(gamefunc_Strafe_Left);
|
|
|
|
JOYSTICK_ClearHat(0);
|
|
|
|
}
|
|
|
|
|
2014-06-16 23:15:49 +00:00
|
|
|
|
|
|
|
int32_t I_MenuRight(void)
|
2012-06-03 16:11:22 +00:00
|
|
|
{
|
|
|
|
return (
|
|
|
|
KB_KeyPressed(sc_RightArrow) ||
|
|
|
|
KB_KeyPressed(sc_kpad_6) ||
|
2014-06-16 23:15:49 +00:00
|
|
|
(!SHIFTS_IS_PRESSED && KB_KeyPressed(sc_Tab)) ||
|
2012-06-03 16:11:22 +00:00
|
|
|
BUTTON(gamefunc_Turn_Right) ||
|
|
|
|
BUTTON(gamefunc_Strafe_Right) ||
|
2014-06-16 23:15:49 +00:00
|
|
|
(MOUSE_GetButtons()&MIDDLE_MOUSE) ||
|
|
|
|
(JOYSTICK_GetHat(0)&HAT_RIGHT)
|
2012-06-03 16:11:22 +00:00
|
|
|
);
|
|
|
|
}
|
2014-06-16 23:15:49 +00:00
|
|
|
|
|
|
|
void I_MenuRightClear(void)
|
2012-06-03 16:11:22 +00:00
|
|
|
{
|
|
|
|
KB_ClearKeyDown(sc_RightArrow);
|
|
|
|
KB_ClearKeyDown(sc_kpad_6);
|
2014-06-16 23:15:49 +00:00
|
|
|
KB_ClearKeyDown(sc_Tab);
|
2012-06-03 16:11:22 +00:00
|
|
|
CONTROL_ClearButton(gamefunc_Turn_Right);
|
|
|
|
CONTROL_ClearButton(gamefunc_Strafe_Right);
|
2014-06-16 23:15:49 +00:00
|
|
|
MOUSE_ClearButton(MIDDLE_MOUSE);
|
2012-06-03 16:11:22 +00:00
|
|
|
JOYSTICK_ClearHat(0);
|
2014-06-16 23:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int32_t I_PanelUp(void)
|
|
|
|
{
|
2012-06-03 16:11:22 +00:00
|
|
|
return (
|
2014-06-16 23:15:49 +00:00
|
|
|
KB_KeyPressed(sc_PgUp) ||
|
|
|
|
I_MenuUp() ||
|
|
|
|
I_MenuLeft()
|
2012-06-03 16:11:22 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2014-06-16 23:15:49 +00:00
|
|
|
void I_PanelUpClear(void)
|
|
|
|
{
|
|
|
|
KB_ClearKeyDown(sc_PgUp);
|
|
|
|
I_MenuUpClear();
|
|
|
|
I_MenuLeftClear();
|
|
|
|
}
|
2012-06-03 16:11:22 +00:00
|
|
|
|
|
|
|
|
2014-06-16 23:15:49 +00:00
|
|
|
int32_t I_PanelDown(void)
|
2014-05-31 12:26:41 +00:00
|
|
|
{
|
|
|
|
return (
|
2014-06-16 23:15:49 +00:00
|
|
|
KB_KeyPressed(sc_PgDn) ||
|
|
|
|
I_MenuDown() ||
|
|
|
|
I_MenuRight() ||
|
|
|
|
I_AdvanceTrigger()
|
2014-05-31 12:26:41 +00:00
|
|
|
);
|
|
|
|
}
|
2014-06-16 23:15:49 +00:00
|
|
|
|
|
|
|
void I_PanelDownClear(void)
|
|
|
|
{
|
|
|
|
KB_ClearKeyDown(sc_PgDn);
|
|
|
|
I_MenuDownClear();
|
|
|
|
I_MenuRightClear();
|
|
|
|
I_AdvanceTriggerClear();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int32_t I_SliderLeft(void)
|
2014-05-31 12:26:41 +00:00
|
|
|
{
|
|
|
|
return (
|
2014-06-16 23:15:49 +00:00
|
|
|
((MOUSE_GetButtons()&LEFT_MOUSE) && (MOUSE_GetButtons()&WHEELUP_MOUSE)) ||
|
|
|
|
I_MenuLeft()
|
2014-05-31 12:26:41 +00:00
|
|
|
);
|
|
|
|
}
|
2012-06-03 16:11:22 +00:00
|
|
|
|
2014-06-16 23:15:49 +00:00
|
|
|
void I_SliderLeftClear(void)
|
|
|
|
{
|
|
|
|
I_MenuLeftClear();
|
|
|
|
MOUSE_ClearButton(WHEELUP_MOUSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-05-31 12:26:41 +00:00
|
|
|
int32_t I_SliderRight(void)
|
|
|
|
{
|
|
|
|
return (
|
|
|
|
((MOUSE_GetButtons()&LEFT_MOUSE) && (MOUSE_GetButtons()&WHEELDOWN_MOUSE)) ||
|
2014-06-16 23:15:49 +00:00
|
|
|
I_MenuRight()
|
2014-05-31 12:26:41 +00:00
|
|
|
);
|
|
|
|
}
|
2014-06-16 23:15:49 +00:00
|
|
|
|
|
|
|
void I_SliderRightClear(void)
|
2014-05-31 12:26:41 +00:00
|
|
|
{
|
2014-06-16 23:15:49 +00:00
|
|
|
I_MenuRightClear();
|
|
|
|
MOUSE_ClearButton(WHEELDOWN_MOUSE);
|
2014-05-31 12:26:41 +00:00
|
|
|
}
|
2012-06-03 16:11:22 +00:00
|
|
|
|
2014-06-16 23:15:49 +00:00
|
|
|
|
2014-05-31 12:26:41 +00:00
|
|
|
int32_t I_EnterText(char *t, int32_t maxlength, int32_t flags)
|
2012-06-03 16:11:22 +00:00
|
|
|
{
|
|
|
|
char ch;
|
2014-05-31 12:26:41 +00:00
|
|
|
int32_t inputloc = Bstrlen(typebuf);
|
2012-06-03 16:11:22 +00:00
|
|
|
|
2012-11-17 16:48:11 +00:00
|
|
|
while ((ch = KB_GetCh()) != 0)
|
2012-06-03 16:11:22 +00:00
|
|
|
{
|
|
|
|
if (ch == asc_BackSpace)
|
|
|
|
{
|
|
|
|
if (inputloc > 0)
|
|
|
|
{
|
|
|
|
inputloc--;
|
|
|
|
*(t+inputloc) = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (ch == asc_Enter)
|
|
|
|
{
|
|
|
|
I_AdvanceTriggerClear();
|
2014-05-31 12:26:41 +00:00
|
|
|
return 1;
|
2012-06-03 16:11:22 +00:00
|
|
|
}
|
|
|
|
else if (ch == asc_Escape)
|
|
|
|
{
|
|
|
|
I_ReturnTriggerClear();
|
2014-05-31 12:26:41 +00:00
|
|
|
return -1;
|
2012-06-03 16:11:22 +00:00
|
|
|
}
|
2014-05-31 12:26:41 +00:00
|
|
|
else if (ch >= 32 && inputloc < maxlength && ch < 127)
|
2012-06-03 16:11:22 +00:00
|
|
|
{
|
2014-05-31 12:26:41 +00:00
|
|
|
if (!(flags & INPUT_NUMERIC) || (ch >= '0' && ch <= '9'))
|
2012-06-03 16:11:22 +00:00
|
|
|
{
|
|
|
|
// JBF 20040508: so we can have numeric only if we want
|
|
|
|
*(t+inputloc) = ch;
|
|
|
|
*(t+inputloc+1) = 0;
|
|
|
|
inputloc++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-31 12:26:41 +00:00
|
|
|
// All gamefuncs (and *only* _gamefuncs_) in I_ReturnTriggerClear() should be replicated here.
|
|
|
|
CONTROL_ClearButton(gamefunc_Crouch);
|
|
|
|
if (I_ReturnTrigger())
|
2012-06-03 16:11:22 +00:00
|
|
|
{
|
2014-05-31 12:26:41 +00:00
|
|
|
I_ReturnTriggerClear();
|
|
|
|
return -1;
|
2012-06-03 16:11:22 +00:00
|
|
|
}
|
|
|
|
|
2014-05-31 12:26:41 +00:00
|
|
|
return 0;
|
2012-06-03 16:11:22 +00:00
|
|
|
}
|