InputSample.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736
  1. #include "InputSample.h"
  2. #include "SamplesGame.h"
  3. #if defined(ADD_SAMPLE)
  4. ADD_SAMPLE("Input", "Basic Input", InputSample, 1);
  5. #endif
  6. /**
  7. * Returns the string representation of the given key.
  8. */
  9. static const char* keyString(int key);
  10. InputSample::InputSample()
  11. : _mouseString("No Mouse"), _font(NULL), _inputSampleControls(NULL), _mouseWheel(0), _crosshair(NULL),
  12. _scene(NULL), _formNode(NULL), _formNodeParent(NULL)
  13. {
  14. }
  15. void InputSample::initialize()
  16. {
  17. setMultiTouch(true);
  18. // Load font
  19. _font = Font::create("res/ui/arial.gpb");
  20. assert(_font);
  21. // Reuse part of the gamepad texture as the crosshair in this sample.
  22. _crosshair = SpriteBatch::create("res/png/gamepad.png");
  23. _crosshairDstRect.set(0, 0, 256, 256);
  24. _crosshairSrcRect.set(256, 0, 256, 256);
  25. _crosshairLowerLimit.set(-_crosshairSrcRect.width / 2.0f, -_crosshairSrcRect.height / 2.0f);
  26. _crosshairUpperLimit.set((float)getWidth(), (float)getHeight());
  27. _crosshairUpperLimit += _crosshairLowerLimit;
  28. // Create input sample controls
  29. _keyboardState = false;
  30. _inputSampleControls = Form::create("res/common/inputs.form");
  31. static_cast<Button*>(_inputSampleControls->getControl("showKeyboardButton"))->addListener(this, Listener::CLICK);
  32. static_cast<Button*>(_inputSampleControls->getControl("captureMouseButton"))->addListener(this, Listener::CLICK);
  33. if (!hasMouse())
  34. {
  35. static_cast<Button*>(_inputSampleControls->getControl("captureMouseButton"))->setVisible(false);
  36. }
  37. _inputSampleControls->getControl("restoreMouseLabel")->setVisible(false);
  38. _mousePoint.set(-100, -100);
  39. // Create a 3D form that responds to raw sensor inputs.
  40. // For this, we will need a scene with a camera node.
  41. Camera* camera = Camera::createPerspective(45.0f, (float)getWidth() / (float)getHeight(), 0.25f, 100.0f);
  42. _scene = Scene::create();
  43. Node* cameraNode = _scene->addNode("Camera");
  44. cameraNode->setCamera(camera);
  45. _scene->setActiveCamera(camera);
  46. SAFE_RELEASE(camera);
  47. _formNodeParent = _scene->addNode("FormParent");
  48. _formNode = Node::create("Form");
  49. _formNodeParent->addChild(_formNode);
  50. Theme* theme = _inputSampleControls->getTheme();
  51. Form* form = Form::create("testForm", theme->getStyle("basicContainer"), Layout::LAYOUT_ABSOLUTE);
  52. form->setSize(225, 100);
  53. Label* label = Label::create("sensorLabel", theme->getStyle("iconNoBorder"));
  54. label->setPosition(25, 15);
  55. label->setSize(175, 50);
  56. label->setText("Raw sensor response (accel/gyro)");
  57. form->addControl(label);
  58. label->release();
  59. _formNode->setScale(0.0015f, 0.0015f, 1.0f);
  60. _formNodeRestPosition.set(0, 0, -1.5f);
  61. _formNodeParent->setTranslation(_formNodeRestPosition);
  62. _formNode->setTranslation(-0.2f, -0.2f, 0);
  63. _formNode->setDrawable(form);
  64. form->release();
  65. }
  66. void InputSample::finalize()
  67. {
  68. setMouseCaptured(false);
  69. if (_keyboardState)
  70. {
  71. displayKeyboard(false);
  72. }
  73. SAFE_RELEASE(_scene);
  74. SAFE_RELEASE(_formNode);
  75. SAFE_RELEASE(_inputSampleControls);
  76. SAFE_DELETE(_crosshair);
  77. SAFE_RELEASE(_font);
  78. }
  79. void InputSample::update(float elapsedTime)
  80. {
  81. if (hasAccelerometer())
  82. {
  83. Vector3 accelRaw, gyroRaw;
  84. getSensorValues(&accelRaw.x, &accelRaw.y, &accelRaw.z, &gyroRaw.x, &gyroRaw.y, &gyroRaw.z);
  85. // Adjust for landscape mode
  86. float temp = accelRaw.x;
  87. accelRaw.x = -accelRaw.y;
  88. accelRaw.y = temp;
  89. temp = gyroRaw.x;
  90. gyroRaw.x = -gyroRaw.y;
  91. gyroRaw.y = temp;
  92. // Respond to raw accelerometer inputs
  93. Vector3 position;
  94. _formNodeParent->getTranslation(&position);
  95. position.smooth(_formNodeRestPosition - accelRaw*0.04f, elapsedTime, 100);
  96. _formNodeParent->setTranslation(position);
  97. // Respond to raw gyroscope inputs
  98. Vector3 rotation;
  99. float angle = _formNodeParent->getRotation(&rotation);
  100. rotation *= angle;
  101. rotation.smooth(gyroRaw*(-0.18f), elapsedTime, 220);
  102. angle = rotation.length();
  103. rotation.normalize();
  104. _formNodeParent->setRotation(rotation, angle);
  105. }
  106. }
  107. void InputSample::render(float elapsedTime)
  108. {
  109. // Clear the color and depth buffers
  110. clear(CLEAR_COLOR_DEPTH, Vector4::zero(), 1.0f, 0);
  111. _inputSampleControls->draw();
  112. // Draw text
  113. unsigned int fontSize = 18;
  114. Vector4 fontColor(1.0f, 1.0f, 1.0f, 1.0f);
  115. unsigned int width, height;
  116. char buffer[50];
  117. _font->start();
  118. if (isMouseCaptured())
  119. {
  120. // Draw crosshair at current offest w.r.t. center of screen
  121. _crosshair->start();
  122. _crosshair->draw(_crosshairDstRect, _crosshairSrcRect);
  123. _crosshair->finish();
  124. }
  125. else
  126. {
  127. for (std::list<TouchPoint>::const_iterator it = _touchPoints.begin(); it != _touchPoints.end(); ++it)
  128. {
  129. sprintf(buffer, "T_%u(%d,%d)", it->_id, (int)it->_coord.x, (int)it->_coord.y);
  130. _font->measureText(buffer, fontSize, &width, &height);
  131. int x = it->_coord.x - (int)(width>>1);
  132. int y = it->_coord.y - (int)(height>>1);
  133. _font->drawText(buffer, x, y, fontColor, fontSize);
  134. }
  135. // Mouse
  136. sprintf(buffer, "M(%d,%d)", (int)_mousePoint.x, (int)_mousePoint.y);
  137. _font->measureText(buffer, fontSize, &width, &height);
  138. int x = _mousePoint.x - (int)(width>>1);
  139. int y = _mousePoint.y - (int)(height>>1);
  140. _font->drawText(buffer, x, y, fontColor, fontSize);
  141. if (!_keyboardState && _mouseString.length() > 0)
  142. {
  143. int y = getHeight() - fontSize;
  144. _font->drawText(_mouseString.c_str(), 0, y, fontColor, fontSize);
  145. }
  146. if (_mouseWheel)
  147. {
  148. sprintf(buffer, "%d", _mouseWheel);
  149. _font->measureText(buffer, fontSize, &width, &height);
  150. int x = _mouseWheelPoint.x - (int)(width>>1);
  151. int y = _mouseWheelPoint.y + 4;
  152. _font->drawText(buffer, x, y, fontColor, fontSize);
  153. }
  154. }
  155. // Pressed keys
  156. if (_keyboardString.length() > 0)
  157. {
  158. _font->drawText(_keyboardString.c_str(), 0, 0, fontColor, fontSize);
  159. }
  160. // Printable symbols typed
  161. if (_symbolsString.length() > 0)
  162. {
  163. _font->drawText(_symbolsString.c_str(), 0, 18, fontColor, fontSize);
  164. }
  165. // Held keys
  166. if (!_downKeys.empty())
  167. {
  168. std::string displayKeys;
  169. for (std::set<int>::const_iterator i = _downKeys.begin(); i != _downKeys.end(); ++i)
  170. {
  171. const char* str = keyString(*i);
  172. displayKeys.append(str);
  173. }
  174. if (!displayKeys.empty())
  175. {
  176. _font->measureText(displayKeys.c_str(), 18, &width, &height);
  177. int x = Game::getInstance()->getWidth() - width;
  178. int y = 0;
  179. _font->drawText(displayKeys.c_str(), x, y, fontColor, fontSize);
  180. }
  181. }
  182. // Draw the accelerometer values in the bottom right corner.
  183. static float pitch, roll;
  184. static float accelerometerDrawRate = 1000.0f;
  185. accelerometerDrawRate += elapsedTime;
  186. if (accelerometerDrawRate > 100.0f)
  187. {
  188. accelerometerDrawRate = 0.0f;
  189. getAccelerometerValues(&pitch, &roll);
  190. }
  191. if (hasAccelerometer() && !_keyboardState)
  192. {
  193. _formNode->getDrawable()->draw();
  194. sprintf(buffer, "Pitch: %f Roll: %f", pitch, roll);
  195. _font->measureText(buffer, 18, &width, &height);
  196. _font->drawText(buffer, getWidth() - width, getHeight() - height, fontColor, fontSize);
  197. }
  198. _font->finish();
  199. }
  200. bool InputSample::drawScene(Node* node)
  201. {
  202. Drawable* drawable = node->getDrawable();
  203. if (drawable)
  204. drawable->draw();
  205. return true;
  206. }
  207. void InputSample::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
  208. {
  209. TouchPoint* tp = NULL;
  210. // Not optimal, however we expect the list size to be very small (<10)
  211. for (std::list<TouchPoint>::iterator it = _touchPoints.begin(); it != _touchPoints.end(); ++it)
  212. {
  213. if (it->_id == contactIndex)
  214. {
  215. tp = &(*it); // (seems redundant, however due to STD)
  216. break;
  217. }
  218. }
  219. // Add a new touch point if not found above
  220. if (!tp)
  221. {
  222. tp = new TouchPoint();
  223. tp->_id = contactIndex;
  224. _touchPoints.push_back(*tp);
  225. }
  226. // Update the touch point
  227. tp->_coord.x = x;
  228. tp->_coord.y = y;
  229. tp->_isStale = false; // (could be overwritten below)
  230. switch (evt)
  231. {
  232. case Touch::TOUCH_PRESS:
  233. // Purge all stale touch points
  234. for (std::list<TouchPoint>::iterator it = _touchPoints.begin(); it != _touchPoints.end(); )
  235. {
  236. if (it->_isStale)
  237. {
  238. it = _touchPoints.erase(it);
  239. }
  240. else
  241. {
  242. ++it;
  243. }
  244. }
  245. if (x < 30 && y < 30)
  246. {
  247. displayKeyboard(true);
  248. }
  249. break;
  250. case Touch::TOUCH_RELEASE:
  251. // Mark the current touch point as stale
  252. if (tp)
  253. {
  254. tp->_isStale = true;
  255. }
  256. break;
  257. case Touch::TOUCH_MOVE:
  258. break;
  259. };
  260. }
  261. bool InputSample::mouseEvent(Mouse::MouseEvent evt, int x, int y, int wheelDelta)
  262. {
  263. _mousePoint.set(x, y);
  264. _mouseString.clear();
  265. switch (evt)
  266. {
  267. case Mouse::MOUSE_PRESS_LEFT_BUTTON:
  268. _mouseString.append("MOUSE_PRESS_LEFT_BUTTON");
  269. break;
  270. case Mouse::MOUSE_RELEASE_LEFT_BUTTON:
  271. _mouseString.append("MOUSE_RELEASE_LEFT_BUTTON");
  272. break;
  273. case Mouse::MOUSE_PRESS_MIDDLE_BUTTON:
  274. _mouseString.append("MOUSE_PRESS_MIDDLE_BUTTON");
  275. break;
  276. case Mouse::MOUSE_RELEASE_MIDDLE_BUTTON:
  277. _mouseString.append("MOUSE_RELEASE_MIDDLE_BUTTON");
  278. break;
  279. case Mouse::MOUSE_PRESS_RIGHT_BUTTON:
  280. _mouseString.append("MOUSE_PRESS_RIGHT_BUTTON");
  281. break;
  282. case Mouse::MOUSE_RELEASE_RIGHT_BUTTON:
  283. _mouseString.append("MOUSE_RELEASE_RIGHT_BUTTON");
  284. break;
  285. case Mouse::MOUSE_MOVE:
  286. _mouseString.append("MOUSE_MOVE");
  287. if (isMouseCaptured())
  288. {
  289. // Control crosshair from captured mouse
  290. _crosshairDstRect.setPosition(_crosshairDstRect.x + x, _crosshairDstRect.y + y);
  291. // Use screen limits to clamp the crosshair position
  292. Vector2 pos(_crosshairDstRect.x, _crosshairDstRect.y);
  293. pos.clamp(_crosshairLowerLimit, _crosshairUpperLimit);
  294. _crosshairDstRect.setPosition(pos.x, pos.y);
  295. }
  296. break;
  297. case Mouse::MOUSE_WHEEL:
  298. _mouseString.append("MOUSE_WHEEL");
  299. _mouseWheelPoint.x = x;
  300. _mouseWheelPoint.y = y;
  301. _mouseWheel = wheelDelta;
  302. break;
  303. }
  304. return false;
  305. }
  306. void InputSample::keyEvent(Keyboard::KeyEvent evt, int key)
  307. {
  308. switch (evt)
  309. {
  310. case Keyboard::KEY_PRESS:
  311. _keyboardString.clear();
  312. _keyboardString.append(keyString(key));
  313. _keyboardString.append(" pressed");
  314. _downKeys.insert(key);
  315. if (key == Keyboard::KEY_ESCAPE)
  316. {
  317. _symbolsString.clear();
  318. }
  319. if (key == Keyboard::KEY_SPACE && hasMouse())
  320. {
  321. setCaptured(false);
  322. }
  323. break;
  324. case Keyboard::KEY_RELEASE:
  325. _keyboardString.clear();
  326. _keyboardString.append(keyString(key));
  327. _keyboardString.append(" released");
  328. _downKeys.erase(key);
  329. break;
  330. case Keyboard::KEY_CHAR:
  331. if (key == Keyboard::KEY_BACKSPACE)
  332. {
  333. if (_symbolsString.size() > 0)
  334. _symbolsString.resize((_symbolsString.size() - 1));
  335. }
  336. else
  337. {
  338. _symbolsString.append(1, (char)(0xFF & key));
  339. }
  340. break;
  341. };
  342. }
  343. void InputSample::controlEvent(Control* control, EventType evt)
  344. {
  345. if (strcmp(control->getId(), "showKeyboardButton") == 0)
  346. {
  347. _keyboardState = !_keyboardState;
  348. displayKeyboard(_keyboardState);
  349. static_cast<Button*>(_inputSampleControls->getControl("showKeyboardButton"))->setText(_keyboardState ? "Hide virtual keyboard" : "Show virtual keyboard");
  350. }
  351. else if (strcmp(control->getId(), "captureMouseButton") == 0 && hasMouse())
  352. {
  353. setCaptured(true);
  354. }
  355. }
  356. void InputSample::setCaptured(bool captured)
  357. {
  358. setMouseCaptured(captured);
  359. if (!captured || isMouseCaptured())
  360. {
  361. _inputSampleControls->getControl("showKeyboardButton")->setVisible(!captured);
  362. _inputSampleControls->getControl("captureMouseButton")->setVisible(!captured);
  363. _inputSampleControls->getControl("restoreMouseLabel")->setVisible(captured);
  364. }
  365. if (captured)
  366. {
  367. _crosshairDstRect.setPosition(
  368. (float)getWidth()/2.0f + _crosshairLowerLimit.x,
  369. (float)getHeight()/2.0f + _crosshairLowerLimit.y);
  370. }
  371. }
  372. const char* keyString(int key)
  373. {
  374. // This function is helpful for finding collisions in the Keyboard::Key enum.
  375. switch (key)
  376. {
  377. case Keyboard::KEY_NONE:
  378. return "NONE";
  379. case Keyboard::KEY_PAUSE:
  380. return "PAUSE";
  381. case Keyboard::KEY_SCROLL_LOCK:
  382. return "SCROLL_LOCK";
  383. case Keyboard::KEY_PRINT:
  384. return "PRINT";
  385. case Keyboard::KEY_SYSREQ:
  386. return "SYSREQ";
  387. case Keyboard::KEY_BREAK:
  388. return "BREAK";
  389. case Keyboard::KEY_ESCAPE:
  390. return "ESCAPE";
  391. case Keyboard::KEY_BACKSPACE:
  392. return "BACKSPACE";
  393. case Keyboard::KEY_TAB:
  394. return "TAB";
  395. case Keyboard::KEY_BACK_TAB:
  396. return "BACK_TAB";
  397. case Keyboard::KEY_RETURN:
  398. return "RETURN";
  399. case Keyboard::KEY_CAPS_LOCK:
  400. return "CAPS_LOCK";
  401. case Keyboard::KEY_SHIFT:
  402. return "SHIFT";
  403. case Keyboard::KEY_CTRL:
  404. return "CTRL";
  405. case Keyboard::KEY_ALT:
  406. return "ALT";
  407. case Keyboard::KEY_MENU:
  408. return "MENU";
  409. case Keyboard::KEY_HYPER:
  410. return "HYPER";
  411. case Keyboard::KEY_INSERT:
  412. return "INSERT";
  413. case Keyboard::KEY_HOME:
  414. return "HOME";
  415. case Keyboard::KEY_PG_UP:
  416. return "PG_UP";
  417. case Keyboard::KEY_DELETE:
  418. return "DELETE";
  419. case Keyboard::KEY_END:
  420. return "END";
  421. case Keyboard::KEY_PG_DOWN:
  422. return "PG_DOWN";
  423. case Keyboard::KEY_LEFT_ARROW:
  424. return "LEFT_ARROW";
  425. case Keyboard::KEY_RIGHT_ARROW:
  426. return "RIGHT_ARROW";
  427. case Keyboard::KEY_UP_ARROW:
  428. return "UP_ARROW";
  429. case Keyboard::KEY_DOWN_ARROW:
  430. return "DOWN_ARROW";
  431. case Keyboard::KEY_NUM_LOCK:
  432. return "NUM_LOCK";
  433. case Keyboard::KEY_KP_PLUS:
  434. return "KP_PLUS";
  435. case Keyboard::KEY_KP_MINUS:
  436. return "KP_MINUS";
  437. case Keyboard::KEY_KP_MULTIPLY:
  438. return "KP_MULTIPLY";
  439. case Keyboard::KEY_KP_DIVIDE:
  440. return "KP_DIVIDE";
  441. case Keyboard::KEY_KP_ENTER:
  442. return "KP_ENTER";
  443. case Keyboard::KEY_KP_HOME:
  444. return "KP_HOME";
  445. case Keyboard::KEY_KP_UP:
  446. return "KP_UP";
  447. case Keyboard::KEY_KP_PG_UP:
  448. return "KP_PG_UP";
  449. case Keyboard::KEY_KP_LEFT:
  450. return "KP_LEFT";
  451. case Keyboard::KEY_KP_FIVE:
  452. return "KP_FIVE";
  453. case Keyboard::KEY_KP_RIGHT:
  454. return "KP_RIGHT";
  455. case Keyboard::KEY_KP_END:
  456. return "KP_END";
  457. case Keyboard::KEY_KP_DOWN:
  458. return "KP_DOWN";
  459. case Keyboard::KEY_KP_PG_DOWN:
  460. return "KP_PG_DOWN";
  461. case Keyboard::KEY_KP_INSERT:
  462. return "KP_INSERT";
  463. case Keyboard::KEY_KP_DELETE:
  464. return "KP_DELETE";
  465. case Keyboard::KEY_F1:
  466. return "F1";
  467. case Keyboard::KEY_F2:
  468. return "F2";
  469. case Keyboard::KEY_F3:
  470. return "F3";
  471. case Keyboard::KEY_F4:
  472. return "F4";
  473. case Keyboard::KEY_F5:
  474. return "F5";
  475. case Keyboard::KEY_F6:
  476. return "F6";
  477. case Keyboard::KEY_F7:
  478. return "F7";
  479. case Keyboard::KEY_F8:
  480. return "F8";
  481. case Keyboard::KEY_F9:
  482. return "F9";
  483. case Keyboard::KEY_F10:
  484. return "F10";
  485. case Keyboard::KEY_F11:
  486. return "F11";
  487. case Keyboard::KEY_F12:
  488. return "F12";
  489. case Keyboard::KEY_SPACE:
  490. return "SPACE";
  491. case Keyboard::KEY_EXCLAM:
  492. return "!";
  493. case Keyboard::KEY_QUOTE:
  494. return "\"";
  495. case Keyboard::KEY_NUMBER:
  496. return "#";
  497. case Keyboard::KEY_DOLLAR:
  498. return "$";
  499. case Keyboard::KEY_PERCENT:
  500. return "%";
  501. case Keyboard::KEY_CIRCUMFLEX:
  502. return "^";
  503. case Keyboard::KEY_AMPERSAND:
  504. return "&";
  505. case Keyboard::KEY_APOSTROPHE:
  506. return "'";
  507. case Keyboard::KEY_LEFT_PARENTHESIS:
  508. return "(";
  509. case Keyboard::KEY_RIGHT_PARENTHESIS:
  510. return ")";
  511. case Keyboard::KEY_ASTERISK:
  512. return "*";
  513. case Keyboard::KEY_PLUS:
  514. return "+";
  515. case Keyboard::KEY_COMMA:
  516. return ",";
  517. case Keyboard::KEY_MINUS:
  518. return "-";
  519. case Keyboard::KEY_PERIOD:
  520. return ".";
  521. case Keyboard::KEY_SLASH:
  522. return "/";
  523. case Keyboard::KEY_ZERO:
  524. return "0";
  525. case Keyboard::KEY_ONE:
  526. return "1";
  527. case Keyboard::KEY_TWO:
  528. return "2";
  529. case Keyboard::KEY_THREE:
  530. return "3";
  531. case Keyboard::KEY_FOUR:
  532. return "4";
  533. case Keyboard::KEY_FIVE:
  534. return "5";
  535. case Keyboard::KEY_SIX:
  536. return "6";
  537. case Keyboard::KEY_SEVEN:
  538. return "7";
  539. case Keyboard::KEY_EIGHT:
  540. return "8";
  541. case Keyboard::KEY_NINE:
  542. return "9";
  543. case Keyboard::KEY_COLON:
  544. return ":";
  545. case Keyboard::KEY_SEMICOLON:
  546. return ";";
  547. case Keyboard::KEY_LESS_THAN:
  548. return "<";
  549. case Keyboard::KEY_EQUAL:
  550. return "=";
  551. case Keyboard::KEY_GREATER_THAN:
  552. return ">";
  553. case Keyboard::KEY_QUESTION:
  554. return "?";
  555. case Keyboard::KEY_AT:
  556. return "@";
  557. case Keyboard::KEY_CAPITAL_A:
  558. return "A";
  559. case Keyboard::KEY_CAPITAL_B:
  560. return "B";
  561. case Keyboard::KEY_CAPITAL_C:
  562. return "C";
  563. case Keyboard::KEY_CAPITAL_D:
  564. return "D";
  565. case Keyboard::KEY_CAPITAL_E:
  566. return "E";
  567. case Keyboard::KEY_CAPITAL_F:
  568. return "F";
  569. case Keyboard::KEY_CAPITAL_G:
  570. return "G";
  571. case Keyboard::KEY_CAPITAL_H:
  572. return "H";
  573. case Keyboard::KEY_CAPITAL_I:
  574. return "I";
  575. case Keyboard::KEY_CAPITAL_J:
  576. return "J";
  577. case Keyboard::KEY_CAPITAL_K:
  578. return "K";
  579. case Keyboard::KEY_CAPITAL_L:
  580. return "L";
  581. case Keyboard::KEY_CAPITAL_M:
  582. return "M";
  583. case Keyboard::KEY_CAPITAL_N:
  584. return "N";
  585. case Keyboard::KEY_CAPITAL_O:
  586. return "O";
  587. case Keyboard::KEY_CAPITAL_P:
  588. return "P";
  589. case Keyboard::KEY_CAPITAL_Q:
  590. return "Q";
  591. case Keyboard::KEY_CAPITAL_R:
  592. return "R";
  593. case Keyboard::KEY_CAPITAL_S:
  594. return "S";
  595. case Keyboard::KEY_CAPITAL_T:
  596. return "T";
  597. case Keyboard::KEY_CAPITAL_U:
  598. return "U";
  599. case Keyboard::KEY_CAPITAL_V:
  600. return "V";
  601. case Keyboard::KEY_CAPITAL_W:
  602. return "W";
  603. case Keyboard::KEY_CAPITAL_X:
  604. return "X";
  605. case Keyboard::KEY_CAPITAL_Y:
  606. return "Y";
  607. case Keyboard::KEY_CAPITAL_Z:
  608. return "Z";
  609. case Keyboard::KEY_LEFT_BRACKET:
  610. return "[";
  611. case Keyboard::KEY_BACK_SLASH:
  612. return "\\";
  613. case Keyboard::KEY_RIGHT_BRACKET:
  614. return "]";
  615. case Keyboard::KEY_UNDERSCORE:
  616. return "_";
  617. case Keyboard::KEY_GRAVE:
  618. return "`";
  619. case Keyboard::KEY_A:
  620. return "a";
  621. case Keyboard::KEY_B:
  622. return "b";
  623. case Keyboard::KEY_C:
  624. return "c";
  625. case Keyboard::KEY_D:
  626. return "d";
  627. case Keyboard::KEY_E:
  628. return "e";
  629. case Keyboard::KEY_F:
  630. return "f";
  631. case Keyboard::KEY_G:
  632. return "g";
  633. case Keyboard::KEY_H:
  634. return "h";
  635. case Keyboard::KEY_I:
  636. return "i";
  637. case Keyboard::KEY_J:
  638. return "j";
  639. case Keyboard::KEY_K:
  640. return "k";
  641. case Keyboard::KEY_L:
  642. return "l";
  643. case Keyboard::KEY_M:
  644. return "m";
  645. case Keyboard::KEY_N:
  646. return "n";
  647. case Keyboard::KEY_O:
  648. return "o";
  649. case Keyboard::KEY_P:
  650. return "p";
  651. case Keyboard::KEY_Q:
  652. return "q";
  653. case Keyboard::KEY_R:
  654. return "r";
  655. case Keyboard::KEY_S:
  656. return "s";
  657. case Keyboard::KEY_T:
  658. return "t";
  659. case Keyboard::KEY_U:
  660. return "u";
  661. case Keyboard::KEY_V:
  662. return "v";
  663. case Keyboard::KEY_W:
  664. return "w";
  665. case Keyboard::KEY_X:
  666. return "x";
  667. case Keyboard::KEY_Y:
  668. return "y";
  669. case Keyboard::KEY_Z:
  670. return "z";
  671. case Keyboard::KEY_LEFT_BRACE:
  672. return "{";
  673. case Keyboard::KEY_BAR:
  674. return "|";
  675. case Keyboard::KEY_RIGHT_BRACE:
  676. return "}";
  677. case Keyboard::KEY_TILDE:
  678. return "~";
  679. case Keyboard::KEY_EURO:
  680. return "EURO";
  681. case Keyboard::KEY_POUND:
  682. return "POUND";
  683. case Keyboard::KEY_YEN:
  684. return "YEN";
  685. case Keyboard::KEY_MIDDLE_DOT:
  686. return "MIDDLE DOT";
  687. case Keyboard::KEY_SEARCH:
  688. return "SEARCH";
  689. default:
  690. return "";
  691. };
  692. return "";
  693. }