private void bLeft_Click(object sender, EventArgs e) { myThread.going = false; if (myThread.connected) { Xim.Input input = new Xim.Input(); input.RightStickX = -(short)27000; Xim.SendInput(ref input, 200); input.RightStickX = -(short)Xim.Stick.Rest; Xim.SendInput(ref input, 20); } }
private void button1_Click(object sender, EventArgs e) { if (xim.Connect() == Xim.Status.OK) { this.watch.Reset(); Xim.Input input = new Xim.Input(); //input.LeftTrigger = (short)Xim.Stick.Max; this.xim.SendInput(ref input, 500); input.RightStickY = 0; input.RightStickX = short.Parse(this.mouseInput.Text); this.watch.Start(); this.xim.SendInput(ref input, 1); } else { this.count++; this.outputBox.Text += Environment.NewLine + " Input: " + this.mouseInput.Text + " \tTime: " + Math.Round((double)watch.ElapsedMilliseconds) + "\t Revolutions: " + this.count; this.count = 0; this.xim.Disconnect(); } }
public void Go() { Xim.Input input = new Xim.Input(); Xim.Input blankInput = new Xim.Input(); Vector2 spot = new Vector2(deadzone,0); Dir direction = Dir.Down; double incVal = 500; while (!abort) { if (going) { if (circular) { spot.Rotate(Math.PI / 90); input.RightStickX = (short)(/*Math.Sign(spot.X) * 9600 +*/ (short)spot.X); input.RightStickY = (short)(/*Math.Sign(spot.Y) * 9600 +*/ (short)spot.Y); Xim.SendInput(ref input, 25); //Xim.SendInput(ref blankInput, 0); } else { switch (direction) { case Dir.Up: if (spot.Y < deadzone) { spot.Y = spot.Y + incVal; } if (spot.Y >= deadzone) { spot.Y = deadzone; direction = Dir.Right; } break; case Dir.Right: if (spot.X < deadzone) { spot.X = spot.X + incVal; } if (spot.X >= deadzone) { spot.X = deadzone; direction = Dir.Down; } break; case Dir.Down: if (spot.Y > -deadzone) { spot.Y = spot.Y - incVal; } if (spot.Y <= -deadzone) { spot.Y = -deadzone; direction = Dir.Left; } break; case Dir.Left: if (spot.X > -deadzone) { spot.X = spot.X - incVal; } if (spot.X <= -deadzone) { spot.X = -deadzone; direction = Dir.Up; } break; } input.RightStickX = (short)spot.X; input.RightStickY = (short)spot.Y; //input.LeftTrigger = (short)Xim.Stick.Max; Xim.SendInput(ref input, 30); //Xim.SendInput(ref blankInput, 0); } } else { spot.X = deadzone; spot.Y = 0; } } this.ximDyn.Disconnect(); this.connected = false; }
public bool ParseLine(String line) { if (line.StartsWith("unbindall")) { m_bindingManager.UnbindAll(); return true; } else if (line.StartsWith("unbind ") || line.StartsWith("unlink ")) { line = line.Substring(7); int firstSpace = line.IndexOf(' '); if (firstSpace == -1) firstSpace = line.Length; String key = line.Substring(0, firstSpace); String linkKey = "link" + key; if (key == line) { // Just display the current bind for that key if one exists. if (m_bindingManager.IsKey(key) || m_bindingManager.IsAnalogKey(key)) { m_bindingManager.Unbind(key); this.ParseLine("bind " + key); return true; } else if (m_bindingManager.IsLinkKey(linkKey)) { m_bindingManager.Unbind(linkKey); this.ParseLine("bind " + linkKey); return true; } } } else if (line.StartsWith("link ")) { line = line.Substring(5); int firstSpace = line.IndexOf(' '); if (firstSpace == -1) firstSpace = line.Length; String key = line.Substring(0, firstSpace); if (key == line) { key = "link" + key; // Just display the current bind for that key if one exists. if (m_bindingManager.IsLinkKey(key)) { m_infoTextManager.WriteLine(m_bindingManager.GetBindString(key)); return true; } } else { key = "link" + key; String macro = line.Substring(firstSpace + 1); if (m_bindingManager.IsLinkKey(key)) { List<InputEvent> events; CreateEventList(macro, out events); if (events.Count > 0) { m_bindingManager.SetKeyBind(key, events); return true; } } } } else if (line.StartsWith("bind ")) { line = line.Substring(5); int firstSpace = line.IndexOf(' '); if (firstSpace == -1) firstSpace = line.Length; String key = line.Substring(0, firstSpace); if (key == line) { // Just display the current bind for that key if one exists. if (m_bindingManager.IsKey(key) || m_bindingManager.IsAnalogKey(key)) { m_infoTextManager.WriteLine(m_bindingManager.GetBindString(key)); return true; } } else { String macro = line.Substring(firstSpace + 1); if (m_bindingManager.IsKey(key)) { List<InputEvent> events; CreateEventList(macro, out events); if (events.Count > 0) { m_bindingManager.SetKeyBind(key, events); return true; } } else if (m_bindingManager.IsAnalogKey(key)) { macro = macro.TrimEnd(c_delims); AnalogEvent analogEvent; if (CreateAnalogEvent(macro, out analogEvent)) { List<InputEvent> events = new List<InputEvent>(); events.Add(analogEvent); m_bindingManager.SetKeyBind(key, events); return true; } } } } else if (line.Equals("listvars")) { VarManager.Instance.ListVars(); return true; } else if (line.Equals("initjoy")) { DxInputManager.Instance.InitJoy(); return true; } else if (line.Equals("joycaps")) { DxInputManager.Instance.OutputJoyCaps(); return true; } else { if (line.IndexOf(' ') == -1 && m_varManager.IsVar(line)) { VarManager.Var v; m_varManager.GetVar(line, out v); m_infoTextManager.Write(" = " + v.Value + Environment.NewLine + v.Info); return true; } else { List<InputEvent> events; CreateEventList(line, out events); if (events.Count >= 1) { foreach (InputEvent inputEvent in events) { Xim.Input input = new Xim.Input(); inputEvent.Run(true, 0, false, ref input, ref input); } return true; } } } return false; }
public void Go() { System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); watch.Start(); double wait = 16.666666; TimeSpan prevTick = watch.Elapsed; TimeSpan flipTime = watch.Elapsed; while (!abort) { while (watch.Elapsed.TotalMilliseconds - prevTick.TotalMilliseconds < wait) { System.Threading.Thread.Sleep(0); } prevTick = watch.Elapsed; if (watch.Elapsed.TotalMilliseconds - flipTime.TotalMilliseconds > this.time) { flipTime = watch.Elapsed; up = !up; if (up) going = false; } if (going) { if (!connected) { connected = Xim.Connect() == Xim.Status.OK; } if (connected) { Xim.Input input = new Xim.Input(); input.RightStickY = up ? (short)ySpeed : (short)-ySpeed; input.RightStickX = xSpeed; Xim.SendInput(ref input, 1); } } else { if (connected) { Xim.Disconnect(); connected = false; } flipTime = watch.Elapsed; up = true; } } }
public void ProcessOutput(double delay, ref Xim.Input input, ref Xim.Input startState) { if (done) { done = false; VarManager.Instance.SetVar(VarManager.Names.TextMode, false); return; } input = new Xim.Input(); if (m_idleFrame == 0) { m_idleFrame++; } else if (m_keyqueue.Count != 0) { m_idleFrame = 0; mutex.WaitOne(); if (FAtDestination()) { Xim.SetButtonState(m_keyqueue.Peek().toPressOnFinished, Xim.ButtonState.Pressed, ref input); if (m_keyqueue.Peek().toPressOnFinished == Xim.Button.Start) { InfoTextManager.Instance.WriteLine("Sending message and exiting TextMode"); this.done = true; m_keyqueue.Clear(); } else { m_keyqueue.Dequeue(); } } else { Destination d = m_keyqueue.Peek(); if (d.coord.X != m_current.coord.X) { if (d.coord.X > m_current.coord.X) { m_current.coord.X++; input.Down = Xim.ButtonState.Pressed; } else { m_current.coord.X--; input.Up = Xim.ButtonState.Pressed; } } else if (d.coord.Y != m_current.coord.Y) { if (d.coord.Y > m_current.coord.Y) { m_current.coord.Y++; input.Right = Xim.ButtonState.Pressed; } else { m_current.coord.Y--; input.Left = Xim.ButtonState.Pressed; } } else if (m_current.shift != m_keyqueue.Peek().shift) { m_current.shift = m_keyqueue.Peek().shift; Xim.SetButtonState(Xim.Button.LeftStick, Xim.ButtonState.Pressed, ref input); } } mutex.ReleaseMutex(); } }
public void Go() { if (Connect()) { m_fXimRunning = true; // Get thing set up. DxInputManager dxInputManager = DxInputManager.Instance; System.Drawing.Point cursorPosition = Cursor.Position; Xim.Input input = new Xim.Input(); Xim.Input startState = new Xim.Input(); ximDyn.SetMode((bool)m_autoAnalogDisconnect.Value ? Xim.Mode.AutoAnalogDisconnect : Xim.Mode.None); ximDyn.SendInput(ref input, 0); System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); bool bTextMode = false; bool done = false; watch.Start(); Cursor.Hide(); // m_textMode.Value = false; TimeSpan prevTick = watch.Elapsed; Log("Press ESCAPE to stop X2 processing"); dxInputManager.Acquire(); if (dxInputManager.ControllersPresent()) m_eventManager.QueueAnalogJoyBinds(); // Main Processing Loop while (!done) { System.Windows.Forms.Application.DoEvents(); double wait = (bool)m_textMode.Value ? (1000 / (double)m_textModeRate.Value) : (1000 / (double)m_rate.Value); while (watch.Elapsed.TotalMilliseconds - prevTick.TotalMilliseconds < wait) { if (m_form.ContainsFocus) { Cursor.Position = cursorPosition; } System.Threading.Thread.Sleep(2); } if (!m_form.ContainsFocus) { m_inputManager.ClearInput(); System.Threading.Thread.Sleep(100); continue; } else { dxInputManager.PollAndProcess(!(bool)m_textMode.Value); } input.CopyFrom(startState); TimeSpan thisTick = watch.Elapsed; double delay = thisTick.TotalMilliseconds - prevTick.TotalMilliseconds; prevTick = thisTick; if (delay > 1000) continue; if ((bool)m_textMode.Value) { if (!bTextMode) { Log("Entering Text Mode. Press END to exit text mode" + Environment.NewLine); bTextMode = true; } m_textModeManager.ProcessOutput(delay, ref input, ref startState); if (m_inputManager.IsKeyDown(DxI.Key.End)) { m_textModeManager.Reset(); m_textMode.Value = false; Log("Exiting Text Mode"); } bTextMode = (bool)m_textMode.Value; } else { bTextMode = (bool)m_textMode.Value; m_eventManager.ProcessEvents(delay, ref input, ref startState); if ((bool)m_useXimApiMouseMath.Value) { this.mouseMath.ProcessMouseMovement(ref input, ref startState); } else { //this.betaMouseMath.XSoftMouseMovement(delay, ref input, ref startState); this.mouseMath.XSoftMouseMovement(ref input, ref startState); } m_eventManager.ProcessLinks(delay, ref input, ref startState); } if ( m_inputManager.IsKeyDown(DxI.Key.Escape)) { break; } if (m_form.ContainsFocus) { m_form.UpdateOutputView(input); ximDyn.SendInput(ref input, 1); } else { ximDyn.SendInput(ref m_blankInput, 1); } } // Shutdown and clear events and input m_form.UpdateOutputView(m_blankInput); m_inputManager.ClearInput(); m_eventManager.ClearEvents(); DxInputManager.Instance.Unaquire(); m_fXimRunning = false; Disconnect(); } }