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 type, int button, InputController* controller)
16 : QEvent(type)
17 , m_button(button)
18 , m_controller(controller)
19 , m_key(GBA_KEY_NONE)
20{
21 ignore();
22#ifdef BUILD_SDL
23 if (controller) {
24 m_key = GBAInputMapKey(controller->map(), SDL_BINDING_BUTTON, button);
25 }
26#endif
27}
28
29QEvent::Type GamepadButtonEvent::Down() {
30 if (s_downType == None) {
31 s_downType = static_cast<Type>(registerEventType());
32 }
33 return s_downType;
34}
35
36QEvent::Type GamepadButtonEvent::Up() {
37 if (s_upType == None) {
38 s_upType = static_cast<Type>(registerEventType());
39 }
40 return s_upType;
41}