5 * th9x - http://code.google.com/p/th9x
6 * er9x - http://code.google.com/p/er9x
7 * gruvin9x - http://code.google.com/p/gruvin9x
9 * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
22 #include "trainersimu.h"
23 #include "ui_trainersimu.h"
25 #include "virtualjoystickwidget.h"
27 TrainerSimulator::TrainerSimulator(QWidget
* parent
, SimulatorInterface
* simulator
):
29 ui(new Ui::TrainerSimulator
),
34 vJoyLeft
= new VirtualJoystickWidget(this, 'L', false);
35 vJoyLeft
->setStickColor(Qt::cyan
);
36 ui
->leftStickLayout
->addWidget(vJoyLeft
);
38 vJoyRight
= new VirtualJoystickWidget(this, 'R', false);
39 vJoyRight
->setStickColor(Qt::cyan
);
40 ui
->rightStickLayout
->addWidget(vJoyRight
);
42 timer
= new QTimer(this);
43 timer
->setInterval(10);
44 connect(timer
, SIGNAL(timeout()), this, SLOT(onTimerEvent()));
47 TrainerSimulator::~TrainerSimulator()
61 void TrainerSimulator::showEvent(QShowEvent
*event
)
67 void TrainerSimulator::closeEvent(QCloseEvent
*event
)
73 void TrainerSimulator::centerSticks()
76 vJoyLeft
->centerStick();
79 vJoyRight
->centerStick();
82 void TrainerSimulator::onTimerEvent()
88 void TrainerSimulator::setTrainerInputs()
94 simulator
->setTrainerInput(0, int( 512 * vJoyLeft
->getStickX())); // LEFT HORZ
95 simulator
->setTrainerInput(1, int(-512 * vJoyLeft
->getStickY())); // LEFT VERT
98 simulator
->setTrainerInput(2, int(-512 * vJoyRight
->getStickY())); // RGHT VERT
99 simulator
->setTrainerInput(3, int( 512 * vJoyRight
->getStickX())); // RGHT HORZ