bgfx/examples/common/entry/entry.h

171 lines
2.3 KiB
C
Raw Normal View History

2013-02-22 09:07:31 +04:00
/*
2014-02-11 10:07:04 +04:00
* Copyright 2011-2014 Branimir Karadzic. All rights reserved.
2013-02-22 09:07:31 +04:00
* License: http://www.opensource.org/licenses/BSD-2-Clause
*/
#ifndef ENTRY_H_HEADER_GUARD
#define ENTRY_H_HEADER_GUARD
2013-02-22 09:07:31 +04:00
#include "dbg.h"
#include <bx/bx.h>
2014-05-04 02:18:28 +04:00
namespace bx { struct FileReaderI; struct FileWriterI; }
2014-06-01 23:01:50 +04:00
extern "C" int _main_(int _argc, char** _argv);
2013-02-22 09:07:31 +04:00
namespace entry
{
struct MouseButton
{
enum Enum
{
None,
Left,
Middle,
Right,
Count
};
};
struct Modifier
{
enum Enum
{
None = 0,
LeftAlt = 0x01,
RightAlt = 0x02,
LeftCtrl = 0x04,
RightCtrl = 0x08,
LeftShift = 0x10,
RightShift = 0x20,
LeftMeta = 0x40,
RightMeta = 0x80,
};
};
struct Key
{
enum Enum
{
None = 0,
Esc,
Return,
Tab,
Space,
Backspace,
Up,
Down,
Left,
Right,
PageUp,
PageDown,
Home,
End,
Print,
Plus,
Minus,
F1,
F2,
F3,
F4,
F5,
F6,
F7,
F8,
F9,
F10,
F11,
F12,
NumPad0,
NumPad1,
NumPad2,
NumPad3,
NumPad4,
NumPad5,
NumPad6,
NumPad7,
NumPad8,
NumPad9,
Key0,
Key1,
Key2,
Key3,
Key4,
Key5,
Key6,
Key7,
Key8,
Key9,
KeyA,
KeyB,
KeyC,
KeyD,
KeyE,
KeyF,
KeyG,
KeyH,
KeyI,
KeyJ,
KeyK,
KeyL,
KeyM,
KeyN,
KeyO,
KeyP,
KeyQ,
KeyR,
KeyS,
KeyT,
KeyU,
KeyV,
KeyW,
KeyX,
KeyY,
KeyZ,
2014-08-06 04:49:21 +04:00
Count,
2013-02-22 09:07:31 +04:00
};
};
struct MouseState
2013-02-22 09:07:31 +04:00
{
MouseState()
: m_mx(0)
, m_my(0)
2014-08-06 08:13:50 +04:00
, m_mz(0)
2013-02-22 09:07:31 +04:00
{
for (uint32_t ii = 0; ii < entry::MouseButton::Count; ++ii)
{
m_buttons[ii] = entry::MouseButton::None;
}
}
2013-02-22 09:07:31 +04:00
2014-08-06 08:13:50 +04:00
int32_t m_mx;
int32_t m_my;
int32_t m_mz;
uint8_t m_buttons[entry::MouseButton::Count];
2013-02-22 09:07:31 +04:00
};
2014-08-06 04:49:21 +04:00
struct KeyState
{
uint8_t m_modifiers;
bool m_keysDown[entry::Key::Count];
};
char keyToAscii(entry::Key::Enum _key, bool _shiftModifier);
bool processEvents(uint32_t& _width, uint32_t& _height, uint32_t& _debug, uint32_t& _reset, MouseState* _mouse = NULL, KeyState* _keyboard = NULL);
2013-02-22 09:07:31 +04:00
2014-08-06 04:49:34 +04:00
bx::FileReaderI* getFileReader();
bx::FileWriterI* getFileWriter();
2014-08-05 23:57:52 +04:00
void setWindowSize(uint32_t _width, uint32_t _height);
void setWindowTitle(const char* _title);
2014-08-05 23:57:52 +04:00
void toggleWindowFrame();
void setMouseLock(bool _lock);
2013-02-22 09:07:31 +04:00
} // namespace entry
#endif // ENTRY_H_HEADER_GUARD