Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

# Modules/BehaviorControl/CommonXabsl2Symbols/JoystickSymbols.cpp

Go to the documentation of this file.

    00001 /**
    00002 * @file JoystickSymbols.cpp
    00003 *
    00004 * Implementation of class JoystickSymbols.
    00005 *
    00006 * @author Matthias Jüngel
    00007 */
    00008
    00009 #include "JoystickSymbols.h"
    00010
    00011 JoystickSymbols::JoystickSymbols(const BehaviorControlInterfaces& interfaces)
    00012 : BehaviorControlInterfaces(interfaces)
    00013 {
    00014 }
    00015
    00016
    00017 void JoystickSymbols::registerSymbols(Xabsl2Engine& engine)
    00018 {
    00019   // "joystick-data.x"
    00020   engine.registerDecimalInputSymbol("joystick-data.x",&(joystickData.x));
    00021   // "joystick-data.y"
    00022   engine.registerDecimalInputSymbol("joystick-data.y",&(joystickData.y));
    00023   // "joystick-data.z"
    00024   engine.registerDecimalInputSymbol("joystick-data.z",&(joystickData.z));
    00025   // "joystick-data.accel"
    00026   engine.registerDecimalInputSymbol("joystick-data.accel",&(joystickData.accel));
    00027   // "joystick-data.button"
    00028   engine.registerEnumeratedInputSymbol("joystick-data.button",this,
    00029     (int (Xabsl2FunctionProvider::*)())&JoystickSymbols::getJoystickButton);
    00030   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.button","no-button",0);
    00031   //numOfJostickButtons-times
    00032   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.button","button1",1);
    00033   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.button","button2",2);
    00034   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.button","button3",3);
    00035   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.button","button4",4);
    00036   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.button","button5",5);
    00037   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.button","button6",6);
    00038   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.button","button7",7);
    00039   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.button","button8",8);
    00040   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.button","button9",9);
    00041   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.button","button10",10);
    00042   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.button","button11",11);
    00043   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.button","button12",12);
    00044   // "joystick-data.coolie"
    00045   engine.registerEnumeratedInputSymbol("joystick-data.coolie",(const int*)&(joystickData.coolie));
    00046   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.coolie","no-coolie",0);
    00047   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.coolie","N",1);
    00048   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.coolie","NE",2);
    00049   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.coolie","E",3);
    00050   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.coolie","SE",4);
    00051   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.coolie","S",5);
    00052   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.coolie","SW",6);
    00053   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.coolie","W",7);
    00054   engine.registerEnumeratedInputSymbolEnumElement("joystick-data.coolie","NW",8);
    00055   // "joystick-data.direct-special-action"
    00056   engine.registerBooleanInputSymbol("joystick-data.direct-special-action",&(joystickData.directSpecialAction));
    00057   // "joystick-data.special-action-id"
    00058   engine.registerDecimalInputSymbol("joystick-data.special-action-id",this,
    00059     (double (Xabsl2FunctionProvider::*)())&JoystickSymbols::getSpecialActionId);
    00060   // "joystick-data.time-since-last-message"
    00061   engine.registerDecimalInputSymbol("joystick-data.time-since-last-message",this,
    00062     (double (Xabsl2FunctionProvider::*)())&JoystickSymbols::getJoystickTimeSinceLastMessage);
    00063 }
    00064
    00065 void JoystickSymbols::update()
    00066 {
    00067 }
    00068
    00069
    00070 double JoystickSymbols::getJoystickTimeSinceLastMessage()
    00071 {
    00072   return (double)SystemCall::getTimeSince(joystickData.timeStamp);
    00073 }
    00074
    00075 int JoystickSymbols::getJoystickButton()
    00076 {
    00077   for (int i=0;i<numOfJoystickButtons;i++)
    00078   {
    00079     if ((joystickData.button >> i)&1)
    00080     {
    00081       //the button with the lowest number has the highest priority
    00082       return i+1;
    00083     }
    00084   }
    00085   return 0;
    00086 }
    00087
    00088 double JoystickSymbols::getSpecialActionId()
    00089 {
    00090   return (double)joystickData.specialActionID;
    00091 }
    00092