Has anyone been able to get an Arduino Minecraft controller

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
pueo
 
Posts: 6
Joined: Tue Mar 04, 2014 1:07 am

Has anyone been able to get an Arduino Minecraft controller

Post by pueo »

I've been trying to build a Minecraft controller for the upcoming Mini Maker Faire that is being held in my area. But I have run into a problem. I am using an Arduino Micro and got the mouse emulator working great. The keyboard (the part that I thought would be easy) is throwing me for a loop. I'm using two microswitch joysticks, one for the mouse and one for WASD keys for movement. I've tried Keyboard.print('w') and Keyboard.write('w') but Minecraft will not respond.

If I start Notepad and move the joystick, "w" will appear. So I know it is sending the character. I have added a delay() so I don't get a ton of wwwwww and have adjusted up and down so I get one w or many. But Minecraft won't respond.

The mouse emulation works fine. Moving that joystick causes Minecraft to move as if you were using a mouse. If I hold the WASD joystick so it sends w's while I move the mouse joystick, Minecraft slows down. Which is what I would expect if the program was receiving multiple commands at the same time. This makes me believe that it is receiving some sort of signal, it just doesn't recognize it as a w.

I'm starting to wonder if Mojang's implementation of Minecraft in Java prevents the program from "seeing" the keystrokes.

I saw that someone here had been working on something similar, but the website that they were using to document their work is gone. And I haven't been able to find anything via Google. So I was wondering if anyone here has an idea on how to approach this. I could hack a keyboard to get this to work, but my goal was to use the Arduino to get the kids at the Faire interested in programming as well as the hardware aspect.

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Has anyone been able to get an Arduino Minecraft control

Post by adafruit_support_mike »

A user-space application shouldn't be able to tell the difference between a Micro pretending to be a keyboard and a regular keyboard. The signals reaching the computer should be identical, and the OS should wrap them up as keyboard events in the same way.

Try creating a sign, or some other task where you can enter text, and see if the controller's signals show up there.

User avatar
pueo
 
Posts: 6
Joined: Tue Mar 04, 2014 1:07 am

Re: Has anyone been able to get an Arduino Minecraft control

Post by pueo »

Thanks for the help. I figured out what was wrong. When I made the sign, moving the joystick created W, A, S, and D on the sign. So it was working in that sense. I finally got it to work by using Keyboard.press() and Keyboard.release(). with a delay.

Keyboard.press('w');
delay(100);
Keyboard.release('w');

I'm assuming that when the Micro sends the "w" it sends it too quickly for Minecraft to detect it correctly. Using press and release with the delay between allows Minecraft to "see" the character.

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Has anyone been able to get an Arduino Minecraft control

Post by adafruit_support_mike »

Interesting.. apparently there's some glitch-prevention or debouncing code in the input stack that assumes a legitimate keypress will last a certain amount of time.

Glad to hear you have it working though. Happy hacking!

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”