You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

584 lines
16 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2015 The Qt Company Ltd.
  4. ** Contact: http://www.qt.io/licensing/
  5. **
  6. ** This file is part of the Qt Gamepad module
  7. **
  8. ** $QT_BEGIN_LICENSE:LGPL3$
  9. ** Commercial License Usage
  10. ** Licensees holding valid commercial Qt licenses may use this file in
  11. ** accordance with the commercial license agreement provided with the
  12. ** Software or, alternatively, in accordance with the terms contained in
  13. ** a written agreement between you and The Qt Company. For licensing terms
  14. ** and conditions see http://www.qt.io/terms-conditions. For further
  15. ** information use the contact form at http://www.qt.io/contact-us.
  16. **
  17. ** GNU Lesser General Public License Usage
  18. ** Alternatively, this file may be used under the terms of the GNU Lesser
  19. ** General Public License version 3 as published by the Free Software
  20. ** Foundation and appearing in the file LICENSE.LGPLv3 included in the
  21. ** packaging of this file. Please review the following information to
  22. ** ensure the GNU Lesser General Public License version 3 requirements
  23. ** will be met: https://www.gnu.org/licenses/lgpl.html.
  24. **
  25. ** GNU General Public License Usage
  26. ** Alternatively, this file may be used under the terms of the GNU
  27. ** General Public License version 2.0 or later as published by the Free
  28. ** Software Foundation and appearing in the file LICENSE.GPL included in
  29. ** the packaging of this file. Please review the following information to
  30. ** ensure the GNU General Public License version 2.0 requirements will be
  31. ** met: http://www.gnu.org/licenses/gpl-2.0.html.
  32. **
  33. ** $QT_END_LICENSE$
  34. **
  35. ****************************************************************************/
  36. #include "qgamepadkeynavigation.h"
  37. #include <QtGui/QKeyEvent>
  38. #include <QtGui/QGuiApplication>
  39. #include <QtGui/QWindow>
  40. #include <QtGamepad/QGamepad>
  41. #include <private/qobject_p.h>
  42. QT_BEGIN_NAMESPACE
  43. class QGamepadKeyNavigationPrivate : public QObjectPrivate
  44. {
  45. Q_DECLARE_PUBLIC(QGamepadKeyNavigation)
  46. public:
  47. QGamepadKeyNavigationPrivate()
  48. : active(true)
  49. , gamepad(nullptr)
  50. , buttonL2Pressed(false)
  51. , buttonR2Pressed(false)
  52. {
  53. }
  54. void sendGeneratedKeyEvent(QKeyEvent *event);
  55. bool active;
  56. QGamepad *gamepad;
  57. QGamepadManager *gamepadManger;
  58. bool buttonL2Pressed;
  59. bool buttonR2Pressed;
  60. QMap<QGamepadManager::GamepadButton, Qt::Key> keyMapping;
  61. void _q_processGamepadButtonPressEvent(int index, QGamepadManager::GamepadButton button, double value);
  62. void _q_processGamepadButtonReleaseEvent(int index, QGamepadManager::GamepadButton button);
  63. };
  64. void QGamepadKeyNavigationPrivate::sendGeneratedKeyEvent(QKeyEvent *event)
  65. {
  66. if (!active) {
  67. delete event;
  68. return;
  69. }
  70. const QGuiApplication *app = qApp;
  71. QWindow *focusWindow = app ? app->focusWindow() : nullptr;
  72. if (focusWindow)
  73. QGuiApplication::sendEvent(focusWindow, event);
  74. }
  75. void QGamepadKeyNavigationPrivate::_q_processGamepadButtonPressEvent(int index, QGamepadManager::GamepadButton button, double value)
  76. {
  77. Q_UNUSED(value)
  78. //If a gamepad has been set then, only use the events of that gamepad
  79. if (gamepad && gamepad->deviceId() != index)
  80. return;
  81. //Trigger buttons are a special case as they get multiple press events as the value changes
  82. if (button == QGamepadManager::ButtonL2 && buttonL2Pressed)
  83. return;
  84. else
  85. buttonL2Pressed = true;
  86. if (button == QGamepadManager::ButtonR2 && buttonR2Pressed)
  87. return;
  88. else
  89. buttonR2Pressed = true;
  90. QKeyEvent *event = new QKeyEvent(QEvent::KeyPress, keyMapping[button], Qt::NoModifier);
  91. sendGeneratedKeyEvent(event);
  92. }
  93. void QGamepadKeyNavigationPrivate::_q_processGamepadButtonReleaseEvent(int index, QGamepadManager::GamepadButton button)
  94. {
  95. //If a gamepad has been set then, only use the events of that gamepad
  96. if (gamepad && gamepad->deviceId() != index)
  97. return;
  98. //Free the trigger buttons if necessary
  99. if (button == QGamepadManager::ButtonL2)
  100. buttonL2Pressed = false;
  101. if (button == QGamepadManager::ButtonR2)
  102. buttonR2Pressed = false;
  103. QKeyEvent *event = new QKeyEvent(QEvent::KeyRelease, keyMapping[button], Qt::NoModifier);
  104. sendGeneratedKeyEvent(event);
  105. }
  106. /*!
  107. \class QGamepadKeyNavigation
  108. \inmodule QtGamepad
  109. \brief Provides support for keyboard events triggered by gamepads.
  110. QGamepadKeyNavigation provides support for keyboard events triggered by
  111. gamepads.
  112. */
  113. /*!
  114. * Constructs a QGamepadNavigation object with the given \a parent.
  115. */
  116. QGamepadKeyNavigation::QGamepadKeyNavigation(QObject *parent)
  117. : QObject(*new QGamepadKeyNavigationPrivate(), parent)
  118. {
  119. Q_D(QGamepadKeyNavigation);
  120. d->gamepadManger = QGamepadManager::instance();
  121. //Default keymap
  122. d->keyMapping.insert(QGamepadManager::ButtonUp, Qt::Key_Up);
  123. d->keyMapping.insert(QGamepadManager::ButtonDown, Qt::Key_Down);
  124. d->keyMapping.insert(QGamepadManager::ButtonLeft, Qt::Key_Left);
  125. d->keyMapping.insert(QGamepadManager::ButtonRight, Qt::Key_Right);
  126. d->keyMapping.insert(QGamepadManager::ButtonA, Qt::Key_Return);
  127. d->keyMapping.insert(QGamepadManager::ButtonB, Qt::Key_Back);
  128. d->keyMapping.insert(QGamepadManager::ButtonX, Qt::Key_Back);
  129. d->keyMapping.insert(QGamepadManager::ButtonY, Qt::Key_Back);
  130. d->keyMapping.insert(QGamepadManager::ButtonSelect, Qt::Key_Back);
  131. d->keyMapping.insert(QGamepadManager::ButtonStart, Qt::Key_Return);
  132. d->keyMapping.insert(QGamepadManager::ButtonGuide, Qt::Key_Back);
  133. d->keyMapping.insert(QGamepadManager::ButtonL1, Qt::Key_Back);
  134. d->keyMapping.insert(QGamepadManager::ButtonR1, Qt::Key_Forward);
  135. d->keyMapping.insert(QGamepadManager::ButtonL2, Qt::Key_Back);
  136. d->keyMapping.insert(QGamepadManager::ButtonR2, Qt::Key_Forward);
  137. d->keyMapping.insert(QGamepadManager::ButtonL3, Qt::Key_Back);
  138. d->keyMapping.insert(QGamepadManager::ButtonR3, Qt::Key_Forward);
  139. connect(d->gamepadManger, SIGNAL(gamepadButtonPressEvent(int,QGamepadManager::GamepadButton,double)),
  140. this, SLOT(_q_processGamepadButtonPressEvent(int,QGamepadManager::GamepadButton,double)));
  141. connect(d->gamepadManger, SIGNAL(gamepadButtonReleaseEvent(int,QGamepadManager::GamepadButton)),
  142. this, SLOT(_q_processGamepadButtonReleaseEvent(int,QGamepadManager::GamepadButton)));
  143. }
  144. /*!
  145. * Returns whether key navigation on the gamepad is active or not.
  146. */
  147. bool QGamepadKeyNavigation::active() const
  148. {
  149. Q_D(const QGamepadKeyNavigation);
  150. return d->active;
  151. }
  152. /*!
  153. * Returns a pointer the current QGamepad
  154. */
  155. QGamepad *QGamepadKeyNavigation::gamepad() const
  156. {
  157. Q_D(const QGamepadKeyNavigation);
  158. return d->gamepad;
  159. }
  160. /*!
  161. * Returns the key mapping of the Up button.
  162. */
  163. Qt::Key QGamepadKeyNavigation::upKey() const
  164. {
  165. Q_D(const QGamepadKeyNavigation);
  166. return d->keyMapping[QGamepadManager::ButtonUp];
  167. }
  168. /*!
  169. * Returns the key mapping of the Down button.
  170. */
  171. Qt::Key QGamepadKeyNavigation::downKey() const
  172. {
  173. Q_D(const QGamepadKeyNavigation);
  174. return d->keyMapping[QGamepadManager::ButtonDown];
  175. }
  176. /*!
  177. * Returns the key mapping of the Left button.
  178. */
  179. Qt::Key QGamepadKeyNavigation::leftKey() const
  180. {
  181. Q_D(const QGamepadKeyNavigation);
  182. return d->keyMapping[QGamepadManager::ButtonLeft];
  183. }
  184. /*!
  185. * Returns the key mapping of the Right button.
  186. */
  187. Qt::Key QGamepadKeyNavigation::rightKey() const
  188. {
  189. Q_D(const QGamepadKeyNavigation);
  190. return d->keyMapping[QGamepadManager::ButtonRight];
  191. }
  192. /*!
  193. * Returns the key mapping of A button.
  194. */
  195. Qt::Key QGamepadKeyNavigation::buttonAKey() const
  196. {
  197. Q_D(const QGamepadKeyNavigation);
  198. return d->keyMapping[QGamepadManager::ButtonA];
  199. }
  200. /*!
  201. * Returns the key mapping of the B button.
  202. */
  203. Qt::Key QGamepadKeyNavigation::buttonBKey() const
  204. {
  205. Q_D(const QGamepadKeyNavigation);
  206. return d->keyMapping[QGamepadManager::ButtonB];
  207. }
  208. /*!
  209. * Returns the key mapping of the X button.
  210. */
  211. Qt::Key QGamepadKeyNavigation::buttonXKey() const
  212. {
  213. Q_D(const QGamepadKeyNavigation);
  214. return d->keyMapping[QGamepadManager::ButtonX];
  215. }
  216. /*!
  217. * Returns the key mapping of the Y button.
  218. */
  219. Qt::Key QGamepadKeyNavigation::buttonYKey() const
  220. {
  221. Q_D(const QGamepadKeyNavigation);
  222. return d->keyMapping[QGamepadManager::ButtonY];
  223. }
  224. /*!
  225. * Returns the key mapping of the Select button.
  226. */
  227. Qt::Key QGamepadKeyNavigation::buttonSelectKey() const
  228. {
  229. Q_D(const QGamepadKeyNavigation);
  230. return d->keyMapping[QGamepadManager::ButtonSelect];
  231. }
  232. /*!
  233. * Returns the key mapping of the Start button.
  234. */
  235. Qt::Key QGamepadKeyNavigation::buttonStartKey() const
  236. {
  237. Q_D(const QGamepadKeyNavigation);
  238. return d->keyMapping[QGamepadManager::ButtonStart];
  239. }
  240. /*!
  241. * Returns the key mapping of the Guide button.
  242. */
  243. Qt::Key QGamepadKeyNavigation::buttonGuideKey() const
  244. {
  245. Q_D(const QGamepadKeyNavigation);
  246. return d->keyMapping[QGamepadManager::ButtonGuide];
  247. }
  248. /*!
  249. * Returns the key mapping of the left shoulder button.
  250. */
  251. Qt::Key QGamepadKeyNavigation::buttonL1Key() const
  252. {
  253. Q_D(const QGamepadKeyNavigation);
  254. return d->keyMapping[QGamepadManager::ButtonL1];
  255. }
  256. /*!
  257. * Returns the key mapping of the Right shoulder button.
  258. */
  259. Qt::Key QGamepadKeyNavigation::buttonR1Key() const
  260. {
  261. Q_D(const QGamepadKeyNavigation);
  262. return d->keyMapping[QGamepadManager::ButtonL2];
  263. }
  264. /*!
  265. * Returns the key mapping of the left trigger button.
  266. */
  267. Qt::Key QGamepadKeyNavigation::buttonL2Key() const
  268. {
  269. Q_D(const QGamepadKeyNavigation);
  270. return d->keyMapping[QGamepadManager::ButtonL2];
  271. }
  272. /*!
  273. * Returns the key mapping of the Right trigger button.
  274. */
  275. Qt::Key QGamepadKeyNavigation::buttonR2Key() const
  276. {
  277. Q_D(const QGamepadKeyNavigation);
  278. return d->keyMapping[QGamepadManager::ButtonL2];
  279. }
  280. /*!
  281. * Returns the key mapping of the left stick button.
  282. */
  283. Qt::Key QGamepadKeyNavigation::buttonL3Key() const
  284. {
  285. Q_D(const QGamepadKeyNavigation);
  286. return d->keyMapping[QGamepadManager::ButtonL3];
  287. }
  288. /*!
  289. * Returns the key mapping of the right stick button.
  290. */
  291. Qt::Key QGamepadKeyNavigation::buttonR3Key() const
  292. {
  293. Q_D(const QGamepadKeyNavigation);
  294. return d->keyMapping[QGamepadManager::ButtonL3];
  295. }
  296. /*!
  297. * Activates key navigation if \a isActive is true,
  298. * disables it otherwise.
  299. */
  300. void QGamepadKeyNavigation::setActive(bool isActive)
  301. {
  302. Q_D(QGamepadKeyNavigation);
  303. if (d->active != isActive) {
  304. d->active = isActive;
  305. emit activeChanged(isActive);
  306. }
  307. }
  308. /*!
  309. * Selects the specified \a gamepad.
  310. */
  311. void QGamepadKeyNavigation::setGamepad(QGamepad *gamepad)
  312. {
  313. Q_D(QGamepadKeyNavigation);
  314. if (d->gamepad != gamepad) {
  315. d->gamepad = gamepad;
  316. emit gamepadChanged(gamepad);
  317. }
  318. }
  319. /*!
  320. * Sets the mapping of the Up button with the
  321. * keycode specified in \a key.
  322. */
  323. void QGamepadKeyNavigation::setUpKey(Qt::Key key)
  324. {
  325. Q_D(QGamepadKeyNavigation);
  326. if (d->keyMapping[QGamepadManager::ButtonUp] != key) {
  327. d->keyMapping[QGamepadManager::ButtonUp] = key;
  328. emit upKeyChanged(key);
  329. }
  330. }
  331. /*!
  332. * Sets the mapping of the Down button with the
  333. * keycode specified in \a key.
  334. */
  335. void QGamepadKeyNavigation::setDownKey(Qt::Key key)
  336. {
  337. Q_D(QGamepadKeyNavigation);
  338. if (d->keyMapping[QGamepadManager::ButtonDown] != key) {
  339. d->keyMapping[QGamepadManager::ButtonDown] = key;
  340. emit downKeyChanged(key);
  341. }
  342. }
  343. /*!
  344. * Sets the mapping of the Left button with the
  345. * keycode specified in \a key.
  346. */
  347. void QGamepadKeyNavigation::setLeftKey(Qt::Key key)
  348. {
  349. Q_D(QGamepadKeyNavigation);
  350. if (d->keyMapping[QGamepadManager::ButtonLeft] != key) {
  351. d->keyMapping[QGamepadManager::ButtonLeft] = key;
  352. emit leftKeyChanged(key);
  353. }
  354. }
  355. /*!
  356. * Sets the mapping of the Right button with the
  357. * keycode specified in \a key.
  358. */
  359. void QGamepadKeyNavigation::setRightKey(Qt::Key key)
  360. {
  361. Q_D(QGamepadKeyNavigation);
  362. if (d->keyMapping[QGamepadManager::ButtonRight] != key) {
  363. d->keyMapping[QGamepadManager::ButtonRight] = key;
  364. emit rightKeyChanged(key);
  365. }
  366. }
  367. /*!
  368. * Sets the mapping of the A button with the keycode
  369. * specified in \a key.
  370. */
  371. void QGamepadKeyNavigation::setButtonAKey(Qt::Key key)
  372. {
  373. Q_D(QGamepadKeyNavigation);
  374. if (d->keyMapping[QGamepadManager::ButtonA] != key) {
  375. d->keyMapping[QGamepadManager::ButtonA] = key;
  376. emit buttonAKeyChanged(key);
  377. }
  378. }
  379. /*!
  380. * Sets the mapping of the B button with the keycode
  381. * specified in \a key.
  382. */
  383. void QGamepadKeyNavigation::setButtonBKey(Qt::Key key)
  384. {
  385. Q_D(QGamepadKeyNavigation);
  386. if (d->keyMapping[QGamepadManager::ButtonB] != key) {
  387. d->keyMapping[QGamepadManager::ButtonB] = key;
  388. emit buttonBKeyChanged(key);
  389. }
  390. }
  391. /*!
  392. * Sets the mapping of the X button with the
  393. * keycode specified in \a key.
  394. */
  395. void QGamepadKeyNavigation::setButtonXKey(Qt::Key key)
  396. {
  397. Q_D(QGamepadKeyNavigation);
  398. if (d->keyMapping[QGamepadManager::ButtonX] != key) {
  399. d->keyMapping[QGamepadManager::ButtonX] = key;
  400. emit buttonXKeyChanged(key);
  401. }
  402. }
  403. /*!
  404. * Sets the mapping of the Y button with the
  405. * keycode specified in \a key.
  406. */
  407. void QGamepadKeyNavigation::setButtonYKey(Qt::Key key)
  408. {
  409. Q_D(QGamepadKeyNavigation);
  410. if (d->keyMapping[QGamepadManager::ButtonY] != key) {
  411. d->keyMapping[QGamepadManager::ButtonY] = key;
  412. emit buttonYKeyChanged(key);
  413. }
  414. }
  415. /*!
  416. * Sets the mapping of the Select button with the
  417. * keycode specified in \a key.
  418. */
  419. void QGamepadKeyNavigation::setButtonSelectKey(Qt::Key key)
  420. {
  421. Q_D(QGamepadKeyNavigation);
  422. if (d->keyMapping[QGamepadManager::ButtonSelect] != key) {
  423. d->keyMapping[QGamepadManager::ButtonSelect] = key;
  424. emit buttonSelectKeyChanged(key);
  425. }
  426. }
  427. /*!
  428. * Sets the mapping of the Start button with the
  429. * keycode specified in \a key.
  430. */
  431. void QGamepadKeyNavigation::setButtonStartKey(Qt::Key key)
  432. {
  433. Q_D(QGamepadKeyNavigation);
  434. if (d->keyMapping[QGamepadManager::ButtonStart] != key) {
  435. d->keyMapping[QGamepadManager::ButtonStart] = key;
  436. emit buttonStartKeyChanged(key);
  437. }
  438. }
  439. /*!
  440. * Sets the mapping of the Guide button with the keycode
  441. * specified in \a key.
  442. */
  443. void QGamepadKeyNavigation::setButtonGuideKey(Qt::Key key)
  444. {
  445. Q_D(QGamepadKeyNavigation);
  446. if (d->keyMapping[QGamepadManager::ButtonGuide] != key) {
  447. d->keyMapping[QGamepadManager::ButtonGuide] = key;
  448. emit buttonGuideKeyChanged(key);
  449. }
  450. }
  451. /*!
  452. * Sets the mapping of the left shoulder button with the
  453. * keycode specified in \a key.
  454. */
  455. void QGamepadKeyNavigation::setButtonL1Key(Qt::Key key)
  456. {
  457. Q_D(QGamepadKeyNavigation);
  458. if (d->keyMapping[QGamepadManager::ButtonL1] != key) {
  459. d->keyMapping[QGamepadManager::ButtonL1] = key;
  460. emit buttonL1KeyChanged(key);
  461. }
  462. }
  463. /*!
  464. * Sets the mapping of the right shoulder button with the
  465. * keycode specified in \a key.
  466. */
  467. void QGamepadKeyNavigation::setButtonR1Key(Qt::Key key)
  468. {
  469. Q_D(QGamepadKeyNavigation);
  470. if (d->keyMapping[QGamepadManager::ButtonR1] != key) {
  471. d->keyMapping[QGamepadManager::ButtonR1] = key;
  472. emit buttonR1KeyChanged(key);
  473. }
  474. }
  475. /*!
  476. * Sets the mapping of the left trigger button with the
  477. * keycode specified in \a key.
  478. */
  479. void QGamepadKeyNavigation::setButtonL2Key(Qt::Key key)
  480. {
  481. Q_D(QGamepadKeyNavigation);
  482. if (d->keyMapping[QGamepadManager::ButtonL2] != key) {
  483. d->keyMapping[QGamepadManager::ButtonL2] = key;
  484. emit buttonL1KeyChanged(key);
  485. }
  486. }
  487. /*!
  488. * Sets the mapping of the right trigger button with the
  489. * keycode specified in \a key.
  490. */
  491. void QGamepadKeyNavigation::setButtonR2Key(Qt::Key key)
  492. {
  493. Q_D(QGamepadKeyNavigation);
  494. if (d->keyMapping[QGamepadManager::ButtonR2] != key) {
  495. d->keyMapping[QGamepadManager::ButtonR2] = key;
  496. emit buttonR1KeyChanged(key);
  497. }
  498. }
  499. /*!
  500. * Sets the mapping of the left stick button with the
  501. * keycode specified in \a key.
  502. */
  503. void QGamepadKeyNavigation::setButtonL3Key(Qt::Key key)
  504. {
  505. Q_D(QGamepadKeyNavigation);
  506. if (d->keyMapping[QGamepadManager::ButtonL3] != key) {
  507. d->keyMapping[QGamepadManager::ButtonL3] = key;
  508. emit buttonL1KeyChanged(key);
  509. }
  510. }
  511. /*!
  512. * Sets the mapping of the right stick button with the
  513. * keycode specified in \a key.
  514. */
  515. void QGamepadKeyNavigation::setButtonR3Key(Qt::Key key)
  516. {
  517. Q_D(QGamepadKeyNavigation);
  518. if (d->keyMapping[QGamepadManager::ButtonR3] != key) {
  519. d->keyMapping[QGamepadManager::ButtonR3] = key;
  520. emit buttonR1KeyChanged(key);
  521. }
  522. }
  523. QT_END_NAMESPACE
  524. #include "moc_qgamepadkeynavigation.cpp"