ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

Common::KeyState Struct Reference

Keyboard status, as used in the Event struct. More...

#include <keyboard.h>

List of all members.

Public Member Functions

 KeyState (KeyCode kc=KEYCODE_INVALID)
 KeyState (KeyCode kc, uint16 asc, byte f=0)
void reset ()
bool hasFlags (byte f) const
 Check whether the non-sticky flags are *exactly* as specified by f.
bool operator== (const KeyState &x) const
 Check if two key states are equal.

Public Attributes

KeyCode keycode
 Abstract key code (will be the same for any given key regardless of modifiers being held at the same time.
uint16 ascii
 ASCII-value of the pressed key (if any).
byte flags
 Status of the modifier keys.

Detailed Description

Keyboard status, as used in the Event struct.

Definition at line 241 of file keyboard.h.


Constructor & Destructor Documentation

Common::KeyState::KeyState ( KeyCode  kc = KEYCODE_INVALID  )  [inline]

Definition at line 272 of file keyboard.h.

Common::KeyState::KeyState ( KeyCode  kc,
uint16  asc,
byte  f = 0 
) [inline]

Definition at line 278 of file keyboard.h.


Member Function Documentation

bool Common::KeyState::hasFlags ( byte  f  )  const [inline]

Check whether the non-sticky flags are *exactly* as specified by f.

This ignores the sticky flags (KBD_NUM, KBD_CAPS, KBD_SCRL). Sticky flags should never be passed to this function. If you just want to check whether a modifier flag is set, just bit-and the flag. E.g. to check whether the control key modifier is set, you can write if (keystate.flags & KBD_CTRL) { ... }

Definition at line 298 of file keyboard.h.

bool Common::KeyState::operator== ( const KeyState x  )  const [inline]

Check if two key states are equal.

This implementation ignores the state of the sticky flags (caps lock, num lock, scroll lock) completely. This functionality is currently only used by the keymapper.

Definition at line 308 of file keyboard.h.

void Common::KeyState::reset (  )  [inline]

Definition at line 284 of file keyboard.h.


Member Data Documentation

ASCII-value of the pressed key (if any).

This depends on modifiers, i.e. pressing the 'A' key results in different values here depending on the status of shift, alt and caps lock. This should be used rather than keycode for text input to avoid keyboard layout issues. For example you cannot assume that KEYCODE_0 without a modifier will be '0' (on AZERTY keyboards it is not).

Definition at line 257 of file keyboard.h.

Status of the modifier keys.

Bits are set in this for each pressed modifier. We distinguish 'non-sticky' and 'sticky' modifiers flags. The former are only set while certain keys (ctrl, alt, shift) are pressed by the user; the latter (num lock, caps lock, scroll lock) are activated when certain keys are pressed and released; and deactivated when that key is pressed and released a second time.

See also:
KBD_CTRL, KBD_ALT, KBD_SHIFT, KBD_NUM, KBD_CAPS, KBD_SCRL

Definition at line 270 of file keyboard.h.

Abstract key code (will be the same for any given key regardless of modifiers being held at the same time.

Definition at line 246 of file keyboard.h.


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


Generated on Sat May 25 2019 05:05:15 for ResidualVM by doxygen 1.7.1
curved edge   curved edge