all repos — mgba @ c4b38790f211b65cb15af26cebe9fc25e3c19914

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_key(GBA_KEY_NONE)
19{
20	ignore();
21	if (controller) {
22		m_key = static_cast<GBAKey>(mInputMapKey(controller->map(), type, button));
23	}
24}
25
26QEvent::Type GamepadButtonEvent::Down() {
27	if (s_downType == None) {
28		s_downType = static_cast<Type>(registerEventType());
29	}
30	return s_downType;
31}
32
33QEvent::Type GamepadButtonEvent::Up() {
34	if (s_upType == None) {
35		s_upType = static_cast<Type>(registerEventType());
36	}
37	return s_upType;
38}