fork/GramFirmware
git clone https://git.julia.blue/fork/GramFirmware
1e2098f
WASD_NeutralSOCD
1#include "comms/N64Backend.hpp" 2 3#include "core/InputSource.hpp" 4 5#include <N64Console.hpp> 6#include <hardware/pio.h> 7 8N64Backend ::N64Backend ( 9InputSource ** input_sources , 10size_t input_source_count , 11uint data_pin , 12PIO pio , 13int sm , 14int offset 15) 16 :CommunicationBackend (input_sources ,input_source_count ) { 17_n64 = new N64Console (data_pin ,pio ,sm ,offset ); 18_report = default_n64_report ; 19} 20 21N64Backend ::~N64Backend () { 22delete _n64 ; 23} 24 25void N64Backend ::SendReport () { 26// Update slower inputs before we start waiting for poll. 27ScanInputs (InputScanSpeed ::SLOW ); 28ScanInputs (InputScanSpeed ::MEDIUM ); 29 30// Read inputs 31_n64 -> WaitForPoll (); 32 33// Update fast inputs in response to poll. 34ScanInputs (InputScanSpeed ::FAST ); 35 36// Run gamemode logic. 37UpdateOutputs (); 38 39// Digital outputs 40_report .a = _outputs .a ; 41_report .b = _outputs .b ; 42_report .z = _outputs .buttonR ; 43_report .l = _outputs .triggerLDigital ; 44_report .r = _outputs .triggerRDigital ; 45_report .start = _outputs .start ; 46_report .dpad_left = _outputs .dpadLeft ; 47_report .dpad_right = _outputs .dpadRight ; 48_report .dpad_down = _outputs .dpadDown ; 49_report .dpad_up = _outputs .dpadUp ; 50// Somewhat ugly way of mapping right stick to C-Pad 51_report .c_left = _outputs .rightStickX < 128 ; 52_report .c_right = _outputs .rightStickX > 128 ; 53_report .c_down = _outputs .rightStickY < 128 ; 54_report .c_up = _outputs .rightStickY > 128 ; 55 56// Analog outputs 57_report .stick_x = _outputs .leftStickX - 128 ; 58_report .stick_y = _outputs .leftStickY - 128 ; 59 60// Send outputs to console. 61_n64 -> SendReport (& _report ); 62} 63 64int N64Backend ::GetOffset () { 65return _n64 -> GetOffset (); 66}