mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-11 22:54:34 +00:00
initial commit jolt
This commit is contained in:
parent
0c2aa5328c
commit
8acf7da95b
1086 changed files with 214612 additions and 4 deletions
96
Engine/lib/JoltPhysics/TestFramework/Input/Keyboard.h
Normal file
96
Engine/lib/JoltPhysics/TestFramework/Input/Keyboard.h
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
|
||||
// SPDX-FileCopyrightText: 2021 Jorrit Rouwe
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
class ApplicationWindow;
|
||||
|
||||
enum class EKey
|
||||
{
|
||||
Invalid,
|
||||
Unknown,
|
||||
A,
|
||||
B,
|
||||
C,
|
||||
D,
|
||||
E,
|
||||
F,
|
||||
G,
|
||||
H,
|
||||
I,
|
||||
J,
|
||||
K,
|
||||
L,
|
||||
M,
|
||||
N,
|
||||
O,
|
||||
P,
|
||||
Q,
|
||||
R,
|
||||
S,
|
||||
T,
|
||||
U,
|
||||
V,
|
||||
W,
|
||||
X,
|
||||
Y,
|
||||
Z,
|
||||
Num0,
|
||||
Num1,
|
||||
Num2,
|
||||
Num3,
|
||||
Num4,
|
||||
Num5,
|
||||
Num6,
|
||||
Num7,
|
||||
Num8,
|
||||
Num9,
|
||||
Space,
|
||||
Comma,
|
||||
Period,
|
||||
Escape,
|
||||
LShift,
|
||||
RShift,
|
||||
LControl,
|
||||
RControl,
|
||||
LAlt,
|
||||
RAlt,
|
||||
Left,
|
||||
Right,
|
||||
Up,
|
||||
Down,
|
||||
Return,
|
||||
NumKeys,
|
||||
};
|
||||
|
||||
/// Keyboard interface class which keeps track on the status of all keys and keeps track of the list of keys pressed.
|
||||
class Keyboard
|
||||
{
|
||||
public:
|
||||
/// Constructor
|
||||
Keyboard() = default;
|
||||
virtual ~Keyboard() = default;
|
||||
|
||||
/// Initialization / shutdown
|
||||
virtual bool Initialize(ApplicationWindow *inWindow) = 0;
|
||||
virtual void Shutdown() = 0;
|
||||
|
||||
/// Update the keyboard state
|
||||
virtual void Poll() = 0;
|
||||
|
||||
/// Checks if a key is pressed or not
|
||||
virtual bool IsKeyPressed(EKey inKey) const = 0;
|
||||
|
||||
/// Checks if a key is pressed and was not pressed the last time this function was called (state is stored in ioPrevState)
|
||||
bool IsKeyPressedAndTriggered(EKey inKey, bool &ioPrevState) const
|
||||
{
|
||||
bool prev_state = ioPrevState;
|
||||
ioPrevState = IsKeyPressed(inKey);
|
||||
return ioPrevState && !prev_state;
|
||||
}
|
||||
|
||||
/// Buffered keyboard input, returns EKey::Invalid for none
|
||||
virtual EKey GetFirstKey() = 0;
|
||||
virtual EKey GetNextKey() = 0;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue