ScummVM API documentation
Sword25::InputEngine Class Reference

Class definitions. More...

#include <inputengine.h>

Inheritance diagram for Sword25::InputEngine:
Sword25::Service Sword25::Persistable

Public Types

enum  KEY_CODES {
  KEY_BACKSPACE = Common::KEYCODE_BACKSPACE, KEY_TAB = Common::KEYCODE_TAB, KEY_CLEAR = Common::KEYCODE_CLEAR, KEY_RETURN = Common::KEYCODE_RETURN,
  KEY_PAUSE = Common::KEYCODE_PAUSE, KEY_CAPSLOCK = Common::KEYCODE_CAPSLOCK, KEY_ESCAPE = Common::KEYCODE_ESCAPE, KEY_SPACE = Common::KEYCODE_SPACE,
  KEY_PAGEUP = Common::KEYCODE_PAGEUP, KEY_PAGEDOWN = Common::KEYCODE_PAGEDOWN, KEY_END = Common::KEYCODE_END, KEY_HOME = Common::KEYCODE_HOME,
  KEY_LEFT = Common::KEYCODE_LEFT, KEY_UP = Common::KEYCODE_UP, KEY_RIGHT = Common::KEYCODE_RIGHT, KEY_DOWN = Common::KEYCODE_DOWN,
  KEY_PRINTSCREEN = Common::KEYCODE_PRINT, KEY_INSERT = Common::KEYCODE_INSERT, KEY_DELETE = Common::KEYCODE_DELETE, KEY_0 = Common::KEYCODE_0,
  KEY_1 = Common::KEYCODE_1, KEY_2 = Common::KEYCODE_2, KEY_3 = Common::KEYCODE_3, KEY_4 = Common::KEYCODE_4,
  KEY_5 = Common::KEYCODE_5, KEY_6 = Common::KEYCODE_6, KEY_7 = Common::KEYCODE_7, KEY_8 = Common::KEYCODE_8,
  KEY_9 = Common::KEYCODE_9, KEY_A = Common::KEYCODE_a, KEY_B = Common::KEYCODE_b, KEY_C = Common::KEYCODE_c,
  KEY_D = Common::KEYCODE_d, KEY_E = Common::KEYCODE_e, KEY_F = Common::KEYCODE_f, KEY_G = Common::KEYCODE_g,
  KEY_H = Common::KEYCODE_h, KEY_I = Common::KEYCODE_i, KEY_J = Common::KEYCODE_j, KEY_K = Common::KEYCODE_k,
  KEY_L = Common::KEYCODE_l, KEY_M = Common::KEYCODE_m, KEY_N = Common::KEYCODE_n, KEY_O = Common::KEYCODE_o,
  KEY_P = Common::KEYCODE_p, KEY_Q = Common::KEYCODE_q, KEY_R = Common::KEYCODE_r, KEY_S = Common::KEYCODE_s,
  KEY_T = Common::KEYCODE_t, KEY_U = Common::KEYCODE_u, KEY_V = Common::KEYCODE_v, KEY_W = Common::KEYCODE_w,
  KEY_X = Common::KEYCODE_x, KEY_Y = Common::KEYCODE_y, KEY_Z = Common::KEYCODE_z, KEY_NUMPAD0 = Common::KEYCODE_KP0,
  KEY_NUMPAD1 = Common::KEYCODE_KP1, KEY_NUMPAD2 = Common::KEYCODE_KP2, KEY_NUMPAD3 = Common::KEYCODE_KP3, KEY_NUMPAD4 = Common::KEYCODE_KP4,
  KEY_NUMPAD5 = Common::KEYCODE_KP5, KEY_NUMPAD6 = Common::KEYCODE_KP6, KEY_NUMPAD7 = Common::KEYCODE_KP7, KEY_NUMPAD8 = Common::KEYCODE_KP8,
  KEY_NUMPAD9 = Common::KEYCODE_KP9, KEY_MULTIPLY = Common::KEYCODE_KP_MULTIPLY, KEY_ADD = Common::KEYCODE_KP_PLUS, KEY_SEPARATOR = Common::KEYCODE_EQUALS,
  KEY_SUBTRACT = Common::KEYCODE_KP_MINUS, KEY_DECIMAL = Common::KEYCODE_KP_PERIOD, KEY_DIVIDE = Common::KEYCODE_KP_DIVIDE, KEY_F1 = Common::KEYCODE_F1,
  KEY_F2 = Common::KEYCODE_F2, KEY_F3 = Common::KEYCODE_F3, KEY_F4 = Common::KEYCODE_F4, KEY_F5 = Common::KEYCODE_F5,
  KEY_F6 = Common::KEYCODE_F6, KEY_F7 = Common::KEYCODE_F7, KEY_F8 = Common::KEYCODE_F8, KEY_F9 = Common::KEYCODE_F9,
  KEY_F10 = Common::KEYCODE_F10, KEY_F11 = Common::KEYCODE_F11, KEY_F12 = Common::KEYCODE_F12, KEY_NUMLOCK = Common::KEYCODE_NUMLOCK,
  KEY_SCROLL = Common::KEYCODE_SCROLLOCK, KEY_LSHIFT = Common::KEYCODE_LSHIFT, KEY_RSHIFT = Common::KEYCODE_RSHIFT, KEY_LCONTROL = Common::KEYCODE_LCTRL,
  KEY_RCONTROL = Common::KEYCODE_RCTRL
}
 
enum  KEY_COMMANDS {
  KEY_COMMAND_ENTER = 1, KEY_COMMAND_LEFT = 2, KEY_COMMAND_RIGHT = 3, KEY_COMMAND_HOME = 4,
  KEY_COMMAND_END = 5, KEY_COMMAND_BACKSPACE = 6, KEY_COMMAND_TAB = 7, KEY_COMMAND_INSERT = 8,
  KEY_COMMAND_DELETE = 9
}
 
typedef void(* CharacterCallback) (int command)
 
typedef void(* CommandCallback) (int command)
 

Public Member Functions

 InputEngine (Kernel *pKernel)
 
bool init ()
 
void update ()
 
bool isLeftMouseDown ()
 
bool isRightMouseDown ()
 
bool wasLeftMouseDown ()
 
bool wasRightMouseDown ()
 
bool isLeftDoubleClick ()
 
int getMouseX ()
 
int getMouseY ()
 
bool isKeyDown (uint keyCode)
 
bool wasKeyDown (uint keyCode)
 
void setCharacterCallback (CharacterCallback callback)
 
void setCommandCallback (CommandCallback callback)
 
void reportCharacter (byte character)
 
void reportCommand (KEY_COMMANDS command)
 
bool persist (OutputPersistenceBlock &writer) override
 
bool unpersist (InputPersistenceBlock &reader) override
 

Additional Inherited Members

- Protected Member Functions inherited from Sword25::Service
 Service (Kernel *pKernel)
 
KernelGetKernel () const
 

Detailed Description

Class definitions.

Member Function Documentation

◆ init()

bool Sword25::InputEngine::init ( )

THESE METHODS MUST BE IMPLEMENTED BY THE INPUT ENGINE

Initializes the input engine

Returns
Returns a true on success, otherwise false.

◆ update()

void Sword25::InputEngine::update ( )

Performs a "tick" of the input engine.

This method should be called once per frame. It can be used by implementations of the input engine that are not running in their own thread, or to perform additional administrative tasks that are needed.

◆ isLeftMouseDown()

bool Sword25::InputEngine::isLeftMouseDown ( )

Returns true if the left mouse button is pressed

◆ isRightMouseDown()

bool Sword25::InputEngine::isRightMouseDown ( )

Returns true if the right mouse button is pressed.

◆ wasLeftMouseDown()

bool Sword25::InputEngine::wasLeftMouseDown ( )

Returns true if the left mouse button was pressed and released.

The difference between this and IsLeftMouseDown() is that this only returns true when the left mouse button is released.

◆ wasRightMouseDown()

bool Sword25::InputEngine::wasRightMouseDown ( )

Returns true if the right mouse button was pressed and released.

The difference between this and IsRightMouseDown() is that this only returns true when the right mouse button is released.

◆ isLeftDoubleClick()

bool Sword25::InputEngine::isLeftDoubleClick ( )

Returns true if the left mouse button double click was done

◆ getMouseX()

int Sword25::InputEngine::getMouseX ( )

Returns the X position of the cursor in pixels

◆ getMouseY()

int Sword25::InputEngine::getMouseY ( )

Returns the Y position of the cursor in pixels

◆ isKeyDown()

bool Sword25::InputEngine::isKeyDown ( uint  keyCode)

Returns true if a given key was pressed

Parameters
KeyCodeThe key code to be checked
Returns
Returns true if the given key is done, otherwise false.

◆ wasKeyDown()

bool Sword25::InputEngine::wasKeyDown ( uint  keyCode)

Returns true if a certain key was pushed and released.

The difference between IsKeyDown() is that this only returns true after the key has been released. This method facilitates the retrieval of keys, and reading strings that users type.

Parameters
KeyCodeThe key code to be checked

◆ setCharacterCallback()

void Sword25::InputEngine::setCharacterCallback ( CharacterCallback  callback)

Registers a callback function for keyboard input.

The callback that is registered with this function will be called whenever an input key is pressed. A letter entry is different from the query using the methods isKeyDown() and wasKeyDown() in the sense that are treated instead of actual scan-coded letters. These were taken into account, among other things: the keyboard layout, the condition the Shift and Caps Lock keys and the repetition of longer holding the key. The input of strings by the user through use of callbacks should be implemented.

◆ setCommandCallback()

void Sword25::InputEngine::setCommandCallback ( CommandCallback  callback)

Registers a callback function for the input of commands that can have influence on the string input

The callback that is registered with this function will be called whenever the input service has a key that affects the character string input. This could be the following keys: Enter, End, Left, Right, ... The input of strings by the user through the use of callbacks should be implemented.


The documentation for this class was generated from the following file: