//------------------------------------------------------------------------- /* 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 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ //------------------------------------------------------------------------- #include "gamecontrol.h" #include "keyboard.h" #include "mouse.h" #include "joystick.h" #include "control.h" #include "input.h" #include "inputstate.h" char typebuf[TYPEBUFSIZE]; int32_t I_CheckAllInput(void) { return inputState.keyBufferWaiting() || inputState.MouseGetButtons() || JOYSTICK_GetButtons(); } void I_ClearAllInput(void) { inputState.keyFlushChars(); inputState.ClearKeysDown(); inputState.MouseClearAllButtonss(); JOYSTICK_ClearAllButtons(); buttonMap.ResetButtonStates(); } int32_t I_TextSubmit(void) { return inputState.GetKeyStatus(sc_Enter) || inputState.GetKeyStatus(sc_kpad_Enter) || gi->mouseInactiveConditional(inputState.MouseGetButtons()&LEFT_MOUSE) || (JOYSTICK_GetGameControllerButtons()&(1<mouseInactiveConditional(buttonMap.ButtonDown(gamefunc_Fire)) || buttonMap.ButtonDown(gamefunc_Crouch) || (JOYSTICK_GetGameControllerButtons()&(1<mouseInactiveConditional((inputState.MouseGetButtons()&LEFT_MOUSE) && (inputState.MouseGetButtons()&WHEELUP_MOUSE)) #endif ; } void I_SliderLeftClear(void) { I_MenuLeftClear(); inputState.MouseClearButton(WHEELUP_MOUSE); } int32_t I_SliderRight(void) { return I_MenuRight() #if !defined EDUKE32_TOUCH_DEVICES || gi->mouseInactiveConditional((inputState.MouseGetButtons()&LEFT_MOUSE) && (inputState.MouseGetButtons()&WHEELDOWN_MOUSE)) #endif ; } void I_SliderRightClear(void) { I_MenuRightClear(); inputState.MouseClearButton(WHEELDOWN_MOUSE); } int32_t I_EnterText(char *t, int32_t maxlength, int32_t flags) { char ch; int32_t inputloc = strlen(typebuf); while ((ch = inputState.keyGetChar()) != 0) { if (ch == asc_BackSpace) { if (inputloc > 0) { inputloc--; *(t+inputloc) = 0; } } else { if (ch == asc_Enter) { I_AdvanceTriggerClear(); return 1; } else if (ch == asc_Escape) { I_ReturnTriggerClear(); return -1; } else if (ch >= 32 && inputloc < maxlength && ch < 127) { if (!(flags & INPUT_NUMERIC) || (ch >= '0' && ch <= '9')) { // JBF 20040508: so we can have numeric only if we want *(t+inputloc) = ch; *(t+inputloc+1) = 0; inputloc++; } } } } if (I_TextSubmit()) { I_TextSubmitClear(); return 1; } if (I_ReturnTrigger()) { I_ReturnTriggerClear(); return -1; } return 0; }