fork/GramFirmware

git clone https://git.julia.blue/fork/GramFirmware

Jonathan HaylettMerge pull request #7 from JonnyHaystack/v23ab6a9b

master
922 B37 linesraw
1#include "input/GamecubeControllerInput.hpp"
2
3#include "core/InputSource.hpp"
4
5#include <GamecubeController.hpp>
6
7GamecubeControllerInput::GamecubeControllerInput(
8    uint pin,
9    uint polling_rate,
10    PIO pio,
11    int sm,
12    int offset
13) {
14    _controller = new GamecubeController(pin, polling_rate, pio, sm, offset);
15}
16
17GamecubeControllerInput::~GamecubeControllerInput() {
18    delete _controller;
19}
20
21InputScanSpeed GamecubeControllerInput::ScanSpeed() {
22    return InputScanSpeed::SLOW;
23}
24
25void GamecubeControllerInput::UpdateInputs(InputState &inputs) {
26    // Only update inputs if poll response is received.
27    if (_controller->Poll(&_report, false)) {
28        inputs.nunchuk_connected = true;
29        inputs.nunchuk_x = _report.stick_x;
30        inputs.nunchuk_y = _report.stick_y;
31        inputs.nunchuk_z = _report.l;
32    }
33}
34
35int GamecubeControllerInput::GetOffset() {
36    return _controller->GetOffset();
37}