2013-08-08 08:45:56 +04:00
|
|
|
/*
|
2017-01-01 11:18:41 +03:00
|
|
|
* Copyright 2010-2017 Branimir Karadzic. All rights reserved.
|
2016-01-01 11:11:04 +03:00
|
|
|
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
|
2013-08-08 08:45:56 +04:00
|
|
|
*/
|
|
|
|
|
2013-11-15 07:10:10 +04:00
|
|
|
#ifndef INPUT_H_HEADER_GUARD
|
|
|
|
#define INPUT_H_HEADER_GUARD
|
2013-08-08 08:45:56 +04:00
|
|
|
|
|
|
|
#include "entry.h"
|
|
|
|
|
|
|
|
typedef void (*InputBindingFn)(const void* _userData);
|
|
|
|
|
|
|
|
struct InputBinding
|
|
|
|
{
|
2016-11-15 08:46:59 +03:00
|
|
|
void set(entry::Key::Enum _key, uint8_t _modifiers, uint8_t _flags, InputBindingFn _fn, const void* _userData = NULL)
|
|
|
|
{
|
|
|
|
m_key = _key;
|
|
|
|
m_modifiers = _modifiers;
|
|
|
|
m_flags = _flags;
|
|
|
|
m_fn = _fn;
|
|
|
|
m_userData = _userData;
|
|
|
|
}
|
|
|
|
|
|
|
|
void end()
|
|
|
|
{
|
|
|
|
m_key = entry::Key::None;
|
|
|
|
m_modifiers = entry::Modifier::None;
|
|
|
|
m_flags = 0;
|
|
|
|
m_fn = NULL;
|
|
|
|
m_userData = NULL;
|
|
|
|
}
|
|
|
|
|
2013-08-08 08:45:56 +04:00
|
|
|
entry::Key::Enum m_key;
|
|
|
|
uint8_t m_modifiers;
|
|
|
|
uint8_t m_flags;
|
|
|
|
InputBindingFn m_fn;
|
|
|
|
const void* m_userData;
|
|
|
|
};
|
|
|
|
|
2013-08-08 09:50:01 +04:00
|
|
|
#define INPUT_BINDING_END { entry::Key::None, entry::Modifier::None, 0, NULL, NULL }
|
2013-08-08 08:45:56 +04:00
|
|
|
|
2015-02-10 07:12:46 +03:00
|
|
|
///
|
|
|
|
void inputInit();
|
|
|
|
|
|
|
|
///
|
|
|
|
void inputShutdown();
|
|
|
|
|
2013-08-08 08:45:56 +04:00
|
|
|
///
|
|
|
|
void inputAddBindings(const char* _name, const InputBinding* _bindings);
|
|
|
|
|
|
|
|
///
|
|
|
|
void inputRemoveBindings(const char* _name);
|
|
|
|
|
|
|
|
///
|
|
|
|
void inputProcess();
|
|
|
|
|
|
|
|
///
|
|
|
|
void inputSetKeyState(entry::Key::Enum _key, uint8_t _modifiers, bool _down);
|
|
|
|
|
2015-06-03 00:28:22 +03:00
|
|
|
///
|
|
|
|
bool inputGetKeyState(entry::Key::Enum _key, uint8_t* _modifiers = NULL);
|
|
|
|
|
2015-06-05 04:26:09 +03:00
|
|
|
///
|
|
|
|
uint8_t inputGetModifiersState();
|
|
|
|
|
2014-11-09 07:57:47 +03:00
|
|
|
/// Adds single UTF-8 encoded character into input buffer.
|
|
|
|
void inputChar(uint8_t _len, const uint8_t _char[4]);
|
|
|
|
|
|
|
|
/// Returns single UTF-8 encoded character from input buffer.
|
|
|
|
const uint8_t* inputGetChar();
|
|
|
|
|
|
|
|
/// Flush internal input buffer.
|
|
|
|
void inputCharFlush();
|
|
|
|
|
2013-08-08 08:45:56 +04:00
|
|
|
///
|
|
|
|
void inputSetMouseResolution(uint16_t _width, uint16_t _height);
|
|
|
|
|
|
|
|
///
|
2014-08-06 08:13:50 +04:00
|
|
|
void inputSetMousePos(int32_t _mx, int32_t _my, int32_t _mz);
|
2013-08-08 08:45:56 +04:00
|
|
|
|
|
|
|
///
|
|
|
|
void inputSetMouseButtonState(entry::MouseButton::Enum _button, uint8_t _state);
|
|
|
|
|
|
|
|
///
|
|
|
|
void inputSetMouseLock(bool _lock);
|
|
|
|
|
|
|
|
///
|
2014-08-06 08:13:50 +04:00
|
|
|
void inputGetMouse(float _mouse[3]);
|
2013-08-08 08:45:56 +04:00
|
|
|
|
|
|
|
///
|
|
|
|
bool inputIsMouseLocked();
|
|
|
|
|
2014-12-16 07:58:54 +03:00
|
|
|
///
|
|
|
|
void inputSetGamepadAxis(entry::GamepadHandle _handle, entry::GamepadAxis::Enum _axis, int32_t _value);
|
|
|
|
|
|
|
|
///
|
|
|
|
int32_t inputGetGamepadAxis(entry::GamepadHandle _handle, entry::GamepadAxis::Enum _axis);
|
|
|
|
|
2013-11-15 07:10:10 +04:00
|
|
|
#endif // INPUT_H_HEADER_GUARD
|