Go Down

Topic: Game controller (Read 2255 times) previous topic - next topic

AznKeto

If anyone out there is familiar with game console emulators, such as the N64 emulator where you can download the virtual console software then download ROM files and play them as N64 games on your computer, or even just PC games in general, you know that having a mouse usually just isnt as great as using a joystick. Depending on how much cash I have, I might buy the arduino joystick shield since it comes with everything nice and clean, but I was wondering how to use the analog values for the joystick for the mouse X & Y on my laptop, and use the buttons as keys on my keyboard. And I'd guess that theres some way you could do this all through the serial port from laptop to arduino, but I'm not quite sure how, any sources or info anyone could toss my way?
I saw a video on Sparkfun website a few weeks ago of them using an accelerometer through an Xbee wireless setup to control the mouse X & Y, so I'd think using a joystick through an arduino on a serial port wouldn't be terribly difficult.

frank26080115

You have choices to make

Do you have an UNO? If yes, you can use the on board ATmega8U2 to act as an USB HID device, the easiest way to do this is to have the ATmega328P read in analog data from the joysticks and button states from the buttons and communicate those information to the ATmega8U2, who will format the data as USB HID reports that are sent to the computer, which will automatically become mouse and keyboard data if you setup the ATmega8U2's USB descriptors correctly. This requires you to know how to use LUFA, and how to make a descriptor for a composite HID device.

If you don't have an UNO, or don't want to use LUFA, you can try V-USB, you'll need some resistors and diodes for this. There are many mice and keyboard examples out there, and I've also written a few tutorials and example projects myself: http://frank.circleofcurrent.com/usnoobie/tut_proj.php , you'll need to understand how to write composite HID descriptors in order to make your device both a mouse and keyboard at the same time. You should read the tutorial on that even if you choose LUFA instead of V-USB.

If you can't do any of those, I have a 3rd solution. Write an AutoIt script that reads the serial port which will translate serial data into mouse movements and key presses. I've done this before, it's the least reliable and least pretty but it's also a trade-off between understanding USB vs learning AutoIt scripting. I had a Wii Nunchuk as a mouse working in this fashion, but as soon as I learned to use V-USB, I completely re-wrote that project to use V-USB.
Freelance engineer, consultant, contractor. Graduated from UW in 2013.

cr0sh


If anyone out there is familiar with game console emulators, such as the N64 emulator where you can download the virtual console software then download ROM files and play them as N64 games on your computer, or even just PC games in general, you know that having a mouse usually just isnt as great as using a joystick. Depending on how much cash I have, I might buy the arduino joystick shield since it comes with everything nice and clean, but I was wondering how to use the analog values for the joystick for the mouse X & Y on my laptop, and use the buttons as keys on my keyboard. And I'd guess that theres some way you could do this all through the serial port from laptop to arduino, but I'm not quite sure how, any sources or info anyone could toss my way?
I saw a video on Sparkfun website a few weeks ago of them using an accelerometer through an Xbee wireless setup to control the mouse X & Y, so I'd think using a joystick through an arduino on a serial port wouldn't be terribly difficult.


First off, which emulator is it?

Secondly, unless it was a really old DOS emulator (such as NESticle or Genecyst), I would think that it would have some way to map a USB joystick to the emulated joysticks. I know I can do that with MAME/MESS, and I know it is available for other "newer" emulators. Barring that, I would think you could find (paid or free) software to map USB joysticks to simulate the mouse and/or keypresses.

Unless rolling your own solution (and the learning about how that comes with it) is your goal, I think there are far easier ways to do what you are trying to do...

:)
I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

AznKeto

Im considering doing this as a senior project, so I just wanted to know a bit more about it before I started anything.


Go Up