Пример #1
0
        private static void Processing()
        {
            try
            {
                while (true)
                {
                    //var inputEvent = new LinuxEventParser.InputEvent();

                    var data = new byte[16];
                    for (var i = 0; i < 16; i++)
                    {
                        var rv = mStream.ReadByte();
                        if (rv > 0)
                        {
                            data[i] = (byte)rv;
                        }
                    }
                    var inputEvent = LinuxEventParser.ParseEvent(data);
                    //Console.Write("e");
                    if (inputEvent.type == LinuxEventParser.EventTypes.EV_KEY)
                    {
                        //Console.WriteLine(":");
                        Application.GetInstance().PostEvent(
                            inputEvent.value == 1 ? Application.EventType.KeyboardRelease : Application.EventType.KeyboardPress,
                            new KeyboardData {
                            Keycode = (int)inputEvent.code
                        });

                        if (OnUpdate != null)
                        {
                            OnUpdate();
                        }
                    }

                    Thread.Sleep(20);


                    //Thread.Sleep(200);
                }
            }
            catch (ThreadAbortException)
            {
                // correct shutdown
            }

            //Console.WriteLine("<-- Gpio Processing");
        }
Пример #2
0
        private static void Processing()
        {
            try
            {
                while (true)
                {
                    var inputEvent = new LinuxEventParser.InputEvent();

                    // get new event
                    while (inputEvent.type != LinuxEventParser.EventTypes.EV_SYN)
                    {
                        var data = new byte[16];
                        for (var i = 0; i < 16; i++)
                        {
                            var rv = mStream.ReadByte();
                            if (rv > 0)
                            {
                                data[i] = (byte)rv;
                            }
                        }
                        inputEvent = LinuxEventParser.ParseEvent(data);

                        if (inputEvent.type == LinuxEventParser.EventTypes.EV_ABS)
                        {
                            switch (inputEvent.code)
                            {
                            case LinuxEventParser.CodeTypes.ABS_X:
                            {
                                mY = inputEvent.value;
                                Application.GetInstance().PostEvent(Application.EventType.MouseMove, AdcToAbsolute(mX, mY));
                                //Console.WriteLine("mY: {0},{1}", AdcToAbsolute(mX, mY).X, AdcToAbsolute(mX, mY).Y);
                            }
                            break;

                            case LinuxEventParser.CodeTypes.ABS_Y:
                            {
                                mX = inputEvent.value;
                                Application.GetInstance().PostEvent(Application.EventType.MouseMove, AdcToAbsolute(mX, mY));
                                //Console.WriteLine("mX: {0},{1}", AdcToAbsolute(mX, mY).X, AdcToAbsolute(mX, mY).Y);
                            }
                            break;

                            case LinuxEventParser.CodeTypes.PRESSURE:
                            {
                                mPressMessage = true;
                                mPress        = inputEvent.value == 1;
                            }
                            break;
                            }

                            if (OnTouch != null)
                            {
                                OnTouch();
                            }
                        }
                    }
                    // need send press message here

                    if (mPressMessage)
                    {
                        Application.GetInstance().PostEvent(
                            mPress ? Application.EventType.MouseDown : Application.EventType.MouseUp,
                            AdcToAbsolute(mX, mY));

                        //Console.WriteLine("{2}: {0},{1}", AdcToAbsolute(mX, mY).X, AdcToAbsolute(mX, mY).Y, mPress ? "Down" : "Up");

                        mPressMessage = false;
                    }
                }
            }
            catch (ThreadAbortException)
            {
                // correct shutdown
            }
        }