public void Initialize() { if (Initialized == true) { return; } VJoyInstance = new vJoy(); if (VJoyInstance.vJoyEnabled() == false) { Console.WriteLine("vJoy driver not enabled!"); return; } //Kimimaru: The data object passed in here will be returned in the callback //This can be used to update the object's data when a vJoy device is connected or disconnected from the computer //This does not get fired when the vJoy device is acquired or relinquished VJoyInstance.RegisterRemovalCB(OnDeviceRemoved, null); string vendor = VJoyInstance.GetvJoyManufacturerString(); string product = VJoyInstance.GetvJoyProductString(); string serialNum = VJoyInstance.GetvJoySerialNumberString(); Console.WriteLine($"vJoy driver found - Vendor: {vendor} | Product: {product} | Version: {serialNum}"); uint dllver = 0; uint drvver = 0; bool match = VJoyInstance.DriverMatch(ref dllver, ref drvver); Console.WriteLine($"Using vJoy DLL version {dllver} and vJoy driver version {drvver} | Version Match: {match}"); //int acquiredCount = InitControllers(BotProgram.BotData.JoystickCount); //Console.WriteLine($"Acquired {acquiredCount} controllers!"); }
public void Initialize() { if (Initialized == true) { return; } VJoyInstance = new vJoy(); if (VJoyInstance.vJoyEnabled() == false) { TRBotLogger.Logger.Error("vJoy driver not enabled!"); return; } //The data object passed in here will be returned in the callback //This can be used to update the object's data when a vJoy device is connected or disconnected from the computer //This does not get fired when the vJoy device is acquired or relinquished VJoyInstance.RegisterRemovalCB(OnDeviceRemoved, null); string vendor = VJoyInstance.GetvJoyManufacturerString(); string product = VJoyInstance.GetvJoyProductString(); string serialNum = VJoyInstance.GetvJoySerialNumberString(); TRBotLogger.Logger.Information($"vJoy driver found - Vendor: {vendor} | Product: {product} | Version: {serialNum}"); uint dllver = 0; uint drvver = 0; bool match = VJoyInstance.DriverMatch(ref dllver, ref drvver); TRBotLogger.Logger.Information($"Using vJoy DLL version {dllver} and vJoy driver version {drvver} | Version Match: {match}"); }
public TesterForm() { InitializeComponent(); joystick = new vJoy(); position = new vJoy.JoystickState(); ///// General driver data short iVer = joystick.GetvJoyVersion(); bool enabled = joystick.vJoyEnabled(); string Prd = joystick.GetvJoyProductString(); string Mnf = joystick.GetvJoyManufacturerString(); string Srl = joystick.GetvJoySerialNumberString(); string prt = String.Format("Product: {0}; Version {1:X}; Manuf: {2}; Serial:{3}", Prd, iVer, Mnf, Srl); label1.Text = prt; Enbld.Checked = enabled; ///// vJoy Device properties int nBtn = joystick.GetVJDButtonNumber(id); int nDPov = joystick.GetVJDDiscPovNumber(id); int nCPov = joystick.GetVJDContPovNumber(id); bool X_Exist = joystick.GetVJDAxisExist(id, HID_USAGES.HID_USAGE_X); bool Y_Exist = joystick.GetVJDAxisExist(id, HID_USAGES.HID_USAGE_Y); bool Z_Exist = joystick.GetVJDAxisExist(id, HID_USAGES.HID_USAGE_Z); bool RX_Exist = joystick.GetVJDAxisExist(id, HID_USAGES.HID_USAGE_RX); prt = String.Format("Device[{0}]: Buttons={1}; DiscPOVs:{2}; ContPOVs:{3}", id, nBtn, nDPov, nCPov); label2.Text = prt; UInt32 DllVer = 0, DrvVer = 0; bool match = joystick.DriverMatch(ref DllVer, ref DrvVer); if (match) { prt = String.Format("Version of Driver Matches DLL Version {0:X}", DllVer); } else { prt = String.Format("Version of Driver ({0:X}) does NOT match DLL Version ({1:X})", DrvVer, DllVer); } label7.Text = prt; long max = 10, min = 10; bool ok; ok = joystick.GetVJDAxisMax(id, HID_USAGES.HID_USAGE_X, ref max); ok = joystick.GetVJDAxisMin(id, HID_USAGES.HID_USAGE_X, ref min); ///// Write access to vJoy Device - Basic VjdStat status; status = joystick.GetVJDStatus(id); bool acq = joystick.AcquireVJD(id); status = joystick.GetVJDStatus(id); position.AxisX = 1000; position.AxisY = 5000; position.AxisZ = 10000; position.AxisXRot = 20000; position.Buttons = 0xA5A5A5A5; position.ButtonsEx1 = 0; bool upd = joystick.UpdateVJD(id, ref position); status = joystick.GetVJDStatus(id); //// Reset functions joystick.ResetButtons(id); // Register callback function // Function to register: Removal() // User data to pass: label2 joystick.RegisterRemovalCB(Removal, label2); }
public MainWindow() { InitializeComponent(); ni = new System.Windows.Forms.NotifyIcon { Icon = new System.Drawing.Icon(Application.GetResourceStream(new Uri("/sc_icon.ico", UriKind.Relative)).Stream), Visible = false, Text = "Sim Companion", BalloonTipText = "Minimized to tray" }; ni.ContextMenu = new System.Windows.Forms.ContextMenu(new System.Windows.Forms.MenuItem[] { new System.Windows.Forms.MenuItem("Show", delegate(object sender, EventArgs args) { ni.Visible = false; Show(); WindowState = WindowState.Normal; }), new System.Windows.Forms.MenuItem("Quit", delegate(object sender, EventArgs args) { //Application.Current.Shutdown(); Close(); }) }); versionText.Text = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + " (alpha)"; /*var parser = new FileIniDataParser(); * * if(!File.Exists("Config.ini")) { * IniData data = new IniData(); * data["Network"]["data_port"] = DATA_PORT.ToString(); * data["Network"]["discovery_port"] = DISCOVERY_PORT.ToString(); * parser.WriteFile(".\\Config.ini", data, null); * } * * * try { * IniData data = parser.ReadFile("Config.ini"); * * try { * string dataPort = data["Network"]["data_port"]; * DATA_PORT = int.Parse(dataPort); * } * catch (Exception) { * data["Network"]["data_port"] = DATA_PORT.ToString(); * parser.WriteFile(".\\Config.ini", data, null); * } * * try { * string discoveryPort = data["Network"]["discovery_port"]; * DISCOVERY_PORT = int.Parse(discoveryPort); * } * catch (Exception) { * data["Network"]["discovery_port"] = DISCOVERY_PORT.ToString(); * parser.WriteFile(".\\Config.ini", data, null); * } * } * catch { * // Should not happen * IniData data = new IniData(); * data["Network"]["data_port"] = DATA_PORT.ToString(); * data["Network"]["discovery_port"] = DISCOVERY_PORT.ToString(); * parser.WriteFile(".\\Config.ini", data, null); * }*/ joystick.RegisterRemovalCB(vJoyConfigChanged, null); if (!joystick.vJoyEnabled()) { tabControl.SelectedIndex = 1; return; } for (byte i = 1; i <= 16; i++) { if (AcquireDevice(i) < 2 && id == 0) { id = i; break; } } if (id == 0) { return; } // Register the callback function & pass the dialog box object //joystick.FfbRegisterGenCB(FfbCB, null); InputThread = new Thread(new ThreadStart(GamePad)) { IsBackground = true }; InputThread.Start(); DiscoveryThread = new Thread(new ThreadStart(Discovery)) { IsBackground = true }; DiscoveryThread.Start(); }