ge211
2021.5.1
A student game engine
|
|
1 #include "ge211_event.hxx"
3 #include <SDL_events.h>
12 bool map_button(uint8_t input, Mouse_button& output) NOEXCEPT
18 case SDL_BUTTON_MIDDLE:
19 output = Mouse_button::middle;
21 case SDL_BUTTON_RIGHT:
33 static Key map_key(
const SDL_KeyboardEvent& e) NOEXCEPT
35 if (e.keysym.sym >= 0 && e.keysym.sym < 128) {
38 switch (e.keysym.sym) {
67 Key::Key(
const SDL_KeyboardEvent& e) NOEXCEPT
71 static const char* mouse_button_name(
Mouse_button button) NOEXCEPT
76 case Mouse_button::middle:
87 return os << mouse_button_name(button);
90 static const char* key_type_name(
Key::Type type) NOEXCEPT
120 return os << key_type_name(type);
128 return os <<
"Key::code('" << char(key.
code()) <<
"')";
130 return os <<
"Key::code(" << key.
code() <<
")";
132 return os <<
"Key::" << key.
type() <<
"()";
138 return type_ ==
Type::code && !iswcntrl(code_);
146 char* end = utf8::append(code_, buffer);
std::string as_text() const
Returns a representation of the key's code as a std::string.
bool is_textual() const
Does the key represent printable text? This is true for some but not all Type::code keys.
Mouse_button
A representation of a mouse button.
static Key control()
Constructs the control key.
static Key command()
Constructs the command (or meta) key.
static Key alt()
Constructs the alt (or option) key.
static Key down()
Constructs the down arrow key.
Type
The possible types of keys.
Represents a key on the keyboard.
@ control
The control key.
The game engine namespace.
@ command
The command or meta key.
@ down
The down arrow key.
@ left
The left arrow key.
static Key up()
Constructs the up arrow key.
static Key right()
Constructs the right arrow key.
@ other
Any other, unknown or invalid key.
@ code
Indicates a key with an Unicode value, which can be gotten with Key::code() const.
static Key code(char32_t c)
Constructs a key with the given Unicode code point code.
char32_t code() const
The Unicode code point of the key, if it has one.
std::ostream & operator<<(std::ostream &, Mouse_button)
Prints a Mouse_button on a std::ostream.
static Key shift()
Constructs the shift key.
static Key left()
Constructs the left arrow key.
@ right
The right arrow key.
Type type() const
The type of the key.
@ right
The secondary mouse button.
Key()
Constructs the empty key, with type Key::Type::other.
@ left
The primary mouse button. This is an ordinary click.
@ alt
The alt or option key.