InputSample.cpp 22 KB

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