Holoseat Firmware Microservices

Added by J. Simmons over 5 years ago

I have been reading about microservices and how they can be used to isolate functions to make code easier to maintain and develop. Below are some thoughts on how the v0.4 Holoseat firmware could be organized into microservices to separate out the hardware interfaces from the game playing logic. Additionally, this would allow us to isolate the web UI from all of the other modules to hopefully make it more resilient so the user will always have access to the UI.

Description of the Microservices

  • UI - implements REST API to review and control Holoseat state and renders the single page application that users interact with from the Configuration Apps on their PCs or from phones/tablets. The UI interacts with all other microservices to be a service aggregator.
    • Data - tbd
    • Service endpoints
      • Enable button events
      • Tbd from other service end points and UI needs
  • Player - manages all of the game play logic. For example, the Player service determines if the current cadence (as sent by the Pedaler service) is fast enough to trigger walking. The Player service also determines what HID input to send to the game (e.g 'w' or forward access) when the walking event occurs. Finally, the Player service is also responsible for passing through (e.g. user pressed 'a' which is passed through to the game as an 'a') and mappping signals (e.g. user pressed left on the analog stick which is mapped to an 'a' sent to the game) from upstream peripherals, which may include masking some peripheral inputs (e.g mask 'w' keys from keyboard) in favor of events from the pedaler
    • Data - tbd
    • Service endpoints
      • cadence events (direction, cadence)
      • hid kb/mouse events
      • hid joypad events
      • Enable messages
      • Report current state
      • Set Mappings (in blob and individually)
  • Pedaler - listens to sensor inputs to calculate the cadence and direction. It sends the cadence and direction to the Player service. The Pedaler also interacts with the Enable button, sending and recieving messages to the UI service about the Enable button
    • Data - no stored data (has constants for various physical configuration data
    • Service endpoints
      • Enable messages
  • HID KB/Mouse In - attaches to keyboard and mouse events with the OS and forwards those events to the Player service for processing
    • Data - tbd
    • Service endpoints
      • Peripheral status - do we have a kb or mouse attached?
  • HID Joypad In - attaches to joypad events with the OS and forwards those events to the Player service
    • Data - mappings of joypads to internal joypad model (to connect events from specific joypad drivers to Holoseat joypad events
    • Service endpoints
      • CRUD for joypad mappings data
      • Select joypad mapping (unless we can auto detect the joypad)
      • Peripheral status - do we have a joypad attached and if so what kind?
  • HID KB/Mouse Out - identifies the Holoseat Controller as a keyboard and mouse to the OS and sends keyboard and mouse events to the OS when signaled to do so
    • Data - thd
    • Service endpoints- tbd
  • HID Joypad Out - identifies the Holoseat Controller as a joypad to the OS and sends joypad events to the Os when signaled to
    • Data - thd
    • Service endpoints- tbd
  • (Missing in diagram) Mappings Manager - stores and manages all of the mapping data used by the Player service to make decisions (note, the UI sends the currently requested mapping data to the Player service to maintain a separation between services (the Player should only know about the input and output streams it works with to enable game play)
    • Data - mappings and event triggers by user and by game (e.g. John's joypad to keyboard mapping and cadence trigger speeds for swtor
    • Service endpoints
      • CRUD for users and their game mappings

Minimal Implementation to Recreate v0.3 Features

  • Some elements of UI Service (access to Mappings service and current state info)
  • Basic Player - no hid events
  • Pedaler
  • HID KB/mouse out - Keyboard out only
  • Basic mapping service - always returns and stores for hard coded user and game (default:default) and only maps cadence and forward/backward characters

Data storage

  • Not mongo, too heavy for embedded systems
  • Maybe
    • JSON files on disk
    • Level Up (JSON keys, user:game, and data, mappings)