Beispiel #1
0
        private void listenerLoop()
        {
            try
            {
                using (FileStream fs = new FileStream(inputDevicePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete))
                {
                    while (true)
                    {
                        LinuxInputEvent     e    = new LinuxInputEvent(fs);
                        LinuxInputEventArgs args = new LinuxInputEventArgs(e);
                        try
                        {
                            InputEvent(this, args);
                        }
                        catch (ThreadAbortException) { throw; }
                        catch (Exception ex)
                        {
                            Logger.Debug(ex);
                        }

                        try
                        {
                            switch (args.KeyEventType)
                            {
                            case KeyEventType.Down:
                                KeyDownEvent(this, args);
                                break;

                            case KeyEventType.Up:
                                KeyUpEvent(this, args);
                                break;

                            case KeyEventType.AutoRepeat:
                                KeyAutoRepeatEvent(this, args);
                                break;

                            default:
                                break;
                            }
                        }
                        catch (ThreadAbortException) { throw; }
                        catch (Exception ex)
                        {
                            Logger.Debug(ex);
                        }
                    }
                }
            }
            catch (ThreadAbortException) { }
            catch (IOException ex)
            {
                Logger.Debug(ex, "The device may have been unplugged (" + inputDevicePath + ")");
            }
            catch (Exception ex)
            {
                Logger.Debug(ex);
            }
            finally
            {
                IsAlive = false;
            }
        }
Beispiel #2
0
 public LinuxInputEventArgs(LinuxInputEvent e)
 {
     this.RawEventData = e;
 }