Skip to content

183 host add webusb#184

Merged
Tails86 merged 114 commits intomainfrom
183-host-add-webusb
Sep 6, 2025
Merged

183 host add webusb#184
Tails86 merged 114 commits intomainfrom
183-host-add-webusb

Conversation

@Tails86
Copy link
Collaborator

@Tails86 Tails86 commented Aug 30, 2025

  • Added configurable settings
  • Added player detection capability
    • By default, poll each player. Once detection is made, permanently enable that controller.
    • Can be changed in settings
    • This removes the need to have 1, 2, 4 player variants of the binary as this can be configured at runtime by the user
    • Player detection modes: Disabled, Enabled, Disabled, Enable On Detect, Auto, Auto, No Disable
  • Added WebUSB interfaces, and all functionality may be accessed through this interface
  • Disable Mass Storage Class (MSC) by default but allow this to be enabled through the WebUSB interface
    • I am not going to support any issues with MSC going forward
    • Read/write of VMUs may now be accessed through WebUSB and the webpage
  • Added WebUSB page which can change settings: https://orangefox86.github.io/DreamPicoPort/webusb/
    • Safari and Firefox don't support WebUSB. As far as I can tell, only Chromium-based browsers support this. These browsers capture about 70% of users
    • Firefox backs up its decision not to support WebUSB due to security concerns, but the user must be asked to select a device before the page gets access to it (unless the page is running locally). I'm a Firefox user myself, so it sucks that I have to manually open in another browser, but I don't feel that will be a deal breaker for many.
  • USB version now matches the release version
  • Serial is now set in all USB string descriptors - this will provide a way to link an SDL instance to libUSB instance more easily on Linux and Mac since serial is not always exposed due to permissions, but the device name is
    • I would like to allow multiple instances of the hardware on a system to function in the future whereas right now, flycast only supports 1 DPP board plugged in
  • Tweaks to Maple packet handling so that byte order may be specified (reduces the need to swap bytes on WebUSB and TTY interfaces)
  • Allow the Maple packet handling to hold a shared_ptr to something. I'm leveraging this in the WinUSB implementation so that I can create an object and automatically have it destroyed once a response is sent over WinUSB due to Maple communication completion.

James Smith added 30 commits July 14, 2025 06:58
…order and use NETWORK order in Maple passthrough parsers
Copy link
Collaborator

@kosekmi kosekmi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional testing on MacOS and Linux (Raspberry Pi OS) concluded, ready for merge

@Tails86
Copy link
Collaborator Author

Tails86 commented Sep 2, 2025

Thanks @kosekmi for your help testing this!

I don't plan on making any more changes to this branch, but I want to sit on it until Sep 5 to make sure no more "one more thing" pops into my mind.

@Tails86 Tails86 requested a review from Copilot September 4, 2025 00:31

This comment was marked as outdated.

@Tails86
Copy link
Collaborator Author

Tails86 commented Sep 6, 2025

Ok, I did end up with a couple more "one more things"...

  • I noticed an issue with flycast integration when just B&C were enabled. There was an indexing issue because internally B was mapped to 0 and C was mapped to 1, but flycast addressed them as 1 and 2 respectively. Indexing is fixed now so that A is always 0, B is always 1, etc. Flycast defaults to using 0 when only 1 controller is detected on a DPP, so that edge case needed to be accounted for in FlycastTtyCommandHandler as well.
  • SDL waits for first input then sends full on then off trigger values for a connected gamepad, so I added another command to force the gamepad to send its state to the host so that this could be triggered (as a future workaround for this weird thing SDL does)
  • Removed printf that was used for debugging which shouldn't have been committed

I'll wait at least another 12 hours before I click merge.

@Tails86 Tails86 requested a review from Copilot September 6, 2025 01:44
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request implements a major refactor to add WebUSB support, configurable settings, and player auto-detection while consolidating multiple player variants into a single build. The changes enable runtime configuration through a web interface and provide device detection capabilities.

  • Adds WebUSB interface for device configuration and control through a web page
  • Implements configurable settings system with persistent storage in flash memory
  • Replaces fixed player count builds with runtime-configurable auto-detection system

Reviewed Changes

Copilot reviewed 109 out of 110 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/main/Host/host_setup.hpp/cpp New setup functions for configuring Dreamcast nodes and parsers
src/main/Host/host_main.cpp New main host implementation with auto-detection and settings support
src/main/Host/host.cpp Removed old host implementation
src/main/Host/CMakeLists.txt Updated to build single host binary instead of multiple variants
src/main/Client/client_usb_host_main.cpp Fixed static cast warning
src/hostLib/webusb_parsers/* New WebUSB command handlers for settings, maple bus, and flycast communication
src/hostLib/tty_parsers/* Refactored TTY parsers with updated interfaces and node data structures
src/hostLib/test/* Updated test files to match new interfaces and data structures
src/hostLib/peripherals/* Updated peripheral classes to use shared pointer interfaces
src/hostLib/* Core library updates for new transmission system and data structures
src/hal/Usb/Client/* WebUSB implementation and USB descriptor updates
src/hal/System/* New settings system and identification updates
src/hal/MapleBus/* Enhanced maple bus with configurable byte order support
Comments suppressed due to low confidence (2)

src/hostLib/webusb_parsers/SettingsWebUsbCommandHandler.cpp:1

  • The variable type has been changed from uint32_t to uint8_t which could cause integer overflow if the calculation exceeds 255. Consider using appropriate integer types for the calculations.
// MIT License

src/hostLib/webusb_parsers/SettingsWebUsbCommandHandler.cpp:1

  • Similar to the previous comment, changing from uint32_t to uint8_t could cause issues if the payload grows beyond 255 words. Consider using uint32_t for consistency and safety.
// MIT License

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

…ads are available and which are connected; only auto setting should cause disconnect
@Tails86
Copy link
Collaborator Author

Tails86 commented Sep 6, 2025

One more thing:

  • Added XO command which will provide information about what gamepads are available and which are connected
  • Minor tweak: Only the auto setting should allow disconnect instead of NOT-auto-no-disconnect

@Tails86 Tails86 merged commit 9ef9027 into main Sep 6, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Host: Add WebUSB

3 participants