I'm running Vista, and Saitek have not ported their SST software to Vista yet.
So I'm using the -ignorejoy option in my X3 shortcut, one for each switch (I've only disabled the bottom detent). The sliding switches actually occupy 6 buttons.
In order to discover which DirectX button assignments the switches were on I wrote a small window app that polls the joystick to see which buttons are depressed. The Saitek control panel concentrates more on being pretty rather than 100% informative.
It's not very good and it assumes you only have one Joystick plugged in (but who needs more than an X45, right?)
Thanks for the rapid response, guys!
Code: Select all
/*
* Created by SharpDevelop.
* User: Adrian
* Date: 16/03/2007
* Time: 23:29
* requires .NET framework 2.0 and managed directx (should be installed with DX9)
* build with
C:\Windows\Microsoft.NET\Framework\v2.0.50727\csc /t:winexe /r:"C:\Windows\Microsoft.NET\DirectX for Managed Code\1.0.2902.0\Microsoft.DirectX.DirectInput.dll" XButtons.cs
Please note that this code is TOTAL RUBBISH and will only show the buttons for the last joystick in the list.
But it demonstrates the principle.
I also take no responsibility for it eating your dog, sodomizing your cat, or any other untoward events.
That said, I release this code into the public domain for anyone to use as they will.
*/
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using Microsoft.DirectX.DirectInput;
using System.Threading;
namespace XButtons
{
/// <summary>
/// Description of MainForm.
/// </summary>
public class MainForm : Form
{
private WaitHandle[] waiters = {new AutoResetEvent(false)};
[STAThread]
public static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
public MainForm()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
//
// TODO: Add constructor code after the InitializeComponent() call.
//
}
void Button1Click(object sender, EventArgs e)
{
DeviceList dl = Manager.GetDevices(DeviceType.Joystick, EnumDevicesFlags.AttachedOnly);
foreach(DeviceInstance d in dl)
{
Device dev = new Device(d.InstanceGuid);
dev.SetEventNotification(waiters[0]);
dev.Acquire();
dev.Poll();
WaitHandle.WaitAll(waiters);
byte[] buttons = dev.CurrentJoystickState.GetButtons();
buttonsListView.Clear();
for(int ii = 0 ; ii < dev.Caps.NumberButtons ; ii++)
{
buttonsListView.Items.Add((ii + 1).ToString());
if(buttons[ii] != 0)
{
buttonsListView.Items[ii].Checked = true;
}
}
dev.Unacquire();
dev.Dispose();
}
}
/// <summary>
/// Designer variable used to keep track of non-visual components.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Disposes resources used by the form.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent()
{
this.buttonsListView = new System.Windows.Forms.ListView();
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// buttonsListView
//
this.buttonsListView.CheckBoxes = true;
this.buttonsListView.Location = new System.Drawing.Point(32, 43);
this.buttonsListView.Name = "buttonsListView";
this.buttonsListView.Size = new System.Drawing.Size(364, 443);
this.buttonsListView.TabIndex = 0;
this.buttonsListView.UseCompatibleStateImageBehavior = false;
//
// button1
//
this.button1.Location = new System.Drawing.Point(477, 67);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(111, 43);
this.button1.TabIndex = 1;
this.button1.Text = "Poll";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.Button1Click);
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(613, 541);
this.Controls.Add(this.button1);
this.Controls.Add(this.buttonsListView);
this.Name = "MainForm";
this.Text = "XButtons";
this.ResumeLayout(false);
}
private System.Windows.Forms.ListView buttonsListView;
private System.Windows.Forms.Button button1;
}
}