Hi,
I’m using Libretro Unity wrapper from here: GitHub - Skurdt/SK.Libretro: Libretro wrapper written in C# with support for the Unity game engine.
It uses Unity’s Input Actions system, and that’s all fine - I have a game loading, and pressing Right Shift adds credits as expected.
However, I need to trigger this ‘add credits’ function / right shift programatically (as well as any others), and I have no idea how to do this.
I can’t seem to tap in to the functions through code. I’ve looked at simulating keypresses - dead end. There’s apparently no way to manually ‘trigger’ an input action either. I looked at creating a virtual keyboard device to register with input actions, dead end too.
KeyboardKey(0, retro_key.RETROK_RSHIFT) looks to be along the lines, although I have no idea if this is just getting the keyboard key (and I can’t even get this to work anywhere anyway).
This might help: https://github.com/Skurdt/SK.Libretro/blob/main/Scripts/Input/InputHandler.cs but I have no idea what it all does or how to tap into it.
Also can see retro_set_input_state_t and things around polling but think that’s just around capturing inputs. I don’t really need to mess with inputs, I just want to run the libretro functions that the inputs trigger. like right shift adds the credits for a MAME game, Enter starts the game etc.
My c# scripting experience isn’t great either!
Any help would be amazing, thank you.
Not that this works, but you can see what I’m aiming for:
using SK.Libretro.Unity;
using UnityEngine;
using System.Collections;
using SK.Libretro;
using SK.Libretro.Header;
public class LibretroDController : MonoBehaviour
{
[SerializeField] private LibretroInstanceVariable _libretro;
private IInputProcessor _inputProcessor; // complete guessing here
void Start()
{
_libretro.StartContent();
StartCoroutine(RunAfterDelay(5f));
}
IEnumerator RunAfterDelay(float delay)
{
yield return new WaitForSeconds(delay);
PressedReload();
}
public void PressedReload()
{
_inputProcessor.KeyboardKey(0, retro_key.RETROK_RSHIFT); // complete guessing, doesn't work at all
}
}