Hi all,
Did anybody come across a C# sample that relates to Saitek X52
I have found some generic Joystick samples which help me read the buttons EXCEPT the Mode button.
The GetButtons() function returns the codes of the pressed buttons, but I cannot get the status of the Mode button out.
I just spoke to Saitek support - No .NET samples whatsoever.
Any tips will be appreciated.
Best
Moni.

Reading the buttons of Joystick Saitek x52
Euclidez
WOW ... it gets more interesting by the minute ... :)
I just installed the Feb. 07 SDK and here the COOL thing that happens.
IMPORTANT - during the test DO NOT touch ANYTHING on the Joystick (makes the test clean).
Step-1: Fire up either your application or the Joystick EXE from the Sample Browser.
Either way you end up with something that shows the code of the pressed buttons.
Step-2: Fire up the Joystick Properties from Control Panel -> Game Controllers.
You notice that the active MODE section lights up in red.
Step-3: Use you mouse and put the focus back on whatever you started at Step-1.
Result: The application instantly recognizes the mode and shows it (23, 24, 25 - for the three modes)
Step-4: Close the Joystick Properties window.
Step-5: Put the focus again on the first application
Result: The mode is NO LONGER recognized.
FYI:
I tested with the samples from both the managed and unmanaged code as well as with my own application.
So ...
Who wants to give it a shot in explaining the possible cause ...
In any event - I am extremely happy that I found it, because the way the DirectX driver reads the Joystick makes a hell of a difference in these two cases.
rockworld
Nathan R
Fantastic,
Thanks ZMan.
Will upgrade to Feb 07 SDK.
Michael Hansen
It is supposed to give different meaning to the same button.
This way Saitek tripples the number of buttons.
This means that the modes should always show in the byte array returned by GetButtons().
23 = Mode 1
24 = Mode 2
25 = Mode 3
Other buttons only show if they are pressed.
This way you get button-code + mode-code concatenated by the standard piece of code as listed above.
If no button is pressed - then only Mode shows.
HWM
I did check.
Mode button is active and well in Control Panel -> Game Controllers.
I use
byte[] buttons = state.GetButtons(); int button = 0; foreach (byte b in buttons){
if (0 != (b & 0x80))strText += button.ToString(
"00| ");button++;
}
richTextBox1.Text = strText; --->> yep ... for the test I use RichTextBox not a label :)
For example for button#3 and different modes I expect to see things like:
23|03| or 24|03| or 25|03|
(or 03|23| etc.)
where 23 = Mode 1; 24 = Mode 2; 25 = Mode 3;
I only see "03|" in all cases.
On the other hand the index-finger trigger has two position and they are properly caught as "00|14|"
If I look at the content of the button array I clearly see 128 as the value of the clicked button, however I do not see 128 for the mode which should be at offsets 23, 24, 25
Next sounds a bit cheesy but is most sincerely meant:
ZMan - I have been around IT for many years but I am yet to see another person who - like you - affects an entire industy by providing the most outstanding help and tutorials.
For whateve it is worth - Thank you man ...
Bassam72
The latest is:
I completely uninstalled the Saitek drivers and re-installed the latest version from their www
Now the Properties screen from Control Panel waits for a couple of seconds but then recognizes the Mode position without me touching anything on the joystick.
The good thing is that the October & February SDK Joystick samples now also initialize the axes, POV etc without the need to engage the controls, however they still do NOT see the Mode.
I will test tomorrow with the C++ February sample - but so far the summary is:
Control Panel sees the Mode knob.
GetButtons() does not return a value for the modes.
It may as well be that the the Mode knob (it is a twist-knob, not a button) is not visible for GetButtons()
Bear23
Kevin Rodgers
Never mind.
It turned that the C++ samples have also the EXE's.
I ran the OCTOBER EXE and I got a slightly different result.
Now I get "-1" in front of the code of the pressed button.
Tonight I will re-install the Saitek drivers and tomorrow I will retest - this time with the FEBRUARY sample.
imranabdulaziz
OK so they sould show up as totally independant button presses and its up to your code to interpret the combinations.
So they show up in control panel but not your code - sadly I don't have a 25 button joystick to test. In the DirectX SDK there is a C++ and a c# sample for direct input that seem to do exactly what you want - they are both called Joystick and are in the February 2007 SDK. So you can check to see if there is a difference between the native and managed code. If they work for you then there is source for both so you can see what you have done differently.
carol chen
Did you try the native(C++) version of the program. I am trying to determine if there is an issue in the managed version of DirectInput. SInce you stated that the control panel applet works (which uses DirectInput as far as I know) then its hard to understand why the sample apps don't
You can find the native version at C:\Program Files\Microsoft DirectX SDK (February 2007)\Samples\C++\DirectInput\Joystick
Raja Prabu
Just for the record - and to remove ambiguity above.
When the mode buttons are read you get the string of numbers in order.
This Joystick's mode-knob lists Mode-1, -2, -3 as 23, 24, 25
This will result in "03|23|" for Button-3, Mode-1 and "23|26" for Button-26 and Mode-1.
This I posted for people who are new to coding Joysticks - Just an FYI to avoid assumption that the Mode will always be first (or last).
It goes without saying that the delimiter (pipe) in the above example is generated by your code and can be whatever you set it to be.
Soumya B
My fault.
I found dinput.h
Have some more problems setting up the environment - but - do not bother with this - it is a silly problem I can deal with.
Sterling Swartwout
.... I am back with some result - it may mean something - it may not.
Both - the SDK sample and the Control Panel - Game Controlers Test behave the same way.
When you fire up the application (SDK or Game Controller Test) neither is initilized with the current values of the joystick.
Then ... if you turn the MODE knob VERY gently (to avoid anything else being moved) and reach the point of switching between modes - THEN the unit initializes all axes buttons etc.
Naturally the same happens if you move or click any other part - but what this tells me is that the Mode button is definitely being processed by the driver- only that I cannot capture it with GetButtons().
I called Saitek Tech support - the same thing happens on their screen.
I will try re-installing the drivers - see what happens - will post here.
williambeaker
Sorry I reopen the topic - just to post the feedback.
Just FYI.
I ran the Joystick sample from the Feb SDK - it is identical to the one I have from Oct. '06
Both using ....\Microsoft.DirectX.DirectInput\1.0.2902.......
Code-lines also the same - Unless I picked the wrong demo project - The one I picked was in:
C:\Program Files (x86)\Microsoft DirectX SDK\Samples\Managed\DirectInput\Joystick
Ran it - no luck.
Many thanks for looking into the issue though - your suggestion was definitely worth trying.
That button is obviously a problem.
He He He ... the neighbors are blasting- Pink Floyd - " ... another brick in the wall ... " ... quite appropriate for my button issue.