00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 00029 00030 00031 00032 00033 00034 00035 00036 00037 00038 00039 00040 #include "jaus/extras/controllers/keyboard.h" 00041 #include <cmath> 00042 #include <tinyxml/tinyxml.h> 00043 00044 using namespace JAUS; 00045 00046 00052 Keyboard::Keyboard() 00053 { 00054 00055 } 00056 00057 00063 Keyboard::~Keyboard() 00064 { 00065 00066 } 00067 00068 00078 bool Keyboard::LoadSettings(const std::string& filename) 00079 { 00080 return ControlDevice::LoadSettings(filename); 00081 } 00082 00083 00091 void Keyboard::CheckServiceStatus(const unsigned int timeSinceLastCheckMs) 00092 { 00093 ControlDevice::CheckServiceStatus(timeSinceLastCheckMs); 00094 ClearWrenchEffort(); 00095 00096 //Reset all possible input wrench efforts to zero, so if buttons have 00097 // been released the wrench effort message will have presence vectors set 00098 // and a thrust = 0. 00099 std::map<int, WrenchEffort> wrenchMap = GetInputIdToWrenchMapping(); 00100 for(std::map<int, WrenchEffort>::iterator it = wrenchMap.begin(); 00101 it != wrenchMap.end(); 00102 it++) 00103 { 00104 UpdateWrench(it->first, 0.0); 00105 } 00106 00107 CxUtils::Keyboard::KeyList keys = CxUtils::Keyboard::GetPressedKeys(); 00108 for(CxUtils::Keyboard::KeyList::iterator k = keys.begin(); k != keys.end(); k++) 00109 { 00110 SignalButtonPress((int)(*k)); 00111 UpdateWrench((int)(*k), 100.0); 00112 } 00113 00114 SendWrenchEffort(); 00115 // Send any MCU command 00116 SendMicrocontrollerState(); 00117 } 00118 00119 00120 /* End of File */