1 /* Copyright (c) 2013-2015 Jeffrey Pfau
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #include "GamepadButtonEvent.h"
7
8 #include "InputController.h"
9
10 using namespace QGBA;
11
12 QEvent::Type GamepadButtonEvent::s_downType = QEvent::None;
13 QEvent::Type GamepadButtonEvent::s_upType = QEvent::None;
14
GamepadButtonEvent(QEvent::Type pressType,int button,int type,InputController * controller)15 GamepadButtonEvent::GamepadButtonEvent(QEvent::Type pressType, int button, int type, InputController* controller)
16 : QEvent(pressType)
17 , m_button(button)
18 , m_key(GBA_KEY_NONE)
19 {
20 ignore();
21 if (controller) {
22 m_key = static_cast<GBAKey>(mInputMapKey(controller->map(), type, button));
23 }
24 }
25
Down()26 QEvent::Type GamepadButtonEvent::Down() {
27 if (s_downType == None) {
28 s_downType = static_cast<Type>(registerEventType());
29 }
30 return s_downType;
31 }
32
Up()33 QEvent::Type GamepadButtonEvent::Up() {
34 if (s_upType == None) {
35 s_upType = static_cast<Type>(registerEventType());
36 }
37 return s_upType;
38 }
39