syntax = "proto2";

import "nanopb.proto";
import "enums.proto";

message GamepadOptions
{
	optional InputMode inputMode = 1;
	optional DpadMode dpadMode = 2;
	optional SOCDMode socdMode = 3;
	optional bool invertXAxis = 4;
	optional bool invertYAxis = 5;
	optional bool switchTpShareForDs4 = 6;
	optional bool lockHotkeys = 7;
	optional bool fourWayMode = 8;
	optional uint32 profileNumber = 9;
	optional PS4ControllerType ps4ControllerType = 10;
}

message KeyboardMapping
{
	optional uint32 keyDpadUp = 1;
	optional uint32 keyDpadDown = 2;
	optional uint32 keyDpadLeft = 3;
	optional uint32 keyDpadRight = 4;
	optional uint32 keyButtonB1 = 5;
	optional uint32 keyButtonB2 = 6;
	optional uint32 keyButtonB3 = 7;
	optional uint32 keyButtonB4 = 8;
	optional uint32 keyButtonL1 = 9;
	optional uint32 keyButtonR1 = 10;
	optional uint32 keyButtonL2 = 11;
	optional uint32 keyButtonR2 = 12;
	optional uint32 keyButtonS1 = 13;
	optional uint32 keyButtonS2 = 14;
	optional uint32 keyButtonL3 = 15;
	optional uint32 keyButtonR3 = 16;
	optional uint32 keyButtonA1 = 17;
	optional uint32 keyButtonA2 = 18;
}

message HotkeyEntry
{
	optional uint32 dpadMask = 1;
	optional GamepadHotkey action = 2;
	optional uint32 buttonsMask = 3;
	optional uint32 auxMask = 4;
}

message HotkeyOptions
{
	optional HotkeyEntry hotkey01 = 1;
	optional HotkeyEntry hotkey02 = 2;
	optional HotkeyEntry hotkey03 = 3;
	optional HotkeyEntry hotkey04 = 4;
	optional HotkeyEntry hotkey05 = 5;
	optional HotkeyEntry hotkey06 = 6;
	optional HotkeyEntry hotkey07 = 7;
	optional HotkeyEntry hotkey08 = 8;
	optional HotkeyEntry hotkey09 = 9;
	optional HotkeyEntry hotkey10 = 10;
	optional HotkeyEntry hotkey11 = 11;
	optional HotkeyEntry hotkey12 = 12;
}

message ForcedSetupOptions
{
	optional ForcedSetupMode mode = 1;
};

message ButtonLayoutParamsCommon
{
	optional int32 startX = 1;
	optional int32 startY = 2;
	optional int32 buttonRadius = 3;
	optional int32 buttonPadding = 4;
}

message ButtonLayoutParamsLeft
{
	optional ButtonLayout layout = 1;
	optional ButtonLayoutParamsCommon common = 2;
}

message ButtonLayoutParamsRight
{
	optional ButtonLayoutRight layout = 1;
	optional ButtonLayoutParamsCommon common = 2;
}

message ButtonLayoutCustomOptions
{
	optional ButtonLayoutParamsLeft paramsLeft = 1;
	optional ButtonLayoutParamsRight paramsRight = 2;
}

message PinMappings
{
	optional int32 pinDpadUp = 1;
	optional int32 pinDpadDown = 2;
	optional int32 pinDpadLeft = 3;
	optional int32 pinDpadRight = 4;
	optional int32 pinButtonB1 = 5;
	optional int32 pinButtonB2 = 6;
	optional int32 pinButtonB3 = 7;
	optional int32 pinButtonB4 = 8;
	optional int32 pinButtonL1 = 9;
	optional int32 pinButtonR1 = 10;
	optional int32 pinButtonL2 = 11;
	optional int32 pinButtonR2 = 12;
	optional int32 pinButtonS1 = 13;
	optional int32 pinButtonS2 = 14;
	optional int32 pinButtonL3 = 15;
	optional int32 pinButtonR3 = 16;
	optional int32 pinButtonA1 = 17;
	optional int32 pinButtonA2 = 18;
	optional int32 pinButtonFn = 19;
}

message GpioMappings
{
	optional GpioAction pin00 = 1;
	optional GpioAction pin01 = 2;
	optional GpioAction pin02 = 3;
	optional GpioAction pin03 = 4;
	optional GpioAction pin04 = 5;
	optional GpioAction pin05 = 6;
	optional GpioAction pin06 = 7;
	optional GpioAction pin07 = 8;
	optional GpioAction pin08 = 9;
	optional GpioAction pin09 = 10;
	optional GpioAction pin10 = 11;
	optional GpioAction pin11 = 12;
	optional GpioAction pin12 = 13;
	optional GpioAction pin13 = 14;
	optional GpioAction pin14 = 15;
	optional GpioAction pin15 = 16;
	optional GpioAction pin16 = 17;
	optional GpioAction pin17 = 18;
	optional GpioAction pin18 = 19;
	optional GpioAction pin19 = 20;
	optional GpioAction pin20 = 21;
	optional GpioAction pin21 = 22;
	optional GpioAction pin22 = 23;
	optional GpioAction pin23 = 24;
	optional GpioAction pin24 = 25;
	optional GpioAction pin25 = 26;
	optional GpioAction pin26 = 27;
	optional GpioAction pin27 = 28;
	optional GpioAction pin28 = 29;
	optional GpioAction pin29 = 30;
}


message AlternativePinMappings
{
	optional int32 pinButtonB1 = 1;
	optional int32 pinButtonB2 = 2;
	optional int32 pinButtonB3 = 3;
	optional int32 pinButtonB4 = 4;
	optional int32 pinButtonL1 = 5;
	optional int32 pinButtonR1 = 6;
	optional int32 pinButtonL2 = 7;
	optional int32 pinButtonR2 = 8;
	optional int32 pinDpadUp = 9;
	optional int32 pinDpadDown = 10;
	optional int32 pinDpadLeft = 11;
	optional int32 pinDpadRight = 12;
}


message ProfileOptions
{
	repeated AlternativePinMappings alternativePinMappings = 1 [(nanopb).max_count = 3];
}

message DisplayOptions
{
	optional bool enabled = 1;
	
	optional int32 i2cBlock = 2;
	optional int32 i2cSDAPin = 3;
	optional int32 i2cSCLPin = 4;
	optional int32 i2cAddress = 5;
	optional int32 i2cSpeed = 6;
	
	optional ButtonLayout buttonLayout = 7;
	optional ButtonLayoutRight buttonLayoutRight = 8;
	optional ButtonLayoutCustomOptions buttonLayoutCustomOptions = 9;
	
	optional SplashMode splashMode = 10;
	optional SplashChoice splashChoice = 11;
	optional int32 splashDuration = 12;
	optional bytes splashImage = 13 [(nanopb).max_size = 1024];
	
	optional int32 size = 14;
	optional int32 flip = 15;
	optional bool invert = 16;
	
	optional int32 displaySaverTimeout = 17;
	optional bool turnOffWhenSuspended = 18;
}

message LEDOptions
{
	optional int32 dataPin = 1;
	optional LEDFormat_Proto ledFormat = 2;
	optional ButtonLayout ledLayout = 3;
	optional uint32 ledsPerButton = 4;
	optional uint32 brightnessMaximum = 5;
	optional uint32 brightnessSteps = 6;
	
	optional int32 indexUp = 7;
	optional int32 indexDown = 8;
	optional int32 indexLeft = 9;
	optional int32 indexRight = 10;
	optional int32 indexB1 = 11;
	optional int32 indexB2 = 12;
	optional int32 indexB3 = 13;
	optional int32 indexB4 = 14;
	optional int32 indexL1 = 15;
	optional int32 indexR1 = 16;
	optional int32 indexL2 = 17;
	optional int32 indexR2 = 18;
	optional int32 indexS1 = 19;
	optional int32 indexS2 = 20;
	optional int32 indexL3 = 21;
	optional int32 indexR3 = 22;
	optional int32 indexA1 = 23;
	optional int32 indexA2 = 24;
	
	optional PLEDType pledType = 25;
	optional int32 pledPin1 = 26;
	optional int32 pledPin2 = 27;
	optional int32 pledPin3 = 28;
	optional int32 pledPin4 = 29;
	optional uint32 pledColor = 30;

	optional bool turnOffWhenSuspended = 31;
};

// This has to be kept in sync with AnimationOptions in AnimationStation.hpp
message AnimationOptions_Proto
{
	optional uint32 baseAnimationIndex = 1;
	optional uint32 brightness = 2;
	optional uint32 staticColorIndex = 3;
	optional uint32 buttonColorIndex = 4;
	optional int32 chaseCycleTime = 5;
	optional int32 rainbowCycleTime = 6;
	optional uint32 themeIndex = 7;
	
	optional bool hasCustomTheme = 8;
	optional uint32 customThemeUp = 9;
	optional uint32 customThemeDown = 10;
	optional uint32 customThemeLeft = 11;
	optional uint32 customThemeRight = 12;
	optional uint32 customThemeB1 = 13;
	optional uint32 customThemeB2 = 14;
	optional uint32 customThemeB3 = 15;
	optional uint32 customThemeB4 = 16;
	optional uint32 customThemeL1 = 17;
	optional uint32 customThemeR1 = 18;
	optional uint32 customThemeL2 = 19;
	optional uint32 customThemeR2 = 20;
	optional uint32 customThemeS1 = 21;
	optional uint32 customThemeS2 = 22;
	optional uint32 customThemeL3 = 23;
	optional uint32 customThemeR3 = 24;
	optional uint32 customThemeA1 = 25;
	optional uint32 customThemeA2 = 26;
	optional uint32 customThemeUpPressed = 27;
	optional uint32 customThemeDownPressed = 28;
	optional uint32 customThemeLeftPressed = 29;
	optional uint32 customThemeRightPressed = 30;
	optional uint32 customThemeB1Pressed = 31;
	optional uint32 customThemeB2Pressed = 32;
	optional uint32 customThemeB3Pressed = 33;
	optional uint32 customThemeB4Pressed = 34;
	optional uint32 customThemeL1Pressed = 35;
	optional uint32 customThemeR1Pressed = 36;
	optional uint32 customThemeL2Pressed = 37;
	optional uint32 customThemeR2Pressed = 38;
	optional uint32 customThemeS1Pressed = 39;
	optional uint32 customThemeS2Pressed = 40;
	optional uint32 customThemeL3Pressed = 41;
	optional uint32 customThemeR3Pressed = 42;
	optional uint32 customThemeA1Pressed = 43;
	optional uint32 customThemeA2Pressed = 44;
}

message BootselButtonOptions
{
	optional bool enabled = 1;
	optional uint32 buttonMap = 2;
}

message OnBoardLedOptions
{
	optional OnBoardLedMode mode = 1;
	optional bool enabled = 2;
}

message AnalogOptions
{
	optional bool enabled = 1;
	
	optional int32 analogAdc1PinX = 2;
	optional int32 analogAdc1PinY = 3;
	optional bool forced_circularity = 4;
	optional uint32 analog_deadzone = 5;
	optional int32 analogAdc2PinX = 6;
	optional int32 analogAdc2PinY = 7;
	optional DpadMode analogAdc1Mode = 8;
	optional DpadMode analogAdc2Mode = 9;
	optional InvertMode analogAdc1Invert = 10;
	optional InvertMode analogAdc2Invert = 11;
	optional bool auto_calibrate = 12;
}

message TurboOptions
{
	optional bool enabled = 1;
	
	optional int32 buttonPin = 2;
	optional int32 ledPin = 3;
	optional uint32 shotCount = 4;
	optional int32 shmupDialPin = 5;
	
	optional bool shmupModeEnabled = 6;
	optional uint32 shmupAlwaysOn1 = 7;
	optional uint32 shmupAlwaysOn2 = 8;
	optional uint32 shmupAlwaysOn3 = 9;
	optional uint32 shmupAlwaysOn4 = 10;
	optional int32 shmupBtn1Pin = 11;
	optional int32 shmupBtn2Pin = 12;
	optional int32 shmupBtn3Pin = 13;
	optional int32 shmupBtn4Pin = 14;
	optional uint32 shmupBtnMask1 = 15;
	optional uint32 shmupBtnMask2 = 16;
	optional uint32 shmupBtnMask3 = 17;
	optional uint32 shmupBtnMask4 = 18;
	optional ShmupMixMode shmupMixMode = 19;
}

message SliderOptions
{
	optional bool enabled = 1;
	
	optional int32 deprecatedPinSliderOne = 2;
	optional int32 deprecatedPinSliderTwo = 3;
	optional DpadMode deprecatedModeOne = 4;
	optional DpadMode deprecatedModeTwo = 5;
	optional DpadMode modeDefault = 6;
}

message SOCDSliderOptions
{
	optional bool enabled = 1;
	
	optional int32 deprecatedPinOne = 2;
	optional int32 deprecatedPinTwo = 3;
	
	optional SOCDMode modeDefault = 4;
	optional SOCDMode deprecatedModeOne = 5;
	optional SOCDMode deprecatedModeTwo = 6;
}

message ReverseOptions
{
	optional bool enabled = 1;
	
	optional int32 buttonPin = 2;
	optional int32 ledPin = 3;
	
	optional uint32 actionUp = 4;
	optional uint32 actionDown = 5;
	optional uint32 actionLeft = 6;
	optional uint32 actionRight = 7;
}

message AnalogADS1219Options
{
	optional bool enabled = 1;
	
	optional int32 i2cBlock = 2;
	optional int32 i2cSDAPin = 3;
	optional int32 i2cSCLPin = 4;
	optional int32 i2cAddress = 5;
	optional int32 i2cSpeed = 6;
}

message DualDirectionalOptions
{
	optional bool enabled = 1;
	
	optional int32 deprecatedUpPin = 2;
	optional int32 deprecatedDownPin = 3;
	optional int32 deprecatedLeftPin = 4;
	optional int32 deprecatedRightPin = 5;
	
	optional DpadMode dpadMode = 6;
	optional uint32 combineMode = 7;
	optional bool fourWayMode = 8;
}

message TiltOptions
{
	optional bool enabled = 1;

	optional int32 tilt1Pin = 2;
	optional int32 tilt2Pin = 3;
	optional int32 deprecatedTiltFunctionPin = 4;
	optional int32 tiltLeftAnalogUpPin = 5;
	optional int32 tiltLeftAnalogDownPin = 6;
	optional int32 tiltLeftAnalogLeftPin = 7;
	optional int32 tiltLeftAnalogRightPin = 8;
	optional int32 tiltRightAnalogUpPin = 9;
	optional int32 tiltRightAnalogDownPin = 10;
	optional int32 tiltRightAnalogLeftPin = 11;
	optional int32 tiltRightAnalogRightPin = 12;

	optional SOCDMode tiltSOCDMode = 13;
	
	optional int32 factorTilt1LeftX =  14;
	optional int32 factorTilt1LeftY =  15;
	optional int32 factorTilt1RightX =  16;
	optional int32 factorTilt1RightY =  17;
	optional int32 factorTilt2LeftX =  18;
	optional int32 factorTilt2LeftY =  19;
	optional int32 factorTilt2RightX =  20;
	optional int32 factorTilt2RightY =  21;
}

message BuzzerOptions
{
	optional bool enabled = 1;
	
	optional int32 pin = 2;
	optional uint32 volume = 3;
}

message ExtraButtonOptions
{
	optional bool enabled = 1;
	
	optional int32 pin = 2;
	optional uint32 buttonMap = 3;
}

message PlayerNumberOptions
{
	optional bool enabled = 1;
	optional uint32 number = 2;
}

message PS4Options
{
	optional bool enabled = 1;
	optional bytes serial = 2 [(nanopb).max_size = 16];
	optional bytes signature = 3 [(nanopb).max_size = 256];
	optional bytes rsaN = 4 [(nanopb).max_size = 256];
	optional bytes rsaE = 5 [(nanopb).max_size = 4];
	optional bytes rsaD = 6 [(nanopb).max_size = 256];
	optional bytes rsaP = 7 [(nanopb).max_size = 128];
	optional bytes rsaQ = 8 [(nanopb).max_size = 128];
	optional bytes rsaDP = 9 [(nanopb).max_size = 128];
	optional bytes rsaDQ = 10 [(nanopb).max_size = 128];
	optional bytes rsaQP = 11 [(nanopb).max_size = 128];
	optional bytes rsaRN = 12 [(nanopb).max_size = 256];
}

message PSPassthroughOptions
{
	optional bool enabled = 1;
	optional int32 pinDplus = 2;
	optional int32 pin5V = 3;
}

message WiiOptions
{
    message AnalogAxis
    {
        optional int32 axisType = 1;
        optional int32 minRange = 2;
        optional int32 maxRange = 3;
    }

    message StickOptions
    {
        optional AnalogAxis x = 1;
        optional AnalogAxis y = 2;
    }
    
	message NunchukOptions
	{
		optional int32 buttonC = 1;
        optional int32 buttonZ = 2;
        optional StickOptions stick = 3;
	}

	message ClassicOptions
	{
		optional int32 buttonA = 1;
        optional int32 buttonB = 2;
        optional int32 buttonX = 3;
        optional int32 buttonY = 4;
        optional int32 buttonL = 5;
        optional int32 buttonZL = 6;
        optional int32 buttonR = 7;
        optional int32 buttonZR = 8;
        optional int32 buttonMinus = 9;
        optional int32 buttonPlus = 10;
        optional int32 buttonHome = 11;
        optional int32 buttonUp = 12;
        optional int32 buttonDown = 13;
        optional int32 buttonLeft = 14;
        optional int32 buttonRight = 15;
        optional StickOptions rightStick = 17;
        optional StickOptions leftStick = 16;
        optional AnalogAxis leftTrigger = 18;
        optional AnalogAxis rightTrigger = 19;
	}

    message TaikoOptions 
    {
        optional int32 buttonKatLeft = 1;
        optional int32 buttonKatRight = 2;
        optional int32 buttonDonLeft = 3;
        optional int32 buttonDonRight = 4;
    }

    message GuitarOptions
    {
        optional int32 buttonRed = 1;
        optional int32 buttonGreen = 2;
        optional int32 buttonYellow = 3;
        optional int32 buttonBlue = 4;
        optional int32 buttonOrange = 5;
        optional int32 buttonPedal = 6;
        optional int32 buttonMinus = 7;
        optional int32 buttonPlus = 8;
        optional int32 strumUp = 9;
        optional int32 strumDown = 10;
        optional StickOptions stick = 11;
        optional AnalogAxis whammyBar = 12;
    }

    message DrumOptions
    {
        optional int32 buttonRed = 1;
        optional int32 buttonGreen = 2;
        optional int32 buttonYellow = 3;
        optional int32 buttonBlue = 4;
        optional int32 buttonOrange = 5;
        optional int32 buttonPedal = 6;
        optional int32 buttonMinus = 7;
        optional int32 buttonPlus = 8;
        optional StickOptions stick = 9;
    }

    message TurntableOptions
    {
        optional int32 buttonLeftRed = 1;
        optional int32 buttonLeftGreen = 2;
        optional int32 buttonLeftBlue = 3;
        optional int32 buttonRightRed = 4;
        optional int32 buttonRightGreen = 5;
        optional int32 buttonRightBlue = 6;
        optional int32 buttonMinus = 7;
        optional int32 buttonPlus = 8;
        optional int32 buttonEuphoria = 9;
        optional StickOptions stick = 10;
        optional AnalogAxis leftTurntable = 11;
        optional AnalogAxis rightTurntable = 12;
        optional AnalogAxis effects = 13;
        optional AnalogAxis fader = 14;
    }

    message ControllerOptions
    {
        optional NunchukOptions nunchuk = 1;
        optional ClassicOptions classic = 2;
        optional TaikoOptions taiko = 3;
        optional GuitarOptions guitar = 4;
        optional DrumOptions drum = 5;
        optional TurntableOptions turntable = 6;
    }

	optional bool enabled = 1;
	optional int32 i2cBlock = 2;
	optional int32 i2cSDAPin = 3;
	optional int32 i2cSCLPin = 4;
	optional int32 i2cSpeed = 5;

    optional ControllerOptions controllers = 6;
}

message SNESOptions
{
	optional bool enabled = 1;
	optional int32 clockPin = 2;
	optional int32 latchPin = 3;
	optional int32 dataPin = 4;
}

message KeyboardHostOptions
{
	optional bool enabled = 1;
	optional int32 pinDplus = 2;
	optional KeyboardMapping mapping = 3;
	optional int32 pin5V = 4;
}

message FocusModeOptions
{
	optional bool enabled = 1;
	optional int32 pin = 2;
	optional int32 buttonLockMask = 3;
	optional bool oledLockEnabled = 4;
	optional bool rgbLockEnabled = 5;
	optional bool buttonLockEnabled = 6;
	optional bool macroLockEnabled = 7;
}

message MacroInput
{
	optional uint32 buttonMask = 1;
	optional uint32 duration = 2;
	optional uint32 waitDuration = 3 [default = 0];
}

message Macro
{
	optional MacroType macroType = 1;
	optional string macroLabel = 2 [(nanopb).max_length = 64];
	repeated MacroInput macroInputs = 3 [(nanopb).max_count = 30];
	optional bool enabled = 4;
	optional bool useMacroTriggerButton = 5;
	optional int32 macroTriggerPin = 6 [default = -1];
	optional uint32 macroTriggerButton = 7;
	optional bool exclusive = 8 [default = true];
	optional bool interruptible = 9 [default = true];
	optional bool showFrames = 10 [default = false];
}

message MacroOptions
{
	optional bool enabled = 1;
	optional int32 pin = 2;
	optional bool macroBoardLedEnabled = 4;
	repeated Macro macroList = 3 [(nanopb).max_count = 6];
}

message AddonOptions
{
	optional BootselButtonOptions bootselButtonOptions = 1;
	optional OnBoardLedOptions onBoardLedOptions = 2;
	optional AnalogOptions analogOptions = 3;
	optional TurboOptions turboOptions = 4;
	optional SliderOptions sliderOptions = 5;
	optional ReverseOptions reverseOptions = 6;
	optional AnalogADS1219Options analogADS1219Options = 7;
	optional DualDirectionalOptions dualDirectionalOptions = 8;
	optional BuzzerOptions buzzerOptions = 9;
	optional ExtraButtonOptions deprecatedExtraButtonOptions = 10;
	optional PlayerNumberOptions playerNumberOptions = 11;
	optional PS4Options ps4Options = 12 [(nanopb).disallow_export = true];
	optional WiiOptions wiiOptions = 13;
	optional SOCDSliderOptions socdSliderOptions = 14;
	optional SNESOptions snesOptions = 15;
	optional FocusModeOptions focusModeOptions = 16;
	optional KeyboardHostOptions keyboardHostOptions = 17;
	optional TiltOptions tiltOptions = 18;
	optional PSPassthroughOptions psPassthroughOptions = 19;
	optional MacroOptions macroOptions = 20;
}

message MigrationHistory
{
	optional bool hotkeysMigrated = 1 [default = false];
	optional bool gpioMappingsMigrated = 2 [default = false];
}

message Config
{
	optional string boardVersion = 1 [(nanopb).max_length = 31];
	
	optional GamepadOptions gamepadOptions = 2;
	optional HotkeyOptions hotkeyOptions = 3;
	optional PinMappings deprecatedPinMappings = 4;
	optional KeyboardMapping keyboardMapping = 5;
	optional DisplayOptions displayOptions = 6;
	optional LEDOptions ledOptions = 7;
	optional AnimationOptions_Proto animationOptions = 8;
	optional AddonOptions addonOptions = 9;
	optional ForcedSetupOptions forcedSetupOptions = 10;
	optional ProfileOptions profileOptions = 11;
	
	optional string boardConfig = 12 [(nanopb).max_length = 63];
	optional GpioMappings gpioMappings = 13;
	optional MigrationHistory migrations = 14;
}
