Support for Linux-side Interfaces [Feature Request]
Posted: Tue Jun 16, 2020 9:17 am
I would like Main_MiSTer to support linux-side interfaces or launchers [1]. I had some working code [2] but I would be happy if a better solution pops out. This is mainly a Feature Request, however I will discuss my prototype implementation for concreteness. I will suppose that no change to the core framework can be done.
Moreover I highlight that the requested feature is just for SUPPORTING external interfaces: the main MiSTer distribution should continue to work without any linux-side interface, but it should just provide us with some way to experiment with such interfaces.
As far a I understand to this goal we need:
1) A way to switch back and forth between current MiSTer menu and an external app.
2) A way to force a core to load a Rom.
My prototype handles such points adding commands to the /deb/MiSTer_cmd. These commands enable the following flow:
- slave_enable 1 - to let the mister switch to the linux-side interface application
- The application, during its execution, can send the following sequence of commands to /dev/MiSTer_cmd, to force to load a core AND a rom.
- load_core /path/to/core - to load the core (already implemented in the main repository)
- scan_mask_add /path/to/rom - from now on, a fixed list of paths will be returned when a core asks to navigate the filesystem; the list contains /path/to/rom only (other paths can be added if needed)
- select_a_rom - to force the core to select a rom in the list
- scan_clear - to clear the scan_mask_add list, returning to the standard filesystem navigation
- slave_enable 0 - to let the mister switch back to the standard visualization
Few notes:
- The select_a_rom command works sending to the core a synthetized sequence of user input that let it navigate the menu and select the last rom file. This is done with a temporary sub-process communicating itself with /dev/MiSTer_cmd
- The slave_enable 0/1 will send SIGSTOP and SIGCONT to the linux-side interface, as well as toggling vt on/off. This means that when the vt is not shown, there is no overhead in linux side.
- If no one of the new commands are sent to MiSTer_cmd, the main app just works as before: no new process are spawned, same filesystem navigation ability, etc.
- The command to use as a linux-side interface, for now, is hardcoded in the new cmd_io.c file. A proper entry in the mister.ini is advisable.
- A keybind for quickly do a "slave_enable 1" can be easily added to menu.cpp, so the MiSTer will normally run the standard interface, then pressing e.g. F8 the linux-side interface will pop-up. This is not meant to be in the main MiSTer distribution so it is out of the example patch [2].
I have a question too, about a minimal proof-of-concept I use for the tests. It loads a toy graphical launcher based on quick-and-dirty framebuffer drawing. In developing this I had a problem: Main_MiSTer will completely reset its process image on a load_core command (with an execv call). This means that it can not (easily) know the status of the linux-side interface (running, stopped, etc). I worked-around just quitting the linux-side interface at each swap, so the Main_MiSTer will correctly restart it the next time. For my small proof-of-concept this is not a problem since it starts very quickly, but for a real interfaces could be an issue.
Since this image-resetting is quite wierd I would ask: Is it really needed? Can just the relevant state be resetted without reloading the process image? I can try to develop this by my self, I am just asking for some hint on its feasibility.
[1] Porting complex gui (e.g. EmulationStation) is probably not possible due to the limited resource of the HPS. But simpler launcher or textual ui should be feasible, simplifying the MiSTer administration and core/rom launching.
[2] forked of an OLD version at https://github.com/pocomane/Main_MiSTer; compact view of the changes at
https://github.com/pocomane/Main_MiSTer ... ane:master
Moreover I highlight that the requested feature is just for SUPPORTING external interfaces: the main MiSTer distribution should continue to work without any linux-side interface, but it should just provide us with some way to experiment with such interfaces.
As far a I understand to this goal we need:
1) A way to switch back and forth between current MiSTer menu and an external app.
2) A way to force a core to load a Rom.
My prototype handles such points adding commands to the /deb/MiSTer_cmd. These commands enable the following flow:
- slave_enable 1 - to let the mister switch to the linux-side interface application
- The application, during its execution, can send the following sequence of commands to /dev/MiSTer_cmd, to force to load a core AND a rom.
- load_core /path/to/core - to load the core (already implemented in the main repository)
- scan_mask_add /path/to/rom - from now on, a fixed list of paths will be returned when a core asks to navigate the filesystem; the list contains /path/to/rom only (other paths can be added if needed)
- select_a_rom - to force the core to select a rom in the list
- scan_clear - to clear the scan_mask_add list, returning to the standard filesystem navigation
- slave_enable 0 - to let the mister switch back to the standard visualization
Few notes:
- The select_a_rom command works sending to the core a synthetized sequence of user input that let it navigate the menu and select the last rom file. This is done with a temporary sub-process communicating itself with /dev/MiSTer_cmd
- The slave_enable 0/1 will send SIGSTOP and SIGCONT to the linux-side interface, as well as toggling vt on/off. This means that when the vt is not shown, there is no overhead in linux side.
- If no one of the new commands are sent to MiSTer_cmd, the main app just works as before: no new process are spawned, same filesystem navigation ability, etc.
- The command to use as a linux-side interface, for now, is hardcoded in the new cmd_io.c file. A proper entry in the mister.ini is advisable.
- A keybind for quickly do a "slave_enable 1" can be easily added to menu.cpp, so the MiSTer will normally run the standard interface, then pressing e.g. F8 the linux-side interface will pop-up. This is not meant to be in the main MiSTer distribution so it is out of the example patch [2].
I have a question too, about a minimal proof-of-concept I use for the tests. It loads a toy graphical launcher based on quick-and-dirty framebuffer drawing. In developing this I had a problem: Main_MiSTer will completely reset its process image on a load_core command (with an execv call). This means that it can not (easily) know the status of the linux-side interface (running, stopped, etc). I worked-around just quitting the linux-side interface at each swap, so the Main_MiSTer will correctly restart it the next time. For my small proof-of-concept this is not a problem since it starts very quickly, but for a real interfaces could be an issue.
Since this image-resetting is quite wierd I would ask: Is it really needed? Can just the relevant state be resetted without reloading the process image? I can try to develop this by my self, I am just asking for some hint on its feasibility.
[1] Porting complex gui (e.g. EmulationStation) is probably not possible due to the limited resource of the HPS. But simpler launcher or textual ui should be feasible, simplifying the MiSTer administration and core/rom launching.
[2] forked of an OLD version at https://github.com/pocomane/Main_MiSTer; compact view of the changes at
https://github.com/pocomane/Main_MiSTer ... ane:master