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

Added Switch single and dual tatacon functionality #2

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

drFerg
Copy link

@drFerg drFerg commented Sep 26, 2018

Let me know if you want me to add or remove anything.

The changes are fairly confined to it's own firmware. The keyboard firmware is only updated to support the new function signatures in the updated lufa.

 - Mimics the Pokken Controller which is a Pro Controller.
 - Currently doesn't perform debouncing like original firmware.
 - When plugged in, it performs the L + R, A combo to be synced.
 - Uses L, R, LSTICK, RSTICK, for Dons and Kats
 - Needs to be fixed to use stored config
 - Performed some code cleanup, needs to be further refactored
 - Added relevant vendor/product ids to manifest
 - Updated code to support V0 (OSU) and V2 (Switch)
 - Correctly updates configuration based on version, as versions
   use differing configuration layouts and sizes
 - Like Keyboard firmware, supports Joystick and HID configuration
 - Switch firmware now supports custom button assignment based on
   the switch pro controller buttons
 - Added debouncing back to match keyboard firmware
 - Updated makefile to add usbclass for configuration
 - Added both C(unix) and Python(windows) versions
 - Updated makefiles to flash using these tools
 - Duplicates the interface and endpoints to add a second controller
 - Drum output depends on which interface reads it first, but it's
   just a proof-of-concept
@mon
Copy link
Owner

mon commented Sep 27, 2018

As I've mentioned before, outstanding work.

Google is deprecating Chrome web apps (I think they're due to break this year), so I wasn't going to continue working on the configurator - I'm currently rewriting using C and hidapi. Trying to find a nice "easy" Linux+Windows toolkit for a UI, but the CLI is almost done.

Having a third VID/PID pair is annoying - can you confirm that you must have the Hori VID/PID for the switch to recognise the controller? Or is it just the descriptors that matter?

I definitely want a unified firmware, but I'm committed to doing that work myself (and finally have some time to achieve it), so no worries there.

It's also excellent to hear that 2-player works, and I guess I'll start designing a new 2-port PCB for that goal.

I see you've enabled the "let mon commit to your repo" option, so any merging/adjustments I'll put in there until it's ready for release.

@mon
Copy link
Owner

mon commented Dec 16, 2018

I just bought a switch. Expect this to be merged sooner rather than later.

@drFerg
Copy link
Author

drFerg commented Dec 17, 2018

Great news! Apologies I never got back to you, I got sidetracked by life haha. Looking forward to seeing progress.

@renanyuu
Copy link

Hi
Whats the status on this?

Copy link

@YaelBx YaelBx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried your work today thank you for this huge contribution !
Had a couple of issues, can you take a look to them ?
Looking forward to hearing your feedbacks :)

Thanks again,
Yaël B.

// Type Defines
// Enumeration for joystick buttons.
typedef enum {
SWITCH_Y = 0x01,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
Looking at my Pro Controller inputs through Windows internal controller calibration system, it seems like I found instead

SWITCH_B       = 0x01,
SWITCH_A       = 0x02,
SWITCH_Y       = 0x04,

Are you sure of those values ? :)

$(AVRDUDE) -U flash:w:DFU/BootloaderHID.hex:i

flash: all
sleep 1
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"sleep" command is not recognized by Windows cmd


flash: all
sleep 1
python2 DFU/hid_bootloader_loader.py atmega16u2 Joystick.hex
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

python instead ?

}
report_count++;
break;
case TATACON_PASSTHROUGH:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something really fishy around here.

Pads were triggering a lot of buttons, including Home, which shouldn't happen at all.
Hard for me to catch the source and find a workaround without a proper debugger... :(

Also, I have almost always double triggering, which should be because of my Tatacon, but debounce (set to 4000 to check if anything happen) seems to do nothing....

Small and dirty workaround I did for the button (didn't found for the debounce yet):

Suggested change
case TATACON_PASSTHROUGH:
case TATACON_PASSTHROUGH:
// Get tatacon button data
data = nunchuck_readByte(BUTTONS_DATA);
CLEAR(LED_PORT, KAT_LED_PIN);
CLEAR(LED_PORT, DON_LED_PIN);
// Tatacon has 4 inputs to check
for(i = 0; i < TATACON_SWITCHES; i++) {
// The I2C data starts at the 6th bit and goes down
uint8_t newState = !(data & _BV(TATACON_BUTTONS_START - i));
if(!switches[i].debounce && switches[i].state != newState) {
switch(i) {
case 0 :
reportData->Button |= SWITCH_LCLICK;
SET(LED_PORT, DON_LED_PIN);
break;
case 1 :
reportData->Button |= SWITCH_ZL;
SET(LED_PORT, KAT_LED_PIN);
break;
case 2 :
reportData->Button |= SWITCH_RCLICK;
SET(LED_PORT, DON_LED_PIN);
break;
case 3 :
reportData->Button |= SWITCH_ZR;
SET(LED_PORT, KAT_LED_PIN);
break;
}
switches[i].state = newState;
switches[i].debounce = tataConfig.debounce;
switchesChanged = 1;
}
}
break;

else if (report_count == 25 || report_count == 50) {
reportData->Button |= SWITCH_L | SWITCH_R;
}
else if (report_count == 75 || report_count == 100) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit too quick for the switch to catch the A button :)
I set my second value to 200 instead of 100, seems to do the trick

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.

4 participants