OpenGothic
Open source reimplementation of Gothic I and II
Loading...
Searching...
No Matches
KeyCodec Class Referencefinal

#include <keycodec.h>

Classes

struct  ActionMapping
 Encapsulates an in-game action and a key mapping that caused it to be fired. More...
 

Public Types

enum class  Mapping { Primary , Secondary }
 
enum  Action : uint8_t {
  Idle , Escape , Inventory , Status ,
  Log , Map , Heal , Potion ,
  LookBack , FirstPerson , Forward , Back ,
  Left , Right , RotateL , RotateR ,
  Jump , ActionGeneric , ActionLeft , ActionRight ,
  Parade , Walk , Sneak , Weapon ,
  WeaponMele , WeaponBow , WeaponMage3 , WeaponMage4 ,
  WeaponMage5 , WeaponMage6 , WeaponMage7 , WeaponMage8 ,
  WeaponMage9 , WeaponMage10 , K_ENTER , K_F8 ,
  K_K , K_O , K_Del , Last
}
 

Public Member Functions

 KeyCodec ()
 
Action tr (Tempest::KeyEvent const &e) const
 
Action tr (Tempest::MouseEvent const &e) const
 
Mapping mapping (Tempest::KeyEvent const &e) const
 Gets a mapping out of a key event.
 
void set (std::string_view section, std::string_view key, int32_t code)
 
void clear (std::string_view section, std::string_view key)
 
void setDefaultKeys (std::string_view preset)
 

Static Public Member Functions

static auto keysStr (std::string_view keys) -> string_frm< 64 >
 
static int32_t keyToCode (Tempest::Event::KeyType t)
 
static int32_t keyToCode (Tempest::Event::MouseButton t)
 
static std::string toCode (int32_t scan)
 

Static Public Attributes

static constexpr auto NumMappings = 2
 

Detailed Description

Definition at line 10 of file keycodec.h.

Member Enumeration Documentation

◆ Action

enum KeyCodec::Action : uint8_t
Enumerator
Idle 
Escape 
Inventory 
Status 
Log 
Map 
Heal 
Potion 
LookBack 
FirstPerson 
Forward 
Back 
Left 
Right 
RotateL 
RotateR 
Jump 
ActionGeneric 
ActionLeft 
ActionRight 
Parade 
Walk 
Sneak 
Weapon 
WeaponMele 
WeaponBow 
WeaponMage3 
WeaponMage4 
WeaponMage5 
WeaponMage6 
WeaponMage7 
WeaponMage8 
WeaponMage9 
WeaponMage10 
K_ENTER 
K_F8 
K_K 
K_O 
K_Del 
Last 

Definition at line 22 of file keycodec.h.

◆ Mapping

enum class KeyCodec::Mapping
strong

Up to two keyboard keys can be mapped to the same action. This enum determines the order of the mapping within a single key.

Enumerator
Primary 
Secondary 

Definition at line 16 of file keycodec.h.

Constructor & Destructor Documentation

◆ KeyCodec()

KeyCodec::KeyCodec ( )

Definition at line 76 of file keycodec.cpp.

Member Function Documentation

◆ clear()

void KeyCodec::clear ( std::string_view  section,
std::string_view  key 
)

Definition at line 162 of file keycodec.cpp.

◆ keysStr()

string_frm< 64 > KeyCodec::keysStr ( std::string_view  keys) -> string_frm<64>
static

Definition at line 305 of file keycodec.cpp.

◆ keyToCode() [1/2]

int32_t KeyCodec::keyToCode ( Tempest::Event::KeyType  t)
static

Definition at line 423 of file keycodec.cpp.

◆ keyToCode() [2/2]

int32_t KeyCodec::keyToCode ( Tempest::Event::MouseButton  t)
static

Definition at line 430 of file keycodec.cpp.

◆ mapping()

KeyCodec::Mapping KeyCodec::mapping ( Tempest::KeyEvent const &  e) const

Gets a mapping out of a key event.

Parameters
eThe key event.
Returns
Requested mapping of an action.

Definition at line 135 of file keycodec.cpp.

◆ set()

void KeyCodec::set ( std::string_view  section,
std::string_view  key,
int32_t  code 
)

Definition at line 139 of file keycodec.cpp.

◆ setDefaultKeys()

void KeyCodec::setDefaultKeys ( std::string_view  preset)

Definition at line 166 of file keycodec.cpp.

◆ toCode()

std::string KeyCodec::toCode ( int32_t  scan)
static

Definition at line 239 of file keycodec.cpp.

◆ tr() [1/2]

KeyCodec::Action KeyCodec::tr ( Tempest::KeyEvent const &  e) const

Definition at line 107 of file keycodec.cpp.

◆ tr() [2/2]

KeyCodec::Action KeyCodec::tr ( Tempest::MouseEvent const &  e) const

Definition at line 127 of file keycodec.cpp.

Member Data Documentation

◆ NumMappings

constexpr auto KeyCodec::NumMappings = 2
staticconstexpr

Definition at line 20 of file keycodec.h.


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