Ejemplo n.º 1
0
 public void SendInput(ISInputData input)
 {
     byte[] data = new byte[6];
     data[0] = (byte)IpcMessageType.AnonIpcInputData;
     input.ToBytes(data, 1);
     Write(data);
 }
Ejemplo n.º 2
0
        public void SendInput(ISInputData input, ISServerSocket client)
        {
            byte[] data = new byte[6];
            data[0] = (byte)UdpMessageType.Input;

            input.ToBytes(data, 1);
            udpSocket.BeginSendTo(data, 0, data.Length, 0, client.UdpAddress, SendToCallback, null);
        }
Ejemplo n.º 3
0
        public void SendInput(ISInputData input)
        {
            if (!Connected)
            {
                return;
            }

            SendQueue.Add(new InputMessage(input));
        }
Ejemplo n.º 4
0
        private void ThreadLoop()
        {
            while (!cancelToken.IsCancellationRequested)
            {
                ISInputData input = outputQueue.Take();

                if (SwitchThreadDesktop)
                {
                    WinDesktop.SwitchThreadToInputDesktop();
                    SwitchThreadDesktop = false;
                }

                outManager.Send(input);
            }

            ISLogger.Write("Exited output thread loop");
        }
Ejemplo n.º 5
0
        /// <summary>
        /// We want to use scan codes instead of virtual codes as they are inserted lower into the stack,
        /// but some virtual keys cannot be mapped into scan codes so we need to decide whether to use
        /// the scan or virtual key
        /// </summary>
        /// <param name="input"></param>
        /// <param name="useScan"></param>
        /// <returns></returns>
        private short CheckKey(ISInputData input, out bool useScan)
        {
            useScan = false;

            if (input.Param2 == 0 || input.Param1 == 91)
            {
                return(input.Param1);
            }

            uint mappedScanb = MapVirtualKeyA((uint)input.Param1, MAPVKTYPE.MAPVK_VK_TO_VSC);

            if (mappedScanb != input.Param2)
            {
                ISLogger.Write("Invalid key virtual key:{0} scan code:{1} mapped: {2}", input.Param1, input.Param2, mappedScanb);
                return(input.Param2);
            }

            useScan = true;
            return(input.Param2);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// We want to use scan codes instead of virtual codes as they are inserted lower into the stack,
        /// but some virtual keys cannot be mapped into scan codes so we need to decide whether to use
        /// the scan or virtual key
        /// </summary>
        /// <param name="input"></param>
        /// <param name="useScan"></param>
        /// <returns></returns>
        private short CheckKey(ISInputData input, out bool useScan)
        {
            useScan = false;

            if (input.Param2 == 0 || input.Param1 == 91)
            {
                return(input.Param1);
            }

            uint mappedScanb = MapVirtualKeyA((uint)input.Param1, MAPVKTYPE.MAPVK_VK_TO_VSC);

            if (mappedScanb != input.Param2)
            {
                ISLogger.Write("Cannot translate key '{0}' to a scan code!", (WindowsVirtualKey)input.Param1);
                return(input.Param1);
            }

            useScan = true;
            return(input.Param2);
        }
Ejemplo n.º 7
0
 public void HandleInputReceived(ISInputData input)
 {
     if (CurrentInputClient != ISServerSocket.Localhost)
     {
         if (CurrentInputClient.IsConnected)
         {
             if (CurrentInputClient.UdpEnabled && udpHost != null)
             {
                 udpHost.SendInput(input, CurrentInputClient);
             }
             else
             {
                 CurrentInputClient.SendInputData(input.ToBytes());
             }
         }
         else
         {
             ISLogger.Write("TARGET NOT CONNECTED");
         }
     }
 }
Ejemplo n.º 8
0
 public abstract void Send(ISInputData input);
Ejemplo n.º 9
0
 public InputMessage(ISInputData input)
 {
     Input = input;
 }
Ejemplo n.º 10
0
        public void Send(ISInputData input)
        {
            ISInputCode c = input.Code;

            switch (c)
            {
            case ISInputCode.IS_MOUSEMOVERELATIVE:
                MoveMouseRelative(input.Param1, input.Param2);
                break;

            case ISInputCode.IS_KEYDOWN:
                if (input.Param1 == 91)                  //Windows key cant be mapped to a scan code, so we'll use the virtual code instead
                {
                    KeyDownVirtual(91, true);
                    break;
                }
                KeyDownScan(input.Param1, true);
                break;

            case ISInputCode.IS_KEYUP:
                if (input.Param1 == 91)
                {
                    KeyDownVirtual(91, false);
                    break;
                }
                KeyDownScan(input.Param1, false);
                break;

            case ISInputCode.IS_MOUSELDOWN:
                MouseLDown(true);
                break;

            case ISInputCode.IS_MOUSELUP:
                MouseLDown(false);
                break;

            case ISInputCode.IS_MOUSERDOWN:
                MouseRDown(true);
                break;

            case ISInputCode.IS_MOUSERUP:
                MouseRDown(false);
                break;

            case ISInputCode.IS_MOUSEMDOWN:
                MouseMDown(true);
                break;

            case ISInputCode.IS_MOUSEMUP:
                MouseMDown(false);
                break;

            case ISInputCode.IS_MOUSEYSCROLL:
                MouseYScroll(input.Param1);
                break;

            case ISInputCode.IS_MOUSEXDOWN:
                MouseXDown(input.Param1, true);
                break;

            case ISInputCode.IS_MOUSEXUP:
                MouseXDown(input.Param1, false);
                break;

            case ISInputCode.IS_RELEASEALL:
                ReleaseAllKeys();
                break;
            }
        }
Ejemplo n.º 11
0
        public override void Send(ISInputData input)
        {
            if (input.Code == ISInputCode.IS_MOUSEMOVERELATIVE)
            {
                XWarpPointer(xConnection.XDisplay, IntPtr.Zero, IntPtr.Zero, 0, 0, 0, 0, input.Param1, input.Param2);
            }
            else if (input.Code == ISInputCode.IS_MOUSELDOWN)
            {
                XTestFakeButtonEvent(xConnection.XDisplay, X11_LEFTBUTTON, true, 0);
            }
            else if (input.Code == ISInputCode.IS_MOUSELUP)
            {
                XTestFakeButtonEvent(xConnection.XDisplay, X11_LEFTBUTTON, false, 0);
            }
            else if (input.Code == ISInputCode.IS_MOUSERDOWN)
            {
                XTestFakeButtonEvent(xConnection.XDisplay, X11_RIGHTBUTTON, true, 0);
            }
            else if (input.Code == ISInputCode.IS_MOUSERUP)
            {
                XTestFakeButtonEvent(xConnection.XDisplay, X11_RIGHTBUTTON, false, 0);
            }
            else if (input.Code == ISInputCode.IS_MOUSEMDOWN)
            {
                XTestFakeButtonEvent(xConnection.XDisplay, X11_MIDDLEBUTTON, true, 0);
            }
            else if (input.Code == ISInputCode.IS_MOUSEMUP)
            {
                XTestFakeButtonEvent(xConnection.XDisplay, X11_MIDDLEBUTTON, false, 0);
            }
            else if (input.Code == ISInputCode.IS_MOUSEYSCROLL)
            {
                //Param1 contains the mouse direction, 120 = up; -120 = down
                if (input.Param1 > 0)
                {
                    XTestFakeButtonEvent(xConnection.XDisplay, X11_SCROLLDOWN, true, 0);
                    XTestFakeButtonEvent(xConnection.XDisplay, X11_SCROLLDOWN, false, 0);
                }
                else
                {
                    XTestFakeButtonEvent(xConnection.XDisplay, X11_SCROLLUP, true, 0);
                    XTestFakeButtonEvent(xConnection.XDisplay, X11_SCROLLUP, false, 0);
                }
            }
            else if (input.Code == ISInputCode.IS_MOUSEXSCROLL)
            {
                //todo
            }
            else if (input.Code == ISInputCode.IS_MOUSEXDOWN)
            {
                //first param is the ID of the button. 4 = forward, 5 = back
                if (input.Param1 == 4)
                {
                    XTestFakeButtonEvent(xConnection.XDisplay, X11_XBUTTONFORWARD, true, 0);
                }
                else
                {
                    XTestFakeButtonEvent(xConnection.XDisplay, X11_XBUTTONBACK, true, 0);
                }
            }
            else if (input.Code == ISInputCode.IS_MOUSEXUP)
            {
                if (input.Param1 == 4)
                {
                    XTestFakeButtonEvent(xConnection.XDisplay, X11_XBUTTONFORWARD, false, 0);
                }
                else
                {
                    XTestFakeButtonEvent(xConnection.XDisplay, X11_XBUTTONBACK, false, 0);
                }
            }
            else if (input.Code == ISInputCode.IS_KEYDOWN || input.Code == ISInputCode.IS_KEYUP)
            {
                bool down = input.Code == ISInputCode.IS_KEYDOWN;

                try
                {
                    uint key = ConvertKey((WindowsVirtualKey)input.Param1);

                    if (input.Code == ISInputCode.IS_KEYDOWN && Settings.DEBUG_PRINTOUTPUTKEYS)
                    {
                        ISLogger.Write("DEBUG: KEY {0}", XKeysymToString(XKeycodeToKeysym(xConnection.XDisplay, (int)key, 0)));
                    }

                    if (key < 1)
                    {
                        throw new Exception("Could not translate key " + (WindowsVirtualKey)input.Param1);
                    }

                    XTestFakeKeyEvent(xConnection.XDisplay, key, down, 0);
                }
                catch (Exception ex)
                {
                    ISLogger.Write("Failed to send key {0}: {1}", (WindowsVirtualKey)input.Param1, ex.Message);
                }
            }

            XFlush(xConnection.XDisplay);
        }
Ejemplo n.º 12
0
 private void OnInputReceived(ISInputData input)
 {
     InputReceived?.Invoke(this, input);
 }
Ejemplo n.º 13
0
        public void Send(ISInputData input)
        {
            ISInputCode c = input.Code;

            switch (c)
            {
            case ISInputCode.IS_MOUSEMOVERELATIVE:
                MoveMouseRelative(input.Param1, input.Param2);
                break;

            case ISInputCode.IS_KEYDOWN:
            {
                short useKey = CheckKey(input, out bool useScan);

                if (useScan)
                {
                    KeyDownScan(useKey, true);
                }
                else
                {
                    KeyDownVirtual(useKey, true);
                }

                break;
            }

            case ISInputCode.IS_KEYUP:
            {
                short useKey = CheckKey(input, out bool useScan);

                if (useScan)
                {
                    KeyDownScan(useKey, false);
                }
                else
                {
                    KeyDownVirtual(useKey, false);
                }

                break;
            }

            case ISInputCode.IS_MOUSELDOWN:
                MouseLDown(true);
                break;

            case ISInputCode.IS_MOUSELUP:
                MouseLDown(false);
                break;

            case ISInputCode.IS_MOUSERDOWN:
                MouseRDown(true);
                break;

            case ISInputCode.IS_MOUSERUP:
                MouseRDown(false);
                break;

            case ISInputCode.IS_MOUSEMDOWN:
                MouseMDown(true);
                break;

            case ISInputCode.IS_MOUSEMUP:
                MouseMDown(false);
                break;

            case ISInputCode.IS_MOUSEYSCROLL:
                MouseYScroll(input.Param1);
                break;

            case ISInputCode.IS_MOUSEXDOWN:
                MouseXDown(input.Param1, true);
                break;

            case ISInputCode.IS_MOUSEXUP:
                MouseXDown(input.Param1, false);
                break;

            case ISInputCode.IS_RELEASEALL:
                ResetKeyStates();
                break;

            case ISInputCode.IS_MOUSEMOVEABSOLUTE:
                MoveMouseAbs(input.Param1, input.Param2);
                break;
            }
        }
Ejemplo n.º 14
0
 public override void Send(ISInputData input)
 {
     host.host.SendInput(input);
 }
Ejemplo n.º 15
0
        public override void Send(ISInputData input)
        {
            switch (input.Code)
            {
            case ISInputCode.IS_MOUSEMOVERELATIVE:
                MoveMouseRelative(input.Param1, input.Param2);
                break;

            case ISInputCode.IS_KEYDOWN:
            {
                if (Settings.DEBUG_PRINTOUTPUTKEYS)
                {
                    ISLogger.Write("DEBUG: VIRTUAL KEY {0} SCAN {1}", (WindowsVirtualKey)input.Param1, input.Param2);
                }

                short useKey = CheckKey(input, out bool useScan);

                if (useScan)
                {
                    KeyDownScan(useKey, true);
                }
                else
                {
                    KeyDownVirtual(useKey, true);
                }

                break;
            }

            case ISInputCode.IS_KEYUP:
            {
                short useKey = CheckKey(input, out bool useScan);

                if (useScan)
                {
                    KeyDownScan(useKey, false);
                }
                else
                {
                    KeyDownVirtual(useKey, false);
                }

                break;
            }

            case ISInputCode.IS_MOUSELDOWN:
                MouseLDown(true);
                break;

            case ISInputCode.IS_MOUSELUP:
                MouseLDown(false);
                break;

            case ISInputCode.IS_MOUSERDOWN:
                MouseRDown(true);
                break;

            case ISInputCode.IS_MOUSERUP:
                MouseRDown(false);
                break;

            case ISInputCode.IS_MOUSEMDOWN:
                MouseMDown(true);
                break;

            case ISInputCode.IS_MOUSEMUP:
                MouseMDown(false);
                break;

            case ISInputCode.IS_MOUSEYSCROLL:
                MouseYScroll(input.Param1);
                break;

            case ISInputCode.IS_MOUSEXDOWN:
                MouseXDown(input.Param1, true);
                break;

            case ISInputCode.IS_MOUSEXUP:
                MouseXDown(input.Param1, false);
                break;

            case ISInputCode.IS_RELEASEALL:
                ResetKeyStates();
                break;

            case ISInputCode.IS_MOUSEMOVEABSOLUTE:
                MoveMouseAbs(input.Param1, input.Param2);
                break;
            }
        }