nngn
Loading...
Searching...
No Matches
nngn::Input Class 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 }
 Indicates that a callback should only handle a sub-set of events. More...
 
enum  Action : std::uint8_t { KEY_PRESS = 0b1 , KEY_RELEASE = 0 }
 
enum  Modifier : std::uint8_t { 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 }
 

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
 

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 

◆ Action

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

◆ Modifier

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

◆ Selector

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 

◆ TerminalFlag

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

Member Function Documentation

◆ add_source()

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

◆ binding_group()

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

◆ get_keys()

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

◆ has_override()

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

◆ init()

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

◆ key_callback()

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

◆ override_keys()

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

◆ register_callback()

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

◆ remove_callback()

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

◆ remove_source()

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

◆ set_binding_group()

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

◆ update()

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

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 class was generated from the following files: