예제 #1
0
        private static void HandlePenBinding(DigitizerIdentifier identifier, ITabletReport report)
        {
            if (TipBinding != null)
            {
                float pressurePercent = (float)report.Pressure / identifier.MaxPressure * 100f;

                if (pressurePercent > TipActivationPressure && !TipState)
                {
                    TipBinding.Press();
                }
                else if (pressurePercent <= TipActivationPressure && TipState)
                {
                    TipBinding.Release();
                }
                TipState = pressurePercent > TipActivationPressure;
            }

            for (var penButton = 0; penButton < report.PenButtons.Length; penButton++)
            {
                if (PenButtonBindings.TryGetValue(penButton, out var binding) && binding != null)
                {
                    if (report.PenButtons[penButton] && !PenButtonStates[penButton])
                    {
                        binding.Press();
                    }
                    else if (!report.PenButtons[penButton] && PenButtonStates[penButton])
                    {
                        binding.Release();
                    }
                }
                PenButtonStates[penButton] = report.PenButtons[penButton];
            }
        }
예제 #2
0
        private void HandlePenBinding(ITabletReport report)
        {
            if (TipBinding != null && TipActivationPressure != 0)
            {
                float pressurePercent = (float)report.Pressure / TabletProperties.MaxPressure * 100f;

                if (pressurePercent >= TipActivationPressure && !TipState)
                {
                    TipBinding.Press();
                }
                else if (pressurePercent < TipActivationPressure && TipState)
                {
                    TipBinding.Release();
                }
                TipState = pressurePercent >= TipActivationPressure;
            }

            for (var penButton = 0; penButton < report.PenButtons.Length; penButton++)
            {
                if (PenButtonBindings.TryGetValue(penButton, out var binding) && binding != null)
                {
                    if (report.PenButtons[penButton] && !PenButtonStates[penButton])
                    {
                        binding.Press();
                    }
                    else if (!report.PenButtons[penButton] && PenButtonStates[penButton])
                    {
                        binding.Release();
                    }
                }
                PenButtonStates[penButton] = report.PenButtons[penButton];
            }
        }