NicoHood / Nintendo

Use Nintendo Controllers with Arduino
http://www.nicohood.de
MIT License
278 stars 55 forks source link

Add Pokémon Colosseum,XD support #31

Closed mizuyoukanao closed 3 years ago

mizuyoukanao commented 3 years ago

Hello, thanks for the great library. I found a problem where data could not be sent only when running Pokémon Colosseum/XD. When running Pokémon Colosseum/XD, the GameCube seems to return different data than the other games. However, i solved the problem by copying line 114 and below of Gamecube.c and changing else if (receivedBytes == 3 && command[0] == 0x40 && command[1] == 0x03) to else if (receivedBytes == 3 && command[0] == 0x40 && command[1] == 0x00) If you are comfortable with this change, I would appreciate it if you could merge the code. Thank you.

NicoHood commented 3 years ago

That should be a different data format:

0x00 First 4 bytes: buttons0+1 + X + Y, C-Stick, L+R minimum of both, 0x00 fixed

So in this case we'd need to modify the data to work correct. Now the question is, does Pokemon XD actually use the left/right buttons? Or do they use the dynamic depth feature?

The code could be something like (not tested):

else if (receivedBytes == 3 && command[0] == 0x40 && (command[1] == 0x03 || command[1] == 0x00))
{
  // Minimum of left + right trigger
  if (command[1] == 0x00) {
    if (report->left > report->right) {
      report->left = report->right;
    }
    report->right = 0x00;
  }
  gc_n64_send(report->raw8, sizeof(Gamecube_Report_t), modePort, outPort, bitMask);

[...]
mizuyoukanao commented 3 years ago

Thank you for your quick reply. Pokémon XD/Colosseum does not use the left/right buttons, dynamic depth feature. And I've tested the code you attached and it seems to work fine! I look forward to updates that incorporate this code.

NicoHood commented 3 years ago

I am checking the dolphin code: https://github.com/dolphin-emu/dolphin/blob/master/Source/Core/Core/HW/SI/SI_DeviceGCController.cpp#L167

And this PR: https://github.com/NicoHood/Nintendo/pull/25

It turns out, that my annotations are possibly incorrect. I currently aint got time or a setup to test this. I do not even know what analog A and B would be. There is no such thing on a normal controller. Do you know any custom controller with such buttons?

NicoHood commented 3 years ago

Please try this: https://github.com/NicoHood/Nintendo/pull/34

NicoHood commented 3 years ago

The last commit is not what I wanted. Let me do the cleanup real quick...

NicoHood commented 3 years ago

Closing in favor of: https://github.com/NicoHood/Nintendo/pull/42