Reading a USB joystick in C# .NET (full .NET)

Chris,

Baby went to sleep so I had a bit to play with your example.

Works great, kinda get it now. Was able to put a couple textboxes in their and display.

It’s simple, but I just couldn’t lay it out, or get it.

I thank you again.

Next step, work on the Panda side to receive and parse it and fire some relays( don’t worry I have a relay board that takes signals, I do know enough,(through asking) not to hook up something like that directly).

Thanks,

Mike in MN

No prob :slight_smile: :slight_smile: :slight_smile:

I’m happy someone was saved from the PITA that finding all that info was. Enjoy!

As for parsing it, you may just want to send sentences like
$BPRESS,15,1;

Or something. Button 15 is now being pressed in that example.

Because I only have relays to trigger on/off(now), I was thinking something along the lines of getting a button status, then make it a 0 or 1, make an array of those (like binary) send that and just have the FEZ run that binary style array to the relay pins.

In my mind it makes perfect sense, but I could be wrong. I guess the only thing that I wonder if, a pin is set “true” and you try to reset it to “true” would it throw an exception or might I have to get the state of the pin first and compare??

I guess, it’s a bit away yet, but the Joystick code on the computer side was still a tremendous help.

By the way Chris, I would totally let that be a PI(My)A, if I just knew how to make it be… ;D ;D ;D

Thanks again,

Mike in MN

If a pin is set to true and you reset it to true, an exception will [italic]not[/italic] be thrown.

Even if it was you could use a try… finally block to ignore it.

Good deal, I will let you know when I get something to work.

Hopefully its not too bad. Got the Serial down(to go back and forth), working on the Joystick, got the Relays to fire with just plain code, now…Just try to put it all together.

Thanks,

Mike in MN

What you are wanting to do should be pretty easy. Parsing the RX’d serial on the FEZ side will be the hardest part, and even that is pretty easy.

Yeah, I hope not.

I have been reading about and playing with parsing examples with delimiters, seems possible. Well I know it’s possible, but can I get it, I think so in time…

On the Fez side, that’s why I am thinking if I can send a binary style array of bytes, just off/on ( 1 and 0) I should be able to control the outputport state fairly easy.

I suppose like anything, anything can be done with time.

Mike in MN

Yeah, bytes will even be easier than ASCII.

EDIT: If you want, show up in the chat and I’ll give you more advice. I am there, but nobody else is :frowning:

Chris,

Sorry I missed the post. Was playing around with that Joystick form. Took me a bit, but I eventually figured out how to access the Buttons. Talk about going in circles.

In the end it was quite easy, I don’t know why I make things hard on myself. I saw the GetButtons method, but just couldn’t get it to work. I eventually found a DirectX example that stated all you need to do is declare a variable array and assign the GetButtons to it.

Boy, I give you guys credit for learning all this stuff.

Sux, I gotta work tomorrow.

Mike in MN