; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

# env's are laid out like:
# $board-$input-$output
# supported values:
# $board: micro, esp32
# $input: snes, genesis, psx, n64, gc, radio, debug
# $output: radio, usb, usbradio, bt, switchusb, debug
# please note not all boards are compatible with all inputs/outputs
# for example esp32 can only do bt
# micro can only do radio or usb

# CODE_PLATFORM == 0: generic, should work on anything
# CODE_PLATFORM == 1: optimized for esp32
# CODE_PLATFORM == 2: optimized for micro

[common]
# change GAMEPAD_COUNT if you want
build_flags = -DGAMEPAD_COUNT=2
# dev: add -save-temps above for troubleshooting macros

[env]
monitor_speed = 115200
framework = arduino

# boards

[esp32]
platform = espressif32
board = esp32dev

[micro]
platform = atmelavr
board = micro

# outputs

[out-debug]
build_flags = -DGAMEPAD_OUTPUT=0 -DDEBUG=1
src_filter = +<gamepad/Debug-Gamepad>

[out-radio]
build_flags = -DGAMEPAD_OUTPUT=1
src_filter = +<gamepad/Radio-Gamepad>
lib_deps = tmrh20/RF24@^1.3.9

[out-usb]
build_flags = -DGAMEPAD_OUTPUT=2
src_filter = +<gamepad/USB-Gamepad>
framework = arduino
platform = atmelavr
extra_scripts = pre:hwids/usb.py
board_build.usb_product = "8BitDo SN30 Pro+"
board_vendor = "8BitDo"

[out-bt]
build_flags = -DGAMEPAD_OUTPUT=3
src_filter = +<gamepad/ESP32-BLE-Gamepad>

[out-usbradio]
extends     = out-usb, out-radio
build_flags = -DGAMEPAD_OUTPUT=4
src_filter = ${out-usb.src_filter} ${out-radio.src_filter}
extra_scripts = pre:hwids/usb.py
board_build.usb_product = "8BitDo SN30 Pro+"
board_vendor = "8BitDo"

[out-switchusb]
# switch only supports 1 controller per dongle
build_flags = -DGAMEPAD_OUTPUT=5 -DGAMEPAD_COUNT=1
src_filter = +<gamepad/Switch-USB-Gamepad>
lib_deps = https://github.com/OpenRetroPad/HID
extra_scripts = pre:hwids/switch.py
board_build.usb_product = "HORIPAD S"
board_vendor = "HORI CO.,LTD."

# radio input

[in-radio]
extends = out-radio
src_filter = -<*> +<RadioReceiver.cpp>
build_flags = ${common.build_flags} -DGAMEPAD_INPUT=1

# this one is a bit crazy, just use esp32-$input-bt directly
[env:esp32-radio-bt]
extends     = esp32, in-radio, out-bt
src_filter  = ${in-radio.src_filter}  ${out-bt.src_filter}
build_flags = ${in-radio.build_flags} ${out-bt.build_flags}

[env:esp32-radio-debug]
extends     = esp32, in-radio, out-debug
src_filter  = ${in-radio.src_filter}  ${out-debug.src_filter}
build_flags = ${in-radio.build_flags} ${out-debug.build_flags}

[env:micro-radio-usb]
extends     = micro, in-radio, out-usb
src_filter  = ${in-radio.src_filter}  ${out-usb.src_filter}
build_flags = ${in-radio.build_flags} ${out-usb.build_flags}

[env:micro-radio-debug]
extends     = micro, in-radio, out-debug
src_filter  = ${in-radio.src_filter}  ${out-debug.src_filter}
build_flags = ${in-radio.build_flags} ${out-debug.build_flags}

[env:micro-radio-switchusb]
extends     = micro, in-radio, out-switchusb
src_filter  = ${in-radio.src_filter}  ${out-switchusb.src_filter}
build_flags = ${in-radio.build_flags} ${out-switchusb.build_flags}
lib_deps    = ${in-radio.lib_deps}, ${out-switchusb.lib_deps}

# not enough pins for env:micro-radio-radio , plus it'd be crazy

# snes input

[in-snes]
src_filter = -<*> +<SnesNes.cpp>
build_flags = ${common.build_flags} -DGAMEPAD_INPUT=2

[env:esp32-snes-bt]
extends     = esp32, in-snes, out-bt
src_filter  = ${in-snes.src_filter}  ${out-bt.src_filter}
build_flags = ${in-snes.build_flags} ${out-bt.build_flags}

[env:esp32-snes-debug]
extends     = esp32, in-snes, out-debug
src_filter  = ${in-snes.src_filter}  ${out-debug.src_filter}
build_flags = ${in-snes.build_flags} ${out-debug.build_flags}

[env:micro-snes-usb]
extends     = micro, in-snes, out-usb
src_filter  = ${in-snes.src_filter}  ${out-usb.src_filter}
build_flags = ${in-snes.build_flags} ${out-usb.build_flags}

[env:micro-snes-debug]
extends     = micro, in-snes, out-debug
src_filter  = ${in-snes.src_filter}  ${out-debug.src_filter}
build_flags = ${in-snes.build_flags} ${out-debug.build_flags}

[env:micro-snes-radio]
extends     = micro, in-snes, out-radio
src_filter  = ${in-snes.src_filter}  ${out-radio.src_filter}
build_flags = ${in-snes.build_flags} ${out-radio.build_flags}

[env:micro-snes-usbradio]
extends     = micro, in-snes, out-usbradio
src_filter  = ${in-snes.src_filter}  ${out-usbradio.src_filter}
build_flags = ${in-snes.build_flags} ${out-usbradio.build_flags}

[env:micro-snes-switchusb]
extends     = micro, in-snes, out-switchusb
src_filter  = ${in-snes.src_filter}  ${out-switchusb.src_filter}
build_flags = ${in-snes.build_flags} ${out-switchusb.build_flags}

# n64 input

[in-n64-esp32]
src_filter = -<*> +<N64Esp32.cpp>
build_flags = ${common.build_flags} -DGAMEPAD_INPUT=3 -DGAMEPAD_COUNT=1 -O0

[in-n64-micro]
src_filter = -<*> +<N64Micro.cpp>
build_flags = ${common.build_flags} -DGAMEPAD_INPUT=3 -DGAMEPAD_COUNT=1
lib_deps = https://github.com/OpenRetroPad/Nintendo

[env:esp32-n64-bt]
extends     = esp32, in-n64-esp32, out-bt
src_filter  = ${in-n64-esp32.src_filter}  ${out-bt.src_filter}
build_flags = ${in-n64-esp32.build_flags} ${out-bt.build_flags}

[env:esp32-n64-debug]
extends     = esp32, in-n64-esp32, out-debug
src_filter  = ${in-n64-esp32.src_filter}  ${out-debug.src_filter}
build_flags = ${in-n64-esp32.build_flags} ${out-debug.build_flags}

[env:micro-n64-usb]
extends     = micro, in-n64-micro, out-usb
src_filter  = ${in-n64-micro.src_filter}  ${out-usb.src_filter}
build_flags = ${in-n64-micro.build_flags} ${out-usb.build_flags}

[env:micro-n64-debug]
extends     = micro, in-n64-micro, out-debug
src_filter  = ${in-n64-micro.src_filter}  ${out-debug.src_filter}
build_flags = ${in-n64-micro.build_flags} ${out-debug.build_flags}

[env:micro-n64-radio]
extends     = micro, in-n64-micro, out-radio
src_filter  = ${in-n64-micro.src_filter}  ${out-radio.src_filter}
build_flags = ${in-n64-micro.build_flags} ${out-radio.build_flags}
lib_deps    = ${in-n64-micro.lib_deps},   ${out-radio.lib_deps}

[env:micro-n64-usbradio]
extends     = micro, in-n64-micro, out-usbradio
src_filter  = ${in-n64-micro.src_filter}  ${out-usbradio.src_filter}
build_flags = ${in-n64-micro.build_flags} ${out-usbradio.build_flags}
lib_deps    = ${in-n64-micro.lib_deps},   ${out-usbradio.lib_deps}

[env:micro-n64-switchusb]
extends     = micro, in-n64-micro, out-switchusb
src_filter  = ${in-n64-micro.src_filter}  ${out-switchusb.src_filter}
build_flags = ${in-n64-micro.build_flags} ${out-switchusb.build_flags}
lib_deps    = ${in-n64-micro.lib_deps},   ${out-switchusb.lib_deps}

# genesis input

[in-genesis]
src_filter = -<*> +<SegaGenesis.cpp>
build_flags = ${common.build_flags} -DGAMEPAD_INPUT=4

[env:esp32-genesis-bt]
extends     = esp32, in-genesis, out-bt
src_filter  = ${in-genesis.src_filter}  ${out-bt.src_filter}
build_flags = ${in-genesis.build_flags} ${out-bt.build_flags}

[env:esp32-genesis-debug]
extends     = esp32, in-genesis, out-debug
src_filter  = ${in-genesis.src_filter}  ${out-debug.src_filter}
build_flags = ${in-genesis.build_flags} ${out-debug.build_flags}

[env:micro-genesis-usb]
extends     = micro, in-genesis, out-usb
src_filter  = ${in-genesis.src_filter}  ${out-usb.src_filter}
build_flags = ${in-genesis.build_flags} ${out-usb.build_flags}

[env:micro-genesis-debug]
extends     = micro, in-genesis, out-debug
src_filter  = ${in-genesis.src_filter}  ${out-debug.src_filter}
build_flags = ${in-genesis.build_flags} ${out-debug.build_flags}

# micro doesn't have enough pins for both radio and 2 gamepads
# so these must be built with only support for 1 gamepad

[env:micro-genesis-radio]
extends     = micro, in-genesis, out-radio
src_filter  = ${in-genesis.src_filter}  ${out-radio.src_filter}
build_flags = ${in-genesis.build_flags} ${out-radio.build_flags} -DGAMEPAD_COUNT=1

[env:micro-genesis-usbradio]
extends     = micro, in-genesis, out-usbradio
src_filter  = ${in-genesis.src_filter}  ${out-usbradio.src_filter}
build_flags = ${in-genesis.build_flags} ${out-usbradio.build_flags} -DGAMEPAD_COUNT=1

[env:micro-genesis-switchusb]
extends     = micro, in-genesis, out-switchusb
src_filter  = ${in-genesis.src_filter}  ${out-switchusb.src_filter}
build_flags = ${in-genesis.build_flags} ${out-switchusb.build_flags}

# psx input

[in-psx]
src_filter = -<*> +<Playstation.cpp>
build_flags = ${common.build_flags} -DGAMEPAD_INPUT=5 -DGAMEPAD_COUNT=4

[env:esp32-psx-bt]
extends     = esp32, in-psx, out-bt
src_filter  = ${in-psx.src_filter}  ${out-bt.src_filter}
build_flags = ${in-psx.build_flags} ${out-bt.build_flags}

[env:esp32-psx-debug]
extends     = esp32, in-psx, out-debug
src_filter  = ${in-psx.src_filter}  ${out-debug.src_filter}
build_flags = ${in-psx.build_flags} ${out-debug.build_flags}

[env:micro-psx-usb]
extends     = micro, in-psx, out-usb
src_filter  = ${in-psx.src_filter}  ${out-usb.src_filter}
build_flags = ${in-psx.build_flags} ${out-usb.build_flags}

[env:micro-psx-debug]
extends     = micro, in-psx, out-debug
src_filter  = ${in-psx.src_filter}  ${out-debug.src_filter}
build_flags = ${in-psx.build_flags} ${out-debug.build_flags}

[env:micro-psx-radio]
extends     = micro, in-psx, out-radio
src_filter  = ${in-psx.src_filter}  ${out-radio.src_filter}
build_flags = ${in-psx.build_flags} ${out-radio.build_flags}

[env:micro-psx-usbradio]
extends     = micro, in-psx, out-usbradio
src_filter  = ${in-psx.src_filter}  ${out-usbradio.src_filter}
build_flags = ${in-psx.build_flags} ${out-usbradio.build_flags}

[env:micro-psx-switchusb]
extends     = micro, in-psx, out-switchusb
src_filter  = ${in-psx.src_filter}  ${out-switchusb.src_filter}
build_flags = ${in-psx.build_flags} ${out-switchusb.build_flags}

# gc input

[in-gc-micro]
src_filter = -<*> +<N64Micro.cpp>
build_flags = ${common.build_flags} -DGAMEPAD_INPUT=5 -DGAMEPAD_COUNT=1 -DGAMECUBE
lib_deps = https://github.com/OpenRetroPad/Nintendo

[env:micro-gc-usb]
extends     = micro, in-gc-micro, out-usb
src_filter  = ${in-gc-micro.src_filter}  ${out-usb.src_filter}
build_flags = ${in-gc-micro.build_flags} ${out-usb.build_flags}

[env:micro-gc-debug]
extends     = micro, in-gc-micro, out-debug
src_filter  = ${in-gc-micro.src_filter}  ${out-debug.src_filter}
build_flags = ${in-gc-micro.build_flags} ${out-debug.build_flags}

[env:micro-gc-radio]
extends     = micro, in-gc-micro, out-radio
src_filter  = ${in-gc-micro.src_filter}  ${out-radio.src_filter}
build_flags = ${in-gc-micro.build_flags} ${out-radio.build_flags}
lib_deps    = ${in-gc-micro.lib_deps},   ${out-radio.lib_deps}

[env:micro-gc-usbradio]
extends     = micro, in-gc-micro, out-usbradio
src_filter  = ${in-gc-micro.src_filter}  ${out-usbradio.src_filter}
build_flags = ${in-gc-micro.build_flags} ${out-usbradio.build_flags}
lib_deps    = ${in-gc-micro.lib_deps},   ${out-usbradio.lib_deps}

[env:micro-gc-switchusb]
extends     = micro, in-gc-micro, out-switchusb
src_filter  = ${in-gc-micro.src_filter}  ${out-switchusb.src_filter}
build_flags = ${in-gc-micro.build_flags} ${out-switchusb.build_flags}
lib_deps    = ${in-gc-micro.lib_deps},   ${out-switchusb.lib_deps}


# debug input

[in-debug]
src_filter = -<*> +<Debug.cpp>
build_flags = ${common.build_flags} -DGAMEPAD_INPUT=0 -DDEBUG=1

[env:esp32-debug-bt]
extends     = esp32, in-debug, out-bt
src_filter  = ${in-debug.src_filter}  ${out-bt.src_filter}
build_flags = ${in-debug.build_flags} ${out-bt.build_flags}

[env:esp32-debug-debug]
extends     = esp32, in-debug, out-debug
src_filter  = ${in-debug.src_filter}  ${out-debug.src_filter}
build_flags = ${in-debug.build_flags} ${out-debug.build_flags}

[env:micro-debug-usb]
extends     = micro, in-debug, out-usb
src_filter  = ${in-debug.src_filter}  ${out-usb.src_filter}
build_flags = ${in-debug.build_flags} ${out-usb.build_flags}

[env:micro-debug-debug]
extends     = micro, in-debug, out-debug
src_filter  = ${in-debug.src_filter}  ${out-debug.src_filter}
build_flags = ${in-debug.build_flags} ${out-debug.build_flags}

[env:micro-debug-radio]
extends     = micro, in-debug, out-radio
src_filter  = ${in-debug.src_filter}  ${out-radio.src_filter}
build_flags = ${in-debug.build_flags} ${out-radio.build_flags}

[env:micro-debug-usbradio]
extends     = micro, in-debug, out-usbradio
src_filter  = ${in-debug.src_filter}  ${out-usbradio.src_filter}
build_flags = ${in-debug.build_flags} ${out-usbradio.build_flags}

[env:micro-debug-switchusb]
extends     = micro, in-debug, out-switchusb
src_filter  = ${in-debug.src_filter}  ${out-switchusb.src_filter}
build_flags = ${in-debug.build_flags} ${out-switchusb.build_flags}
