private void remote_ButtonReleased(object sender, PS3Remote.ButtonEventArgs e)
        {
            if (DebugLog.isLogging)
            {
                DebugLog.write("Button released: " + e.button.ToString());
            }

            if (timerRepeat.Enabled)
            {
                if (DebugLog.isLogging)
                {
                    DebugLog.write("Keys repeat send off: { " + String.Join(",", keyboard.lastKeysDown.ToArray()) + " }");
                }

                timerRepeat.Enabled = false;
                return;
            }

            if (DebugLog.isLogging && this.keyboard.lastKeysDown != null)
            {
                DebugLog.write("Keys up: { " + String.Join(",", keyboard.lastKeysDown.ToArray()) + " }");
            }

            keyboard.releaseLastKeys();
        }
        private void remote_ButtonDown(object sender, PS3Remote.ButtonEventArgs e)
        {
            if (DebugLog.isLogging)
            {
                DebugLog.write("Button down: " + e.button.ToString());
            }

            ButtonMapping mapping = buttonMappings[(int)e.button];

            if (mapping.repeat)
            {
                keyboard.sendKeysDown(mapping.keysMapped);
                keyboard.releaseLastKeys();

                if (DebugLog.isLogging)
                {
                    DebugLog.write("Keys repeat send on : { " + String.Join(",", mapping.keysMapped.ToArray()) + " }");
                }

                timerRepeat.Enabled = true;
                return;
            }

            keyboard.sendKeysDown(mapping.keysMapped);

            if (DebugLog.isLogging)
            {
                DebugLog.write("Keys down: { " + String.Join(",", mapping.keysMapped.ToArray()) + " }");
            }
        }
        private void remote_ButtonReleased(object sender, PS3Remote.ButtonEventArgs e)
        {
            if (DebugLog.isLogging)
            {
                DebugLog.write("Button released: " + e.button.ToString());
            }

            if (timerRepeat.Enabled)
            {
                //if (DebugLog.isLogging) DebugLog.write("Keys repeat send off: { " + String.Join(",", keyboard.lastKeysDown.ToArray()) + " }");

                timerRepeat.Enabled = false;
                return;
            }

            switch (e.button)
            {
            //case PS3Remote.Button.Arrow_Up:
            //    y -= increment;
            //    break;
            //case PS3Remote.Button.Arrow_Down:
            //    y += increment;
            //    break;
            //case PS3Remote.Button.Arrow_Left:
            //    x -= increment;
            //    break;
            //case PS3Remote.Button.Arrow_Right:
            //    x += increment;
            //    break;
            case PS3Remote.Button.Enter:
                MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftUp);
                return;

            case PS3Remote.Button.PopUp_Menu:
                MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.RightUp);
                return;
            }
        }
        private void remote_ButtonDown(object sender, PS3Remote.ButtonEventArgs e)
        {
            if (DebugLog.isLogging)
            {
                DebugLog.write("Button down: " + e.button.ToString());
            }

            int y = 0;
            int x = 0;

            switch (e.button)
            {
            case PS3Remote.Button.Arrow_Up:
                y -= increment;
                break;

            case PS3Remote.Button.Arrow_Down:
                y += increment;
                break;

            case PS3Remote.Button.Arrow_Left:
                x -= increment;
                break;

            case PS3Remote.Button.Arrow_Right:
                x += increment;
                break;

            case PS3Remote.Button.R1:
                increment++;
                if (increment >= 100)
                {
                    increment = 5;
                }
                break;

            case PS3Remote.Button.L1:
                increment--;
                if (increment <= 0)
                {
                    increment = 5;
                }
                break;

            case PS3Remote.Button.Enter:
                MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.LeftDown);
                return;

            case PS3Remote.Button.PopUp_Menu:
                MouseOperations.MouseEvent(MouseOperations.MouseEventFlags.RightDown);
                return;
            }

            lastButton = e.button;

            if (x != 0 || y != 0)
            {
                //keyboard.sendKeysDown(mapping.keysMapped);
                //keyboard.releaseLastKeys();

                var position = MouseOperations.GetCursorPosition();
                position.X += x;
                position.Y += y;
                MouseOperations.SetCursorPosition(position);


                timerRepeat.Enabled = true;
                return;
            }

            //keyboard.sendKeysDown(mapping.keysMapped);
        }