Organize firmware sources by responsibility

This commit is contained in:
Joey Yakimowich-Payne 2026-09-03 14:28:09 -06:00
commit 200ffc92be
101 changed files with 295 additions and 305 deletions

View file

@ -1,5 +1,4 @@
#include "adapter_host_probe.h"
#include "adapter/adapter_host_probe.h"
#include <cstdint>
#include <cstdlib>
#include <cstring>
@ -7,7 +6,7 @@
#include "hardware/structs/watchdog.h"
#include "pico/time.h"
#include "xinput_descriptors.h"
#include "usb/xinput/xinput_descriptors.h"
namespace {

View file

@ -1,16 +1,15 @@
#include "adapter_mode_controller.h"
#include "adapter/adapter_mode_controller.h"
#include <algorithm>
#include <cstdint>
#include <cstdlib>
#include <iostream>
#include <vector>
#include "adapter_configuration.h"
#include "adapter_reboot.h"
#include "bluepad32_input_backend.h"
#include "configuration_service.h"
#include "controller_profile.h"
#include "configuration/adapter_configuration.h"
#include "adapter/adapter_reboot.h"
#include "input/bluepad32_input_backend.h"
#include "configuration/configuration_service.h"
#include "profile/controller_profile.h"
namespace {

View file

@ -4,7 +4,7 @@
#include <string>
#include <uni.h>
#include "../controller_color_config.h"
#include "platform/pico/controller_color_config.h"
namespace {
@ -442,8 +442,9 @@ uint32_t btstack_run_loop_get_time_ms() {
}
#include "../controller_identity.cpp"
#include "../bluepad32_input_backend.cpp"
#include "core/controller_identity.cpp"
#include "input/bluepad32_input_backend.cpp"
namespace {
void require_clear_completion_pending() {
if (expected_pending_clear_token != 0) {

View file

@ -1,5 +1,4 @@
#include "bootsel_pairing_button.h"
#include "platform/pico/bootsel_pairing_button.h"
#include <cstdlib>
#include <cstdint>
#include <iostream>

View file

@ -1,8 +1,7 @@
#include "adapter_configuration.h"
#include "configuration_service.h"
#include "configuration_storage.h"
#include "pico_configuration_storage.h"
#include "configuration/adapter_configuration.h"
#include "configuration/configuration_service.h"
#include "configuration/configuration_storage.h"
#include "platform/pico/pico_configuration_storage.h"
#include <cstdlib>
#include <cstring>
#include <iostream>

View file

@ -1,7 +1,6 @@
#include "adapter_configuration.h"
#include "configuration_storage.h"
#include "configuration_transaction.h"
#include "configuration/adapter_configuration.h"
#include "configuration/configuration_storage.h"
#include "configuration/configuration_transaction.h"
#include <cstdlib>
#include <cstring>
#include <iostream>

View file

@ -2,7 +2,7 @@
#include <stdint.h>
#include "controller_profile.h"
#include "profile/controller_profile.h"
constexpr uint8_t kLegacyDefaultProfile[CONTROLLER_PROFILE_ENCODED_SIZE] = {
0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,

View file

@ -1,9 +1,7 @@
#include "controller_profile_runtime.h"
#include "controller_identity.h"
#include "controller_profile.h"
#include "profile_service.h"
#include "profile/controller_profile_runtime.h"
#include "core/controller_identity.h"
#include "profile/controller_profile.h"
#include "profile/profile_service.h"
#include <array>
#include <cstdlib>
#include <cstring>

View file

@ -1,6 +1,6 @@
#include "controller_identity.h"
#include "controller_profile.h"
#include "tests/controller_profile_legacy_fixtures.h"
#include "core/controller_identity.h"
#include "profile/controller_profile.h"
#include "controller_profile_legacy_fixtures.h"
#include <cstdlib>
#include <cstring>

View file

@ -1,7 +1,6 @@
#include "controller_identity.h"
#include "controller_profile.h"
#include "controller_profile_transform.h"
#include "core/controller_identity.h"
#include "profile/controller_profile.h"
#include "profile/controller_profile_transform.h"
#include <cstdlib>
#include <cstring>
#include <iostream>

View file

@ -1,5 +1,4 @@
#include "controller_synthetic_input.h"
#include "profile/controller_synthetic_input.h"
#include <array>
#include <cstdlib>
#include <cstring>

View file

@ -1,5 +1,4 @@
#include "generic_hid_descriptors.h"
#include "usb/generic_hid/generic_hid_descriptors.h"
#include <array>
#include <cstddef>
#include <cstdint>

View file

@ -1,7 +1,5 @@
#include "generic_hid_driver.h"
#include "generic_hid_descriptors.h"
#include "usb/generic_hid/generic_hid_driver.h"
#include "usb/generic_hid/generic_hid_descriptors.h"
#include <array>
#include <cstddef>
#include <cstdint>

View file

@ -1,9 +1,8 @@
#include "controller_identity.h"
#include "controller_profile.h"
#include "pico_profile_storage.h"
#include "profile_service.h"
#include "profile_storage.h"
#include "core/controller_identity.h"
#include "profile/controller_profile.h"
#include "platform/pico/pico_profile_storage.h"
#include "profile/profile_service.h"
#include "profile/profile_storage.h"
#include <cstdlib>
#include <cstring>
#include <iostream>

View file

@ -1,7 +1,7 @@
#include "controller_identity.h"
#include "controller_profile.h"
#include "profile_storage.h"
#include "tests/controller_profile_legacy_fixtures.h"
#include "core/controller_identity.h"
#include "profile/controller_profile.h"
#include "profile/profile_storage.h"
#include "controller_profile_legacy_fixtures.h"
#include <cstdlib>
#include <cstring>

View file

@ -1,5 +1,4 @@
#include "switch_haptics.h"
#include "usb/switch/switch_haptics.h"
#include <array>
#include <cstdint>
#include <iostream>

View file

@ -1,6 +1,5 @@
#include "switch_pro_descriptors.h"
#include "tusb_config.h"
#include "usb/switch/switch_pro_descriptors.h"
#include "platform/pico/tusb_config.h"
#include <array>
#include <cstddef>
#include <cstdint>

View file

@ -1,6 +1,6 @@
#include "switch_pro_driver.h"
#include "usb_output_driver.h"
#include "controller_color_config.h"
#include "usb/switch/switch_pro_driver.h"
#include "usb/usb_output_driver.h"
#include "platform/pico/controller_color_config.h"
#include "tusb.h"
#include "pico/time.h"

View file

@ -20,8 +20,8 @@ def test_adapter_host_probe_native(tmp_path: Path) -> None:
"-pedantic",
"-DSWITCH_PICO_HID_INSTANCE_COUNT=4",
f"-I{root / 'tests' / 'mode_native_stubs'}",
f"-I{root}",
str(root / "adapter_host_probe.cpp"),
f"-I{root / 'src' / 'firmware'}",
str(root / "src" / "firmware" / "adapter" / "adapter_host_probe.cpp"),
str(root / "tests" / "adapter_host_probe_test.cpp"),
"-o",
str(executable),

View file

@ -20,8 +20,8 @@ def test_adapter_mode_controller_native(tmp_path: Path) -> None:
"-pedantic",
"-DSWITCH_PICO_HID_INSTANCE_COUNT=4",
f"-I{root / 'tests' / 'mode_native_stubs'}",
f"-I{root}",
str(root / "adapter_mode_controller.cpp"),
f"-I{root / 'src' / 'firmware'}",
str(root / "src" / "firmware" / "adapter" / "adapter_mode_controller.cpp"),
str(root / "tests" / "adapter_mode_controller_test.cpp"),
"-o",
str(executable),

View file

@ -27,7 +27,7 @@ def test_bluepad32_backend_lifecycle_native(tmp_path: Path) -> None:
command.extend(
[
f"-I{root / 'tests' / 'bluepad32_native_stubs'}",
f"-I{root}",
f"-I{root / 'src' / 'firmware'}",
str(root / "tests" / "bluepad32_backend_lifecycle_test.cpp"),
"-o",
str(executable),

View file

@ -22,8 +22,8 @@ def test_bootsel_pairing_button_native(tmp_path: Path) -> None:
"-pedantic",
f"-DPICO_RP2350={rp2350}",
f"-I{root / 'tests' / 'bootsel_native_stubs'}",
f"-I{root}",
str(root / "bootsel_pairing_button.cpp"),
f"-I{root / 'src' / 'firmware'}",
str(root / "src" / "firmware" / "platform" / "pico" / "bootsel_pairing_button.cpp"),
str(root / "tests" / "bootsel_pairing_button_test.cpp"),
"-o",
str(executable),

View file

@ -18,12 +18,12 @@ def test_configuration_service_native(tmp_path: Path) -> None:
"-Werror",
"-pedantic",
f"-I{root / 'tests' / 'bluepad32_native_stubs'}",
f"-I{root}",
f"-I{root / 'src' / 'firmware'}",
str(root / "tests" / "configuration_service_test.cpp"),
str(root / "adapter_configuration.cpp"),
str(root / "configuration_service.cpp"),
str(root / "configuration_storage.cpp"),
str(root / "configuration_transaction.cpp"),
str(root / "src" / "firmware" / "configuration" / "adapter_configuration.cpp"),
str(root / "src" / "firmware" / "configuration" / "configuration_service.cpp"),
str(root / "src" / "firmware" / "configuration" / "configuration_storage.cpp"),
str(root / "src" / "firmware" / "configuration" / "configuration_transaction.cpp"),
"-o",
str(executable),
],

View file

@ -17,11 +17,11 @@ def test_configuration_storage_native(tmp_path: Path) -> None:
"-Wextra",
"-Werror",
"-pedantic",
f"-I{root}",
f"-I{root / 'src' / 'firmware'}",
str(root / "tests" / "configuration_storage_test.cpp"),
str(root / "adapter_configuration.cpp"),
str(root / "configuration_storage.cpp"),
str(root / "configuration_transaction.cpp"),
str(root / "src" / "firmware" / "configuration" / "adapter_configuration.cpp"),
str(root / "src" / "firmware" / "configuration" / "configuration_storage.cpp"),
str(root / "src" / "firmware" / "configuration" / "configuration_transaction.cpp"),
"-o",
str(executable),
],

View file

@ -17,10 +17,10 @@ def test_controller_profile_native(tmp_path: Path) -> None:
"-Wextra",
"-Werror",
"-pedantic",
f"-I{root}",
f"-I{root / 'src' / 'firmware'}",
str(root / "tests" / "controller_profile_test.cpp"),
str(root / "controller_identity.cpp"),
str(root / "controller_profile.cpp"),
str(root / "src" / "firmware" / "core" / "controller_identity.cpp"),
str(root / "src" / "firmware" / "profile" / "controller_profile.cpp"),
"-o",
str(executable),
],

View file

@ -17,13 +17,13 @@ def test_controller_profile_runtime_native(tmp_path: Path) -> None:
"-Wextra",
"-Werror",
"-pedantic",
f"-I{root}",
f"-I{root / 'src' / 'firmware'}",
str(root / "tests" / "controller_profile_runtime_test.cpp"),
str(root / "controller_identity.cpp"),
str(root / "controller_profile.cpp"),
str(root / "controller_profile_transform.cpp"),
str(root / "controller_synthetic_input.cpp"),
str(root / "controller_profile_runtime.cpp"),
str(root / "src" / "firmware" / "core" / "controller_identity.cpp"),
str(root / "src" / "firmware" / "profile" / "controller_profile.cpp"),
str(root / "src" / "firmware" / "profile" / "controller_profile_transform.cpp"),
str(root / "src" / "firmware" / "profile" / "controller_synthetic_input.cpp"),
str(root / "src" / "firmware" / "profile" / "controller_profile_runtime.cpp"),
"-o",
str(executable),
],

View file

@ -17,11 +17,11 @@ def test_controller_profile_transform_native(tmp_path: Path) -> None:
"-Wextra",
"-Werror",
"-pedantic",
f"-I{root}",
f"-I{root / 'src' / 'firmware'}",
str(root / "tests" / "controller_profile_transform_test.cpp"),
str(root / "controller_identity.cpp"),
str(root / "controller_profile.cpp"),
str(root / "controller_profile_transform.cpp"),
str(root / "src" / "firmware" / "core" / "controller_identity.cpp"),
str(root / "src" / "firmware" / "profile" / "controller_profile.cpp"),
str(root / "src" / "firmware" / "profile" / "controller_profile_transform.cpp"),
"-o",
str(executable),
],

View file

@ -17,12 +17,12 @@ def test_controller_synthetic_input_native(tmp_path: Path) -> None:
"-Wextra",
"-Werror",
"-pedantic",
f"-I{root}",
f"-I{root / 'src' / 'firmware'}",
str(root / "tests" / "controller_synthetic_input_test.cpp"),
str(root / "controller_identity.cpp"),
str(root / "controller_profile.cpp"),
str(root / "controller_profile_transform.cpp"),
str(root / "controller_synthetic_input.cpp"),
str(root / "src" / "firmware" / "core" / "controller_identity.cpp"),
str(root / "src" / "firmware" / "profile" / "controller_profile.cpp"),
str(root / "src" / "firmware" / "profile" / "controller_profile_transform.cpp"),
str(root / "src" / "firmware" / "profile" / "controller_synthetic_input.cpp"),
"-o",
str(executable),
],

View file

@ -32,7 +32,7 @@ def compile_cpp(
command.append(f"-I{root / 'tests' / 'native_stubs'}")
command.extend(
[
f"-I{root}",
f"-I{root / 'src' / 'firmware'}",
*[str(source) for source in sources],
"-o",
str(output),
@ -98,7 +98,7 @@ def test_generic_hid_driver_contexts(tmp_path: Path) -> None:
host_compiler(),
executable,
[
root / "generic_hid_driver.cpp",
root / "src" / "firmware" / "usb" / "generic_hid" / "generic_hid_driver.cpp",
root / "tests" / "generic_hid_driver_test.cpp",
],
["SWITCH_PICO_HID_INSTANCE_COUNT=4"],

View file

@ -18,12 +18,12 @@ def test_profile_service_native(tmp_path: Path) -> None:
"-Werror",
"-pedantic",
f"-I{root / 'tests' / 'bluepad32_native_stubs'}",
f"-I{root}",
f"-I{root / 'src' / 'firmware'}",
str(root / "tests" / "profile_service_test.cpp"),
str(root / "controller_identity.cpp"),
str(root / "controller_profile.cpp"),
str(root / "profile_storage.cpp"),
str(root / "profile_service.cpp"),
str(root / "src" / "firmware" / "core" / "controller_identity.cpp"),
str(root / "src" / "firmware" / "profile" / "controller_profile.cpp"),
str(root / "src" / "firmware" / "profile" / "profile_storage.cpp"),
str(root / "src" / "firmware" / "profile" / "profile_service.cpp"),
"-o",
str(executable),
],

View file

@ -17,11 +17,11 @@ def test_profile_storage_native(tmp_path: Path) -> None:
"-Wextra",
"-Werror",
"-pedantic",
f"-I{root}",
f"-I{root / 'src' / 'firmware'}",
str(root / "tests" / "profile_storage_test.cpp"),
str(root / "controller_identity.cpp"),
str(root / "controller_profile.cpp"),
str(root / "profile_storage.cpp"),
str(root / "src" / "firmware" / "core" / "controller_identity.cpp"),
str(root / "src" / "firmware" / "profile" / "controller_profile.cpp"),
str(root / "src" / "firmware" / "profile" / "profile_storage.cpp"),
"-o",
str(executable),
],

View file

@ -19,8 +19,8 @@ def test_switch_haptics_native(tmp_path: Path) -> None:
"-Wextra",
"-Werror",
"-pedantic",
f"-I{root}",
str(root / "switch_haptics.cpp"),
f"-I{root / 'src' / 'firmware'}",
str(root / "src" / "firmware" / "usb" / "switch" / "switch_haptics.cpp"),
str(root / "tests" / "switch_haptics_test.cpp"),
"-o",
str(executable),

View file

@ -25,7 +25,7 @@ def compile_descriptor_test(
command.append(f"-DSWITCH_PICO_HID_INSTANCE_COUNT={configured_count}")
command.extend(
[
f"-I{root}",
f"-I{root / 'src' / 'firmware'}",
str(root / "tests" / "switch_pro_descriptors_test.cpp"),
"-o",
str(output),

View file

@ -21,10 +21,10 @@ def test_switch_pro_driver_four_contexts_native(tmp_path: Path) -> None:
"-pedantic",
"-DSWITCH_PICO_HID_INSTANCE_COUNT=4",
f"-I{root / 'tests' / 'native_stubs'}",
f"-I{root}",
str(root / "switch_pro_driver.cpp"),
str(root / "usb_output_driver.cpp"),
str(root / "switch_haptics.cpp"),
f"-I{root / 'src' / 'firmware'}",
str(root / "src" / "firmware" / "usb" / "switch" / "switch_pro_driver.cpp"),
str(root / "src" / "firmware" / "usb" / "usb_output_driver.cpp"),
str(root / "src" / "firmware" / "usb" / "switch" / "switch_haptics.cpp"),
str(root / "tests" / "switch_pro_driver_context_test.cpp"),
"-o",
str(executable),

View file

@ -19,7 +19,7 @@ def test_usb_configuration_management_native(tmp_path: Path) -> None:
"-Werror",
"-pedantic",
f"-I{root / 'tests' / 'usb_management_native_stubs'}",
f"-I{root}",
f"-I{root / 'src' / 'firmware'}",
str(root / "tests" / "usb_configuration_management_test.cpp"),
"-o",
str(executable),

View file

@ -36,13 +36,13 @@ def test_usb_output_driver_contracts(tmp_path: Path) -> None:
"-DSWITCH_PICO_USB_OUTPUT_MODES=1",
*backend_definitions,
f"-I{root / 'tests' / 'native_stubs'}",
f"-I{root}",
f"-I{root / 'src' / 'firmware'}",
str(root / "tests" / "usb_output_driver_test.cpp"),
str(root / "switch_pro_driver.cpp"),
str(root / "usb_output_driver.cpp"),
str(root / "generic_hid_driver.cpp"),
str(root / "xinput_driver.cpp"),
str(root / "switch_haptics.cpp"),
str(root / "src" / "firmware" / "usb" / "switch" / "switch_pro_driver.cpp"),
str(root / "src" / "firmware" / "usb" / "usb_output_driver.cpp"),
str(root / "src" / "firmware" / "usb" / "generic_hid" / "generic_hid_driver.cpp"),
str(root / "src" / "firmware" / "usb" / "xinput" / "xinput_driver.cpp"),
str(root / "src" / "firmware" / "usb" / "switch" / "switch_haptics.cpp"),
"-o",
str(executable),
],

View file

@ -1,12 +1,11 @@
#include "usb_configuration_management.h"
#include "usb/usb_configuration_management.h"
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <tusb.h>
#include "usb_output_driver.h"
#include "usb/usb_output_driver.h"
namespace {
@ -788,10 +787,10 @@ bool tud_control_status(uint8_t, const tusb_control_request_t*) {
return true;
}
#include "../adapter_configuration.cpp"
#include "../controller_identity.cpp"
#include "../controller_profile.cpp"
#include "../usb_configuration_management.cpp"
#include "configuration/adapter_configuration.cpp"
#include "core/controller_identity.cpp"
#include "profile/controller_profile.cpp"
#include "usb/usb_configuration_management.cpp"
int main() {
current_configuration.state = ConfigurationServiceState::kReady;

View file

@ -4,17 +4,17 @@
#include <cstring>
#include <iostream>
#include "adapter_host_probe_state.h"
#include "generic_hid_descriptors.h"
#include "generic_hid_driver.h"
#include "xinput_descriptors.h"
#include "xinput_protocol.h"
#include "adapter/adapter_host_probe_state.h"
#include "usb/generic_hid/generic_hid_descriptors.h"
#include "usb/generic_hid/generic_hid_driver.h"
#include "usb/xinput/xinput_descriptors.h"
#include "usb/xinput/xinput_protocol.h"
#include "device/usbd_pvt.h"
#include "pico/time.h"
#include "switch_pro_driver.h"
#include "usb/switch/switch_pro_driver.h"
#include "tusb.h"
#include "usb_output_driver.h"
#include "xinput_driver.h"
#include "usb/usb_output_driver.h"
#include "usb/xinput/xinput_driver.h"
namespace {