Cross-platform C SDK logo

Cross-platform C SDK

Keyboard buffer

❮ Back
Next ❯
This page has been automatically translated using the Google Translate API services. We are working on improving texts. Thank you for your understanding and patience.

Buffer to read keystrokes synchronously or asynchronously.


Functions

KeyBuf*keybuf_create (void)
voidkeybuf_destroy (...)
voidkeybuf_OnUp (...)
voidkeybuf_OnDown (...)
voidkeybuf_clear (...)
bool_tkeybuf_pressed (...)
voidkeybuf_str (...)
voidkeybuf_dump (...)

The operating system generates events related to the pressing or releasing keys view_OnDown view_OnUp. Sometimes we need to know the state of a key without having to be aware of the events they generate. KeyBuf offers a very simple query mechanism using only the value of the vkey_t key.

  • Use keybuf_create to create the buffer.
  • Use view_keybuf to assign the buffer to any generic view, which will be in charge of capturing events and updating it. The status may be consulted from any program function at any time.
❮ Back
Next ❯

keybuf_create ()

Create a buffer with keyboard status.

KeyBuf*
keybuf_create(void);

Return

The buffer.


keybuf_destroy ()

Destroy the buffer.

void
keybuf_destroy(KeyBuf **bufer);
bufer

The buffer. It will be set to NULL after the destruction.


keybuf_OnUp ()

Set the state of a key as released.

void
keybuf_OnUp(KeyBuf *bufer,
            const vkey_t key);
bufer

The buffer.

key

The key code.

Remarks

Normally it will not be necessary to call this function. It will be done by View or the module that captures keyboard events.


keybuf_OnDown ()

Sets the state of a key as pressed.

void
keybuf_OnDown(KeyBuf *bufer,
              const vkey_t key);
bufer

The buffer.

key

The key code.

Remarks

Normally it will not be necessary to call this function. It will be done by View or the module that captures keyboard events.


keybuf_clear ()

Clear the buffer. Set all keys as released.

void
keybuf_clear(KeyBuf *bufer);
bufer

The buffer.

Remarks

Normally it will not be necessary to call this function. It will be done by View or the module that captures keyboard events.


keybuf_pressed ()

Returns the state of a key.

bool_t
keybuf_pressed(const KeyBuf *bufer,
               const vkey_t key);
bufer

The buffer.

key

The key code.

Return

Pulsed (TRUE) or released (FALSE).


keybuf_str ()

Returns a text string associated with a key.

void
keybuf_str(const vkey_t key);
key

The key code.


keybuf_dump ()

Dump the buffer status into the Log.

void
keybuf_dump(const KeyBuf *bufer);
bufer

The buffer.

❮ Back
Next ❯