switchbrew / switch-examples

Switch examples for devkitA64 and libnx.
https://devkitpro.org/viewforum.php?f=42
559 stars 99 forks source link

usb/usb-comms: add example #73

Closed macabeus closed 4 years ago

macabeus commented 4 years ago

Add a new example using usb_comms functions to read and write on USB interface. Since we'll need another player to interact with Switch, I wrote a very simple web-based code.

fincs commented 4 years ago

usbComms is an old interface that is really limited in what it can do, and it has many shortcomings and poor error handling. For this reason I do not recommend its use (and thus it doesn't make sense to have an example for it). On top of that, I'm not sure if it's really a good idea to have the host application counterpart be implemented as a webpage that needs external dependencies...

macabeus commented 4 years ago

@fincs I think that usbComms is an enough interface. There are projects that uses a lot of it to provide nice tools, such as (removed). Instead of hidden it, is better to document it. Also, about the host application, there isn't so much way to avoid that. Is necessary a host application in order to show the demonstration about this API, and this webpage is a real and complete use case of that. On (removed) is used a java application, for example.

fincs commented 4 years ago

If all, I think it should be removed (or at the very least comprehensively refactored). It's a leftover from a very early development stage of libnx. User apps should really be using usbds directly, and properly handling error conditions. Also, it would be appreciated to avoid using piracy-related applications as examples.

macabeus commented 4 years ago

@fincs Okay, I understand better now. Thank you. Just one last question: do you have some idea of what exactly that would be done to improve usbComms? Such as which errors handlers that should be improved, or which functions that should have a better interface?

I'm learning about libnx and I would like to understand it better. (We would open an issue of that, if you prefer, of course).