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

used serial_number to identify and set type to a specific device #663

Merged
merged 1 commit into from
Jan 13, 2021

Conversation

maxill1
Copy link
Contributor

@maxill1 maxill1 commented Jan 13, 2021

This fixes the ability to change the type of a 3rd party JoyCon as described also here.

I noticed that 3rd party joycons (in my case joysky "wireless controller for N/SW") reported the same name "wireless gamepad" and vendor id to windows for Left and Right Joycon.
BetterJoy is using this args for generating a unique id for 3rdParty configuration that results the same for Left/Right.

3rdPartyControllers file content in 6.4a version:
Wireless Gamepad|1406|8201|2
Wireless Gamepad|1406|8201|3

3rdPartyControllers file content in current master:
Wireless Gamepad(1406-8201)|1406|8201|2
Wireless Gamepad(1406-8201)|1406|8201|3

In both cases the first joycon is assigning 2 as type to the other joycon.

By using bluetooth serial number as additional identifier we can target specific device with correct type:
Wireless Gamepad(1406-8201-98b6e99a9c77)|1406|8201|2|98b6e99a9c77
Wireless Gamepad(1406-8201-98b6e904ea9e)|1406|8201|3|98b6e904ea9e

Changes:

  • used serial_number as additional condition in "check list of custom controllers specified" block
  • SController now incapsulate serial_number and use it for hash, equals, serialize etc
  • Read the 5 index of 3rdPartyController file on _3rdPartyControllers

This pull request in addition to "NonOriginalController"="DefaultCalibration" (as suggested here) fixed my 3rdParty joycons.

P.S. This is my first attempt on C#, so be kind to me and I'm opened toy suggestions.

3rd party joycons (tested on joysky "wireless controller for N/SW) reported the same name "wireless gamepad" so i was unable to correcly address the left/right type of joycon. 

By using bluetooth serial number as additional identifier we can target specific device with correct type.

Changes:
- used serial_number as additional condition in "check list of custom controllers specified" block
- SController now incapsulate serial_number and use it for hash, equals, serialize etc
- Read the 5 index of 3rdPartyController file on _3rdPartyControllers
@Davidobot
Copy link
Owner

Nice one! Very clean commit adhering to the set code style of the repo.

Glad the 3rd party support is slowly getting there. If it's not a bother, could you compile the latest master (with your pushed changes) and reply to those issues you linked with a build for them to try out? To see if it resolves their problems?

@Davidobot Davidobot merged commit 53a0a27 into Davidobot:master Jan 13, 2021
@maxill1
Copy link
Contributor Author

maxill1 commented Jan 13, 2021

Of course. I will post the build also here for future reference.

BetterJoy_53a0a2.zip

P.S. For 3rd party support i also had to change the "BetterJoyForCemu.exe.Config" file to set"NonOriginalController" to value="DefaultCalibration" (as suggested here).

@junwen12221
Copy link

I think it does job of #567, so I turn off #567

@calum12
Copy link

calum12 commented Jan 14, 2021

I tried out the build with all 3 NonOriginalController settings

Pro controller connected.
Subcommand 0x38 sent. Data: 0x18 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
Response ID 0x3F. Data: 0x00 00 08 F0 78 CF 79 D0 74 2F 83 00 80 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
Response ID 0x3F. Data: 0x00 00 08 00 79 DF 79 D0 74 3F 83 00 80 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
Response ID 0x3F. Data: 0x00 00 08 00 79 CF 79 D0 74 1F 83 00 80 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
Response ID 0x3F. Data: 0x00 00 08 F0 78 DF 79 D0 74 1F 83 00 80 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
Response ID 0x3F. Data: 0x00 00 08 00 79 DF 79 D0 74 2F 83 00 80 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
No response.
No response.
No response.
No response.
No response.
Subcommand 0x30 sent. Data: 0x01 
No response.
No response.
No response.
No response.
No response.
No response.
No response.
No response.
No response.
No response.
Subcommand 0x40 sent. Data: 0x01 
No response.
No response.
No response.
No response.
No response.
No response.
No response.
No response.
No response.
No response.
Subcommand 0x48 sent. Data: 0x01 
No response.
No response.
No response.
No response.
No response.
No response.
No response.
No response.
No response.
No response.
Subcommand 0x41 sent. Data: 0x03 00 00 01 
No response.
No response.
No response.
No response.
No response.
No response.
No response.
No response.
No response.
No response.
Subcommand 0x03 sent. Data: 0x30 
No response.
No response.
No response.
No response.
No response.
No response.
No response.
No response.
No response.
No response.
Done with init.
Subcommand 0x38 sent. Data: 0x10 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
No response.
No response.
No response.
No response.
No response.
No response.
No response.
No response.
No response.
No response.
Starting poll thread.
Starting server on 127.0.0.1:26760
All systems go
Rumble data Recived: XInput
Rumble data sent: 10 07 00 01 40 40 00 01 40 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
Rumble data Recived: XInput
Dropped.
Connection lost. Is the Joy-Con connected?
Removed dropped controller. Can be reconnected.

I used debug 1 and get the following output when it's left to default.
If I used defaultcalibration or defaultcontroller then nothing happens, there is no noticeable attempt from the program/controller to attempt connecting but the controller remains in the 3rdpartycontrollers gui and file, switching back to default has the controller attempt to connect again and give the same output as above.

I have the PowerA Wireless gamecube controller

this is what shows in the 3rdpartycontrollers file, Wireless Gamepad(0-0-000be474443d)|0|0|1|000be474443d

@calum12
Copy link

calum12 commented Jan 14, 2021

having retried all the options, defaultcontroller actually causes the same issue as default now, not sure what changed the behaviour though. I tried with and without rumble and with and without homeLED enabled, same issue.

@Davidobot
Copy link
Owner

Davidobot commented Jan 14, 2021

@calum12

I have the PowerA Wireless gamecube controller

I'm not sure why a Gamecube controller would even have a chance of working? Surely it's not seen as a Pro controller (as it wouldn't have gyro/accel and would have analogue triggers).

EDIT: I take back the gyro/accel bit. It doesn't however support HD rumble, so maybe something breaks there?

@calum12
Copy link

calum12 commented Jan 14, 2021

The gamecube controller acts as and is seen as a pro controller on the switch. It also has digital triggers instead of analogue, and like you mention in the edit does have gyro/accel but as you point out it lacks any rumble feature so it does seem plausible that the issue lies there. The controller works on steam using the nintendo controller configuration and can use gyro if that provides any additional info.

If theres anything you can think of me doing to try to get more info about the controller that could be useful don't hesitate to ask.

@Davidobot
Copy link
Owner

Davidobot commented Jan 22, 2021

I tried out the build with all 3 NonOriginalController settings

Pro controller connected.
Subcommand 0x38 sent. Data: 0x18 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
Response ID 0x3F. Data: 0x00 00 08 F0 78 CF 79 D0 74 2F 83 00 80 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 

I took a look at this. The 0x3F report id from the controller suggests that it is in simple HID mode and isn't providing the full report. It is sent when you press a button on the controller.

It stops reacting when you try to blink the lights, so maybe comment out these two lines https://github.com/Davidobot/BetterJoy/blob/master/BetterJoyForCemu/Joycon.cs#L422

Maybe it needs to be manually paired via BT? Though I'm not sure. If the above doesn't work, try changing https://github.com/Davidobot/BetterJoy/blob/master/BetterJoyForCemu/Joycon.cs#L374 to !isUSB

@calum12

@calum12
Copy link

calum12 commented Feb 1, 2021

so I changed

if (form.nonOriginal) {
    enumerate.product_id = product_pro;
}

to

if (form.nonOriginal) {
    enumerate.product_id = product_pro;
    if (enumerate.product_string == "Wireless Gamepad" && enumerate.manufacturer_string == "Nintendo")
        enumerate.vendor_id = vendor_id;
}

and this makes my controller get detected in nonOriginal mode (defaultCalibration) without having to add it to the third party menu.

I tried blanking out those two LED lines and it doesn't really seem to change much from what I can tell. I tried the !isUSB change too and the controller just drops and then auto reconnects repeatedly.

I also noticed then when I turn rumble to false it apparently still tries to use rumble, but instead of simply dropping the controller it instead gives an error about the feedback received

Debug log with the 2 lines you suggested to cut out and the lines I posted above

Starting server on 127.0.0.1:26760
All systems go
Pro controller connected.
Using factory stick calibration data.
Stick calibration data: 4095 4095 4095 4095 4095 4095 
Using factory stick calibration data.
Stick calibration data: 4095 4095 4095 4095 4095 4095 
User gyro neutral position: -1 -1 -1 
Factory gyro neutral position: -23 -14 13 
Subcommand 0x40 sent. Data: 0x01 
Response ID 0x21. Data: 0xE3 80 00 00 00 32 77 83 36 D7 7A 00 90 10 32 60 00 00 0A AF 3C AF 3C AF 3C FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
Subcommand 0x48 sent. Data: 0x01 
Response ID 0x21. Data: 0xE6 80 00 00 00 33 87 83 38 E7 7A 00 80 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
Subcommand 0x41 sent. Data: 0x03 00 00 01 
Response ID 0x21. Data: 0xE9 80 00 00 00 33 77 83 36 E7 7A 00 80 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
Subcommand 0x03 sent. Data: 0x30 
Response ID 0x21. Data: 0xEC 80 00 00 00 33 77 83 36 D7 7A 00 80 41 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
Done with init.
Subcommand 0x38 sent. Data: 0x10 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
Response ID 0x21. Data: 0xEF 80 00 00 00 33 77 83 38 E7 7A 00 80 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
Starting poll thread.
Rumble data sent: 10 00 00 01 40 40 00 01 40 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
Rumble data Recived: XInput
Dropped.
Connection lost. Is the Joy-Con connected?
Removed dropped controller. Can be reconnected.

Debug Log with rumble disabled

Starting server on 127.0.0.1:26760
All systems go
Pro controller connected.
Using factory stick calibration data.
Stick calibration data: 4095 4095 4095 4095 4095 4095 
Using factory stick calibration data.
Stick calibration data: 4095 4095 4095 4095 4095 4095 
User gyro neutral position: -1 -1 -1 
Factory gyro neutral position: -23 -14 13 
Subcommand 0x40 sent. Data: 0x01 
Response ID 0x21. Data: 0x6F 80 00 00 00 7C 97 81 00 47 79 00 90 10 32 60 00 00 0A AF 3C AF 3C AF 3C FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
Subcommand 0x48 sent. Data: 0x01 
Response ID 0x21. Data: 0x72 80 00 00 00 7C 87 81 01 57 79 00 80 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
Subcommand 0x41 sent. Data: 0x03 00 00 01 
Response ID 0x21. Data: 0x75 80 00 00 00 7D 97 81 01 47 79 00 80 48 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
Subcommand 0x03 sent. Data: 0x30 
Response ID 0x21. Data: 0x78 80 00 00 00 7C 87 81 00 57 79 00 80 41 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
Done with init.
Subcommand 0x38 sent. Data: 0x10 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 
Response ID 0x21. Data: 0x7B 80 00 00 00 7B 97 81 00 37 79 00 80 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
Starting poll thread.
Rumble data sent: 10 00 00 01 40 40 00 01 40 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 

The Error

System.NullReferenceException
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=BetterJoyForCemu
  StackTrace:
   at BetterJoyForCemu.Controller.OutputControllerXbox360.FeedbackReceivedRcv(Object _sender, Xbox360FeedbackReceivedEventArgs e) in .\BetterJoyForCemu\Controller\OutputControllerXbox360.cs:line 94

@AnUrbanPenguin
Copy link

I have the Power A Enhanced Wireless Swicth controller. Just tried this build after talking to David. My controller is detected but only for a few seconds before being dropped and turning off. If I turn it back on it is detected again (as a different player [1-4]) then drops again.

I have tried with each of the 3 modes in Third Party config settings. The only one that the controller pairs at all in is Disabled. All the others it wont connect at all.

It seems like great progress though!

d3xMachina pushed a commit to d3xMachina/BetterJoy that referenced this pull request Nov 19, 2021
…idobot#663)

3rd party joycons (tested on joysky "wireless controller for N/SW) reported the same name "wireless gamepad" so i was unable to correcly address the left/right type of joycon. 

By using bluetooth serial number as additional identifier we can target specific device with correct type.

Changes:
- used serial_number as additional condition in "check list of custom controllers specified" block
- SController now incapsulate serial_number and use it for hash, equals, serialize etc
- Read the 5 index of 3rdPartyController file on _3rdPartyControllers
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

Successfully merging this pull request may close these issues.

None yet

5 participants