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
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
2019-10-25 22:32:49 +00:00
|
|
|
#include "gamecontrol.h"
|
2012-06-03 16:11:22 +00:00
|
|
|
#include "keyboard.h"
|
|
|
|
#include "mouse.h"
|
|
|
|
#include "joystick.h"
|
|
|
|
#include "control.h"
|
|
|
|
#include "input.h"
|
2019-10-28 06:00:31 +00:00
|
|
|
#include "inputstate.h"
|
2012-06-03 16:11:22 +00:00
|
|
|
|
2019-10-28 17:32:05 +00:00
|
|
|
char typebuf[TYPEBUFSIZE];
|
|
|
|
|
2019-09-21 20:53:00 +00:00
|
|
|
|
|
|
|
|
2012-06-03 16:11:22 +00:00
|
|
|
int32_t I_CheckAllInput(void)
|
|
|
|
{
|
2019-08-13 09:15:49 +00:00
|
|
|
return
|
2019-11-03 23:53:55 +00:00
|
|
|
inputState.keyBufferWaiting()
|
2019-11-04 00:01:54 +00:00
|
|
|
|| inputState.MouseGetButtons()
|
2019-10-28 17:32:05 +00:00
|
|
|
|| JOYSTICK_GetButtons();
|
2012-06-03 16:11:22 +00:00
|
|
|
}
|
|
|
|
void I_ClearAllInput(void)
|
|
|
|
{
|
2019-11-03 23:53:55 +00:00
|
|
|
inputState.keyFlushChars();
|
|
|
|
inputState.ClearKeysDown();
|
2019-11-04 00:01:54 +00:00
|
|
|
inputState.MouseClearAllButtonss();
|
2012-06-03 16:11:22 +00:00
|
|
|
JOYSTICK_ClearAllButtons();
|
2019-10-28 06:00:31 +00:00
|
|
|
inputState.ClearAllButtons();
|
2012-06-03 16:11:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-16 00:20:52 +00:00
|
|
|
int32_t I_TextSubmit(void)
|
2012-06-03 16:11:22 +00:00
|
|
|
{
|
2019-08-13 09:15:49 +00:00
|
|
|
return
|
2019-11-03 23:53:55 +00:00
|
|
|
inputState.GetKeyStatus(sc_Enter)
|
|
|
|
|| inputState.GetKeyStatus(sc_kpad_Enter)
|
2019-11-04 00:01:54 +00:00
|
|
|
//|| MOUSEINACTIVECONDITIONAL(inputState.MouseGetButtons()&LEFT_MOUSE)
|
2019-10-28 17:32:05 +00:00
|
|
|
|| (JOYSTICK_GetGameControllerButtons()&(1<<GAMECONTROLLER_BUTTON_A));
|
2012-06-03 16:11:22 +00:00
|
|
|
}
|
2014-06-16 23:15:49 +00:00
|
|
|
|
2019-08-16 00:20:52 +00:00
|
|
|
void I_TextSubmitClear(void)
|
2012-06-03 16:11:22 +00:00
|
|
|
{
|
2019-11-03 23:53:55 +00:00
|
|
|
inputState.keyFlushChars();
|
|
|
|
inputState.ClearKeyStatus(sc_kpad_Enter);
|
|
|
|
inputState.ClearKeyStatus(sc_Enter);
|
2019-11-04 00:01:54 +00:00
|
|
|
inputState.MouseClearButton(LEFT_MOUSE);
|
2019-08-14 16:11:55 +00:00
|
|
|
JOYSTICK_ClearGameControllerButton(1<<GAMECONTROLLER_BUTTON_A);
|
2012-06-03 16:11:22 +00:00
|
|
|
}
|
2014-06-16 23:15:49 +00:00
|
|
|
|
2019-08-16 00:20:52 +00:00
|
|
|
int32_t I_AdvanceTrigger(void)
|
|
|
|
{
|
|
|
|
return
|
|
|
|
I_TextSubmit()
|
2019-11-03 23:53:55 +00:00
|
|
|
|| inputState.GetKeyStatus(sc_Space);
|
2019-08-16 00:20:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void I_AdvanceTriggerClear(void)
|
|
|
|
{
|
|
|
|
I_TextSubmitClear();
|
2019-11-03 23:53:55 +00:00
|
|
|
inputState.ClearKeyStatus(sc_Space);
|
2019-08-16 00:20:52 +00:00
|
|
|
}
|
|
|
|
|
2014-06-16 23:15:49 +00:00
|
|
|
int32_t I_ReturnTrigger(void)
|
2012-06-03 16:11:22 +00:00
|
|
|
{
|
2019-08-13 09:15:49 +00:00
|
|
|
return
|
2019-11-03 23:53:55 +00:00
|
|
|
inputState.GetKeyStatus(sc_Escape)
|
2019-11-04 00:01:54 +00:00
|
|
|
|| (inputState.MouseGetButtons()&RIGHT_MOUSE)
|
2019-10-28 17:32:05 +00:00
|
|
|
|| (JOYSTICK_GetGameControllerButtons()&(1<<GAMECONTROLLER_BUTTON_B));
|
2012-06-03 16:11:22 +00:00
|
|
|
}
|
2014-06-16 23:15:49 +00:00
|
|
|
|
|
|
|
void I_ReturnTriggerClear(void)
|
2012-06-03 16:11:22 +00:00
|
|
|
{
|
2019-11-03 23:53:55 +00:00
|
|
|
inputState.keyFlushChars();
|
|
|
|
inputState.ClearKeyStatus(sc_Escape);
|
2019-11-04 00:01:54 +00:00
|
|
|
inputState.MouseClearButton(RIGHT_MOUSE);
|
2019-08-14 16:11:55 +00:00
|
|
|
JOYSTICK_ClearGameControllerButton(1<<GAMECONTROLLER_BUTTON_B);
|
2012-06-03 16:11:22 +00:00
|
|
|
}
|
2014-06-16 23:15:49 +00:00
|
|
|
|
2019-08-07 19:12:07 +00:00
|
|
|
int32_t I_GeneralTrigger(void)
|
|
|
|
{
|
2019-08-13 09:15:49 +00:00
|
|
|
return
|
|
|
|
I_AdvanceTrigger()
|
|
|
|
|| I_ReturnTrigger()
|
2019-11-03 23:53:55 +00:00
|
|
|
|| inputState.BUTTON(gamefunc_Open)
|
|
|
|
//|| MOUSEINACTIVECONDITIONAL(inputState.BUTTON(gamefunc_Fire))
|
|
|
|
|| inputState.BUTTON(gamefunc_Crouch)
|
2019-10-28 17:32:05 +00:00
|
|
|
|| (JOYSTICK_GetGameControllerButtons()&(1<<GAMECONTROLLER_BUTTON_START));
|
2019-08-07 19:12:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void I_GeneralTriggerClear(void)
|
|
|
|
{
|
|
|
|
I_AdvanceTriggerClear();
|
|
|
|
I_ReturnTriggerClear();
|
2019-10-28 06:00:31 +00:00
|
|
|
inputState.ClearButton(gamefunc_Open);
|
|
|
|
inputState.ClearButton(gamefunc_Fire);
|
|
|
|
inputState.ClearButton(gamefunc_Crouch);
|
2019-08-13 09:15:49 +00:00
|
|
|
JOYSTICK_ClearGameControllerButton(1<<GAMECONTROLLER_BUTTON_START);
|
2019-08-07 19:12:07 +00:00
|
|
|
}
|
|
|
|
|
2014-06-16 23:15:49 +00:00
|
|
|
|
|
|
|
int32_t I_EscapeTrigger(void)
|
2012-06-03 16:11:22 +00:00
|
|
|
{
|
2019-08-13 09:15:49 +00:00
|
|
|
return
|
2019-11-03 23:53:55 +00:00
|
|
|
inputState.GetKeyStatus(sc_Escape)
|
2019-10-28 17:32:05 +00:00
|
|
|
|| (JOYSTICK_GetGameControllerButtons()&(1<<GAMECONTROLLER_BUTTON_START));
|
2012-06-03 16:11:22 +00:00
|
|
|
}
|
2014-06-16 23:15:49 +00:00
|
|
|
|
|
|
|
void I_EscapeTriggerClear(void)
|
2012-06-03 16:11:22 +00:00
|
|
|
{
|
2019-11-03 23:53:55 +00:00
|
|
|
inputState.keyFlushChars();
|
|
|
|
inputState.ClearKeyStatus(sc_Escape);
|
2019-08-13 09:15:49 +00:00
|
|
|
JOYSTICK_ClearGameControllerButton(1<<GAMECONTROLLER_BUTTON_START);
|
2012-06-03 16:11:22 +00:00
|
|
|
}
|
|
|
|
|
2014-06-16 23:15:49 +00:00
|
|
|
|
|
|
|
int32_t I_MenuUp(void)
|
2012-06-03 16:11:22 +00:00
|
|
|
{
|
2019-08-13 09:15:49 +00:00
|
|
|
return
|
2019-11-03 23:53:55 +00:00
|
|
|
inputState.GetKeyStatus(sc_UpArrow)
|
|
|
|
|| inputState.GetKeyStatus(sc_kpad_8)
|
2019-11-04 00:01:54 +00:00
|
|
|
|| (inputState.MouseGetButtons()&WHEELUP_MOUSE)
|
2019-11-03 23:53:55 +00:00
|
|
|
|| inputState.BUTTON(gamefunc_Move_Forward)
|
2019-08-13 09:15:49 +00:00
|
|
|
|| (JOYSTICK_GetHat(0)&HAT_UP)
|
|
|
|
|| (JOYSTICK_GetGameControllerButtons()&(1<<GAMECONTROLLER_BUTTON_DPAD_UP))
|
2019-10-28 17:32:05 +00:00
|
|
|
|| CONTROL_GetGameControllerDigitalAxisNeg(GAMECONTROLLER_AXIS_LEFTY);
|
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
|
|
|
{
|
2019-11-03 23:53:55 +00:00
|
|
|
inputState.ClearKeyStatus(sc_UpArrow);
|
|
|
|
inputState.ClearKeyStatus(sc_kpad_8);
|
2019-11-04 00:01:54 +00:00
|
|
|
inputState.MouseClearButton(WHEELUP_MOUSE);
|
2019-10-28 06:00:31 +00:00
|
|
|
inputState.ClearButton(gamefunc_Move_Forward);
|
2014-06-16 23:15:49 +00:00
|
|
|
JOYSTICK_ClearHat(0);
|
2019-08-13 09:15:49 +00:00
|
|
|
JOYSTICK_ClearGameControllerButton(1<<GAMECONTROLLER_BUTTON_DPAD_UP);
|
2019-08-13 09:15:58 +00:00
|
|
|
CONTROL_ClearGameControllerDigitalAxisNeg(GAMECONTROLLER_AXIS_LEFTY);
|
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
|
|
|
{
|
2019-08-13 09:15:49 +00:00
|
|
|
return
|
2019-11-03 23:53:55 +00:00
|
|
|
inputState.GetKeyStatus(sc_DownArrow)
|
|
|
|
|| inputState.GetKeyStatus(sc_kpad_2)
|
2019-11-04 00:01:54 +00:00
|
|
|
|| (inputState.MouseGetButtons()&WHEELDOWN_MOUSE)
|
2019-11-03 23:53:55 +00:00
|
|
|
|| inputState.BUTTON(gamefunc_Move_Backward)
|
2019-08-13 09:15:49 +00:00
|
|
|
|| (JOYSTICK_GetHat(0)&HAT_DOWN)
|
|
|
|
|| (JOYSTICK_GetGameControllerButtons()&(1<<GAMECONTROLLER_BUTTON_DPAD_DOWN))
|
2019-10-28 17:32:05 +00:00
|
|
|
|| CONTROL_GetGameControllerDigitalAxisPos(GAMECONTROLLER_AXIS_LEFTY);
|
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
|
|
|
{
|
2019-11-03 23:53:55 +00:00
|
|
|
inputState.ClearKeyStatus(sc_DownArrow);
|
|
|
|
inputState.ClearKeyStatus(sc_kpad_2);
|
|
|
|
inputState.ClearKeyStatus(sc_PgDn);
|
2019-11-04 00:01:54 +00:00
|
|
|
inputState.MouseClearButton(WHEELDOWN_MOUSE);
|
2019-10-28 06:00:31 +00:00
|
|
|
inputState.ClearButton(gamefunc_Move_Backward);
|
2014-06-16 23:15:49 +00:00
|
|
|
JOYSTICK_ClearHat(0);
|
2019-08-13 09:15:49 +00:00
|
|
|
JOYSTICK_ClearGameControllerButton(1<<GAMECONTROLLER_BUTTON_DPAD_DOWN);
|
2019-08-13 09:15:58 +00:00
|
|
|
CONTROL_ClearGameControllerDigitalAxisPos(GAMECONTROLLER_AXIS_LEFTY);
|
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
|
|
|
{
|
2019-08-13 09:15:49 +00:00
|
|
|
return
|
2019-11-03 23:53:55 +00:00
|
|
|
inputState.GetKeyStatus(sc_LeftArrow)
|
|
|
|
|| inputState.GetKeyStatus(sc_kpad_4)
|
|
|
|
|| (inputState.ShiftPressed() && inputState.GetKeyStatus(sc_Tab))
|
|
|
|
|| inputState.BUTTON(gamefunc_Turn_Left)
|
|
|
|
|| inputState.BUTTON(gamefunc_Strafe_Left)
|
2019-08-13 09:15:49 +00:00
|
|
|
|| (JOYSTICK_GetHat(0)&HAT_LEFT)
|
|
|
|
|| (JOYSTICK_GetGameControllerButtons()&(1<<GAMECONTROLLER_BUTTON_DPAD_LEFT))
|
2019-10-28 17:32:05 +00:00
|
|
|
|| CONTROL_GetGameControllerDigitalAxisNeg(GAMECONTROLLER_AXIS_LEFTX);
|
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
|
|
|
{
|
2019-11-03 23:53:55 +00:00
|
|
|
inputState.ClearKeyStatus(sc_LeftArrow);
|
|
|
|
inputState.ClearKeyStatus(sc_kpad_4);
|
|
|
|
inputState.ClearKeyStatus(sc_Tab);
|
2019-10-28 06:00:31 +00:00
|
|
|
inputState.ClearButton(gamefunc_Turn_Left);
|
|
|
|
inputState.ClearButton(gamefunc_Strafe_Left);
|
2012-06-03 16:11:22 +00:00
|
|
|
JOYSTICK_ClearHat(0);
|
2019-08-13 09:15:49 +00:00
|
|
|
JOYSTICK_ClearGameControllerButton(1<<GAMECONTROLLER_BUTTON_DPAD_LEFT);
|
2019-08-13 09:15:58 +00:00
|
|
|
CONTROL_ClearGameControllerDigitalAxisNeg(GAMECONTROLLER_AXIS_LEFTX);
|
2012-06-03 16:11:22 +00:00
|
|
|
}
|
|
|
|
|
2014-06-16 23:15:49 +00:00
|
|
|
|
|
|
|
int32_t I_MenuRight(void)
|
2012-06-03 16:11:22 +00:00
|
|
|
{
|
2019-08-13 09:15:49 +00:00
|
|
|
return
|
2019-11-03 23:53:55 +00:00
|
|
|
inputState.GetKeyStatus(sc_RightArrow)
|
|
|
|
|| inputState.GetKeyStatus(sc_kpad_6)
|
|
|
|
|| (!inputState.ShiftPressed() && inputState.GetKeyStatus(sc_Tab))
|
|
|
|
|| inputState.BUTTON(gamefunc_Turn_Right)
|
|
|
|
|| inputState.BUTTON(gamefunc_Strafe_Right)
|
2019-11-04 00:01:54 +00:00
|
|
|
|| (inputState.MouseGetButtons()&MIDDLE_MOUSE)
|
2019-08-13 09:15:49 +00:00
|
|
|
|| (JOYSTICK_GetHat(0)&HAT_RIGHT)
|
|
|
|
|| (JOYSTICK_GetGameControllerButtons()&(1<<GAMECONTROLLER_BUTTON_DPAD_RIGHT))
|
2019-08-13 09:15:58 +00:00
|
|
|
|| CONTROL_GetGameControllerDigitalAxisPos(GAMECONTROLLER_AXIS_LEFTX)
|
2019-08-13 09:15:49 +00:00
|
|
|
;
|
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
|
|
|
{
|
2019-11-03 23:53:55 +00:00
|
|
|
inputState.ClearKeyStatus(sc_RightArrow);
|
|
|
|
inputState.ClearKeyStatus(sc_kpad_6);
|
|
|
|
inputState.ClearKeyStatus(sc_Tab);
|
2019-10-28 06:00:31 +00:00
|
|
|
inputState.ClearButton(gamefunc_Turn_Right);
|
|
|
|
inputState.ClearButton(gamefunc_Strafe_Right);
|
2019-11-04 00:01:54 +00:00
|
|
|
inputState.MouseClearButton(MIDDLE_MOUSE);
|
2012-06-03 16:11:22 +00:00
|
|
|
JOYSTICK_ClearHat(0);
|
2019-08-13 09:15:49 +00:00
|
|
|
JOYSTICK_ClearGameControllerButton(1<<GAMECONTROLLER_BUTTON_DPAD_RIGHT);
|
2019-08-13 09:15:58 +00:00
|
|
|
CONTROL_ClearGameControllerDigitalAxisPos(GAMECONTROLLER_AXIS_LEFTX);
|
2014-06-16 23:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int32_t I_PanelUp(void)
|
|
|
|
{
|
2019-08-13 09:15:49 +00:00
|
|
|
return
|
|
|
|
I_MenuUp()
|
|
|
|
|| I_MenuLeft()
|
2019-11-03 23:53:55 +00:00
|
|
|
|| inputState.GetKeyStatus(sc_PgUp)
|
2019-08-13 09:15:49 +00:00
|
|
|
;
|
2012-06-03 16:11:22 +00:00
|
|
|
}
|
|
|
|
|
2014-06-16 23:15:49 +00:00
|
|
|
void I_PanelUpClear(void)
|
|
|
|
{
|
|
|
|
I_MenuUpClear();
|
|
|
|
I_MenuLeftClear();
|
2019-11-03 23:53:55 +00:00
|
|
|
inputState.ClearKeyStatus(sc_PgUp);
|
2014-06-16 23:15:49 +00:00
|
|
|
}
|
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
|
|
|
{
|
2019-08-13 09:15:49 +00:00
|
|
|
return
|
|
|
|
I_MenuDown()
|
|
|
|
|| I_MenuRight()
|
2019-11-03 23:53:55 +00:00
|
|
|
|| inputState.GetKeyStatus(sc_PgDn)
|
2019-08-13 09:15:49 +00:00
|
|
|
|| I_AdvanceTrigger()
|
|
|
|
;
|
2014-05-31 12:26:41 +00:00
|
|
|
}
|
2014-06-16 23:15:49 +00:00
|
|
|
|
|
|
|
void I_PanelDownClear(void)
|
|
|
|
{
|
|
|
|
I_MenuDownClear();
|
|
|
|
I_MenuRightClear();
|
2019-11-03 23:53:55 +00:00
|
|
|
inputState.ClearKeyStatus(sc_PgDn);
|
2014-06-16 23:15:49 +00:00
|
|
|
I_AdvanceTriggerClear();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int32_t I_SliderLeft(void)
|
2014-05-31 12:26:41 +00:00
|
|
|
{
|
2019-08-13 09:15:49 +00:00
|
|
|
return
|
|
|
|
I_MenuLeft()
|
2014-12-27 18:36:58 +00:00
|
|
|
#if !defined EDUKE32_TOUCH_DEVICES
|
2019-11-04 00:01:54 +00:00
|
|
|
//|| MOUSEINACTIVECONDITIONAL((inputState.MouseGetButtons()&LEFT_MOUSE) && (inputState.MouseGetButtons()&WHEELUP_MOUSE))
|
2014-12-27 18:36:58 +00:00
|
|
|
#endif
|
2019-08-13 09:15:49 +00:00
|
|
|
;
|
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();
|
2019-11-04 00:01:54 +00:00
|
|
|
inputState.MouseClearButton(WHEELUP_MOUSE);
|
2014-06-16 23:15:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-05-31 12:26:41 +00:00
|
|
|
int32_t I_SliderRight(void)
|
|
|
|
{
|
2019-08-13 09:15:49 +00:00
|
|
|
return
|
|
|
|
I_MenuRight()
|
2014-12-27 18:36:58 +00:00
|
|
|
#if !defined EDUKE32_TOUCH_DEVICES
|
2019-11-04 00:01:54 +00:00
|
|
|
//|| MOUSEINACTIVECONDITIONAL((inputState.MouseGetButtons()&LEFT_MOUSE) && (inputState.MouseGetButtons()&WHEELDOWN_MOUSE))
|
2014-12-27 18:36:58 +00:00
|
|
|
#endif
|
2019-08-13 09:15:49 +00:00
|
|
|
;
|
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();
|
2019-11-04 00:01:54 +00:00
|
|
|
inputState.MouseClearButton(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;
|
2019-10-28 17:32:05 +00:00
|
|
|
int32_t inputloc = strlen(typebuf);
|
2012-06-03 16:11:22 +00:00
|
|
|
|
2019-11-03 23:53:55 +00:00
|
|
|
while ((ch = inputState.keyGetChar()) != 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++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-16 00:20:52 +00:00
|
|
|
if (I_TextSubmit())
|
2019-08-14 03:04:04 +00:00
|
|
|
{
|
2019-08-16 00:20:52 +00:00
|
|
|
I_TextSubmitClear();
|
2019-08-14 03:04:04 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2014-05-31 12:26:41 +00:00
|
|
|
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
|
|
|
}
|
2019-09-21 20:53:00 +00:00
|
|
|
|