Smart Remote 3 nRF52 v1.2
Data Structures | Macros | Typedefs | Functions
Key combo utility

Functions for detecting hardware-specific key combinations. More...

Data Structures

struct  key_combo_desc_t
 Key combo description. Used to describe key combinations. More...
 
union  key_combo_member_t
 Member key in a key combo. Used to register keys that will be used in one or more key combinations. More...
 

Macros

#define KEY_COMBO_MEMBER_REGISTER(_key_id)
 Macro for registering key to use in subsequent combo definitions. More...
 
#define KEY_COMBO_ONE_KEY_REGISTER(key_id_1, duration_ms, evt_handler)
 Macro for registering one-key combo handler. More...
 
#define KEY_COMBO_THREE_KEY_REGISTER(key_id_1, key_id_2, key_id_3, duration_ms, evt_handler)
 Macro for registering three-key combo handler. More...
 
#define KEY_COMBO_TWO_KEY_REGISTER(key_id_1, key_id_2, duration_ms, evt_handler)
 Macro for registering two-key combo handler. More...
 

Typedefs

typedef void(* key_combo_handler_t )(void *p_context)
 Definition for key combination triggered callback.
 

Functions

ret_code_t key_combo_util_init (void)
 Key combo detection utility initialization. More...
 
bool key_combo_util_key_process (const event_t *p_event)
 Event bus event handler. More...
 

Detailed Description

Functions for detecting hardware-specific key combinations.

Macro Definition Documentation

#define KEY_COMBO_MEMBER_REGISTER (   _key_id)
Value:
NRF_SECTION_ITEM_REGISTER(combo_member_keys, static const key_combo_member_t CONCAT_2(_COMBO_MEMBER, __LINE__)) = \
{.key_id = _key_id}

Macro for registering key to use in subsequent combo definitions.

Key ID follows format = 0xRowColumn. E.g. 0x14 = key on row 1, column 4.

Note
Maximum 32 keys can be registered for use in key combos
Parameters
[in]_key_idID of key that will be used in one or more key combos.
#define KEY_COMBO_ONE_KEY_REGISTER (   key_id_1,
  duration_ms,
  evt_handler 
)
Value:
NRF_SECTION_ITEM_REGISTER(combo_descriptions, static const key_combo_desc_t CONCAT_2(evt_handler, _combo_cb)) = \
{ \
.handler = evt_handler, \
.combo_keys = {key_id_1, 0xFF, 0xFF, 0xFF}, \
.combo_num_keys = 1, \
.combo_duration_ms = duration_ms \
}

Macro for registering one-key combo handler.

Parameters
[in]key_id_1First key ID in key combo
[in]duration_msDuration in milliseconds that the combo keys must be pressed to trigger the combo
[in]evt_handlerEvent handler to call when combo is triggered
#define KEY_COMBO_THREE_KEY_REGISTER (   key_id_1,
  key_id_2,
  key_id_3,
  duration_ms,
  evt_handler 
)
Value:
NRF_SECTION_ITEM_REGISTER(combo_descriptions, static const key_combo_desc_t CONCAT_2(evt_handler, _combo_cb)) = \
{ \
.handler = evt_handler, \
.combo_keys = {key_id_1, key_id_2, key_id_3, 0xFF}, \
.combo_num_keys = 3, \
.combo_duration_ms = duration_ms \
}

Macro for registering three-key combo handler.

Parameters
[in]key_id_1First key ID in key combo
[in]key_id_2Second key ID in key combo
[in]key_id_3Third key ID in key combo
[in]duration_msDuration in milliseconds that the combo keys must be pressed to trigger the combo
[in]evt_handlerEvent handler to call when combo is triggered
#define KEY_COMBO_TWO_KEY_REGISTER (   key_id_1,
  key_id_2,
  duration_ms,
  evt_handler 
)
Value:
NRF_SECTION_ITEM_REGISTER(combo_descriptions, static const key_combo_desc_t CONCAT_2(evt_handler, _combo_cb)) = \
{ \
.handler = evt_handler, \
.combo_keys = {key_id_1, key_id_2, 0xFF, 0xFF}, \
.combo_num_keys = 2, \
.combo_duration_ms = duration_ms \
}

Macro for registering two-key combo handler.

Parameters
[in]key_id_1First key ID in key combo
[in]key_id_2Second key ID in key combo.
[in]duration_msDuration in milliseconds that the combo keys must be pressed to trigger the combo
[in]evt_handlerEvent handler to call when combo is triggered

Function Documentation

ret_code_t key_combo_util_init ( void  )

Key combo detection utility initialization.

Returns
NRF_SUCCESS on success, otherwise an error code.
bool key_combo_util_key_process ( const event_t *  p_event)

Event bus event handler.

Parameters
[in]p_eventPointer to the event structure.
Returns
True if further processing of the given event should be abandoned.

Documentation feedback | Developer Zone | Subscribe | Updated