#include <SDLTranslator.h>
Inheritance diagram for cmil::SDL::SDLKeyboards:
Public Member Functions | |
SDLKeyboards (System *const sys) | |
virtual | ~SDLKeyboards () |
void | setKey (SDLKey key, InputData *const press) |
This is used for key translation. | |
Press * | getData (SDLKey key) const |
This is used for key translation. | |
std::string | getName () const |
bool | translate (const SDL_Event &input_event) |
This should return a boolean as to whether or not translation was successful. | |
DeviceRegistry & | getDevices () |
Private Member Functions | |
void | assign_inputs () |
Private Attributes | |
InputDevice * | m_keyboard |
DeviceRegistry | m_registry |
tInputIndex< Press > | m_keys |
At the moment only one set of these is needed. |
Definition at line 146 of file SDLTranslator.h.
cmil::SDL::SDLKeyboards::SDLKeyboards | ( | System *const | sys | ) | [inline] |
Definition at line 148 of file SDLTranslator.h.
00148 : 00149 tDeviceTranslator<Keyboard>(sys), 00150 m_keyboard(NULL), 00151 m_keys(SDLK_LAST) {}
virtual cmil::SDL::SDLKeyboards::~SDLKeyboards | ( | ) | [inline, virtual] |
Definition at line 153 of file SDLTranslator.h.
References Logger::log_debug(), and m_keyboard.
00153 { 00154 log_debug("dtor"); 00155 if(m_keyboard) { 00156 log_debug("deleting keyboard"); 00157 delete m_keyboard; 00158 } 00159 };
Here is the call graph for this function:
void cmil::SDL::SDLKeyboards::assign_inputs | ( | ) | [private] |
Definition at line 90 of file SDLTranslator.cpp.
References cmil::InputDevice::getData(), Logger::log_error(), m_keyboard, and setKey().
Referenced by getDevices().
00090 { 00091 if(m_keyboard) { 00093 setKey(SDLK_F1, m_keyboard->getData("F1")); 00094 setKey(SDLK_F2, m_keyboard->getData("F2")); 00095 setKey(SDLK_F3, m_keyboard->getData("F3")); 00096 setKey(SDLK_F4, m_keyboard->getData("F4")); 00097 setKey(SDLK_F5, m_keyboard->getData("F5")); 00098 setKey(SDLK_F6, m_keyboard->getData("F6")); 00099 setKey(SDLK_F7, m_keyboard->getData("F7")); 00100 setKey(SDLK_F8, m_keyboard->getData("F8")); 00101 setKey(SDLK_F9, m_keyboard->getData("F9")); 00102 setKey(SDLK_F10, m_keyboard->getData("F10")); 00103 setKey(SDLK_F11, m_keyboard->getData("F11")); 00104 setKey(SDLK_F12, m_keyboard->getData("F12")); 00105 setKey(SDLK_PRINT, m_keyboard->getData("Print")); 00106 00108 setKey(SDLK_SYSREQ, m_keyboard->getData( "Print")); 00109 00110 setKey(SDLK_SCROLLOCK, m_keyboard->getData("Scroll Lock")); 00111 setKey(SDLK_PAUSE, m_keyboard->getData("Pause")); 00112 00114 setKey(SDLK_1, m_keyboard->getData("1")); 00115 setKey(SDLK_EXCLAIM, m_keyboard->getData("Exclaimation Mark")); 00116 00117 setKey(SDLK_2, m_keyboard->getData("2")); 00118 setKey(SDLK_AT, m_keyboard->getData("@")); 00119 00120 setKey(SDLK_3, m_keyboard->getData("3")); 00121 setKey(SDLK_HASH, m_keyboard->getData("Hash")); 00122 00123 setKey(SDLK_4, m_keyboard->getData("4")); 00124 setKey(SDLK_DOLLAR, m_keyboard->getData("Dollar Sign")); 00125 00126 setKey(SDLK_5, m_keyboard->getData("5")); 00127 00128 setKey(SDLK_6, m_keyboard->getData("6")); 00129 setKey(SDLK_CARET, m_keyboard->getData("Caret")); 00130 00131 setKey(SDLK_7, m_keyboard->getData("7")); 00132 setKey(SDLK_AMPERSAND, m_keyboard->getData("Ampersand")); 00133 00134 setKey(SDLK_8, m_keyboard->getData("8")); 00135 setKey(SDLK_ASTERISK, m_keyboard->getData("Asterisk")); 00136 00137 setKey(SDLK_9, m_keyboard->getData("9")); 00138 setKey(SDLK_LEFTPAREN, m_keyboard->getData("Left Parenthesis")); 00139 00140 setKey(SDLK_0, m_keyboard->getData("0")); 00141 setKey(SDLK_RIGHTPAREN, m_keyboard->getData("Right Parenthesis")); 00142 00143 setKey(SDLK_MINUS, m_keyboard->getData("Minus")); 00144 setKey(SDLK_UNDERSCORE, m_keyboard->getData("Underscore")); 00145 00146 setKey(SDLK_PLUS, m_keyboard->getData("Plus")); 00147 setKey(SDLK_EQUALS, m_keyboard->getData("Equals")); 00148 00149 setKey(SDLK_BACKSPACE, m_keyboard->getData("Backspace")); 00150 00151 setKey(SDLK_q, m_keyboard->getData("Q")); 00152 setKey(SDLK_w, m_keyboard->getData("W")); 00153 setKey(SDLK_e, m_keyboard->getData("E")); 00154 setKey(SDLK_r, m_keyboard->getData("R")); 00155 setKey(SDLK_t, m_keyboard->getData("T")); 00156 setKey(SDLK_y, m_keyboard->getData("Y")); 00157 setKey(SDLK_u, m_keyboard->getData("U")); 00158 setKey(SDLK_i, m_keyboard->getData("I")); 00159 setKey(SDLK_o, m_keyboard->getData("O")); 00160 setKey(SDLK_p, m_keyboard->getData("P")); 00161 setKey(SDLK_a, m_keyboard->getData("A")); 00162 setKey(SDLK_s, m_keyboard->getData("S")); 00163 setKey(SDLK_d, m_keyboard->getData("D")); 00164 setKey(SDLK_f, m_keyboard->getData("F")); 00165 setKey(SDLK_g, m_keyboard->getData("G")); 00166 setKey(SDLK_h, m_keyboard->getData("H")); 00167 setKey(SDLK_j, m_keyboard->getData("J")); 00168 setKey(SDLK_k, m_keyboard->getData("K")); 00169 setKey(SDLK_l, m_keyboard->getData("L")); 00170 setKey(SDLK_z, m_keyboard->getData("Z")); 00171 setKey(SDLK_x, m_keyboard->getData("X")); 00172 setKey(SDLK_c, m_keyboard->getData("C")); 00173 setKey(SDLK_v, m_keyboard->getData("V")); 00174 setKey(SDLK_b, m_keyboard->getData("B")); 00175 setKey(SDLK_n, m_keyboard->getData("N")); 00176 setKey(SDLK_m, m_keyboard->getData("M")); 00177 00179 setKey(SDLK_TAB, m_keyboard->getData("Tab")); 00180 setKey(SDLK_CAPSLOCK, m_keyboard->getData("Capslock")); 00181 00182 setKey(SDLK_LESS, m_keyboard->getData("Less Than")); 00183 setKey(SDLK_COMMA, m_keyboard->getData("Comma")); 00184 setKey(SDLK_GREATER, m_keyboard->getData("Greater Than")); 00185 setKey(SDLK_PERIOD, m_keyboard->getData("Period")); 00186 00189 00192 00193 setKey(SDLK_LSHIFT, m_keyboard->getData("Shift")); 00194 setKey(SDLK_RSHIFT, m_keyboard->getData("Shift")); 00195 00198 00199 setKey(SDLK_LCTRL, m_keyboard->getData("Ctrl")); 00200 setKey(SDLK_RCTRL, m_keyboard->getData("Ctrl")); 00201 00204 00205 setKey(SDLK_LALT, m_keyboard->getData("Alt")); 00206 setKey(SDLK_RALT, m_keyboard->getData("Alt")); 00207 00208 setKey(SDLK_RETURN, m_keyboard->getData("Return")); 00209 setKey(SDLK_SPACE, m_keyboard->getData("Space")); 00210 00211 setKey(SDLK_INSERT, m_keyboard->getData("Insert")); 00212 setKey(SDLK_HOME, m_keyboard->getData("Home")); 00213 setKey(SDLK_PAGEUP, m_keyboard->getData("Page Up")); 00214 setKey(SDLK_DELETE, m_keyboard->getData("Delete")); 00215 setKey(SDLK_END, m_keyboard->getData("End")); 00216 setKey(SDLK_PAGEDOWN, m_keyboard->getData("Page Down")); 00217 00218 setKey(SDLK_LEFT, m_keyboard->getData("Left")); 00219 setKey(SDLK_RIGHT, m_keyboard->getData("Right")); 00220 setKey(SDLK_DOWN, m_keyboard->getData("Down")); 00221 setKey(SDLK_UP, m_keyboard->getData("Up")); 00222 00223 setKey(SDLK_NUMLOCK, m_keyboard->getData("NumLock")); 00224 setKey(SDLK_KP_DIVIDE, m_keyboard->getData("Keypad Forward Slash")); 00225 setKey(SDLK_KP_MULTIPLY, m_keyboard->getData("Keypad Asterisk")); 00226 setKey(SDLK_KP_MINUS, m_keyboard->getData("Keypad Minus ")); 00227 setKey(SDLK_KP_PLUS, m_keyboard->getData("Keypad Plus")); 00228 setKey(SDLK_KP_ENTER, m_keyboard->getData("Keypad Enter")); 00229 00230 setKey(SDLK_KP0, m_keyboard->getData("Keypad Zero")); 00231 00232 setKey(SDLK_KP_PERIOD, m_keyboard->getData("Keypad Period")); 00233 00234 setKey(SDLK_KP1, m_keyboard->getData("Keypad 1")); 00235 setKey(SDLK_KP2, m_keyboard->getData("Keypad 2")); 00236 setKey(SDLK_KP3, m_keyboard->getData("Keypad 3")); 00237 setKey(SDLK_KP4, m_keyboard->getData("Keypad 4")); 00238 setKey(SDLK_KP5, m_keyboard->getData("Keypad 5")); 00239 setKey(SDLK_KP6, m_keyboard->getData("Keypad 6")); 00240 setKey(SDLK_KP7, m_keyboard->getData("Keypad 7")); 00241 setKey(SDLK_KP8, m_keyboard->getData("Keypad 8")); 00242 setKey(SDLK_KP9, m_keyboard->getData("Keypad 9")); 00243 00246 setKey(SDLK_SLASH, m_keyboard->getData("Foward Slash")); 00247 setKey(SDLK_QUESTION, m_keyboard->getData("Question Mark")); 00248 00250 setKey(SDLK_BACKSLASH, m_keyboard->getData("Back Slash")); 00251 setKey(SDLK_RIGHTBRACKET, m_keyboard->getData("Right Bracket")); 00252 setKey(SDLK_LEFTBRACKET, m_keyboard->getData("Left Bracket")); 00253 00255 setKey(SDLK_BACKQUOTE, m_keyboard->getData("Backquote")); 00256 setKey(SDLK_COLON, m_keyboard->getData("Colon")); 00257 setKey(SDLK_SEMICOLON, m_keyboard->getData("Semi Colon")); 00258 setKey(SDLK_QUOTEDBL, m_keyboard->getData("Double Quote")); 00259 setKey(SDLK_QUOTE, m_keyboard->getData("Quote")); 00260 00261 setKey(SDLK_ESCAPE, m_keyboard->getData("Escape")); 00262 } 00263 else 00264 log_error("assign_inputs m_keyboard device is NULL, unable to provide event translation"); 00265 }
Here is the call graph for this function:
Here is the caller graph for this function:
Press* cmil::SDL::SDLKeyboards::getData | ( | SDLKey | key | ) | const [inline] |
This is used for key translation.
Definition at line 165 of file SDLTranslator.h.
References m_keys.
Referenced by translate().
00165 { return m_keys.getData(key); }
Here is the caller graph for this function:
DeviceRegistry & cmil::SDL::SDLKeyboards::getDevices | ( | ) | [virtual] |
This retrieves a registry of devices provided by this translator, for instance, if there were only 1 joystick attached, it should return a registry containing just that joystick.
Implements cmil::SDL::tDeviceTranslator< DeviceBase >.
Definition at line 267 of file SDLTranslator.cpp.
References assign_inputs(), cmil::InputDevice::cleanup(), cmil::DeviceRegistry::clear(), cmil::DeviceRegistry::getSize(), Logger::log_debug(), Logger::log_error(), cmil::SDL::tDeviceTranslator< DeviceBase >::m_custom_devices, m_keyboard, m_registry, and cmil::DeviceRegistry::registerDevice().
00267 { 00270 00271 if(m_registry.getSize()) 00272 m_registry.clear(); 00273 00274 log_debug("getDevices()"); 00275 std::list<Keyboard*>::const_iterator i; 00276 InputDevice* clone = NULL; 00277 00278 DefaultKeyboard default_keyboard; 00279 00280 for(i = m_custom_devices.begin() ; i != m_custom_devices.end(); ++i) { 00281 log_debug ("getDevices() loop iterating..."); 00282 00284 if(*(*i) == default_keyboard) { 00285 clone = ((*i)->clone()); 00286 00287 if(!(m_keyboard = dynamic_cast<Keyboard*>(clone))) { 00288 log_error("getDevices() casting failure of cloned InputDevice"); 00289 delete clone; 00290 } 00291 else { 00292 continue; 00293 } 00294 } 00295 } 00296 00297 if(!m_keyboard) { 00298 log_debug("getDevices() No valid custom device found, using SDL::DefaultKeyboard"); 00299 m_keyboard = new Keyboard(default_keyboard); 00300 } 00301 else 00302 default_keyboard.cleanup(); 00303 00304 assign_inputs(); 00305 00307 m_registry.registerDevice(*m_keyboard); 00308 00309 return m_registry; 00310 }
Here is the call graph for this function:
std::string cmil::SDL::SDLKeyboards::getName | ( | ) | const [inline, virtual] |
Reimplemented from cmil::SDL::tDeviceTranslator< DeviceBase >.
Definition at line 167 of file SDLTranslator.h.
void cmil::SDL::SDLKeyboards::setKey | ( | SDLKey | key, | |
InputData *const | press | |||
) |
This is used for key translation.
Definition at line 81 of file SDLTranslator.cpp.
References Logger::log_error(), and m_keys.
Referenced by assign_inputs().
00081 { 00082 if(input) { 00083 if( !(m_keys.setData((unsigned)key, input)) ) 00084 log_error("setKey( Key ) was unable to assign the input due to improperly setup key index"); 00085 } 00086 else 00087 log_error("setKey( Key ) was unable to assign the input due to NULL parameter "); 00088 }
Here is the call graph for this function:
Here is the caller graph for this function:
bool cmil::SDL::SDLKeyboards::translate | ( | const SDL_Event & | input_event | ) | [virtual] |
This should return a boolean as to whether or not translation was successful.
Implements cmil::SDL::tDeviceTranslator< DeviceBase >.
Definition at line 312 of file SDLTranslator.cpp.
References getData(), Logger::log_error(), cmil::pressed, cmil::released, cmil::ModData::setState(), and cmil::SDL::Relay::UpdateSystem().
00312 { 00313 if((input_event.type == SDL_KEYDOWN) || (input_event.type == SDL_KEYUP)) { 00314 Press* press = getData(input_event.key.keysym.sym); 00315 00316 if(press) { 00317 if( input_event.key.state == SDL_PRESSED) { 00318 press->setState(pressed); 00319 } 00320 else { 00321 press->setState(released); 00322 } 00323 00324 UpdateSystem(*press); 00325 00326 return true; 00327 } 00328 else 00329 log_error("translate( ) unable set NULL press type "); 00330 00331 } 00332 //log_debug("translate() returning false"); 00333 return false; 00334 };
Here is the call graph for this function:
InputDevice* cmil::SDL::SDLKeyboards::m_keyboard [private] |
Definition at line 176 of file SDLTranslator.h.
Referenced by assign_inputs(), getDevices(), and ~SDLKeyboards().
tInputIndex<Press> cmil::SDL::SDLKeyboards::m_keys [private] |