Ignore:
Timestamp:
02/16/13 18:14:55 (11 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
hg-Phase:
(<MercurialRepository 3 'hg:/home/ivaradi/xplane/hg/xplra' '/'>, 'public')
Message:

Added the C client API for hotkey handling and the test program. Also changed the name of _sleep to xplra_sleep to be able to compile the code for Windows

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/client/c/hu/varadiistvan/xplra/xplra.cc

    r40 r55  
    13091309//------------------------------------------------------------------------------
    13101310
     1311extern "C" int xplra_register_hotkeys(int connectionID,
     1312                                      const uint16_t* codes, size_t length)
     1313{
     1314    Connection* connection = ConnectionSlot::getValue(connectionID);
     1315    if (connection==0) return -1;
     1316
     1317    try {
     1318        connection->registerHotkeys(codes, length);
     1319        return 0;
     1320    } catch(...) {
     1321        connection->handleException();
     1322        return -1;
     1323    }
     1324}
     1325
     1326/*----------------------------------------------------------------------------*/
     1327
     1328extern "C" int xplra_query_hotkeys(int connectionID,
     1329                                   uint8_t* states, size_t length)
     1330{
     1331    Connection* connection = ConnectionSlot::getValue(connectionID);
     1332    if (connection==0) return -1;
     1333
     1334    try {
     1335        connection->queryHotkeys(states, length);
     1336        return 0;
     1337    } catch(...) {
     1338        connection->handleException();
     1339        return -1;
     1340    }
     1341}
     1342
     1343/*----------------------------------------------------------------------------*/
     1344
     1345extern "C" int xplra_unregister_hotkeys(int connectionID)
     1346{
     1347    Connection* connection = ConnectionSlot::getValue(connectionID);
     1348    if (connection==0) return -1;
     1349
     1350    try {
     1351        connection->unregisterHotkeys();
     1352        return 0;
     1353    } catch(...) {
     1354        connection->handleException();
     1355        return -1;
     1356    }
     1357}
     1358
     1359//------------------------------------------------------------------------------
     1360//------------------------------------------------------------------------------
     1361
    13111362extern "C" int xplra_disconnect(int connectionID)
    13121363{
Note: See TracChangeset for help on using the changeset viewer.