anyKode Marilou
ContentsIndexHome
PreviousUpNext
Connection::GetKeyboadKeysState

Read keyboard keys state.

C++
int GetKeyboadKeysState(MU8 * pKeys);
Parameters 
Description 
MU8 * pKeys 
[in/out] Array to fill in with the keys state : the size must be 256 bytes (MU8)

The written states count.

GetKeyboardKeysState reads the Exec's computer's keyboard keys state. The call is using Microsoft Direct Input : check if your computer is ready with this feature.

//////////////////////////////////////////////////
//C++ sample code
//////////////////////////////////////////////////

#include "Modacpp.h"
#include "conio.h"

#define MODASERVER "localhost"

int main(int argc, char* argv[])
{
ModaCPP::Connection *pConnection=new ModaCPP::Connection(true);
//Try connect to MODA server
if(pConnection->Connect(MODASERVER))
    {
    _cprintf("Connection ok to moda server\r\n");
    while(!_kbhit())
        {
        bool bKeys=false;
        MU8 states[256];
        pConnection->GetKeyboadKeysState(states);
        for(int i=0;i<256;i++)
            {
            if(states[i]!=0)
                {
                bKeys=true;
                _cprintf("%2.2X ",i,states[Moda::Keys::MKEY_CONVERT]);
                }
            }
        if(bKeys)    _cprintf("\r\n");
        pConnection->Sleep(50);
        }
    }
else
    {
    _cprintf("Unable to connect to moda server\r\n");
    }
//Disconnect & delete
pConnection->Disconnect();
delete pConnection;
_getch();
return 0;
}
Documentation v4.7 (18/01/2015), Copyright (c) 2015 anyKode. All rights reserved.
What do you think about this topic? Send feedback!