all repos — mgba @ 59f78a05e4e0da2be407e41e6845434dace902df

mGBA Game Boy Advance Emulator

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

 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
10using namespace QGBA;
11
12QEvent::Type GamepadButtonEvent::s_downType = QEvent::None;
13QEvent::Type GamepadButtonEvent::s_upType = QEvent::None;
14
15GamepadButtonEvent::GamepadButtonEvent(QEvent::Type pressType, int button, int type, InputController* controller)
16	: QEvent(pressType)
17	, m_button(button)
18	, m_controller(controller)
19	, m_key(GBA_KEY_NONE)
20{
21	ignore();
22	if (controller) {
23		m_key = static_cast<GBAKey>(mInputMapKey(controller->map(), type, button));
24	}
25}
26
27QEvent::Type GamepadButtonEvent::Down() {
28	if (s_downType == None) {
29		s_downType = static_cast<Type>(registerEventType());
30	}
31	return s_downType;
32}
33
34QEvent::Type GamepadButtonEvent::Up() {
35	if (s_upType == None) {
36		s_upType = static_cast<Type>(registerEventType());
37	}
38	return s_upType;
39}