GSDP:GAM100/CProcessing/KeyboardInputCallbackFunction

From Inside
Jump to: navigation, search

KeyboardInputCallbackFunction

Description

The type used to define a callback function that can be set to be called every time the state of a key on the keyboard changes. When making the function, it must have the parameters Key and KeyState.

Example

// Note the parameters as these must be here in that order
void MyKeyboardCallback(Key key, KeyState state)
{
    // Check whichever keys you need to
    // and perform actions based on their state
    switch(key)
    {
        case KEY_ESCAPE :
            if(state == KeyPressed)
                QuitGame();
            break;
        case KEY_ENTER :
            if(state == KeyPressed)
                StartGame();
            break;
    }
}

void Init()
{
    // Sets it so every time a key changes state
    // your callback function is called
    setKeyboardInputCallback(MyKeyboardCallback);
}

Related

Personal tools
Namespaces

Variants
Actions
Navigation
NameSpaces:>
Tools
Dynamic:>