Giter VIP home page Giter VIP logo

ps2plus's Introduction

PS2+ License CI

Under construction!

Overview

Requirements

Software

Name Purpose
Python 3 Build system
Docker Build system
SCons (pip install scons) Build system (local)
gcovr (pip install gcovr) Code coverage (local)
gcc/mingw Compiler (local)

Hardware

Build instructions

Firmware

Configurator

As with each firmware platform, there are two options for building the configurator app: using a local installation of the PS2SDK, or using this repository's Docker image.

Local PS2SDK installation

(TBD)

Repository Docker image

The configurator can be built locally using the same infrastructure that the GitHub CI build system uses. With Docker installed, the following will directly build the configurator application:

docker compose run configurator

On the first run, this command will build the Docker image and then immediately build the configurator, which will be available as dist/PS2PLMAN.elf. On future runs, the Docker image will be cached. To obtain an interactive shell into the Docker image in order to control the build step:

docker compose run configurator sh

From within the interactive shell, you can run make to build the configurator and make clean to clear the build.

Development

Repository layout

Platform porting

The firmware/bootloader's platform abstraction layer makes porting to new hardware relatively straightforward. New ports need modifications in the following locations:

  • 👩‍💻 Platform code. Create a new folder in the firmware/src/platforms directory. This should contain implementations of the platform abstraction functions defined in the firmware/src/platforms/*.h header files. Implementation files should be #ifdef-guarded using the PLATFORM_<NAME> definition (provided by the build system).

  • 🛠 Platform/toolchain build configuration:

    • Toolchain configuration. If the new platform uses a different toolchain than any existing platform, a new SCons toolchain has to be created for building. Create a new toolchain class in site_scons/firmware/toolchains.py. Its job is to set the correct C compiler/linker paths and flags so that the firmware source files can be properly built.

    • Platform configuration. Create a new platform class in site_scons/firmware/platforms.py. Its job is to select the correct toolchain, and to set the correct C compiler/linker flags to differentiate between the bootloader and firmware targets (the bootloader and firmware occupy different spaces in program memory). The platform class can also generate platform-specific IDE project files if desired. Include a new instance of this class in the ALL_PLATFORMS list.

  • 🐳 Docker-based continuous integration:

    • Docker toolchain image. If the new platform uses a different toolchain than any existing platform, a new Docker image has to be created for building. Create a new <toolchain>.Dockerfile file in the docker/ directory; this image should have the following installed:

      • Platform toolchain
      • python3 and python3-pip (required for the build system and tools)
      • scons (via pip3; required for the build system)
    • Docker Compose platform command. Add the new platform to docker/docker-compose.yml as a new service named firmware-<PLATFORM> (must be all lowercase). If the platform also uses a new toolchain, add the toolchain to this same file in the x-toolchains section. (TBD: Add a command that specifies to SCons which platform will be built.)

    • GitHub CI platform build. The new platform has to be integrated into this repository's GitHub Workflows-based continuous integration building. (TBD: This CI step should probably be refactored as a local GitHub Action that takes a list of platform names as inputs.)

References

License

See LICENSE.

ps2plus's People

Contributors

kbhomes avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

nold360

ps2plus's Issues

[configurator] Disable/enable configuration when remapping joystick axis ranges

The joystick axis range remapping can only be calibrated while remapping is disabled; otherwise, calibration would be inaccurate as it interprets the already-remapped joystick values as raw values. To fix, the configurator should disable configurations when calibration begins and re-enable them once calibration completes.

Note: the disable/enable command is all-or-nothing, so things like button remapping will be paused as well during calibration. May not be an issue, but something to be aware of.

No 480p Video Output

I'm testing ps2plus on my portable & noticed the configurater is not outputting progressive video. I took a quick look at the code and it seems like you're trying to force 720p. I guess 480p would be sufficient, but idk how to correctly detect the current/max. video output anyways.

[dev] Automatically build and release artifacts

  • Bootloader + Firmware (HEX file)
  • Firmware (HEX file)
  • Configurator (ELF application)

In addition to the artifacts being built, they should be named so that they contain the information about firmware version and microcontroller platform. Only tagged commits should have versioned releases -- we don't want to upload possibly corrupted artifacts.

[dev] Build up unit tests and "native" platform

Flesh out unit tests by implementing them against the "native" platform, which simulates a PS2+ controller on the compiler's platform. It obviously can't communicate with a real console, but it should be able to simulate enough of the device to test it's logic.

Also, it may be worthwhile to create unit tests that can run on-device. This would help to determine that platform abstractions are functioning properly.

[firmware] Implement analog button support

Analog button currently doesn’t do anything. The firmware currently acts as just an indicator of whether the controller is in analog lock mode. The logic for the analog button should be:

  • If in analog mode lock, do nothing
  • Otherwise, toggle analog mode on button-up

Configurator: Control via D-Pad is very sensitive

I's very hard hitting a specific item in the configurator using the d-pad. it's nearly impossible to navigate & it's a matter of luck if you are going to hit the wanted button.

Scrolling doesn't seem to work, too.

[firmware] Add better versioning scheme

Goals for a better versioning scheme:

  • Support a more human-readable identifier (like SemVer)
    • Currently using a uint16_t as a flat number for the version number
    • Consider changing to something like uint64_t, with a byte pattern such as:
      • Major: 1 byte
      • Minor: 2 bytes
      • Patch: 4 bytes
      • Metadata: 1 byte (for example, dev for local builds, latest for automatic builds)
  • Automatically bump patch version with every commit (?)
  • Automatically create versioned and latest GitHub releases on commits
    • Use ps2link's GitHub Actions workflow as an example
    • Briefly:
      • For all commits, create a latest release that is tagged as prerelease
      • For commits which are tagged

Not sure what the best strategy is for making sure the versions in the application and in Git stay in sync. Maybe keep major/minor in code, and patch and metadata passed in from the environment. Patch number might be "number of commits since last tag", and tags will always be "<major>.<minor>.0". This could be problematic if the commit history isn't linear -- need to think about that.

Configrator: Joystick calibration options disappeared

I think there are some options missing in the configurator. IIRC they showed up when i stared the app for the first time, but now they are just gone.

The missing options are for the analog stick calibration & axis reset

[firmware] Add button combo to reset configuration

The ability to remap the digital buttons and the joysticks axes could lead a user to being stuck in an unusable configuration state — for example, they may have forgotten to map a button to X, preventing them from opening the configurator. A button combo should be added that can be input/held down at any time to reset the configuration.

Maybe Triangle + L1 + L2 + R1 + R2 for 5 seconds?

[firmware] Implement watchdog timer for internal state

Mimic the behavior of a real DualShock controller — after some amount of time with no communication from the console, the controller should automatically reset its state in preparation for a new, future connection.

As it is currently, disconnecting the controller would leave the controller in its current state which may be confusing for the console (or any games) which are expecting a new controller connection to start in plain digital mode.

The Curious Inventor documentation says:

Some controllers have a watch-dog timer that reverts back into digital mode if a command is not received within a second or so.

[dev] Replace MPLAB X build with different build solution

Doing containerized builds of the firmware/bootloader on Microchip hardware (i.e. the only current platform) requires installing XC8 and MPLAB X, running the prjMakefilesGenerator script, and then running Make. Replacing this with custom Makefiles that invoke XC8 directly would have some benefits:

  • Eases ports to other Microchip hardware without inflating the MPLAB X project with additional configurations
  • Eases ports to non-Microchip hardware as compiling must occur outside of MPLAB X anyway
  • Allows development in any C editor or IDE (VS Code and CLion would be ideal)
  • Significantly slimlines the build container image

Downside of this is potentially losing the ability to do on-device debugging.

[configurator] Enable configuring PS2+ controller on different ports

All configurator code currently assumes the PS2+ is found on port 1. It should be able to manage one in any port, and switch between if there are multiple.

Also maybe part of this issue: allow standard controllers to navigate the UI, including while a PS2+ controller is being managed in another port. Maybe not a common use case, but could be another solution to flashing the firmware of a corrupted PS2+.

Analog sticks are "dying"?

I currently have the problem that my analog sticks [switch analogs] are working at first, but suddenly stop working after a few seconds. It happens at the same time for both sticks and they never come back "alive". After reboot they are working again for a few seconds...

[bootloader] Enable bootloader as a digital controller

My original plan for the bootloader was to allow it to be used as a fallback digital controller in case the firmware was known to be corrupted. This would allow the user to at least be able to enter the configurator to attempt another firmware update.

Because of bootloader space constraints (self-imposed), I took out that functionality but would like to put it back in before calling this shippable, so that nobody is stuck with a bricked controller. Once I take out the strings from the source, there will probably be enough space; otherwise, I’ll have to change the space constraints on the bootloader and firmware.

[firmware] Debounce digital button inputs

Digital button inputs are currently read immediately and instead should be debounced slightly to account for any fluctuations (or should they?). The original PS2+ used a 3-frame debounce, but I don’t know how that would translate to wall clock time.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.