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, int type, InputController* controller)
15 : QEvent(Type())
16 , m_axis(axis)
17 , m_direction(direction)
18 , m_isNew(isNew)
19 , m_key(GBA_KEY_NONE)
20{
21 ignore();
22 if (controller) {
23 m_key = static_cast<GBAKey>(mInputMapAxis(controller->map(), type, axis, direction * INT_MAX));
24 }
25}
26
27QEvent::Type GamepadAxisEvent::Type() {
28 if (s_type == None) {
29 s_type = static_cast<enum Type>(registerEventType());
30 }
31 return s_type;
32}