Can GameControlPlus send data TO device?

I am using @Quark’s SUPER GameControlPlus to have a custom joystick (using an Arduino Micro) to send to Processing. And it is working great!

When the joystick fire button is pressed this may or may not start an event in Processing. If the event does occur I need to tell the joystick/Micro to close a relay for some length of time.

Is there any way in GCP to SEND something back to the Controller?

=Alan R.

1 Like

Not directly.

Can’t you just write a function to send information back to your custom joystick to close the relay, and then call this function when it detects the button is pressed.

I find this confusing, how does it decide whether or not to fire an event?

2 Likes

Heh - I’m sure this IS confusing!

The joystick is used to control a simulation of a Navy radar display called a 'Target Determination System". Bogies would show on the radar, and operators would move a cursor to the target in question. The
cursor is divided in to “C” shaped sections: One represents the actual bogie, and the other slow moving is the gun director. The gun is BIG and
takes a while to catch up to the actual bogie. When the two are closed, the operator presses the joystick, and that target is marked and
shot at and hopefully destroyed.

Since this is a ‘simulation’, the joystick may be pressed incorrectly so
there will be false presses. When Processing sees the two cursors being close enough, the target is outlined to indicate, and the director
cursor holds on it for about 10 seconds and then it is removed from the
screen - destroyed! It gets worse - The museum people would like to have a sound system play a loud BOOM when the target is destroyed - so even though the joystick initiates the target selection - Processing decides when it is actually on-target.

Next part of the fun is that I’m using an Arduino library “Joystick” that creates a real HID controller. So GameControlPlus can see it and Processing is reading it - but I have no other way to communicate with the Micro.

What is the effect of closing the relay?

1 Like

This is what triggers the sound file player.

Can’t this be done in Processing? After all it decides whether it is ‘on target’.

1 Like

Umm - not sure. :slight_smile: Processing is running on a PC and the relay is (currently) on the custom joystick board. Immediately I can’t think how the PC/Processing would trigger the relay without yet another com port.

Originally when I was a Logitech joystick, the fire button pressed was just sent to two existing contracts on the joystick (previous buttons). I wonder if I overlooked the issue of the possible false triggers plus now the extended delay has been added.

It seems the joystick is (as expected) pretty much an open-loop affair when accessed as an HID controller. I did try serial but even at high baud rate the delays were so slow that the cursors were drawn in a very clunky manner.

PROBLEM SOLVED!
I am using the great Arduino library “ClickButton” to sense the joystick switch closure. ClickButton offers a number of ‘click-counts’ and also returns -1 on a LONG click. So - The requirement will be the stick needs to be pressed about a second or so - seems to work very nicely and short clicks/presses are not seen.

That was a head-scratcher for me - wasn’t sure how I’d get it going. Thanks for getting back to me.

It might be a unique feature to add to GCP to allow some short ‘message’ to be sent back to the controller - a single character or Boolean should offer plenty of capability. Manly for custom cases like mine. :slight_smile:

=A.

1 Like

Nice :slight_smile:

Out of curiosity, does Processing have anything to say about whether or not the long click is “justified”, IE if processing is sending back a “Ok, fire at will” signal? Or does any long click trigger the relay?

Btw, I didn’t know about this GameControlPlus thing. Sounds interesting! I’ve been thinking a bit about sending info back to an Arduino joystick. So far I’ve briefly tried the excellent ArduinoJoystickLibrary a little while ago. But I don’t think it can send info back to the Arduino (or I don’t know how). Also, it requires an Arduino Leonardo (or I guess, any arduino with a built-in USB controller).

This is a fairly convoluted affair. It turns out that any Arduino style board based on the Atmel 34u4 (what is on a Leo) MCU has USB and the extra serial port. I used a Micro as it cheap and all the capability for a joystick.

The joystick library does its magic by creating a real HID device out of the Arduino running it. It turns out there is no way to send data TO an HID joystick.

GameControlPlus is a super library for Processing that provides very configurable access to joysticks and similar. Def look into it - but it IS for Processing only.

In my case the original code I had sent the joystick button press to Processing with a 250ms delay. The response was too quick so there could be clicks received that weren’t timed right. By using the long click, Processing only sees valid clicks. It starts ;a timer which takes the bogie off the radar after it is “shot” - but I have to start another timer on the relay on the joystick board. This signals an Ackman media player to play a loud BOOM sound.

Visit the battleship New Jersey museum ship in a few months, and you can see it in operation. :grinning:

1 Like