-
-
Notifications
You must be signed in to change notification settings - Fork 409
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
Gamepad + Keyboard/Mouse doesn't seem to be working properly #139
Comments
Thats a known issue. Use the single report mouse/keyboard/gamepad. (aka Gamepad1, Bootkeyboard, Bootmouse) |
Unfortunately this is not sufficient, as even using (= calling
Commenting out two of those instances allows the BootKeyboard to show up:
I'm not sure how this can be fixed. I'm not a big fan of object instances defined at library level, but you went for this approach everywhere, and that's what all the official Arduino libraries do, so I guess it's ok. Maybe the default instances can be reduced to one or two and if a user needs more, they can just declare as many extra as they need. Maybe just calling IMPORTANT: It should be noted that I have the Multiple Input USB “quirk” enabled on my system, maybe this is influencing the way the devices show up. |
Could this having anything to do with it? This output is from some USB debugging software I picked up on the Interwebz so I can't really comment beyond what this says, however, this is a SAMD powered device as you can see, operating in Gamepad mode per example. There are other factors in the report that are "off" too but this one seems to be something that could actually trip everything up. I'm going to have a look through Nico's code but my C++ skills are so poor that it's unlikely I'll be able to find it. Perhaps this will help someone else, even Nico - although I understand that he has pretty much left this project and I can understand why, given the lack of contributions from outside.
|
I really recommend using LUFA if you want a reliably working USB Core. The arduino core is not flexible enough for all usecases. It is made to abstract the basics, not the complex things. USB is such kind of ultra complex thing, and I did not use it for a long time, so I am so so so sorry that I am really no help (anymore) :-/ |
Hey Nico, you've done us all a solid man! Don't sweat it... doing stuff for free is expensive (if you get my drift)! I'm itching to try Hoodloader 2 on my new "Uno" clone though! 👍 |
Reading your recommendation Nico (https://www.beyondlogic.org/usbnutshell/) which is a great reference for the terrified, I'm starting to think this is a USB2/3 issue in the underlying HID software/firmware. I don't have a Windows 10 box with USB2 handy, but I have one I can test this on. Be nice to rule that out as our suspect! |
I'm not sure what we're talking about here. In my experience, commenting out 2 instances of On a side note, the initialization order doesn't seem to change anything: even calling |
It works fine on Linux - that's the issue, it fails on Windows - and it doesn't look like Nico's code that's the problem, I think it's in the underlying Arduino HID implementation which hasn't been touched in years. Per Nico's suggestion, I've switched to a different library, which doesn't use the Arduino base a works flawlessly across several different boards. |
Understood, but I'll try to make a test to confirm this. What library did you switch to, @marcdraco? |
Dean Camera's LUFA - although I've also switched from an Arduino to a Teensy - I think on Dean's suggestion. It's primarily because I had a spare Teensy 3.1 in stock gathering dust (soldered to a board) and I figured... how hard can it be (to remove). Harder than I thought. Dang those SMT chips are close to the header soldering! I think (and I could be wrong - I'm working on something else right now - that the Teensy also uses LUFA). It's a very well-used library with commercial and free tiers. I don't blame Nico for dropping out of this - it's all fine and well debugging our own code but when a library we rely on has issues we end up taking the heat for something that's (often) outside of our control. USB is stupidly complex so it's something I'm happy to leave to experts and just hope it sends/returns what I expect it to. |
I have 4 gamepads, bootmouse, and bootkeyboard on Windows 10 and Linux. I have not done much testing though. The trick is to remove the Arduino CDC ACM port (frees 3 endpoints) and clean up the device class, subclass, and protocol fields. The IDE auto upload will not work without the CDC ACM port but double clicking the reset button before uploading works.
All my testing has been done with an Adafruit M0 board. Patches to the Adafruit SAMD board files are required. Also use version 1.5.14. Higher versions do not work for me. Patches in diff format to disable Arduino CDC ACM port and fix device descriptor.
Class, subclass, protocol before patches.
After patches.
|
Nice! Have you filed a Pull Request for those? I'm still very much splodging around after a >30 year (!) hiatus from any serious programming and a lot of this is new... Y'know long before Stroustrup dreamed up C++ and even then, I was a middle-road 6502/6809/Z80 assembly-language and BASIC (ugh) programmer! Oh, the shame... but BASIC was all we had for high-level stuff on some of those machines. |
None of the changes are in the the HID library. The changes are in the Adafruit SAMD board package but they cannot be made permanent. Doing so would remove the CDC ACM port on all Adafruit SAMD boards. Use the Arduino IDE portable feature to create a sandboxed build environment for these kinds of changes. https://www.arduino.cc/en/Guide/PortableIDE I forgot to mention if using SAMD boards, use the latest version of the HID library from github. The last release does not include the latest SAMD board fixes. |
Actually the HID library is working pretty well here. I'm typing this message on a Commodore 16 keyboard connected via USB to a Dell Laptop running Win10Pro through a custom ATmega32U4 board. Two joysticks are connected at the same time, they have been detected and are working perfectly. HID serial is in use as well. |
Yes, I do not see any problems with the HID library. Removing the USB serial is optional. Very handy if you want to want to free up endpoints for more devices. |
Ok, I was mainly referring to @marcdraco's comment above. The only mod i did was commenting out SingleGamepad3 and 4. So I'm using SingleGamepad1, 2 and a multi-report combination of Keyboard, Consumer and System. Everything seems to work fine on both Linux and Windows. |
Well I'm totally confused but I'm dug in like a tick developing something different for the Arduino Uno so I'm off the map right now. Hopefully, I'll get back to this and try these changes. |
I have a simple sketch where I initialize one gamepad, mouse and keyboard. (attached)
If i try to use all three at the same time, mouse and keyboard send events, but gamepad does not.
If i switch gamepad to gamepad1, then only gamepad1 sends events, but mouse and keyboard do not. Also for some reason, three joysticks are detected instead of the one I have initialized.
hidproject_example.txt
The text was updated successfully, but these errors were encountered: