redphx / joydance

Use Joy-Cons to play Ubisoft's Just Dance on all platforms
MIT License
85 stars 5 forks source link

Add Stadia support #2

Closed redphx closed 2 years ago

redphx commented 2 years ago

Stadia isn't available in where I live, so I couldn't test it myself.
With the console version, JD has a local websocket server running inside the game, but for Stadia I think it uses a live server somewhere. If you're able to test JoyDance on Stadia, please help me on this issue.

Thank you.

DNNH97 commented 2 years ago

Hi there, I have all three Just Dance games on Stadia (2020-2022) and I just tried to connect it to JoyDance, but it doesn't work. It just says "Couldn't connect with console!"

I would be down to help find a way to make this work with Stadia, but I'm not really a programmer. That being said, just let me know if you need my help!

redphx commented 2 years ago

Hi @DNNH97, thank you.

Please try this version: https://github.com/redphx/joydance/archive/refs/heads/feature/stadia.zip
It will show some info in the Terminal. Please post it here (don't forget to remove any sensitive info first, if any).

DNNH97 commented 2 years ago

Hey @redphx ,

this is what the terminal spat back out, I hope it's helpful! joydance_stadia01

redphx commented 2 years ago

Hi @DNNH97, thanks for the info. I've updated the code, please download and try again.

rama0dev commented 2 years ago

If i use stadia, which ip i need use? image

redphx commented 2 years ago

@rama0dev for Stadia you can enter any IP you want. The IP in your screenshot will work fine. I'll make it optional in future version.

rama0dev commented 2 years ago

Thank you. How i can contact you?

DNNH97 commented 2 years ago

I just tried out the new version you provided @redphx , and it works! Though there's an interesting side effect: Since Stadia is compatible with the Stadia controller, mouse and keyboard OR any HID-conforming controller, the Joy-Con acts as both the scoring device, as well as an actual controller to navigate. The game will (almost) show the corresponding buttons on screen, but the Joy-Con needs to be held sideways, so A would be X, B would be Y, etc.

DNNH97 commented 2 years ago

Also, funny enough, this pops up when using the Joy-Con (Or rather, when Stadia sees a non-Stadia controller used to control the game): jdstadiacontroller

Johnny-DPH commented 2 years ago

image

FYI Stadia doesn't require any device to be connected on the same network, just to the internet. <3

redphx commented 2 years ago

@DNNH97 thanks for testing, glad that it worked. Could you please try to connect again, then copy/paste the entire line that starts with {'__class': 'JD_InputCollectionPhoneData', in the Terminal?

For example:

{'__class': 'JD_InputCollectionPhoneData', 'availableInput': {'DOWN': '{"root":{"__class":"JD_Input_PhoneCommandData","input":2467711647}}', 'LEFT': '{"root":{"__class":"JD_Input_PhoneCommandData","input":3652315484}}', 'RIGHT': '{"root":{"__class":"JD_Input_PhoneCommandData","input":1099935642}}', 'TOUCH_OFF': '{"root":{"__class":"JD_TouchFeedback_PhoneCommandData","touchOn":false}}', 'TOUCH_ON': '{"root":{"__class":"JD_TouchFeedback_PhoneCommandData","touchOn":true}}', 'UP': '{"root":{"__class":"JD_Input_PhoneCommandData","input":3690595578}}', 'VALID': '{"root":{"__class":"JD_Input_PhoneCommandData","input":1084313942}}'}}

@Johnny-DPH thank you. I'll update that in the next version.

DNNH97 commented 2 years ago

@redphx I tried pasting the code, but neither right-clicking, nor Ctrl+V do anything. I can't even type anything manually when the Python script is running, only Ctrl+C to quit works.

redphx commented 2 years ago

@DNNH97 that's weird. Maybe you could copy (select the line then right click) after closing JoyDance with Ctrl + C.

DNNH97 commented 2 years ago

Which line would you like me to copy? The last line I can see in terminal or the line of code you provided here? I definitely can't paste that line into the terminal, and I also found another issue: I tried to see if local multiplayer would work, but as soon as I try to change the profile on the left Joy-Con, the script crashes and all controllers disconnect. I can only change the profile for player one on the right Joy-Con. Don't know if that's also an issue on other consoles. Plus, when using the stick to go left or right to select a coach, every connected Joy-Con moves over by one spot, not just the one I'm currently using.

redphx commented 2 years ago

The line starts with {'__class': 'JD_InputCollectionPhoneData', similar to my example. Sorry I didn't mean to ask you to paste the line to the Terminal, but other way around: I want you to copy a line in the Terminal and paste it here, on Github. Sorry for the confusion.
If it crashes, please also share the last few lines in the Terminal too.

Thank you.

DNNH97 commented 2 years ago

Ah, got you! Would this be it then? {'__class': 'JD_InputCollectionPhoneData', 'availableInput': {'DOWN': '{"root":{"__class":"JD_Input_PhoneCommandData","input":2467711647}}', 'LEFT': '{"root":{"__class":"JD_Input_PhoneCommandData","input":3652315484}}', 'RIGHT': '{"root":{"__class":"JD_Input_PhoneCommandData","input":1099935642}}', 'TOUCH_OFF': '{"root":{"__class":"JD_TouchFeedback_PhoneCommandData","touchOn":false}}', 'TOUCH_ON': '{"root":{"__class":"JD_TouchFeedback_PhoneCommandData","touchOn":true}}', 'UP': '{"root":{"__class":"JD_Input_PhoneCommandData","input":3690595578}}', 'VALID': '{"root":{"__class":"JD_Input_PhoneCommandData","input":1084313942}}'}}

As for the crashing with the left Joy-Con, I'll recreate the issue now and will post the last line here.

DNNH97 commented 2 years ago

As for the crash that happens using the left Joy-Con, this is what shows up after the crash: {'__class': 'JD_PhoneUiShortcutData', 'navigationBar': [{'__class': 'Phone_Action', 'title': '[icon:GEN-BACK] Back', 'command': '{"root":{"__class":"JD_Custom_PhoneCommandData","identifier":"SHORTCUT_BACK"}}', 'icon': '/resources/images/1565109232/shortcut_back.png'}], 'shortcuts': [{'__class': 'JD_PhoneAction_Shortcut', 'title': '[icon:CHANGE_DANCERCARD] Change Dancer Card', 'command': '{"root":{"__class":"JD_Custom_PhoneCommandData","identifier":"SHORTCUT_CHANGE_DANCERCARD"}}', 'icon': '/resources/images/1713223549/shortcut_dancercards.png', 'shortcutType': 'SHORTCUT_CHANGE_DANCERCARD'}, {'__class': 'JD_PhoneAction_Shortcut', 'title': 'Dance Together!', 'command': '{"root":{"__class":"JD_Custom_PhoneCommandData","identifier":"SHORTCUT_TOGGLE_COOP"}}', 'icon': '/resources/images/159306955/shortcut_coop.png', 'shortcutType': 'SHORTCUT_TOGGLE_COOP'}]} 'JoyConButton' object is not iterable disconnected

redphx commented 2 years ago

@DNNH97 thank you. That's super helpful. I still couldn't understand why Stadia didn't think JoyDance as a phone.
Could you please copy the first few lines after pairing with Stadia? It looks something like this:

'{"root": {"__class": "JD_PhoneDataCmdHandshakeHello'...
>>> {"__class":"JD_PhoneDataCmdHandshakeContinue"
...
{'__class': 'JD_PhoneDataCmdSyncEnd', 'phoneID': 44}

(all lines between JD_PhoneDataCmdHandshakeHello and JD_PhoneDataCmdSyncEnd)

redphx commented 2 years ago

I made a fix about the crash. Please download and try again.

DNNH97 commented 2 years ago

I should mention that it's probably an issue with streaming Stadia on a Computer, cause the player will look for connected HID-conforming devices (Such as the Joy-Con, wired or wireless) and try to map the game's controls to it, having it act like a virtual Stadia controller. What I previously mentioned about the pop-up screen regarding 3rd party controllers in Just Dance and the button icons changing does NOT happen when playing on my Chromecast! This is what shows up after successfully pairing with Stadia running ON A CHROMECAST:

JD_PhoneDataCmdHandshakeHello {'accelAcquisitionFreqHz': 50.0, 'accelAcquisitionLatency': 20.0, 'accelMaxRange': 8.0} Pairing... JD_PhoneDataCmdHandshakeHello {'accelAcquisitionFreqHz': 50.0, 'accelAcquisitionLatency': 20.0, 'accelMaxRange': 8.0} {'__class': 'JD_PhoneDataCmdHandshakeContinue', 'jdVersion': 'jd2022', 'protocolVersion': 5, 'phoneID': 1, 'platformName': 'GGP', 'titleID': '5cdcbb07449b4131bb302b9606334c87app1', 'consoleName': 'Stadia'} JD_PhoneDataCmdSync {'phoneID': 1} {'__class': 'JD_PhoneDataCmdHandshakeContinue', 'jdVersion': 'jd2022', 'protocolVersion': 5, 'phoneID': 0, 'platformName': 'GGP', 'titleID': '5cdcbb07449b4131bb302b9606334c87app1', 'consoleName': 'Stadia'} JD_PhoneDataCmdSync {'phoneID': 0} {'__class': 'JD_PhoneDataCmdSyncStart', 'phoneID': 1} {'__class': 'JD_PhoneDataCmdSyncStart', 'phoneID': 0} {'__class': 'JD_PhoneDataCmdSyncEnd', 'phoneID': 0} JD_PhoneDataCmdSyncEnd {'phoneID': 0} 48a5e7642545 PairingState.CONNECTED {'__class': 'JD_PhoneDataCmdSyncEnd', 'phoneID': 1} JD_PhoneDataCmdSyncEnd {'phoneID': 1}

I will now download the latest version and see if the left Joy-Con issue persists!

redphx commented 2 years ago

Hi, quick tip: if you want to post multiple lines of code, put them between a code block

LINE 1 LINE 2

redphx commented 2 years ago

Is it possible to disable Stadia from accessing bluetooth devices on your computer?

DNNH97 commented 2 years ago

Thanks for the hint! The script doesn't crash anymore, but the left Joy-Con still gets kicked out of the game. I have to click on Disconnect on the local website, refresh and reconnect it. Only the analog stick and A button (right) work. As soon as I press anything else, it disconnects, and in terminal, it says:

 File "G:\windows\joydance-0.2\current\joydance\__init__.py", line 320, in send_command
    for shortcut in SHORTCUT_MAPPING[joycon_button]:
TypeError: 'JoyConButton' object is not iterable
disconnected

I took a look at that section in the script and was wondering, could we add commands for the buttons Y and X (which is used to change the dancer card) and maybe that would fix it?

As for disabling Bluetooth for Stadia on my PC, it seems like I can only turn off HID devices altogether, so that would disable USB devices too. But it should be fine, cause the Stadia controller directly connects to the datacenter over WiFi.

redphx commented 2 years ago

I think I fixed it for real this time: https://github.com/redphx/joydance/archive/refs/heads/feature/stadia.zip

DNNH97 commented 2 years ago

Yes, that version finally works, thanks! To change profiles, I need to hold the Joy-Con sideways and press Y on the right Joy-Con and left (down if held sideways) on the left Joy-Con. Thought it was important to mention that too.

redphx commented 2 years ago

Yeah the button layout is different because I based on the Xbox version.

DNNH97 commented 2 years ago

The most important part is that it's working now, so thank you for writing this program!

redphx commented 2 years ago

@DNNH97 thank you so much. Without your help it wouldn't be possible. I'll implement these changes in the main code soon.

redphx commented 2 years ago

@DNNH97 version 0.3 with Stadia support is officially released: https://github.com/redphx/joydance/releases/tag/v0.3. Please help me test it one last time. Thank you.

DNNH97 commented 2 years ago

@redphx Version 0.3 works flawlessly, no bugs or crashes!

redphx commented 2 years ago

@DNNH97 thank you.