all repos — mgba @ 1093849ad5f6103d8eb1817e9b913255a3218eb9

mGBA Game Boy Advance Emulator

src/platform/qt/GamepadHatEvent.cpp (view raw)

 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
10using namespace QGBA;
11
12QEvent::Type GamepadHatEvent::s_downType = QEvent::None;
13QEvent::Type GamepadHatEvent::s_upType = QEvent::None;
14
15GamepadHatEvent::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_controller(controller)
20	, m_key(GBA_KEY_NONE)
21{
22	ignore();
23	if (controller) {
24		m_key = static_cast<GBAKey>(mInputMapHat(controller->map(), type, hatId, direction));
25	}
26}
27
28QEvent::Type GamepadHatEvent::Down() {
29	if (s_downType == None) {
30		s_downType = static_cast<Type>(registerEventType());
31	}
32	return s_downType;
33}
34
35QEvent::Type GamepadHatEvent::Up() {
36	if (s_upType == None) {
37		s_upType = static_cast<Type>(registerEventType());
38	}
39	return s_upType;
40}