Keyboard Input in DS Java?

I am trying to trigger commands on our robot using a breakout arcade buttuon board that displays as a keyboard. Does anybody know how to read keystrokes from the Driver Station in Java?

1 Like

I don’t think there is a direct interface. I also would not recommend this as if you accidentally hit the space bar you will E-Stop your robot or hit enter which disables it.

1 Like

Well, we have five buttons that map to u, v, c, x, and Ctrl (until recently Spacebar because the guy who built it didn’t know about e stop)

The answer is it depends what dashboard you’re using. The only way the robot can get the keyboard data is if the dashboard sends it. If you’re programming in Java, you’re probably either using SmartDashboard or Shuffleboard. I don’t have a ton of experience with Java, but as far as I know, neither of these allow you to send keyboard data to the robot.

If, however, you use a custom programmed dashboard like a LabVIEW dashboard, locally-hosted website, or other custom program, you can choose any data to send over NetworkTables. If you don’t mind learning a bit of LabVIEW, the functions to get the currently pressed buttons and send them over NetworkTables aren’t too difficult. Since the LabVIEW dashboard is running locally on the driver station and the Java code is running on the roboRIO, they should be able to communicate by NetworkTables, which they both can read/write to.

I assume you are trying to do something like team 1370 has done in this image?
They have an button box on the right side.
You could ask @pugsly14 to see what they did. I am also curious so please update here when/if you figure it out.

1 Like

That looks like a COTS box for controlling a device. We just have some arcade buttons stuck through a piece of wood and soldered to a board. We are switching it to a cypress board.

Is it too late to change the controller to something that appears to the DS computer as a joystick/gamepad? If you can make this change, then you will be able to interact with your custom device from robot code the same way you read button presses off a joystick.

There is a discussion here about commonly-used options for custom gamepads available from FIRST Choice.

Obligatory pictures of our DS from last year: Robot Controller Options - #4 by tpc.

Edit: Didn’t see your last post before I posted. Sounds like you have it figured out:

the cypress board might be too old…

Which Cypress board are you using? What makes you say that it might be too old?

CYC8CKIT-059. All the documentation i could find was from 2014. We also have a LaunchPad so I am using that

That part will still work. (We used one last year, and plan to use one again this year.)

Here is slightly newer documentation: https://community.cypress.com/thread/30090. It hasn’t been updated, but nothing’s really changed, so not much need to update.

That is probably the easier option!

Yep. It’s already programmed and sent off for wiring. Thanks for all your help guys

We used the TI Launchpad with a the following box from Digi-Key
https://www.digikey.com/product-detail/en/bud-industries/PC-11491/377-1960-ND/439698

We use a Button Board from AndyMark. It maps to normal controller buttons so adding functionality for it should take as long as it would to map a command to a normal controller button. You should give it a look, we’re actually using 2 because of all the subsystems on our bot.

You can buy the exact same arcade button encoder from Amazon for around 1/2 the price of Andymark’s. They are just marking it up.
XCSOURCE Zero Delay Arcade Game USB Encoder

1 Like

I used vJoy one time when I forgot my controller. It is recognized by driverstation automatically and I just assigned keyoard keys to Xbox controller buttons and joysticks.