Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Export/Import Pads as JSON #7

Open
imsamuka opened this issue Jan 26, 2025 · 4 comments
Open

Feature request: Export/Import Pads as JSON #7

imsamuka opened this issue Jan 26, 2025 · 4 comments

Comments

@imsamuka
Copy link

Feature request

This FR has 2 important parts.

  • Export and Import as JSON - Easiest and most important
  • Request layout from Server

Export and Import

Being able to export a layout as a plain JSON file, and import it. It would be very useful specially with more complex pads, that have been extensively customized, with colors, labels, icons etc.

Request a layout to the Server

Since all protocols are bi-directional, it would be convenient if you could "ask" the server for default layout (for portrait/landscape).

Example

For example, the server may know that it only support a joystick with id 'handle' and a button with id 'shoot' and mode 'click', so when asked, it could send a very barebones layout with only these 2 configured controls.

DroidPad sends to the server:

{
  "type": "LAYOUT_REQUEST",
  "orientation": "LANDSCAPE"
}

The server sends back:

{
    "type": "LAYOUT_RESPONSE",
    "layout": {
        "orientation": "PORTRAIT",
        "elements": [
            {
                "id": "handle",
                "type": "JOYSTICK",
                "x": null,
                "y": null,
                "scale": 1.0,
                "color_handle": null,
                "color_bg": null
            },
            {
                "id": "shoot",
                "type": "BUTTON",
                "x": null,
                "y": null,
                "scale": 1.0,
                "text": "Shoot",
                "action_mode": true,
                "color_button": null,
                "color_text": null,
                "use_icon": false,
                "icon": 0,
                "color_icon": null
            }
        ]
    }
  }

The fields with null can be setup as default by the app. Processing this layout, you have a pad with all the necessary/possible elements on the screen, and you can customize as you want. Of course, the server could send a customized pad for you as well, with the correct positioning, labels and colors.

@umer0586
Copy link
Owner

umer0586 commented Jan 26, 2025

Exporting and importing control pads as JSON is definitely a handy feature, but I’ve got a slightly different idea. What if the app could generate a QR code (JSON string) for the control pad? Users could create their control pad and then share it as a QR code image. Other DroidPad apps could scan the QR code and load the control pad. The server could also show the QR code on startup to make sharing easy.

@imsamuka
Copy link
Author

A QR code is indeed a very good idea! Since the JSON would already be created to make the QR code, can we have both QR and JSON files? It would aid development and make backup easier, removing the QR middle man.

@umer0586
Copy link
Owner

can we have both QR and JSON files?

Sure, but having the server send JSON to the app doesn’t seem feasible since the app isn’t set up to expect incoming data. This would require extra setup for things like a UDP server, MQTT broker (or app subscribing to a topic) and with BLE’s small MTU, it can’t handle large strings. So, using QR scanning or sharing an image seems like a better option since it avoids dealing with any connection protocols.

@umer0586
Copy link
Owner

QR code feature now available in the latest version (v2.0.0)

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

No branches or pull requests

2 participants