1 /* Copyright (c) 2013-2017 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 "GamepadHatEvent.h"
7
8 #include "InputController.h"
9
10 using namespace QGBA;
11
12 QEvent::Type GamepadHatEvent::s_downType = QEvent::None;
13 QEvent::Type GamepadHatEvent::s_upType = QEvent::None;
14
GamepadHatEvent(QEvent::Type pressType,int hatId,Direction direction,int type,InputController * controller)15 GamepadHatEvent::GamepadHatEvent(QEvent::Type pressType, int hatId, Direction direction, int type, InputController* controller)
16 : QEvent(pressType)
17 , m_hatId(hatId)
18 , m_direction(direction)
19 , m_key(GBA_KEY_NONE)
20 {
21 ignore();
22 if (controller) {
23 m_key = static_cast<GBAKey>(mInputMapHat(controller->map(), type, hatId, direction));
24 }
25 }
26
Down()27 QEvent::Type GamepadHatEvent::Down() {
28 if (s_downType == None) {
29 s_downType = static_cast<Type>(registerEventType());
30 }
31 return s_downType;
32 }
33
Up()34 QEvent::Type GamepadHatEvent::Up() {
35 if (s_upType == None) {
36 s_upType = static_cast<Type>(registerEventType());
37 }
38 return s_upType;
39 }
40