InputSample.cpp 22 KB

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