nngn
Loading...
Searching...
No Matches
nngn::Input Struct Reference

Dispatches keyboard input events to pre-registered Lua functions. More...

#include <input.h>

Collaboration diagram for nngn::Input:

Classes

struct  Source
 

Public Types

enum  Selector : std::uint8_t {
  PRESS = 1u << 0 , CTRL = 1u << 1 , ALT = 1u << 2 , PRESS = 1u << 0 ,
  CTRL = 1u << 1 , ALT = 1u << 2
}
 Indicates that a callback should only handle a sub-set of events. More...
 
enum  Action : std::uint8_t { KEY_PRESS = 0b1 , KEY_RELEASE = 0 , KEY_PRESS = 0b1 , KEY_RELEASE = 0 }
 
enum  Modifier : std::uint8_t {
  MOD_SHIFT = 0b1 , MOD_CTRL = 0b10 , MOD_ALT = 0b100 , MOD_SHIFT = 0b1 ,
  MOD_CTRL = 0b10 , MOD_ALT = 0b100
}
 
enum  {
  KEY_ESC = 256 , KEY_ENTER , KEY_TAB , KEY_RIGHT = 262 ,
  KEY_LEFT , KEY_DOWN , KEY_UP , KEY_PAGE_UP = 266 ,
  KEY_PAGE_DOWN , KEY_MAX = 348
}
 
enum  TerminalFlag : std::uint8_t { OUTPUT_PROCESSING = 1u << 0 , OUTPUT_PROCESSING = 1u << 0 }
 
enum  Selector : std::uint8_t {
  PRESS = 1u << 0 , CTRL = 1u << 1 , ALT = 1u << 2 , PRESS = 1u << 0 ,
  CTRL = 1u << 1 , ALT = 1u << 2
}
 Indicates that a callback should only handle a sub-set of events. More...
 
enum  Action : std::uint8_t { KEY_PRESS = 0b1 , KEY_RELEASE = 0 , KEY_PRESS = 0b1 , KEY_RELEASE = 0 }
 
enum  Modifier : std::uint8_t {
  MOD_SHIFT = 0b1 , MOD_CTRL = 0b10 , MOD_ALT = 0b100 , MOD_SHIFT = 0b1 ,
  MOD_CTRL = 0b10 , MOD_ALT = 0b100
}
 
enum  {
  KEY_ESC = 256 , KEY_ENTER , KEY_TAB , KEY_RIGHT = 262 ,
  KEY_LEFT , KEY_DOWN , KEY_UP , KEY_PAGE_UP = 266 ,
  KEY_PAGE_DOWN , KEY_MAX = 348
}
 
enum  TerminalFlag : std::uint8_t { OUTPUT_PROCESSING = 1u << 0 , OUTPUT_PROCESSING = 1u << 0 }
 

Public Member Functions

void init (lua_State *L_)
 
void get_keys (std::span< i32 > keys) const
 
void has_override (std::size_t n, i32 *keys) const
 
BindingGroupbinding_group () const
 
void set_binding_group (BindingGroup *g)
 
void add_source (std::unique_ptr< Source > p)
 
bool remove_source (Source *p)
 
bool override_keys (bool pressed, std::span< const i32 > keys)
 
bool register_callback ()
 
bool remove_callback ()
 
bool update ()
 
bool key_callback (int key, Action action, Modifier mods) const
 
void init (lua_State *L_)
 
void get_keys (std::span< i32 > keys) const
 
void has_override (std::size_t n, i32 *keys) const
 
BindingGroupbinding_group () const
 
void set_binding_group (BindingGroup *g)
 
void add_source (std::unique_ptr< Source > p)
 
bool remove_source (Source *p)
 
bool override_keys (bool pressed, std::span< const i32 > keys)
 
bool register_callback ()
 
bool remove_callback ()
 
bool update ()
 
bool key_callback (int key, Action action, Modifier mods) const
 

Private Attributes

lua_State * L = {}
 
int callback_ref = {}
 
BindingGroupm_binding_group = {}
 
std::bitset< KEY_MAX+1 > overrides = {}
 
std::vector< std::unique_ptr< Source > > sources = {}
 

Detailed Description

Dispatches keyboard input events to pre-registered Lua functions.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
KEY_ESC 
KEY_ENTER 
KEY_TAB 
KEY_RIGHT 
KEY_LEFT 
KEY_DOWN 
KEY_UP 
KEY_PAGE_UP 
KEY_PAGE_DOWN 
KEY_MAX 

◆ anonymous enum

anonymous enum
Enumerator
KEY_ESC 
KEY_ENTER 
KEY_TAB 
KEY_RIGHT 
KEY_LEFT 
KEY_DOWN 
KEY_UP 
KEY_PAGE_UP 
KEY_PAGE_DOWN 
KEY_MAX 

◆ Action [1/2]

enum nngn::Input::Action : std::uint8_t
Enumerator
KEY_PRESS 
KEY_RELEASE 
KEY_PRESS 
KEY_RELEASE 

◆ Action [2/2]

enum nngn::Input::Action : std::uint8_t
Enumerator
KEY_PRESS 
KEY_RELEASE 
KEY_PRESS 
KEY_RELEASE 

◆ Modifier [1/2]

enum nngn::Input::Modifier : std::uint8_t
Enumerator
MOD_SHIFT 
MOD_CTRL 
MOD_ALT 
MOD_SHIFT 
MOD_CTRL 
MOD_ALT 

◆ Modifier [2/2]

enum nngn::Input::Modifier : std::uint8_t
Enumerator
MOD_SHIFT 
MOD_CTRL 
MOD_ALT 
MOD_SHIFT 
MOD_CTRL 
MOD_ALT 

◆ Selector [1/2]

enum nngn::Input::Selector : std::uint8_t

Indicates that a callback should only handle a sub-set of events.

E.g.: a callback specified with the PRESS selector will only handle key press events. The absence of a selector matches both possible cases.

Enumerator
PRESS 
CTRL 
ALT 
PRESS 
CTRL 
ALT 

◆ Selector [2/2]

enum nngn::Input::Selector : std::uint8_t

Indicates that a callback should only handle a sub-set of events.

E.g.: a callback specified with the PRESS selector will only handle key press events. The absence of a selector matches both possible cases.

Enumerator
PRESS 
CTRL 
ALT 
PRESS 
CTRL 
ALT 

◆ TerminalFlag [1/2]

enum nngn::Input::TerminalFlag : std::uint8_t
Enumerator
OUTPUT_PROCESSING 
OUTPUT_PROCESSING 

◆ TerminalFlag [2/2]

enum nngn::Input::TerminalFlag : std::uint8_t
Enumerator
OUTPUT_PROCESSING 
OUTPUT_PROCESSING 

Member Function Documentation

◆ add_source() [1/2]

void nngn::Input::add_source ( std::unique_ptr< Source p)

◆ add_source() [2/2]

void nngn::Input::add_source ( std::unique_ptr< Source p)

◆ binding_group() [1/2]

BindingGroup * nngn::Input::binding_group ( ) const
inline

◆ binding_group() [2/2]

BindingGroup * nngn::Input::binding_group ( ) const
inline

◆ get_keys() [1/2]

void nngn::Input::get_keys ( std::span< i32 keys) const
Here is the call graph for this function:

◆ get_keys() [2/2]

void nngn::Input::get_keys ( std::span< i32 keys) const

◆ has_override() [1/2]

void nngn::Input::has_override ( std::size_t  n,
i32 keys 
) const

◆ has_override() [2/2]

void nngn::Input::has_override ( std::size_t  n,
i32 keys 
) const

◆ init() [1/2]

void nngn::Input::init ( lua_State *  L_)
inline

◆ init() [2/2]

void nngn::Input::init ( lua_State *  L_)
inline

◆ key_callback() [1/2]

bool nngn::Input::key_callback ( int  key,
Action  action,
Modifier  mods 
) const
Here is the call graph for this function:

◆ key_callback() [2/2]

bool nngn::Input::key_callback ( int  key,
Action  action,
Modifier  mods 
) const

◆ override_keys() [1/2]

bool nngn::Input::override_keys ( bool  pressed,
std::span< const i32 keys 
)
Here is the call graph for this function:

◆ override_keys() [2/2]

bool nngn::Input::override_keys ( bool  pressed,
std::span< const i32 keys 
)

◆ register_callback() [1/2]

bool nngn::Input::register_callback ( )
Here is the call graph for this function:

◆ register_callback() [2/2]

bool nngn::Input::register_callback ( )

◆ remove_callback() [1/2]

bool nngn::Input::remove_callback ( )
Here is the call graph for this function:

◆ remove_callback() [2/2]

bool nngn::Input::remove_callback ( )

◆ remove_source() [1/2]

bool nngn::Input::remove_source ( Source p)
Here is the call graph for this function:

◆ remove_source() [2/2]

bool nngn::Input::remove_source ( Source p)

◆ set_binding_group() [1/2]

void nngn::Input::set_binding_group ( BindingGroup g)
inline

◆ set_binding_group() [2/2]

void nngn::Input::set_binding_group ( BindingGroup g)
inline

◆ update() [1/2]

bool nngn::Input::update ( )
Here is the call graph for this function:

◆ update() [2/2]

bool nngn::Input::update ( )

Member Data Documentation

◆ callback_ref

int nngn::Input::callback_ref = {}
private

◆ L

lua_State * nngn::Input::L = {}
private

◆ m_binding_group

BindingGroup * nngn::Input::m_binding_group = {}
private

◆ overrides

std::bitset< KEY_MAX+1 > nngn::Input::overrides = {}
private

◆ sources

std::vector< std::unique_ptr< Source > > nngn::Input::sources = {}
private

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