fork/GramFirmware
git clone https://git.julia.blue/fork/GramFirmware
1f92ae6
master
1#include "modes/extra/DarkSouls.hpp" 2 3#define ANALOG_STICK_MIN 0 4#define ANALOG_STICK_NEUTRAL 128 5#define ANALOG_STICK_MAX 255 6 7DarkSouls ::DarkSouls (socd::SocdType socd_type ) { 8_socd_pair_count = 4 ; 9_socd_pairs = new socd::SocdPair [_socd_pair_count ]{ 10 socd::SocdPair {& InputState ::left ,& InputState ::right ,socd_type }, 11 socd::SocdPair {& InputState ::down ,& InputState ::mod_x ,socd_type }, 12 socd::SocdPair {& InputState ::c_left ,& InputState ::c_right ,socd_type }, 13 socd::SocdPair {& InputState ::c_down ,& InputState ::c_up ,socd_type }, 14 }; 15} 16 17void DarkSouls ::UpdateDigitalOutputs (InputState & inputs ,OutputState & outputs ) { 18outputs .y = inputs .y ; 19outputs .x = inputs .r ; 20 21// Base layer. 22bool layer0 = !inputs .x && !inputs .nunchuk_c ; 23// Secondary layer when X is held. 24bool layerX = inputs .x && !inputs .nunchuk_c ; 25// DPad layer when Nunchuk C is held. 26bool layerC = inputs .nunchuk_c ; 27 28if (layer0 ) { 29outputs .a = inputs .a ; 30outputs .b = inputs .b ; 31outputs .buttonR = inputs .z ; 32outputs .buttonL = inputs .up ; 33outputs .start = inputs .start |inputs .nunchuk_z ; 34 }else if (layerX ) { 35outputs .rightStickClick = inputs .a ; 36outputs .triggerRDigital = inputs .z ; 37outputs .triggerLDigital = inputs .up ; 38outputs .select = inputs .start ; 39 }else if (layerC ) { 40outputs .a = inputs .a ; 41outputs .dpadLeft = inputs .b ; 42outputs .dpadDown = inputs .x ; 43outputs .dpadUp = inputs .z ; 44outputs .dpadRight = inputs .up ; 45outputs .select = inputs .nunchuk_z ; 46 } 47} 48 49void DarkSouls ::UpdateAnalogOutputs (InputState & inputs ,OutputState & outputs ) { 50UpdateDirections ( 51inputs .left , 52inputs .right , 53inputs .down , 54inputs .mod_x , 55inputs .c_left , 56inputs .c_right , 57inputs .c_down , 58inputs .c_up , 59ANALOG_STICK_MIN , 60ANALOG_STICK_NEUTRAL , 61ANALOG_STICK_MAX , 62outputs 63 ); 64 65// Nunchuk overrides left stick. 66if (inputs .nunchuk_connected ) { 67outputs .leftStickX = inputs .nunchuk_x ; 68outputs .leftStickY = inputs .nunchuk_y ; 69 } 70}