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

Support for tty2rpi #68

Open
ojaksch opened this issue Jun 26, 2024 · 14 comments
Open

Support for tty2rpi #68

ojaksch opened this issue Jun 26, 2024 · 14 comments

Comments

@ojaksch
Copy link

ojaksch commented Jun 26, 2024

I'm the author of tty2rpi (and co-author of tty2oled) and got a user's request to add TapTo support.
While TapTo already supports tty2oled it would be logical to add support for tty2rpi into TapTo than vice versa.

If that request is acceptable to you I would add the needed info here what variables, files and strings to use and to send... no russian rocket sience there and only a few lines of code.

@wizzomafizzo
Copy link
Member

Hey! Absolutely, love to add support. Let me know what needs to happen

@asturur
Copy link
Collaborator

asturur commented Jun 26, 2024

Consider that if you want to add something else cool to tty2rpi, there is also a different possible integration, mrext supports a websocket endpoint that informs you of current game loaded but also current game highlighted in the menu.
With a dedicated rasbperry project like yours, the RPI could listen to the websocket and reflect changes on game load and menu navigation

@ojaksch
Copy link
Author

ojaksch commented Jun 26, 2024

Great!
The process is simple. The device is defined in the file /media/fat/tty2rpi/tty2rpi-user.ini (MiSTer) as a variable, similar as in tty2oled: TTYDEV="/dev/tcp/IP-ADDRESS-OF-RPI/6666"

There are two functions in tty2rpi (on the RPi side), one simply displays the loaded Core (for example NEOGEO), the other is doing the same plus the loaded game as set in MiSTer's /tmp/CURRENTPATH if log_file_entry=1 is set in mister.ini

That said, the logic is

  • if log_file_entry=0 in mister.ini or undefined, send a echo "CMDCOR§-§NEOGEO" > ${TTYDEV}
  • if log_file_entry=1 in mister.ini echo "CMDCOR§NEOGEO§1945kiii" > ${TTYDEV}

NEOGEO here is an example of the active Core as stated in MiSTer's /tmp/CORENAME.
1945kiii here is an example of the loaded game as stated in MiSTer's /tmp/CURRENTPATH.

I think it's up to you to decide whether to respect log_file_entry or to just use your own setting of "USETTY2RPI=true" or something like this.

@ojaksch
Copy link
Author

ojaksch commented Jun 26, 2024

@asturur Thanks for that hint! I'm using my own socket but will keep mrext in my mind. For now I won't force my user to use mrext as a dependency to keep the setup as simple as possible. I think some or most of them or Linux beginners and are already challenged ;)

@wizzomafizzo
Copy link
Member

wizzomafizzo commented Jun 27, 2024

Having a think about this, maybe there is a simpler way to get this working. Are you aware that both Remote and TapTo write the launched game to /tmp/ACTIVEGAME? Everything in the mrext repo should write to this file when it launches something.

You can test this file exists to see if either is running (they create an empty one on startup), and then monitor it like CORENAME to get the full file path to the game that was launched.

A couple of notes with it:

  • It doesn't just log launches made by TapTo and Remote, it attempts to log the game running period. So it will also update if a game is launched from the menu and do its best for other scripts. It also clears the file when the menu is open again.
  • TapTo and Remote both manage this file independently, so if there's both running it can write the game path twice. Just make sure to keep the path in memory and compare it before acting on it after you receive an inotify event about it.

If you can support this method, you'll actually have automatic support for everything I've made rather than just TapTo.

@ojaksch
Copy link
Author

ojaksch commented Jun 27, 2024

Thanks for the headup! I'll have a deeper look at it the next days (very busy over weekend 😞 ) and report.

EDIT1: Did a quick test with the Remote, /tmp/ACTIVEGAME is created and the Remote UI is available and working. But no matter what game I choose in MiSTer's menu or in the Remote UI, /tmp/ACTIVEGAME remains empty and never got touched/updated (timestamp still at date of creation).

EDIT2: Ah, just explored that /tmp/ACTIVEGAME seems to be be updated only when starting a game in Remote's "Games" section...

@ojaksch
Copy link
Author

ojaksch commented Jun 27, 2024

So far so good and working, but what I'm missing is that "under some circumstances" (ie while running Remote but starting something per MiSTer menu or starting an arcade core) /tmp/ACTIVEGAME doesn't get touched. It would be easier to "inotifywait" for it to get touched even if it remained empty.

@wizzomafizzo
Copy link
Member

Do you have the recents feature enabled in your ini? This is necessary for the game tracking service to work and update for all games. Otherwise yeah it'll only update the file when Remote or TapTo itself are the ones launching

@ojaksch
Copy link
Author

ojaksch commented Jun 28, 2024

It's getting better and better after enabling recents, but there are still sometimes situations where /tmp/ACTIVEGAME isn't getting updated.
While most Computers, Consoles and games are working and displayed, I was jumping to /Games/_Arcade/ in Remote and selected one and another there but ACTIVEGAME isn't getting touched.

@wizzomafizzo
Copy link
Member

In the case of Arcade games specifically they won't be populated in this file because they're cores rather than loaded files. It's intentional. You'd have to still rely on the CORENAME file like usual.

I've thought about it but just decided it complicates things too much. It's actually not possible to see what .rbf file is loaded in memory, and a core can set the "corename" to anything it likes. You also can't inspect an rbf file and see what corename it would set. So it's just impossible to reliably resolve either way.

If you need a unified way to get this information where Arcade counts as a "game", you could send an HTTP request to the Remote REST API to get this information. But you won't be able to wait for it to change like with inotifywait, you'd have to poll it repeatedly (which is ok too, it's not resource heavy)

@wizzomafizzo
Copy link
Member

Personally I would recommend using a combination of CORENAME and ACTIVEGAME to cover all the cases.

@ojaksch
Copy link
Author

ojaksch commented Jun 29, 2024

I see and understand, but wouldn't it be enough just to touch the ACTIVEGAME and/or to write nothing to it (leaving it empty). I'm already watching CORENAME and ACTIVEGAME (and others) but the actual situation (with Remote) requires several ifs and thens to compare which of these files has changed and what happened to the remaining ones.

Sure, I can write some lines of code/logic to address this, but imho the not-touched ACTIVEGAME is an exception that leaves the usual process how MiSTer handles it's files in /tmp ...

@wizzomafizzo
Copy link
Member

Fair enough! I've made a change to TapTo's game tracker that will write the corename to ACTIVEGAME if the game is an Arcade core. It'll be in the 1.5 release. A copy of it is attached.

tapto-1.5-activegame.zip

I'll make the same change to Remote. I'll try get a new release of that out soon.

@ojaksch
Copy link
Author

ojaksch commented Jun 29, 2024

Great, thanks! Will continue tomorrow when weather changes from today's 25°C to 19°C 🌦️

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

3 participants