ManaPlus
|
#include <sdlinput.h>
Public Member Functions | |
SDLInput () | |
void | pushInput (const SDL_Event &event) |
KeyInput | dequeueKeyInput () |
bool | isKeyQueueEmpty () const |
bool | isMouseQueueEmpty () const |
MouseInput | dequeueMouseInput () |
void | simulateMouseClick (const int x, const int y, const MouseButtonT button) |
void | simulateMouseMove () |
void | simulateKey (const int guiKey, const InputActionT actionId) |
Static Protected Member Functions | |
static MouseButtonT | convertMouseButton (const int button) |
static int | convertKeyCharacter (const SDL_Event &event) |
static void | convertKeyEventToKey (const SDL_Event &event, KeyInput &keyInput) |
Protected Attributes | |
std::queue< KeyInput > | mKeyInputQueue |
std::queue< MouseInput > | mMouseInputQueue |
time_t | mMouseMoveTime |
bool | mMouseDown |
bool | mMouseInWindow |
SDL implementation of SDLInput.
Definition at line 104 of file sdlinput.h.
SDLInput::SDLInput | ( | ) |
|
inlinestaticprotected |
Converts an SDL event key to a key value.
event | an SDL event with a key to convert. |
Definition at line 157 of file sdlinput.h.
References KeyValue::ALT_GR, KeyValue::BACKSPACE, KeyValue::CAPS_LOCK, CAST_U32, KeyValue::DELETE_, KeyValue::DOWN, KeyValue::END, KeyValue::ENTER, KeyValue::ESCAPE, KeyValue::F1, KeyValue::F10, KeyValue::F11, KeyValue::F12, KeyValue::F13, KeyValue::F14, KeyValue::F15, KeyValue::F2, KeyValue::F3, KeyValue::F4, KeyValue::F5, KeyValue::F6, KeyValue::F7, KeyValue::F8, KeyValue::F9, KeyValue::HOME, KeyValue::INSERT, KeyValue::LEFT, KeyValue::LEFT_ALT, KeyValue::LEFT_CONTROL, KeyValue::LEFT_META, KeyValue::LEFT_SHIFT, KeyValue::LEFT_SUPER, KeyValue::NUM_LOCK, KeyValue::PAGE_DOWN, KeyValue::PAGE_UP, KeyValue::PAUSE, PRAGMA45(), KeyValue::PRINT_SCREEN, KeyValue::RIGHT, KeyValue::RIGHT_ALT, KeyValue::RIGHT_CONTROL, KeyValue::RIGHT_META, KeyValue::RIGHT_SHIFT, KeyValue::RIGHT_SUPER, KeyValue::SCROLL_LOCK, KeyValue::SPACE, KeyValue::TAB, and KeyValue::UP.
Referenced by convertKeyEventToKey().
|
staticprotected |
Definition at line 329 of file sdlinput.cpp.
References convertKeyCharacter(), InputManager::getActionByKey(), inputManager, InputAction::NO_VALUE, KeyInput::setActionId(), and KeyInput::setKey().
Referenced by pushInput().
|
staticprotected |
Converts a mouse button from SDL to a Guichan mouse button representation.
button | an SDL mouse button. |
Definition at line 337 of file sdlinput.cpp.
References MouseButton::EMPTY, MouseButton::LEFT, Logger::log(), logger, MouseButton::MIDDLE, and MouseButton::RIGHT.
Referenced by pushInput().
KeyInput SDLInput::dequeueKeyInput | ( | ) |
Definition at line 112 of file sdlinput.cpp.
References mKeyInputQueue.
Referenced by Gui::handleKeyInput().
MouseInput SDLInput::dequeueMouseInput | ( | ) |
Definition at line 123 of file sdlinput.cpp.
References mMouseInputQueue.
Referenced by Gui::handleMouseInput().
|
inline |
Definition at line 124 of file sdlinput.h.
References mKeyInputQueue.
Referenced by Gui::handleKeyInput().
|
inline |
Definition at line 127 of file sdlinput.h.
References mMouseInputQueue.
Referenced by Gui::handleMouseInput().
void SDLInput::pushInput | ( | const SDL_Event & | event | ) |
Pushes an SDL event. It should be called at least once per frame to update input with user input.
event | an event from SDL. |
< The app has mouse coverage
< The app has mouse coverage
Definition at line 136 of file sdlinput.cpp.
References BLOCK_END, BLOCK_START, convertKeyEventToKey(), convertMouseButton(), cur_time, MouseButton::EMPTY, KeyValue::ENTER, Gui::getLastMouseX(), Gui::getLastMouseY(), Graphics::getScale(), gui, InputAction::GUI_SELECT2, mainGraphics, mKeyInputQueue, mMouseDown, mMouseInputQueue, mMouseInWindow, mMouseMoveTime, MouseEventType::MOVED, KeyEventType::PRESSED, MouseEventType::PRESSED, KeyEventType::RELEASED, MouseEventType::RELEASED, MouseInput::setButton(), KeyInput::setKey(), MouseInput::setReal(), MouseInput::setTimeStamp(), KeyInput::setType(), MouseInput::setType(), MouseInput::setX(), MouseInput::setY(), simulateKey(), KeyValue::TEXTINPUT, MouseButton::WHEEL, MouseEventType::WHEEL_MOVED_DOWN, MouseEventType::WHEEL_MOVED_UP, x, and y.
Referenced by InputManager::handleEvent().
void SDLInput::simulateKey | ( | const int | guiKey, |
const InputActionT | actionId | ||
) |
Definition at line 403 of file sdlinput.cpp.
References CAST_S8, mKeyInputQueue, InputAction::NO_VALUE, KeyEventType::PRESSED, KeyEventType::RELEASED, KeyInput::setActionId(), KeyInput::setKey(), KeyInput::setType(), and KeyValue::TEXTINPUT.
Referenced by pushInput().
void SDLInput::simulateMouseClick | ( | const int | x, |
const int | y, | ||
const MouseButtonT | button | ||
) |
Definition at line 360 of file sdlinput.cpp.
References MouseButton::EMPTY, mMouseInputQueue, MouseEventType::MOVED, MouseEventType::PRESSED, MouseEventType::RELEASED, MouseInput::setButton(), MouseInput::setReal(), MouseInput::setTimeStamp(), MouseInput::setType(), MouseInput::setX(), MouseInput::setY(), x, and y.
void SDLInput::simulateMouseMove | ( | ) |
Definition at line 380 of file sdlinput.cpp.
References cur_time, MouseButton::EMPTY, Gui::getMouseState(), gui, mMouseInputQueue, mMouseMoveTime, MouseEventType::MOVED, MouseInput::setButton(), MouseInput::setReal(), MouseInput::setTimeStamp(), MouseInput::setType(), MouseInput::setX(), MouseInput::setY(), x, and y.
Referenced by ActorManager::addChar(), and Gui::slowLogic().
|
protected |
Definition at line 380 of file sdlinput.h.
Referenced by dequeueKeyInput(), isKeyQueueEmpty(), pushInput(), and simulateKey().
|
protected |
Definition at line 384 of file sdlinput.h.
Referenced by pushInput().
|
protected |
Definition at line 381 of file sdlinput.h.
Referenced by dequeueMouseInput(), isMouseQueueEmpty(), pushInput(), simulateMouseClick(), and simulateMouseMove().
|
protected |
Definition at line 385 of file sdlinput.h.
Referenced by pushInput().
|
protected |
Definition at line 382 of file sdlinput.h.
Referenced by pushInput(), and simulateMouseMove().