private bool disposedValue = false; // To detect redundant calls protected virtual void Dispose(bool disposing) { if (!disposedValue) { //if (disposing) { } if (Initialized) // Must release the controller { vJoy.RelinquishDev((int)handle); } disposedValue = true; } }
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(); }
private void button2_Click(object sender, EventArgs e) { joystick.RelinquishDev(hDev); }