static void dev_axes(int hDev) { string[] j_axes = new string[8] { " X ", " Y ", " Z ", "Rx ", "Ry ", "Rz ", "S1 ", "S2 " }; string[] x_axes = new string[6] { " X ", " Y ", "TR ", "Rx ", "Ry ", "TL " }; bool Exist = false; DevType type = DevType.vJoy; int lim = 6; if (type == DevType.vJoy) { lim = 8; } joystick.GetDevType(hDev, ref type); Console.WriteLine(""); for (uint i = 1; i <= lim; i++) { joystick.isAxisExist(hDev, i, ref Exist); if (Exist) { if (type == DevType.vJoy) { Console.Write(j_axes[i - 1]); } else { Console.Write(x_axes[i - 1]); } } else { Console.Write(" "); } } }
static void Main(string[] args) { Char last_c = '\0'; uint id = 0; string line; DevType type = DevType.vJoy; int hDev = 0; joystick = new vGen(); // Print device' status dev_stat(); // Get type of device Console.WriteLine("\n\nvJoy or vXbox [J/X]?"); ConsoleKeyInfo key = Console.ReadKey(); last_c = Char.ToUpper(key.KeyChar); if (last_c == 'X') { type = DevType.vXbox; } //get device ID Console.WriteLine("\n\nDevice ID [1-16]?"); line = Console.ReadLine(); if (line.Length == 0) { Console.WriteLine("\n\nDevice ID <empty>, exiting?"); return; } id = Convert.ToUInt32(line); // Verify ID if (id < 1) { Console.WriteLine("\n\nDevice ID negative, exiting?"); return; } if ((type == DevType.vXbox) && (id > 4)) { Console.WriteLine("\n\nDevice ID is greater than 4, exiting?"); return; } if ((type == DevType.vJoy) && (id > 16)) { Console.WriteLine("\n\nDevice ID is greater than 16, exiting?"); return; } // Acquire Device and verify joystick.AcquireDev(id, type, ref hDev); dev_stat(); Console.WriteLine("\nHit any key to reliquish device"); Console.ReadKey(); joystick.RelinquishDev(hDev); dev_stat(); Console.WriteLine("\nHit any key to re-acquire device"); Console.ReadKey(); joystick.AcquireDev(id, type, ref hDev); dev_stat(); joystick.GetDevType(hDev, ref type); Console.WriteLine("\nDevice type: " + type.ToString()); dev_axes(hDev); uint nBtn = 0; joystick.GetDevButtonN(hDev, ref nBtn); Console.WriteLine("\nNumber of buttons: " + nBtn.ToString()); uint nHat = 0; joystick.GetDevHatN(hDev, ref nHat); Console.WriteLine("\nNumber of Hats: " + nHat.ToString()); bool go_on = true; do { go_on = SetVal(hDev); } while (go_on); Console.WriteLine("\nHit any key to exit"); Console.ReadKey(); }