Skip to content

port: Miyoo Mini Plus #839

@Gadgetoid

Description

@Gadgetoid

I picked up a Miyoo Mini Plus recently so I had something to distract me from all the Linux gpio tomfoolery. The few 32blit examples I've managed to port over run pretty well.

https://droix.co.uk/product/miyoo-mini-plus/

TODO

  1. New toolchain file
  2. Expand SDL bindings, or find a way to overload the config to support MMPs key binding (see below)
  3. Figure out how to build our own SDL2 without the DraStic specific hacks
  4. GitHub actions autobuild? Looks like OnionOS does this via Docker
  5. Build and populate an app dir with config.json, launch.sh, libs/, icon and binary.
  6. Icon image looks to be 74x74 pixels so we might need some conversion?

Notes

I used https://github.com/shauninman/union-miyoomini-toolchain or, more specifically, https://github.com/shauninman/miyoomini-toolchain-buildroot/ and added the SDL2 libs via the buildroot make menuconfig, then used the following toolchain file to configure 32blit-sdk:

set(COMMON_FLAGS "-Os -marm -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -march=armv7ve+simd")

set(CMAKE_C_FLAGS_INIT "${COMMON_FLAGS}")
set(CMAKE_CXX_FLAGS_INIT "${COMMON_FLAGS} -fno-exceptions")

set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++)

set(CMAKE_FIND_ROOT_PATH
/root/buildroot/output/host/arm-buildroot-linux-gnueabihf/sysroot)

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)

# search headers and libraries in the target environment
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

SDL2

It looks like SDL2 is not natively supported, and the SDL2 libraries nabbed from the buildroot don't seem to work. I had to borrow the ones from https://github.com/steward-fu/sdl/tree/sdl-2.0.20_ssd202d_miyoo-mini though I just grabbed the compiled binaries out of the DraStic port and added SDL2 net.

I dumped these into a libs dir inside the app dir (as per DraStic) and then used the following launch.sh:

#!/bin/sh
echo $0 $*

mydir=`dirname "$0"`

export HOME=$mydir
export PATH=$mydir:$PATH
export LD_LIBRARY_PATH=$mydir/libs:$LD_LIBRARY_PATH
export SDL_VIDEODRIVER=mmiyoo
export SDL_AUDIODRIVER=mmiyoo
export EGL_VIDEODRIVER=mmiyoo

cd $mydir
./geometry --fullscreen > geometry.log 2>&1

Input

The SDL scancodes for input are:

    SDLK_UP,
    SDLK_DOWN,
    SDLK_LEFT,
    SDLK_RIGHT,

    SDLK_SPACE,     // A
    SDLK_LCTRL,     // B
    SDLK_LSHIFT,    // X
    SDLK_LALT,      // Y

    SDLK_e,         // L1
    SDLK_t,         // R1
    SDLK_TAB,       // L2
    SDLK_BACKSPACE, // R2

    SDLK_RCTRL,     // Select
    SDLK_RETURN,    // Start
    
    SDLK_HOME,      // MENU
    SDLK_0,         // Quick Save
    SDLK_1,         // Quick Load
    
    SDLK_2,         // Exit
    SDLK_3,         // Power
    SDLK_HOME,      // Vol Up
    SDLK_BACKSPACE  // Vol Down

The following patch handles key bindings and makes "menu" exit, note that the LCTRL for B conflicts with our use of Ctrl for something, I forget what:

diff --git a/32blit-sdl/Input.cpp b/32blit-sdl/Input.cpp
index c1d65f0..e2bdcb4 100644
--- a/32blit-sdl/Input.cpp
+++ b/32blit-sdl/Input.cpp
@@ -23,6 +23,12 @@ std::map<int, int> Input::keys = {
        {SDLK_c,       blit::Button::X},
        {SDLK_v,       blit::Button::Y},
 
+    //  Miyoo Mini Plus XBXY
+    {SDLK_SPACE,   blit::Button::A},
+    {SDLK_LCTRL,   blit::Button::B},
+    {SDLK_LSHIFT,  blit::Button::X},
+    {SDLK_LALT,    blit::Button::Y},
+
        {SDLK_u,       blit::Button::A},
        {SDLK_i,       blit::Button::B},
        {SDLK_o,       blit::Button::X},
@@ -33,7 +39,8 @@ std::map<int, int> Input::keys = {
        {SDLK_2,       blit::Button::MENU},
        {SDLK_3,       blit::Button::JOYSTICK},
   
-  {SDLK_ESCAPE,  blit::Button::MENU},
+    {SDLK_ESCAPE,  blit::Button::MENU},
+    {SDLK_RCTRL,   blit::Button::HOME},
 };
 
 std::map<int, int> Input::buttons = {
diff --git a/32blit-sdl/Main.cpp b/32blit-sdl/Main.cpp
index 4eb6a2c..e7e06ed 100644
--- a/32blit-sdl/Main.cpp
+++ b/32blit-sdl/Main.cpp
@@ -63,6 +63,10 @@ void handle_event(SDL_Event &event) {
                        break;
 
                case SDL_KEYDOWN: // fall-though
+            if (event.key.keysym.sym == SDLK_HOME) {
+                running = false;
+                break;
+            }
                case SDL_KEYUP:
                        if (!blit_input->handle_keyboard(event.key.keysym.sym, event.type == SDL_KEYDOWN)) {
 #ifdef VIDEO_CAPTURE

Geometry.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions