src/platform/qt/GamepadAxisEvent.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 "GamepadAxisEvent.h"
7
8#include "InputController.h"
9
10using namespace QGBA;
11
12QEvent::Type GamepadAxisEvent::s_type = QEvent::None;
13
14GamepadAxisEvent::GamepadAxisEvent(int axis, Direction direction, bool isNew, InputController* controller)
15 : QEvent(Type())
16 , m_axis(axis)
17 , m_direction(direction)
18 , m_isNew(isNew)
19 , m_controller(controller)
20 , m_key(GBA_KEY_NONE)
21{
22 ignore();
23#ifdef BUILD_SDL
24 if (controller) {
25 m_key = GBAInputMapAxis(controller->map(), SDL_BINDING_BUTTON, axis, direction * INT_MAX);
26 }
27#endif
28}
29
30QEvent::Type GamepadAxisEvent::Type() {
31 if (s_type == None) {
32 s_type = static_cast<enum Type>(registerEventType());
33 }
34 return s_type;
35}