Files
OpenRCT2-Web/src/openrct2/Input.cpp
T

76 lines
1.3 KiB
C++
Raw Normal View History

2014-08-24 18:45:47 +01:00
/*****************************************************************************
* Copyright (c) 2014-2024 OpenRCT2 developers
2015-10-20 20:16:30 +02:00
*
2018-06-15 14:07:34 +02:00
* For a complete list of all authors, please refer to contributors.md
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
2015-10-20 20:16:30 +02:00
*
2018-06-15 14:07:34 +02:00
* OpenRCT2 is licensed under the GNU General Public License version 3.
2014-08-24 18:45:47 +01:00
*****************************************************************************/
2017-12-12 14:52:57 +01:00
#include "Input.h"
2014-08-24 18:45:47 +01:00
2018-06-22 23:25:16 +02:00
#include "Context.h"
2023-05-18 18:07:57 +03:00
#include "Game.h"
2018-06-22 23:25:16 +02:00
InputState _inputState;
uint8_t _inputFlags;
2016-01-04 22:45:51 +00:00
2023-01-19 15:13:23 +00:00
WidgetRef gHoverWidget;
WidgetRef gPressedWidget;
2016-01-05 21:46:38 +00:00
2023-05-18 18:07:57 +03:00
uint32_t _tooltipNotShownTimeout;
2016-01-05 00:02:23 +00:00
2017-06-11 16:31:54 +01:00
/**
*
* rct2: 0x006E3B43
*/
void TitleHandleKeyboardInput()
2017-06-11 16:31:54 +01:00
{
2022-11-06 20:49:07 +00:00
ContextInputHandleKeyboard(true);
2017-06-11 16:31:54 +01:00
}
/**
*
* rct2: 0x006E3B43
*/
void GameHandleKeyboardInput()
2017-06-11 16:31:54 +01:00
{
2022-11-06 20:49:07 +00:00
ContextInputHandleKeyboard(false);
2017-06-11 16:31:54 +01:00
}
void InputSetFlag(INPUT_FLAGS flag, bool on)
2017-02-27 20:20:41 +01:00
{
2018-06-22 23:25:16 +02:00
if (on)
{
2017-06-06 23:24:18 +02:00
_inputFlags |= flag;
2018-06-22 23:25:16 +02:00
}
else
{
2017-06-06 23:24:18 +02:00
_inputFlags &= ~flag;
}
2017-02-27 20:20:41 +01:00
}
bool InputTestFlag(INPUT_FLAGS flag)
2017-02-27 20:20:41 +01:00
{
2017-06-06 23:24:18 +02:00
return _inputFlags & flag;
2017-02-27 20:20:41 +01:00
}
void InputResetFlags()
2017-02-27 20:20:41 +01:00
{
2017-06-06 23:24:18 +02:00
_inputFlags = 0;
2017-02-27 20:20:41 +01:00
}
void InputSetState(InputState state)
2017-02-27 20:20:41 +01:00
{
2017-06-06 23:24:18 +02:00
_inputState = state;
2017-02-27 20:20:41 +01:00
}
InputState InputGetState()
2017-02-27 20:20:41 +01:00
{
2017-06-06 23:24:18 +02:00
return _inputState;
2017-02-27 20:20:41 +01:00
}
void ResetTooltipNotShown()
2017-02-27 20:20:41 +01:00
{
2023-05-18 18:07:57 +03:00
_tooltipNotShownTimeout = gCurrentRealTimeTicks + 50;
2017-02-27 20:20:41 +01:00
}