DirectKeyboard Struct Reference


Public Methods

void DirectKeyboard_dtor (struct DirectKeyboard *ptr_direct_keyboard, int memory_flag)
struct DirectKeyboard* DirectKeyboard_get_instance (void)
void DirectKeyboard_scan (struct DirectKeyboard *ptr_direct_keyboard)
bool DirectKeyboard_is_key_pressed (struct DirectKeyboard *ptr_direct_keyboard, short scancode)


Detailed Description

Use a DirectKeyboard object to scan the CYBIKO keyboard and determine what keys are being pressed. You must call the DirectKeyboard_get_instance() function before use and the DirectKeyboard_dtor() function after use.

See also:
Keyboard Input


Member Function Documentation

void DirectKeyboard_dtor ( struct DirectKeyboard * ptr_direct_keyboard,
int memory_flag )
 

Deletes a DirectKeyboard object.

Parameters:
ptr_direct_keyboard   A pointer to the initialized DirectKeyboard object
memory_flag   THE MEMORY FLAG MUST BE FREE_MEMORY.
Returns:
None.
       #include <cybiko.h>
       ...
       struct DirectKeyboard* ptr_direct_keyboard;
       ptr_direct_keyboard = DirectKeyboard_get_instance();
       ...
       DirectKeyboard_scan( ptr_direct_keyboard );
       if ( DirectKeyboard_is_key_pressed( ptr_direct_keyboard, KEY_ESC ) )
       ...
       DirectKeyboard_dtor( ptr_direct_keyboard, FREE_MEMORY );
       ...
See also:
FREE_MEMORY, LEAVE_MEMORY.

struct DirectKeyboard * DirectKeyboard_get_instance ( void )
 

Initializes a DirectKeyboard object.

Returns:
A pointer to the initialized DirectKeyboard object
       #include <cybiko.h>
       ...
       struct DirectKeyboard* ptr_direct_keyboard;
       ptr_direct_keyboard = DirectKeyboard_get_instance();
       ...
       DirectKeyboard_scan( ptr_direct_keyboard );
       if ( DirectKeyboard_is_key_pressed( ptr_direct_keyboard, KEY_ESC ) )
       ...
       DirectKeyboard_dtor( ptr_direct_keyboard, FREE_MEMORY );
       ...

bool DirectKeyboard_is_key_pressed ( struct DirectKeyboard * ptr_direct_keyboard,
short scancode )
 

Checks whether a specified key is being pressed.
The DirectKeyboard_scan function must be called before using this function!

Parameters:
ptr_direct_keyboard   A pointer to the initialized DirectKeyboard object
scancode   The scancode of the tested key
Returns:
TRUE if the specified key is pressed
       #include <cybiko.h>
       ...
       struct DirectKeyboard* ptr_direct_keyboard;
       ptr_direct_keyboard = DirectKeyboard_get_instance();
       ...
       DirectKeyboard_scan( ptr_direct_keyboard );
       if( DirectKeyboard_is_key_pressed( ptr_direct_keyboard, KEY_ESC ) )
       ...
       DirectKeyboard_dtor( ptr_direct_keyboard, FREE_MEMORY );
See also:
DirectKeyboard_scan

void DirectKeyboard_scan ( struct DirectKeyboard * ptr_direct_keyboard )
 

Scans the Cybiko computer's keyboard to determine what keys are being pressed.

Parameters:
ptr_direct_keyboard   A pointer to the initialized DirectKeyboard object
Returns:
None.
       #include <cybiko.h>
       ...
       struct DirectKeyboard* ptr_direct_keyboard;
       ptr_direct_keyboard = DirectKeyboard_get_instance();
       ...
       DirectKeyboard_scan( ptr_direct_keyboard );
       if ( DirectKeyboard_is_key_pressed( ptr_direct_keyboard, KEY_ESC ) )
       ...
       DirectKeyboard_dtor( ptr_direct_keyboard, FREE_MEMORY );
       ...
See also:
DirectKeyboard_is_key_pressed