mirror of
https://github.com/ReMinecraftPE/mcpe.git
synced 2025-01-23 09:44:34 -05:00
f7915a1dab
* Mac OS X 10.6 & More C++03 Support * Fix SDL2 options.txt loading for C++03 --------- Co-authored-by: Brent Da Mage <BrentDaMage@users.noreply.github.com>
53 lines
1 KiB
C++
53 lines
1 KiB
C++
/********************************************************************
|
|
Minecraft: Pocket Edition - Decompilation Project
|
|
Copyright (C) 2023 iProgramInCpp
|
|
|
|
The following code is licensed under the BSD 1 clause license.
|
|
SPDX-License-Identifier: BSD-1-Clause
|
|
********************************************************************/
|
|
|
|
#pragma once
|
|
#if __cplusplus < 201103L
|
|
#include <stdint.h>
|
|
#endif
|
|
|
|
#include <vector>
|
|
#include <stdint.h>
|
|
|
|
#define KEYBOARD_STATES_SIZE (256)
|
|
|
|
struct KeyboardAction;
|
|
|
|
class Keyboard
|
|
{
|
|
public:
|
|
enum KeyState
|
|
{
|
|
UP,
|
|
DOWN
|
|
};
|
|
|
|
static void feed(KeyState state, int key);
|
|
static bool next();
|
|
static int getEventKey();
|
|
static int getEventKeyState();
|
|
static bool isKeyDown(int keyCode);
|
|
static void reset();
|
|
|
|
private:
|
|
static std::vector<KeyboardAction> _inputs;
|
|
static Keyboard::KeyState _states[KEYBOARD_STATES_SIZE];
|
|
static int _index;
|
|
};
|
|
|
|
struct KeyboardAction
|
|
{
|
|
int _keyState;
|
|
uint8_t _keyCode;
|
|
|
|
KeyboardAction(uint8_t keyCode, Keyboard::KeyState keyState)
|
|
{
|
|
_keyState = keyState;
|
|
_keyCode = keyCode;
|
|
}
|
|
};
|