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

[Question] Check for running emulators or kodi #9483

Open
tonilsz opened this issue Sep 19, 2019 · 2 comments
Open

[Question] Check for running emulators or kodi #9483

tonilsz opened this issue Sep 19, 2019 · 2 comments

Comments

@tonilsz
Copy link

tonilsz commented Sep 19, 2019

Hi,

I have a nespi+ case and I use safe shutdown and reset buttons from here:
https://github.com/edus44/lakka-gpio-control

It works perfectly, but I wanted a little update like here:
https://github.com/crcerror/retroflag-picase/blob/master/SafeShutdown.py

what I want is when reset button is pressed, check if we are running any emulator or kodi is open, for this we can inspire in this piece of code:

def reboot():
 output = int(subprocess.check_output(['/opt/RetroFlag/multi_switch.sh', '--es-pid']))
 output_rc = int(subprocess.check_output(['/opt/RetroFlag/multi_switch.sh', '--rc-pid']))
 if output_rc:
     os.system("/opt/RetroFlag/multi_switch.sh --closeemu")
 elif output:
     os.system("/opt/RetroFlag/multi_switch.sh --es-restart")
 else:
     os.system("sudo reboot")

I know that we don't have ES but I hope that check for some process can be possible

this is the code/pseudocode that I should develop:

def reset():
  oldState = True
  while True:
    GPIO.wait_for_edge(resetPin, GPIO.FALLING)

    state = GPIO.input(resetPin)
    if state != oldState and state == False:

      ## state_kodi =  funtionToCheckIfKodiIsRunning()
      ## state_cores =  funtionToCheckIfAnyCoreIsRunning()
      ## if state_kodi:
      ##         os.system("kodi-send --action="Quit"")
      ## elif state_cores:
      ##         FuntionLikeXMBCloseContent
      ## else:
      ##         os.system("pkill retroarch")
      ## time.sleep(1)

I hope that it isn't very confused, there is no problem if I have to develop a multi_switch.sh to handle better the events, but first I have to know if its possible and how to find references.

What I really need are two functions:

Can anyone show me the way or a doc page to find info related with this commands?

is it related to #4235

Thanks

@tonilsz tonilsz changed the title [Question] Check for running emulators or lakka [Question] Check for running emulators or kodi Sep 19, 2019
@hhromic
Copy link
Contributor

hhromic commented Sep 19, 2019

I think an easy way to accomplish this would be to implement a new network-based command for unloading cores. Then you configure RetroArch to listen for network commands (set network_cmd_enable = true) and lastly you program whatever script you have to send the command to RetroArch for example doing retroarch --command UNLOAD_CORE. Other commands like this are already implemented.

See: https://github.com/libretro/RetroArch/blob/master/command.h
See: https://github.com/libretro/RetroArch/blob/master/retroarch.c#L2159-L2215

@tonilsz
Copy link
Author

tonilsz commented Sep 20, 2019

Thanks it looks really interesting and powerfull, I suppose that I can use the loopback address to this.

If I have understood, it's as simple as use --command as interface.

Can I edit the c file to add an extra feature?
f.e. I want to add a boolean handling when core is loaded/unloaded and write it to a file or variable and then when button preset check for this file/variable.
But this shouldn't be called by system to, I think I should override system calls to load/unload core for this. am I wright?

eadmaster added a commit to eadmaster/RetroArch that referenced this issue Jan 27, 2020
will return a string with the name of the current core running, the content name and crc32
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