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_controller(controller)
20 , m_key(GBA_KEY_NONE)
21{
22 ignore();
23 if (controller) {
24 m_key = static_cast<GBAKey>(mInputMapAxis(controller->map(), type, axis, direction * INT_MAX));
25 }
26}
27
28QEvent::Type GamepadAxisEvent::Type() {
29 if (s_type == None) {
30 s_type = static_cast<enum Type>(registerEventType());
31 }
32 return s_type;
33}