InputSample.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739
  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->setForm(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->getForm()->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. // If the node visited contains a model, draw it
  203. Model* model = node->getModel();
  204. if (model)
  205. {
  206. model->draw();
  207. }
  208. return true;
  209. }
  210. void InputSample::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
  211. {
  212. TouchPoint* tp = NULL;
  213. // Not optimal, however we expect the list size to be very small (<10)
  214. for (std::list<TouchPoint>::iterator it = _touchPoints.begin(); it != _touchPoints.end(); ++it)
  215. {
  216. if (it->_id == contactIndex)
  217. {
  218. tp = &(*it); // (seems redundant, however due to STD)
  219. break;
  220. }
  221. }
  222. // Add a new touch point if not found above
  223. if (!tp)
  224. {
  225. tp = new TouchPoint();
  226. tp->_id = contactIndex;
  227. _touchPoints.push_back(*tp);
  228. }
  229. // Update the touch point
  230. tp->_coord.x = x;
  231. tp->_coord.y = y;
  232. tp->_isStale = false; // (could be overwritten below)
  233. switch (evt)
  234. {
  235. case Touch::TOUCH_PRESS:
  236. // Purge all stale touch points
  237. for (std::list<TouchPoint>::iterator it = _touchPoints.begin(); it != _touchPoints.end(); )
  238. {
  239. if (it->_isStale)
  240. {
  241. it = _touchPoints.erase(it);
  242. }
  243. else
  244. {
  245. ++it;
  246. }
  247. }
  248. if (x < 30 && y < 30)
  249. {
  250. displayKeyboard(true);
  251. }
  252. break;
  253. case Touch::TOUCH_RELEASE:
  254. // Mark the current touch point as stale
  255. if (tp)
  256. {
  257. tp->_isStale = true;
  258. }
  259. break;
  260. case Touch::TOUCH_MOVE:
  261. break;
  262. };
  263. }
  264. bool InputSample::mouseEvent(Mouse::MouseEvent evt, int x, int y, int wheelDelta)
  265. {
  266. _mousePoint.set(x, y);
  267. _mouseString.clear();
  268. switch (evt)
  269. {
  270. case Mouse::MOUSE_PRESS_LEFT_BUTTON:
  271. _mouseString.append("MOUSE_PRESS_LEFT_BUTTON");
  272. break;
  273. case Mouse::MOUSE_RELEASE_LEFT_BUTTON:
  274. _mouseString.append("MOUSE_RELEASE_LEFT_BUTTON");
  275. break;
  276. case Mouse::MOUSE_PRESS_MIDDLE_BUTTON:
  277. _mouseString.append("MOUSE_PRESS_MIDDLE_BUTTON");
  278. break;
  279. case Mouse::MOUSE_RELEASE_MIDDLE_BUTTON:
  280. _mouseString.append("MOUSE_RELEASE_MIDDLE_BUTTON");
  281. break;
  282. case Mouse::MOUSE_PRESS_RIGHT_BUTTON:
  283. _mouseString.append("MOUSE_PRESS_RIGHT_BUTTON");
  284. break;
  285. case Mouse::MOUSE_RELEASE_RIGHT_BUTTON:
  286. _mouseString.append("MOUSE_RELEASE_RIGHT_BUTTON");
  287. break;
  288. case Mouse::MOUSE_MOVE:
  289. _mouseString.append("MOUSE_MOVE");
  290. if (isMouseCaptured())
  291. {
  292. // Control crosshair from captured mouse
  293. _crosshairDstRect.setPosition(_crosshairDstRect.x + x, _crosshairDstRect.y + y);
  294. // Use screen limits to clamp the crosshair position
  295. Vector2 pos(_crosshairDstRect.x, _crosshairDstRect.y);
  296. pos.clamp(_crosshairLowerLimit, _crosshairUpperLimit);
  297. _crosshairDstRect.setPosition(pos.x, pos.y);
  298. }
  299. break;
  300. case Mouse::MOUSE_WHEEL:
  301. _mouseString.append("MOUSE_WHEEL");
  302. _mouseWheelPoint.x = x;
  303. _mouseWheelPoint.y = y;
  304. _mouseWheel = wheelDelta;
  305. break;
  306. }
  307. return true;
  308. }
  309. void InputSample::keyEvent(Keyboard::KeyEvent evt, int key)
  310. {
  311. switch (evt)
  312. {
  313. case Keyboard::KEY_PRESS:
  314. _keyboardString.clear();
  315. _keyboardString.append(keyString(key));
  316. _keyboardString.append(" pressed");
  317. _downKeys.insert(key);
  318. if (key == Keyboard::KEY_ESCAPE)
  319. {
  320. _symbolsString.clear();
  321. }
  322. if (key == Keyboard::KEY_SPACE && hasMouse())
  323. {
  324. setCaptured(false);
  325. }
  326. break;
  327. case Keyboard::KEY_RELEASE:
  328. _keyboardString.clear();
  329. _keyboardString.append(keyString(key));
  330. _keyboardString.append(" released");
  331. _downKeys.erase(key);
  332. break;
  333. case Keyboard::KEY_CHAR:
  334. if (key == Keyboard::KEY_BACKSPACE)
  335. {
  336. if (_symbolsString.size() > 0)
  337. _symbolsString.resize((_symbolsString.size() - 1));
  338. }
  339. else
  340. {
  341. _symbolsString.append(1, (char)(0xFF & key));
  342. }
  343. break;
  344. };
  345. }
  346. void InputSample::controlEvent(Control* control, EventType evt)
  347. {
  348. if (strcmp(control->getId(), "showKeyboardButton") == 0)
  349. {
  350. _keyboardState = !_keyboardState;
  351. displayKeyboard(_keyboardState);
  352. static_cast<Button*>(_inputSampleControls->getControl("showKeyboardButton"))->setText(_keyboardState ? "Hide virtual keyboard" : "Show virtual keyboard");
  353. }
  354. else if (strcmp(control->getId(), "captureMouseButton") == 0 && hasMouse())
  355. {
  356. setCaptured(true);
  357. }
  358. }
  359. void InputSample::setCaptured(bool captured)
  360. {
  361. setMouseCaptured(captured);
  362. if (!captured || isMouseCaptured())
  363. {
  364. _inputSampleControls->getControl("showKeyboardButton")->setVisible(!captured);
  365. _inputSampleControls->getControl("captureMouseButton")->setVisible(!captured);
  366. _inputSampleControls->getControl("restoreMouseLabel")->setVisible(captured);
  367. }
  368. if (captured)
  369. {
  370. _crosshairDstRect.setPosition(
  371. (float)getWidth()/2.0f + _crosshairLowerLimit.x,
  372. (float)getHeight()/2.0f + _crosshairLowerLimit.y);
  373. }
  374. }
  375. const char* keyString(int key)
  376. {
  377. // This function is helpful for finding collisions in the Keyboard::Key enum.
  378. switch (key)
  379. {
  380. case Keyboard::KEY_NONE:
  381. return "NONE";
  382. case Keyboard::KEY_PAUSE:
  383. return "PAUSE";
  384. case Keyboard::KEY_SCROLL_LOCK:
  385. return "SCROLL_LOCK";
  386. case Keyboard::KEY_PRINT:
  387. return "PRINT";
  388. case Keyboard::KEY_SYSREQ:
  389. return "SYSREQ";
  390. case Keyboard::KEY_BREAK:
  391. return "BREAK";
  392. case Keyboard::KEY_ESCAPE:
  393. return "ESCAPE";
  394. case Keyboard::KEY_BACKSPACE:
  395. return "BACKSPACE";
  396. case Keyboard::KEY_TAB:
  397. return "TAB";
  398. case Keyboard::KEY_BACK_TAB:
  399. return "BACK_TAB";
  400. case Keyboard::KEY_RETURN:
  401. return "RETURN";
  402. case Keyboard::KEY_CAPS_LOCK:
  403. return "CAPS_LOCK";
  404. case Keyboard::KEY_SHIFT:
  405. return "SHIFT";
  406. case Keyboard::KEY_CTRL:
  407. return "CTRL";
  408. case Keyboard::KEY_ALT:
  409. return "ALT";
  410. case Keyboard::KEY_MENU:
  411. return "MENU";
  412. case Keyboard::KEY_HYPER:
  413. return "HYPER";
  414. case Keyboard::KEY_INSERT:
  415. return "INSERT";
  416. case Keyboard::KEY_HOME:
  417. return "HOME";
  418. case Keyboard::KEY_PG_UP:
  419. return "PG_UP";
  420. case Keyboard::KEY_DELETE:
  421. return "DELETE";
  422. case Keyboard::KEY_END:
  423. return "END";
  424. case Keyboard::KEY_PG_DOWN:
  425. return "PG_DOWN";
  426. case Keyboard::KEY_LEFT_ARROW:
  427. return "LEFT_ARROW";
  428. case Keyboard::KEY_RIGHT_ARROW:
  429. return "RIGHT_ARROW";
  430. case Keyboard::KEY_UP_ARROW:
  431. return "UP_ARROW";
  432. case Keyboard::KEY_DOWN_ARROW:
  433. return "DOWN_ARROW";
  434. case Keyboard::KEY_NUM_LOCK:
  435. return "NUM_LOCK";
  436. case Keyboard::KEY_KP_PLUS:
  437. return "KP_PLUS";
  438. case Keyboard::KEY_KP_MINUS:
  439. return "KP_MINUS";
  440. case Keyboard::KEY_KP_MULTIPLY:
  441. return "KP_MULTIPLY";
  442. case Keyboard::KEY_KP_DIVIDE:
  443. return "KP_DIVIDE";
  444. case Keyboard::KEY_KP_ENTER:
  445. return "KP_ENTER";
  446. case Keyboard::KEY_KP_HOME:
  447. return "KP_HOME";
  448. case Keyboard::KEY_KP_UP:
  449. return "KP_UP";
  450. case Keyboard::KEY_KP_PG_UP:
  451. return "KP_PG_UP";
  452. case Keyboard::KEY_KP_LEFT:
  453. return "KP_LEFT";
  454. case Keyboard::KEY_KP_FIVE:
  455. return "KP_FIVE";
  456. case Keyboard::KEY_KP_RIGHT:
  457. return "KP_RIGHT";
  458. case Keyboard::KEY_KP_END:
  459. return "KP_END";
  460. case Keyboard::KEY_KP_DOWN:
  461. return "KP_DOWN";
  462. case Keyboard::KEY_KP_PG_DOWN:
  463. return "KP_PG_DOWN";
  464. case Keyboard::KEY_KP_INSERT:
  465. return "KP_INSERT";
  466. case Keyboard::KEY_KP_DELETE:
  467. return "KP_DELETE";
  468. case Keyboard::KEY_F1:
  469. return "F1";
  470. case Keyboard::KEY_F2:
  471. return "F2";
  472. case Keyboard::KEY_F3:
  473. return "F3";
  474. case Keyboard::KEY_F4:
  475. return "F4";
  476. case Keyboard::KEY_F5:
  477. return "F5";
  478. case Keyboard::KEY_F6:
  479. return "F6";
  480. case Keyboard::KEY_F7:
  481. return "F7";
  482. case Keyboard::KEY_F8:
  483. return "F8";
  484. case Keyboard::KEY_F9:
  485. return "F9";
  486. case Keyboard::KEY_F10:
  487. return "F10";
  488. case Keyboard::KEY_F11:
  489. return "F11";
  490. case Keyboard::KEY_F12:
  491. return "F12";
  492. case Keyboard::KEY_SPACE:
  493. return "SPACE";
  494. case Keyboard::KEY_EXCLAM:
  495. return "!";
  496. case Keyboard::KEY_QUOTE:
  497. return "\"";
  498. case Keyboard::KEY_NUMBER:
  499. return "#";
  500. case Keyboard::KEY_DOLLAR:
  501. return "$";
  502. case Keyboard::KEY_PERCENT:
  503. return "%";
  504. case Keyboard::KEY_CIRCUMFLEX:
  505. return "^";
  506. case Keyboard::KEY_AMPERSAND:
  507. return "&";
  508. case Keyboard::KEY_APOSTROPHE:
  509. return "'";
  510. case Keyboard::KEY_LEFT_PARENTHESIS:
  511. return "(";
  512. case Keyboard::KEY_RIGHT_PARENTHESIS:
  513. return ")";
  514. case Keyboard::KEY_ASTERISK:
  515. return "*";
  516. case Keyboard::KEY_PLUS:
  517. return "+";
  518. case Keyboard::KEY_COMMA:
  519. return ",";
  520. case Keyboard::KEY_MINUS:
  521. return "-";
  522. case Keyboard::KEY_PERIOD:
  523. return ".";
  524. case Keyboard::KEY_SLASH:
  525. return "/";
  526. case Keyboard::KEY_ZERO:
  527. return "0";
  528. case Keyboard::KEY_ONE:
  529. return "1";
  530. case Keyboard::KEY_TWO:
  531. return "2";
  532. case Keyboard::KEY_THREE:
  533. return "3";
  534. case Keyboard::KEY_FOUR:
  535. return "4";
  536. case Keyboard::KEY_FIVE:
  537. return "5";
  538. case Keyboard::KEY_SIX:
  539. return "6";
  540. case Keyboard::KEY_SEVEN:
  541. return "7";
  542. case Keyboard::KEY_EIGHT:
  543. return "8";
  544. case Keyboard::KEY_NINE:
  545. return "9";
  546. case Keyboard::KEY_COLON:
  547. return ":";
  548. case Keyboard::KEY_SEMICOLON:
  549. return ";";
  550. case Keyboard::KEY_LESS_THAN:
  551. return "<";
  552. case Keyboard::KEY_EQUAL:
  553. return "=";
  554. case Keyboard::KEY_GREATER_THAN:
  555. return ">";
  556. case Keyboard::KEY_QUESTION:
  557. return "?";
  558. case Keyboard::KEY_AT:
  559. return "@";
  560. case Keyboard::KEY_CAPITAL_A:
  561. return "A";
  562. case Keyboard::KEY_CAPITAL_B:
  563. return "B";
  564. case Keyboard::KEY_CAPITAL_C:
  565. return "C";
  566. case Keyboard::KEY_CAPITAL_D:
  567. return "D";
  568. case Keyboard::KEY_CAPITAL_E:
  569. return "E";
  570. case Keyboard::KEY_CAPITAL_F:
  571. return "F";
  572. case Keyboard::KEY_CAPITAL_G:
  573. return "G";
  574. case Keyboard::KEY_CAPITAL_H:
  575. return "H";
  576. case Keyboard::KEY_CAPITAL_I:
  577. return "I";
  578. case Keyboard::KEY_CAPITAL_J:
  579. return "J";
  580. case Keyboard::KEY_CAPITAL_K:
  581. return "K";
  582. case Keyboard::KEY_CAPITAL_L:
  583. return "L";
  584. case Keyboard::KEY_CAPITAL_M:
  585. return "M";
  586. case Keyboard::KEY_CAPITAL_N:
  587. return "N";
  588. case Keyboard::KEY_CAPITAL_O:
  589. return "O";
  590. case Keyboard::KEY_CAPITAL_P:
  591. return "P";
  592. case Keyboard::KEY_CAPITAL_Q:
  593. return "Q";
  594. case Keyboard::KEY_CAPITAL_R:
  595. return "R";
  596. case Keyboard::KEY_CAPITAL_S:
  597. return "S";
  598. case Keyboard::KEY_CAPITAL_T:
  599. return "T";
  600. case Keyboard::KEY_CAPITAL_U:
  601. return "U";
  602. case Keyboard::KEY_CAPITAL_V:
  603. return "V";
  604. case Keyboard::KEY_CAPITAL_W:
  605. return "W";
  606. case Keyboard::KEY_CAPITAL_X:
  607. return "X";
  608. case Keyboard::KEY_CAPITAL_Y:
  609. return "Y";
  610. case Keyboard::KEY_CAPITAL_Z:
  611. return "Z";
  612. case Keyboard::KEY_LEFT_BRACKET:
  613. return "[";
  614. case Keyboard::KEY_BACK_SLASH:
  615. return "\\";
  616. case Keyboard::KEY_RIGHT_BRACKET:
  617. return "]";
  618. case Keyboard::KEY_UNDERSCORE:
  619. return "_";
  620. case Keyboard::KEY_GRAVE:
  621. return "`";
  622. case Keyboard::KEY_A:
  623. return "a";
  624. case Keyboard::KEY_B:
  625. return "b";
  626. case Keyboard::KEY_C:
  627. return "c";
  628. case Keyboard::KEY_D:
  629. return "d";
  630. case Keyboard::KEY_E:
  631. return "e";
  632. case Keyboard::KEY_F:
  633. return "f";
  634. case Keyboard::KEY_G:
  635. return "g";
  636. case Keyboard::KEY_H:
  637. return "h";
  638. case Keyboard::KEY_I:
  639. return "i";
  640. case Keyboard::KEY_J:
  641. return "j";
  642. case Keyboard::KEY_K:
  643. return "k";
  644. case Keyboard::KEY_L:
  645. return "l";
  646. case Keyboard::KEY_M:
  647. return "m";
  648. case Keyboard::KEY_N:
  649. return "n";
  650. case Keyboard::KEY_O:
  651. return "o";
  652. case Keyboard::KEY_P:
  653. return "p";
  654. case Keyboard::KEY_Q:
  655. return "q";
  656. case Keyboard::KEY_R:
  657. return "r";
  658. case Keyboard::KEY_S:
  659. return "s";
  660. case Keyboard::KEY_T:
  661. return "t";
  662. case Keyboard::KEY_U:
  663. return "u";
  664. case Keyboard::KEY_V:
  665. return "v";
  666. case Keyboard::KEY_W:
  667. return "w";
  668. case Keyboard::KEY_X:
  669. return "x";
  670. case Keyboard::KEY_Y:
  671. return "y";
  672. case Keyboard::KEY_Z:
  673. return "z";
  674. case Keyboard::KEY_LEFT_BRACE:
  675. return "{";
  676. case Keyboard::KEY_BAR:
  677. return "|";
  678. case Keyboard::KEY_RIGHT_BRACE:
  679. return "}";
  680. case Keyboard::KEY_TILDE:
  681. return "~";
  682. case Keyboard::KEY_EURO:
  683. return "EURO";
  684. case Keyboard::KEY_POUND:
  685. return "POUND";
  686. case Keyboard::KEY_YEN:
  687. return "YEN";
  688. case Keyboard::KEY_MIDDLE_DOT:
  689. return "MIDDLE DOT";
  690. case Keyboard::KEY_SEARCH:
  691. return "SEARCH";
  692. default:
  693. return "";
  694. };
  695. return "";
  696. }