Exemplo n.º 1
0
        public Fingers()
        {
            api = new SynAPICtrlClass();
            api.Initialize();
            int deviceHandle = 0;
            deviceHandle = api.FindDevice(SynConnectionType.SE_ConnectionUSB, SynDeviceType.SE_DeviceForcePad, -1);
            device = new SynDeviceCtrlClass();
            device.Select(deviceHandle);
            device.Activate();
            device.OnPacket += device_OnPacket;

            device.SetLongProperty(SynDeviceProperty.SP_IsMultiFingerReportEnabled, 1);
            device.SetLongProperty(SynDeviceProperty.SP_IsGroupReportEnabled, 1);
            minX = device.GetLongProperty(SynDeviceProperty.SP_XLoBorder);
            maxX = device.GetLongProperty(SynDeviceProperty.SP_XHiBorder);
            minY = device.GetLongProperty(SynDeviceProperty.SP_YLoBorder);
            maxY = device.GetLongProperty(SynDeviceProperty.SP_YHiBorder);
            numForces = device.GetLongProperty(SynDeviceProperty.SP_NumForceSensors);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes the touch input manager.
        /// </summary>
        /// <exception cref="SynDriverException">
        /// Thrown if the Synaptics driver is not installed or is outdated.
        /// </exception>
        /// <exception cref="SynDeviceNotFoundException">
        /// Thrown if a touchpad could not be found.
        /// </exception>
        public SynTouchpadInput()
        {
            try
            {
                _api.Initialize();
            }
            catch (COMException ex) when(ex.ErrorCode == (int)SynError.Fail)
            {
                throw new SynDriverException();
            }
            int handle = _api.FindDevice(SynConnectionType.SE_ConnectionAny, SynDeviceType.SE_DeviceTouchPad, -1);

            if (handle < 0)
            {
                throw new SynDeviceNotFoundException();
            }
            _device.Select(handle);
            _device.Activate();
            _lowX  = _device.GetLongProperty(SynDeviceProperty.SP_XLoSensor);
            _highY = _device.GetLongProperty(SynDeviceProperty.SP_YHiSensor);
        }
Exemplo n.º 3
0
        /* Helper function to properly initialize the touchpad with the Synaptics API */
        private void initTouchpad()
        {
            // Start the API and look for a Touchpad
            SynCtrl.Activate();
            deviceHandle = SynCtrl.FindDevice(SynConnectionType.SE_ConnectionAny, SynDeviceType.SE_DeviceTouchPad, -1);
            if (deviceHandle == -1)
            {
                MessageBox.Show("Could not find Synaptics Touchpad!");
                Application.Exit();
            }
            else
            {
                // Touchpad Found! Let's make sure the API is set to use it.
                // Caveat: Only one touchpad is supported here.
                SynDevCtrl.Select(deviceHandle);
                SynDevCtrl.Activate();

                // We need to record the Touchpad sensitivity
                ZTouchThreshold = SynDevCtrl.GetLongProperty(SynDeviceProperty.SP_ZTouchThreshold);
            }
        }
Exemplo n.º 4
0
        private void CheckTappingProperty()
        {
            var tapEnabled = _synTouchPad.GetLongProperty(SynDeviceProperty.SP_IsTapEnabled);

            if (tapEnabled == 0)
            {
                _synTouchPad.SetLongProperty(SynDeviceProperty.SP_IsTapEnabled, 1);
            }

            /*
             * var dragEnabled = _synTouchPad.GetLongProperty(SYNCTRLLib.SynDeviceProperty.SP_IsDragEnabled);
             * if (dragEnabled == 0) _synTouchPad.SetLongProperty(SYNCTRLLib.SynDeviceProperty.SP_IsDragEnabled, 1);
             *
             * var cornerTapEnabled = _synTouchPad.GetLongProperty(SYNCTRLLib.SynDeviceProperty.SP_IsCornerTapEnabled);
             * if (cornerTapEnabled == 1) _synTouchPad.SetLongProperty(SYNCTRLLib.SynDeviceProperty.SP_IsCornerTapEnabled, 0);
             */
        }
Exemplo n.º 5
0
        public bool Init()
        {
            _log = new Logger();
            try
            {
                _log.LogDebug("Create SynAPI");
                _synApi = new SynAPICtrl();
                _log.LogDebug("Create SynDeviceCtrl");
                _synTouchPad = new SynDeviceCtrl();


                _log.LogDebug("Init SynAPI");
                _synApi.Initialize();
                _synApi.Activate();

                _log.LogDebug("Find Synaptics Device");
                _devHandle = _synApi.FindDevice(
                    SynConnectionType.SE_ConnectionAny,
                    SynDeviceType.SE_DeviceTouchPad,
                    -1);
                _synTouchPad.Select(_devHandle);

                _synTouchPad.Activate();
                _log.LogDebug("Create OnPacketEventHandler");
                _synTouchPad.OnPacket += OnPacket;
            }
            catch (Exception ex)
            {
                _log.LogDebug("Error on init: " + ex.InnerException.Message);
                MessageBox.Show(
                    Resources.error_startup_no_driver_found,
                    Resources.error_msg_title,
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error
                    );
                Application.Exit();
                return(false);
            }

            if (_devHandle < 0)
            {
                _log.LogDebug("No device handle found");
                MessageBox.Show(Resources.error_startup_no_device_found,
                                Resources.error_msg_title, MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
                return(false);
            }
            _log.LogDebug("Device handle found: " + _devHandle);

            //check if the touchpad has support for multiple fingers
            var multi = _synTouchPad.GetLongProperty(SynDeviceProperty.SP_IsMultiFingerCapable);

            if (multi < 0)
            {
                //HKLM "System\\CurrentControlSet\\Services\\SynTP\\Parameters" -> CapabilitiesMask must be 0xFFFFFFFF
                var parampath = @"System\CurrentControlSet\Services\SynTP\Parameters";
                var key       = Registry.LocalMachine.CreateSubKey(parampath);
                key.SetValue("CapabilitiesMask", 0xFFFFFFFF);
                MessageBox.Show("Multiple finger support was missing. We made some changes to the registry.\n\nTry running SynGestures again or reboot your computer and try again then.",
                                Resources.error_msg_title, MessageBoxButtons.OK, MessageBoxIcon.Information);

                Application.Exit();
                return(false);
            }
            ReadDeviceProperties();

            return(true);
        }
Exemplo n.º 6
0
        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                // Get the SID of the admin group on the local machine.
                var localAdminGroupSid = new SecurityIdentifier(
                    WellKnownSidType.BuiltinAdministratorsSid, null);
                WindowsIdentity windowsIdentity = WindowsIdentity.GetCurrent();

                //Then you can check the Groups property on the WindowsIdentity of the user to see if that user is a member of the local admin group, like so:
                bool isLocalAdmin = windowsIdentity.Groups.
                                    Select(g => (SecurityIdentifier)g.Translate(typeof(SecurityIdentifier))).
                                    Any(s => s == localAdminGroupSid);
                if (isLocalAdmin)
                {
                    adminButton.Visible = false;
                }
            }
            catch (Exception) { }
            synAPI.Initialize();
            synAPI.Activate();
            DeviceHandle = synAPI.FindDevice(SynConnectionType.SE_ConnectionAny, SynDeviceType.SE_DeviceTouchPad, -1);
            if (DeviceHandle == -1)
            {
                MessageBox.Show("Unable to find a Synaptics TouchPad");
            }
            else
            {
                synDev.Select(DeviceHandle);
                synDev.Activate();
                oldDisableState = synDev.GetLongProperty(SynDeviceProperty.SP_DisableState);
                synDev.SetLongProperty(SynDeviceProperty.SP_DisableState, 0);
                bool     s    = TouchInjector.InitializeTouchInjection(256, TouchFeedback.INDIRECT);//initialize with default settings
                Settings sett = Settings.Default;
                hideBox.Checked = sett.HideToTaskbar;
                if (sett.XMin != 0)
                {
                    XMin = sett.XMin;
                }
                else
                {
                    XMin = synDev.GetLongProperty(SynDeviceProperty.SP_XLoSensor);
                }
                if (sett.XMax != 0)
                {
                    XMax = sett.XMax;
                }
                else
                {
                    XMax = synDev.GetLongProperty(SynDeviceProperty.SP_XHiSensor);
                }
                if (sett.YMin != 0)
                {
                    YMin = sett.YMin;
                }
                else
                {
                    YMin = synDev.GetLongProperty(SynDeviceProperty.SP_YLoSensor);
                }
                if (sett.YMax != 0)
                {
                    YMax = sett.YMax;
                }
                else
                {
                    YMax = synDev.GetLongProperty(SynDeviceProperty.SP_YHiSensor);
                }
                ZTouchThreshold = synDev.GetLongProperty(SynDeviceProperty.SP_ZTouchThreshold) + 20;
                wHeight         = GetScreen().Height - 1;
                wWidth          = GetScreen().Width - 1;
                synDev.Acquire(0);
                updateCalibrationStatusLabel();

                synDev.OnPacket += synDev_OnPacket;
            }
        }