Need help programming Teensy 2.0 for digital arcade stick

Status
Not open for further replies.

Drambit

Active member
I custom built an arcade stick that I want to work as a universal controller, rather than emulate a keyboard. I have very little experience programming, but I have a very solid fundamental foundation of knowledge from a long history of working with electronics and computers, as well as dabbling a tiny bit in programming but being really bad at it. I could probably pick it up quickly but not without instructions, so I'm looking for some help here.

Here are the specifics of what I need to accomplish:
  • The stick is composed of 10 buttons, 8 face buttons, 1 start button, 1 select button, and a digital 8 way joystick. It looks just like this xbox10.jpg.
  • A lot of people seem to like emulating keyboards just so that it barely works on PC, but I want it to operate just like universal pcb, so that it works on PC, PS3, Mac, and the two next-gen consoles.
  • I'm using a Teensy 2.0 without any pins, but I have a bunch of wires soldered onto the board so I can breadboard everything.
  • Input lag is an absolute no-no, so if it reduces input lag even by 1 millisecond using C I will try to use C, although it is obviously much more difficult.

Any and all help is appreciated, I could probably eventually figure it out on my own but find it extremely difficult and have no intuition when it comes to computer programming, so this is a very challenging task for me. I would prefer if things are explained a bit rather than just someone sending me a carbon copy of their code, but I'll take anything I can get.
 
There is a lot of good software to help with this. First, there are examples that ship with the Teensyduino overlay. Most are very small and easy to understand. Second, there's joystick support that includes support for controllers with lots of axes and buttons. There's support for denouncing buttons, timers, interrupts and everything I can imagine you'll need. The hard part is finding all these things.

If I were you, I'd build up features and knowledge bit by bit. Start by making one button print to the serial monitor using the Debounce library.

[Edited: Drat you autocorrect!!! 'denounce' should indeed be 'Debounce'. Thank you, Storbeck. :)]
 
Last edited:
There is a lot of good software to help with this. First, there are examples that ship with the Teensyduino overlay. Most are very small and easy to understand. Second, there's joystick support that includes support for controllers with lots of axes and buttons. There's support for denouncing buttons, timers, interrupts and everything I can imagine you'll need. The hard part is finding all these things.

If I were you, I'd build up features and knowledge bit by bit. Start by making one button print to the serial monitor using the denounce library.

I'm pretty sure he means "Debounce" library rather than "denounce" library.

Just throwing it out there in case somebody new to this finds this thread and is googling "denounce" and coming up with nothing. Yelling at their keyboard "WHAT THE DUCK!!!!???"

I've been in similar situations myself! :)
 
In Arduino, after you've installed Teensyduino, start with File > Examples > Teensy > USB_Joystick > Buttons. You can install that software (free downloads) and at least look at the examples before buying anything.

I highly recommend at least getting it working before you dive into timing optimizations. There are many things you can do for lower latency, and I'm willing to help explain them if you want to try, but until you've at least made it work with the example, all that explanation is probably not going to mean much.
 
There is a lot of good software to help with this. First, there are examples that ship with the Teensyduino overlay. Most are very small and easy to understand. Second, there's joystick support that includes support for controllers with lots of axes and buttons. There's support for denouncing buttons, timers, interrupts and everything I can imagine you'll need. The hard part is finding all these things.

If I were you, I'd build up features and knowledge bit by bit. Start by making one button print to the serial monitor using the denounce library.

I don't even know what a serial monitor is, lol. I tried studying the usb joystick examples in teensyduino and didn't understand anything on the page, it seems simultaneously not complicated enough for what it is, and too complicated enough for me to understand. Gotta put in my homework I guess.
 
Maybe these 4 tutorials can help you get up to speed on Arduino basics?

http://www.pjrc.com/teensy/tutorial.html

The serial monitor is covered in tutorial #3.

Okay so I read the arduino website instructions as well as the teensy instructions (they are both good at different things.) I managed to get an example working where the code outputs text every second when a button is not pressed and different text when it is pressed. I imagine it's not that difficult to do that for 10 buttons and a joystick, but I have a feeling that the process is completely different for attempting to get the digital joystick as well as all 10 buttons running properly as a USB HiD compared to just outputting text in Arduino.

Where should I look to start learning how to do the HiD stuff? Also is it worth doing it in C to save on lag? Obviously I will have much more trouble in C than I will in Arduino but I'll do it if it means a better circuit.
 
You should not have to go to HID level if all you are really doing is a reasonably straightforward joystick - Tools->USB Type->*Pick one with Joystick*

Beauty of "Keyboard + Mouse + Joystick" is that you can have a variety more controls on your joystick and have them drive keyboard and mouse alongside the joystick stuff for a fuller controller if desired.
 
You should not have to go to HID level if all you are really doing is a reasonably straightforward joystick - Tools->USB Type->*Pick one with Joystick*

Beauty of "Keyboard + Mouse + Joystick" is that you can have a variety more controls on your joystick and have them drive keyboard and mouse alongside the joystick stuff for a fuller controller if desired.

The main thing is I want the teensy to serve as a permanent PCB. So, consistency and keeping lag to an absolute minimum are really important, once I get it working I'm probably never going to reprogram it. I don't want it to be emulating keyboard or mouse, just a classic controller.
 
It won't have less lag no matter how well you cut out the keyboard and mouse stuff mate - no quicker will it anything about it be.
 
Status
Not open for further replies.
Back
Top