public GameManager(Form mainForm) { instance = this; games = new Dictionary <string, GenericGameInfo>(); gameInfos = new Dictionary <string, GenericGameInfo>(); GameManager.mainForm = mainForm; GameManager.mainFormHandle = mainForm.Handle; string appData = GetAppContentPath(); Directory.CreateDirectory(appData); string gameJs = GetJsScriptsPath(); Directory.CreateDirectory(gameJs); inputInterceptor = new InputInterceptor(); //Subscribe to raw input //TODO: update isRunningSplitScreen Debug.WriteLine("Registering raw input"); rawInputProcessor = new RawInputProcessor(() => LockInput.IsLocked); //TODO: needs more robust method //Action<IntPtr> rawInputAction = rawInputProcessor.Process; //GameManager.mainForm.GetType().GetProperty("RawInputAction").SetValue(GameManager.mainForm, rawInputAction, new object[] { }); //IntPtr rawInputHwnd = GameManager.mainFormHandle; RawInputManager.RegisterRawInput(rawInputProcessor); Initialize(); LoadUser(); }
private void GetControllers() { foreach (TextBox tbox in controllerGuids) { tbox.Clear(); } foreach (TextBox tbox in controllerNicks) { tbox.Clear(); } dinput = new DirectInput(); IList <DeviceInstance> devices = dinput.GetDevices(DeviceClass.GameControl, DeviceEnumerationFlags.AttachedOnly); int gcDevicesCnt = devices.Count; for (int i = 0; i < devices.Count; i++) { DeviceInstance device = devices[i]; Joystick gamePad = new Joystick(dinput, device.InstanceGuid); string hid = gamePad.Properties.InterfacePath; int start = hid.IndexOf("hid#"); int end = hid.LastIndexOf("#{"); string fhid = hid.Substring(start, end - start).Replace('#', '\\').ToUpper(); controllerGuids[i].Text = fhid; if (ini.IniReadValue("ControllerMapping", fhid) != "") { controllerNicks[i].Text = ini.IniReadValue("ControllerMapping", fhid); } gamePad.Dispose(); } dinput.Dispose(); foreach (var device in RawInputManager.GetDeviceList().Where(x => x.deviceInfo.dwType <= 1)) { //string hid = device.deviceInfo.hid.ToString(); //int start = hid.IndexOf("hid#"); //int end = hid.LastIndexOf("#{"); //string fhid = hid.Substring(start, end - start).Replace('#', '\\').ToUpper(); //controllerGuids[gcDevicesCnt].Text = fhid; string did = string.Empty; if (device.deviceInfo.dwType == 0) { did = "T" + device.deviceInfo.dwType + "PID" + device.deviceInfo.hid.dwProductId + "VID" + device.deviceInfo.hid.dwVendorId + "VN" + device.deviceInfo.hid.dwVersionNumber; controllerGuids[gcDevicesCnt].Text = did; gcDevicesCnt++; } if (ini.IniReadValue("ControllerMapping", did) != "") { controllerNicks[gcDevicesCnt].Text = ini.IniReadValue("ControllerMapping", did); } } }
static void Main(string[] args) { Config = Config.LoadConfig(); if (Config?.AutomaticallyCheckForUpdatesOnStartup ?? true) { UpdateChecker.CheckUpdateDialog(false); } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Form = new Form1(); Form_hWnd = Form.Handle; Form.SetAutomaticallyCheckUpdatesChecked(Config?.AutomaticallyCheckForUpdatesOnStartup ?? true); Options = new OptionsStructure(); Core.Options.LoadOptions(); SplitScreenManager = new SplitScreenManager(); SplitScreenManager.Init(); MessageProcessor = new MessageProcessor(); i = new Intercept(); var x = new RawInputManager(Form_hWnd); InputDisabler.Init(); Application.Run(Form); //Not required for RegisterRawInputDevices to work SplitScreenManager.DeactivateSplitScreen(); Logger.WriteLine("Exiting application"); Environment.Exit(0); }