Virtual Gamepad
A virtual controller for smartphones to operate microcontroller cars and more. (PCs are also supported)
GitHub (Japanese README): TwoSquirrels/virtual-gamepad
Settings
ms
Usage
Server Side (Microcontroller, etc.)
- Run a program that can handle HTTP requests in the format of the following protocol. (An example microcomputer car with M5Atom)
- Check the address of the target server.
Controller Side
- Open the address of the target server (e.g., microcomputer) in your browser.
- Adjust the joystick transmission interval (default 100 ms). It is recommended to keep it small enough that it does not choke communication.
- Hide the A, B buttons if you are not using them.
- Close the settings screen and operate with swipe or WASD (+ Shift).
Protocol
When communicating from an HTTPS page, such as on github.io, to an HTTP host, a security error occurs. This can be handled by configuring the browser, but it is recommended to serve HTML on the same host as the API and access the page from there.
GET /
Request
Basically, it is accessed through a browser.
Response
Please return the gamepad HTML, we recommend that you download the latest HTML from this page.
POST /joystick?p=aaff
Request
When the joystick is being operated or WASD is being used, the polar coordinates of the joystick are sent at the set interval as a 4-digit hexadecimal string in the query.
-
aa
: A 2-digit hexadecimal string representing the angle0 ≤ θ < 256
, with the right direction as0
and increasing counterclockwise, with a full circle being256
. -
ff
: A 2-digit hexadecimal string representing the radial distance0 ≤ r < 256
, with the center as0
and the maximum stick limit as255
(for WASD operation, it becomes7F
when Shift is pressed).
The body is always empty.
Response
Ignored, except for being displayed in the debug console.
POST /a
, /b
Request
Sent to the path corresponding to the content of the button when the right-side button is pressed. The body is always empty.
Response
Ignored, except for being displayed in the debug console.