flyinghead / flycast

Flycast is a multiplatform Sega Dreamcast, Naomi, Naomi 2 and Atomiswave emulator
GNU General Public License v2.0
1.51k stars 176 forks source link

[RawInput] Parsec/Remote support #1174

Open TemporaryPSP opened 1 year ago

TemporaryPSP commented 1 year ago

Flycast has support for RawInput and it works great and very configurable with 2 mice/2 keyboards. However I've come to notice that remote desktop software such as Parsec can't utilize it. In fact, the client's inputs aren't working in menus.

I'd come to accept this as a limitation but I noticed that TeknoParrot supports Parsec's inputs as Unknown Device for both mouse and keyboard. Obviously input binding in Flycast doesn't quite work like TeknoParrot but this might be possible? It'd be very cool to see this one day but I'd understand if this is off-limits or not in the plans.

image

vkedwardli commented 1 year ago

Post a screenshot of Flycast Settings -> Controls tab from your host computer? Did Parsec remote's controller show in the Physical Devices list?

the client's inputs aren't working in menus

Do you mean SDL controllers or RAW controllers? or both are not working?

TemporaryPSP commented 1 year ago

I should've been more specific in what I was trying to do, keyboard and mouse. Parsec's remote controller is practically flawless, no surprise there. However when it comes to keyboard and mouse, there aren't any "new" devices in RAW nor does any input register (I was testing RAW mapping with the client). SDL keyboard/mouse works fine, I was able to get the client to type and aim with the mouse, but this leaves no room for the host to set up multiplayer if both players need the same "controller".

image

vkedwardli commented 1 year ago

I just did a quick search in TeknoParrot's github, From: JoystickControlRawInput.cs

RawInputDevice.GetDevices().OfType<RawInputMouse>();

And from rawinput-sharp's RawInputDevice.cs

    public static RawInputDevice FromHandle(RawInputDeviceHandle device)
    {
        var deviceInfo = User32.GetRawInputDeviceInfo(device);

        switch (deviceInfo.Type)
        {
            case RawInputDeviceType.Mouse:
                return new RawInputMouse(device, deviceInfo);
            case RawInputDeviceType.Keyboard:
                return new RawInputKeyboard(device, deviceInfo);
            case RawInputDeviceType.Hid:
                return RawInputDigitizer.IsSupported(deviceInfo.Hid.UsageAndPage)
                    ? new RawInputDigitizer(device, deviceInfo)
                    : new RawInputHid(device, deviceInfo);
            default:
                throw new ArgumentException();
        }
    }

Seems the difference is they are using the information from GetRawInputDeviceInfo to classify a RAWINPUT device?

But in Flycast we just classify it using the dwType from GetRawInputDeviceList first, and then call GetRawInputDeviceInfo https://github.com/flyinghead/flycast/blob/92a10ba0f0a5ca0d1ec9498962002f4cdcc8e7f6/core/windows/rawinput.cpp#L350-L368

So yea, I would say this might be possible!

p.s. Apple fanboy here, just 5 minutes of searching + 5 minutes of typing... the above info could be wrong.