public override Action Start() { IntPtr handle = Process.GetCurrentProcess().MainWindowHandle; KeyboardDevice = new SharpDX.DirectInput.Keyboard(DirectInputInstance); if (KeyboardDevice == null) { throw new Exception("Failed to create keyboard device"); } KeyboardDevice.SetCooperativeLevel(handle, CooperativeLevel.Background | CooperativeLevel.NonExclusive); KeyboardDevice.Acquire(); KeyboardDevice.GetCurrentState(ref KeyState); mouseDevice = new SharpDX.DirectInput.Mouse(DirectInputInstance); if (mouseDevice == null) { throw new Exception("Failed to create mouse device"); } mouseDevice.SetCooperativeLevel(handle, CooperativeLevel.Background | CooperativeLevel.NonExclusive); mouseDevice.Properties.AxisMode = DeviceAxisMode.Relative; // Get delta values mouseDevice.Acquire(); getPressedStrategy = new GetPressedStrategy <int>(IsDown); setPressedStrategy = new SetPressedStrategy <int>(KeyOrButtonDown, KeyOrButtonUp); OnStarted(this, new EventArgs()); return(null); }
public Device(PPJoyPlugin plugin, VirtualJoystick joystick) { LowerRange = -1000; UpperRange = 1000; this.plugin = plugin; Joystick = joystick; setPressedStrategy = new SetPressedStrategy(OnPress, OnRelease); }
public override Action Start() { setPressedStrategy = new SetPressedStrategy <int>(KeyOrButtonDown, KeyOrButtonUp); getPressedStrategy = new GetPressedStrategy <int>(IsDown); KeysPressed = new List <int>(); ewh = new EventWaitHandle(false, EventResetMode.AutoReset, "ewhFreePIE"); memory = MemoryMappedFile.CreateOrOpen("hookFreePIE", 68, MemoryMappedFileAccess.ReadWrite); accessor = memory.CreateViewAccessor(); for (byte i = 0; i < 68; i++) { accessor.Write(i, 0); } if (!Debug) { Process.Start("FreePIE.HookInput.exe", hookstatus.ToString()); } return(null); }
//----------------------------------------------------------------------- public override System.Action Start() { IntPtr handle = Process.GetCurrentProcess().MainWindowHandle; MouseDevice = new Mouse(DirectInputInstance); if (MouseDevice == null) { throw new Exception("Failed to create mouse device"); } MouseDevice.SetCooperativeLevel(handle, CooperativeLevel.Background | CooperativeLevel.Nonexclusive); MouseDevice.Properties.AxisMode = DeviceAxisMode.Relative; // Get delta values MouseDevice.Acquire(); getButtonPressedStrategy = new GetPressedStrategy(IsButtonDown); setButtonPressedStrategy = new SetPressedStrategy(SetButtonDown, SetButtonUp); OnStarted(this, new EventArgs()); return(null); }
//----------------------------------------------------------------------- public override System.Action Start() { IntPtr handle = Process.GetCurrentProcess().MainWindowHandle; KeyboardDevice = new Keyboard(DirectInputInstance); if (KeyboardDevice == null) { throw new Exception("Failed to create keyboard device"); } KeyboardDevice.SetCooperativeLevel(handle, CooperativeLevel.Background | CooperativeLevel.Nonexclusive); KeyboardDevice.Acquire(); KeyboardDevice.GetCurrentState(ref KeyState); setKeyPressedStrategy = new SetPressedStrategy(KeyDown, KeyUp); getKeyPressedStrategy = new GetPressedStrategy <int>(IsKeyDown); OnStarted(this, new EventArgs()); return(null); }
public VJoyGlobalHolder(uint index) { Index = index; Global = new VJoyGlobal(this); setPressedStrategy = new SetPressedStrategy(b => SetButton(b, true), b => SetButton(b, false)); joystick = new vJoy(); if (index < 1 || index > 16) { throw new ArgumentException(string.Format("Illegal joystick device id: {0}", index)); } if (!joystick.vJoyEnabled()) { throw new Exception("vJoy driver not enabled: Failed Getting vJoy attributes"); } uint apiVersion = 0; uint driverVersion = 0; bool match = joystick.DriverMatch(ref apiVersion, ref driverVersion); if (!match) { Console.WriteLine("vJoy version of Driver ({0:X}) does NOT match DLL Version ({1:X})", driverVersion, apiVersion); } Version = new VjoyVersionGlobal(apiVersion, driverVersion); var status = joystick.GetVJDStatus(index); string error = null; switch (status) { case VjdStat.VJD_STAT_BUSY: error = "vJoy Device {0} is already owned by another feeder"; break; case VjdStat.VJD_STAT_MISS: error = "vJoy Device {0} is not installed or disabled"; break; case VjdStat.VJD_STAT_UNKN: error = ("vJoy Device {0} general error"); break; } if (error == null && !joystick.AcquireVJD(index)) { error = "Failed to acquire vJoy device number {0}"; } if (error != null) { throw new Exception(string.Format(error, index)); } long max = 0; joystick.GetVJDAxisMax(index, HID_USAGES.HID_USAGE_X, ref max); AxisMax = (int)max / 2 - 1; enabledAxis = new Dictionary <HID_USAGES, bool>(); foreach (HID_USAGES axis in Enum.GetValues(typeof(HID_USAGES))) { enabledAxis[axis] = joystick.GetVJDAxisExist(index, axis); } maxButtons = joystick.GetVJDButtonNumber(index); maxDirPov = joystick.GetVJDDiscPovNumber(index); maxContinuousPov = joystick.GetVJDContPovNumber(index); currentAxisValue = new Dictionary <HID_USAGES, int>(); joystick.ResetVJD(index); }