Kinova API Documentation
KINOVAAPIUSBCOMMANDLAYER_API int GetControlMapping ( ControlMappingCharts Response)

This function gets the control mapping charts.

Parameters:
ResponseA struct containing the control mapping charts.
#include <iostream>
#include <dlfcn.h> //Ubuntu
#include <vector>
#include "KinovaTypes.h"
//Note that under windows, you may/will have to perform other #include

using namespace std;

int main()
{
        int result;

        cout << "GetControlMapping function example" << endl;

        //Handle for the library's command layer.
        void * commandLayer_handle;

        //Function pointers to the functions we need
        int (*MyInitAPI)();
        int (*MyCloseAPI)();
        int (*MyGetControlMapping)(ControlMappingCharts &);
        int (*MyStartControlAPI)();

        //We load the library (Under Windows, use the function LoadLibrary)
        commandLayer_handle = dlopen("Kinova.API.USBCommandLayerUbuntu.so",RTLD_NOW|RTLD_GLOBAL);

        //We load the functions from the library (Under Windows, use GetProcAddress)
        MyInitAPI = (int (*)()) dlsym(commandLayer_handle,"InitAPI");
        MyCloseAPI = (int (*)()) dlsym(commandLayer_handle,"CloseAPI");
        MyGetControlMapping = (int (*)(ControlMappingCharts &)) dlsym(commandLayer_handle,"GetControlMapping");
        MyStartControlAPI = (int (*)()) dlsym(commandLayer_handle,"StartControlAPI");

        //If the was loaded correctly
        if((MyInitAPI == NULL) || (MyCloseAPI == NULL) || (MyGetControlMapping == NULL))
        {
                cout << "Unable to initialize the command layer." << endl;
        }
        else
        {
                cout << "The command has been initialized correctly." << endl << endl;

                cout << "Calling the method InitAPI()" << endl;
                result = (*MyInitAPI)();
                cout << "result of InitAPI() = " << result << endl;

                (*MyStartControlAPI)();

                ControlMappingCharts controlMappingCharts;

                result = (*MyGetControlMapping)(controlMappingCharts);

                //The value contained in ActualControlMapping can be compared with the enum Controller.
                switch(controlMappingCharts.ActualControlMapping)
                {
                        case 0:
                        {
                                cout << "ActualControlMapping = THREE_AXIS_JOYSTICK" << endl;
                                break;
                        }

                        case 1:
                        {
                                cout << "ActualControlMapping = TWO_AXIS_JOYSTICK" << endl;
                                break;
                        }

                        case 2:
                        {
                                cout << "ActualControlMapping = API" << endl;
                                break;
                        }

                        default:
                        {
                                break;
                        }
                }

                //We want to know in which mode list we are on. We cannot be on both list, it is either A or B. If the actual mode is -1,
                //that means that this is not the list we want.
                int actualModeA = controlMappingCharts.Mapping[controlMappingCharts.ActualControlMapping].ActualModeA;
                int actualModeB = controlMappingCharts.Mapping[controlMappingCharts.ActualControlMapping].ActualModeB;
                int currentMode;

                if(actualModeA >= 0)
                {
                        cout << "We are in list A in the mode " << actualModeA << endl;
                        cout << "Functionality mapped with the BUTTON 1 click event of the current mode = "
                                 << (ControlFunctionalityTypeEnum)controlMappingCharts.Mapping[controlMappingCharts.ActualControlMapping].ModeControlsA[actualModeA].ControlButtons[1].HoldDown
                                 << endl;
                }
                else if(actualModeB >= 0)
                {
                        cout << "We are in list B in the mode " << actualModeB << endl;
                        cout << "Functionality mapped with the BUTTON 1 click event of the current mode = "
                                 << (ControlFunctionalityTypeEnum)controlMappingCharts.Mapping[controlMappingCharts.ActualControlMapping].ModeControlsA[actualModeB].ControlButtons[1].HoldDown
                                 << endl;
                }
                else
                {
                        cout << "No mode list found. Error" << endl;
                }

                cout << endl << "Calling the method CloseAPI()" << endl;
                result = (*MyCloseAPI)();
                cout << "result of CloseAPI() = " << result << endl;
        }

        return 0;
}
 All Classes Files Functions Variables Enumerations Enumerator Defines