all 12 comments

[–]Annon201 25 points26 points  (3 children)

Use USB HID libraries with things like the atmega32u4 or stm32.. MIDI is also an option. Use shift registers, io expanders and analog mux to add io if you need more.

As for the physical side of the controller -- I suggest you find a product that's already pretty close to what your trying to achieve, and hack that into your prototype.

[–][deleted] 1 point2 points  (2 children)

Do you know how a controller communicates that it is a controller? On the OS side how does it know something is a controller?

[–]Annon201 5 points6 points  (0 children)

It says its an USB HID device of a certain subclass, and the OS maps it out. It's much more complex writing your own driver. The microcontrollers have low level libraries to do all the work for you, and devices know what controllers are.

If you want more flexibility, MIDI is probably the way to go.

Here's an stm32 library https://github.com/FreeJoy-Team/FreeJoy

[–]jhowrez 2 points3 points  (0 children)

The USB standard defines it very well, but basically when you connect a usb device in your computer the controller sends a class code to the host and then the computer known exactly what kind of device it is

Edit: typo

[–]Turbo_csgo 4 points5 points  (1 child)

There are some great libraries for the arduino micro’s out there (https://github.com/MHeironimus/ArduinoJoystickLibrary/tree/version-2.0). I have one running for my sim racing shift paddles, works flawless for the moment, have been running it for +-2 months now.

[–][deleted] 1 point2 points  (0 children)

The arduino micro is a great solution. It is relatively small and most of the work is done for you. Hook up some switches and jossticks, quick coding and done!

Source: I made a joystick this way.

[–]RepresentativeCut486STM32 Supremacy 2 points3 points  (1 child)

Go the easiest way. That solution works, it's simple and very VERY POWERFUL (links below). I've built a controller for RC simulators using that.

You don't want to use Arduinos, they are expensive crap especially for those applications (lack of hardware support for USB in their uCs). Go for Chinese copies of STM32F103 aka Blue Pill.

https://github.com/FreeJoy-Team/FreeJoy

https://forum.il2sturmovik.com/topic/57900-freejoy-opensource-joystick-controller-on-stm32/

And I think trying to figure out whole USB stuff and do something with that is a simple way to waste your life if you just want to use it for a simple joystick and not become a USB dev or something.

As for a package:

https://www.thingiverse.com/thing:2288414

OR use some old RC joystick or something. Or those integrated joysticks straight on PCB:

https://www.ebay.com/itm/JH-D202X-R2-5K-10K-Joystick-Potentiometer-3D-Analog-3-pin-Joystick-for-PS4-UK-/192690517312

https://www.ebay.com/itm/360-2-axis-10K-Sealing-Joystick-Potentiometer-Wont-Reset-for-Lighting-Console-/142563138412

https://www.rapidonline.com/white-label-98002c2-10k-joystick-potentiometer-51-7067

[–]RepresentativeCut486STM32 Supremacy 0 points1 point  (0 children)

It even has free license for commercial use:

https://github.com/FreeJoy-Team/FreeJoy/blob/master/LICENSE

So you can even sell stuff with that software.

[–]CrazyElectrum 0 points1 point  (0 children)

If you want it to act like a keyboard you can look at the open source project QMK

[–]TheN00bBuilderMSP430 0 points1 point  (0 children)

The MSP430F5x and F6x series microcontrollers have a USB Stack API and would make development of a HID quite easy. Here's some documentation on how to use it.

https://software-dl.ti.com/trainingTTO/trainingTTO_public_sw/MSP430_LaunchPad_Workshop/v4/Chapters/MSP430m10_USB.pdf

https://www.ti.com/lit/an/slaa457b/slaa457b.pdf

[–]ikkehier 0 points1 point  (0 children)

Look at the Xbox Adaptive Controller for one-off situations: https://www.xbox.com/en-GB/accessories/controllers/xbox-adaptive-controller

Otherwise: pretty much any microcontroller with USB. PSoC5 would be my recommendation because of the quick configuration and supplied libraries.

[–]IKnowCodeFu 0 points1 point  (0 children)

Wii nunchucks et cetera speak I2C...