示例#1
0
 public SynapticsAPI()
 {
     synAPICtrl = new SynAPICtrl();
     synAPICtrl.Initialize();
     synAPICtrl.Activate();
     CreateDeviceList();
 }
示例#2
0
        public void Resume()
        {
            //this is necessery after coming back from standby/hibernation
            _log.LogDebug("resuming...");
            _synApi      = new SynAPICtrl();
            _synTouchPad = new SynDeviceCtrl();
            _synApi.Initialize();
            _synApi.Activate();

            _devHandle = _synApi.FindDevice(
                SynConnectionType.SE_ConnectionAny,
                SynDeviceType.SE_DeviceTouchPad,
                -1);
            if (_devHandle < 0)
            {
                //I know, this should be async...
                Thread.Sleep(500);
                Resume();
                return;
            }
            _synTouchPad.Select(_devHandle);
            _synTouchPad.Activate();
            _synTouchPad.OnPacket += OnPacket;
            ReadDeviceProperties();
        }
示例#3
0
        //Constructor
        public Syn()
        {
            SynTP_API.Initialize();
            SynTP_API.Activate();

            //Readonly instance field can only be initialized
            //in constructor or in variable declaration.
            xBLCornerCtr = 2;
            yBLCornerCtr = 4;

            //Initialize Region to Unicode char in hashtable
            regionUnicode.Add(TP_Region.topleft, "hello");
            regionUnicode.Add(TP_Region.topright, "hello");
            regionUnicode.Add(TP_Region.center, "hello");
            regionUnicode.Add(TP_Region.bottomleft, "hello");
            regionUnicode.Add(TP_Region.bottomright, "hello");
            //ERR:
            //Resolved:
            //DeviceHandle == -1: Can't find device?
            //DeviceHandle = SynTP_API.FindDevice(new SynConnectionType(), new SynDeviceType(), 0);

            DeviceHandle = SynTP_API.FindDevice(SynConnType.SE_ConnectionAny, SynDeviceType.SE_DeviceTouchPad, -1);
            Console.WriteLine("Device Handle: {0} ", DeviceHandle);
            SynTP_Dev.Select(DeviceHandle);
            SynTP_Dev.Activate();

            SynTP_Dev.OnPacket += new SynOnPacketEventHandler(SynTP_Dev_OnPacket);
        }
 static void Main(string[] args)
 {
     api.Initialize();
     api.Activate();
     //select the first device found
     deviceHandle = api.FindDevice(SynConnectionType.SE_ConnectionAny, SynDeviceType.SE_DeviceTouchPad, -1);
     device.Select(deviceHandle);
     device.Activate();
     device.OnPacket += SynTP_Dev_OnPacket;
     Console.ReadLine();
 }
示例#5
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);
            }
        }
示例#6
0
        static public float targetx = 960, targety = 540;                       // Center of FHD Resolution

        static void Main(string[] args)
        {
            try
            {
                new Program();
                api.Initialize();
            }
            catch (Exception e)
            {
                Console.WriteLine("Error calling API, you didn't have Synaptics hardware or driver (if you just installed it you need to reboot)");
loop:
                Console.WriteLine("Press enter to quit OR type \"info\"");
                if (Console.ReadLine().Contains("info"))
                {
                    Console.WriteLine("{0} Exception caught.", e);
                    goto loop;
                }
                return;
            }

            api.Activate();
            //select the first device found
            deviceHandle = api.FindDevice(SynConnectionType.SE_ConnectionAny, SynDeviceType.SE_DeviceTouchPad, -1);
            device.Select(deviceHandle);
            device.Activate();
            device.OnPacket += SynTP_Dev_OnPacket;
            //Console.Title = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
            Console.SetWindowSize(80, 25);
            Console.SetBufferSize(80, 25);
            Console.WriteLine("터치패드 좌표");
            Console.WriteLine("X:0 Y:0");
            Console.WriteLine("Xmin:" + Xmin + " Ymin:" + Ymin);
            Console.WriteLine("Xmax:" + Xmax + " Ymax:" + Ymax);
            Console.WriteLine("윈도우 좌표");
            Console.WriteLine("X:" + 0 + " Y:" + 0);
            Console.WriteLine("엔터키를 눌러 종료");
            Console.ReadLine();
        }
示例#7
0
        public SearchResultsView()
        {
            InitializeComponent();

            SearchResultsListView.ItemsSource = EverythingSearch.Instance.SearchResults;
            ((INotifyCollectionChanged)SearchResultsListView.Items).CollectionChanged += OnCollectionChanged;

#if SYNAPTICS
            try
            {
                api         = new SynAPICtrl();
                synTouchPad = new SynDeviceCtrl();
                synPacket   = new SynPacketCtrl();

                api.Initialize();
                api.Activate();
                deviceHandle = api.FindDevice(SynConnectionType.SE_ConnectionAny, SynDeviceType.SE_DeviceTouchPad, -1);
                synTouchPad.Select(deviceHandle);
                synTouchPad.Activate();
                synTouchPad.OnPacket += OnSynapticsPacket;
            }
            catch (COMException) { }
#endif
        }
示例#8
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);
        }
示例#9
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;
            }
        }