Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
I'm new to using libraries so I'm not sure where to start.

Background:

1. Using Visual Studio 2019
2. Window Forms in C#
3. I've added the Microsoft.DirectX.DirectInput file into the reference
4. Implementing a Razor Ruiji Master Joystick to the window form

Using this JoystickState Microsoft Docs[^] I'm trying to figure out how to get the X-axis position as well as outputting it on the window forms (Visual proof it works for testing).

What are the steps needed to use this library?

If there is any info I missed please message me and I'll add it in

What I have tried:

I've tried using JoystickState| Microsoft Docs[^], pasting in
C#
public int Z { get; }
Which doesn't do anything.

I"ve been able to output the thumbstick directions, but not their positions on the x-axis.

I know I'm missing a lot here, just don't know where to start.

Thank You!
Posted
Updated 20-Jan-21 17:19pm
v4
Comments
Garth J Lancaster 19-Jan-21 0:58am    
That appears to be a curly one ! I don't have a joystick, so can't test for you, and searching for a useable project you can use a test/starter is seeming hard at the moment - there's this I found https://stackoverflow.com/questions/3929764/taking-input-from-a-joystick-with-c-sharp-net that may be of some use. Note the response from Valdemar there, sometimes dealing with hardware it's useful to try a simple console mode program to see if you can 'talk' to the hardware before going on to Winforms stuff


One thing, you say 'comes up with errors' .. we can't see your screen, so, that's not really helpful for us - maybe you could see what the 'highest level' error or 'most important' error appears to be and post that (edit your question)

[edit] this https://www.codeproject.com/Articles/16704/Interfacing-with-a-Joystick-using-C might also help as a 'starter' [/edit]
User-15002776 20-Jan-21 23:16pm    
Hi Garth J Lancaster, thanks for the reply! Yeah, I've managed to implement the visual output for left and right directions on the thumbstick on a richtext box in the visual studio (basically talking to the hardware). I'm trying to get the position of the thumbstick on the x-axis only (possibly showing some sort of output on the window form to show it works). Since I've updated the question to the joystick state which I think is the right one for joystick positioning there is no errors when I paste the (public int Z { get; }) in. But I"m not sure where to go from here, such as how to implement it. Thank you!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900