Example #1
0
 internal static extern ErrorCode AddEventHandler(out IntPtr handle, DefaultCoreBackend.AppEventType eventType, AppEventCallback callback, IntPtr data);
Example #2
0
 internal static extern HRESULT RzSBAppEventSetCallback([In] AppEventCallback callback);
Example #3
0
 internal static extern ErrorCode AddEventHandler(out IntPtr handle, AppEventType eventType, AppEventCallback callback, IntPtr userData);
Example #4
0
        /// <summary>
        /// Prevents a default instance of the <see cref="Switchblade" /> class from being created.
        /// </summary>
        /// <remarks>
        /// The constructor will disable all OS gestures, to enable them, use the Touchpad property
        /// and call the EnableOSGesture() method to enable gestures wanted.
        /// </remarks>
        private Switchblade()
        {
            _log = LogManager.GetLogger(this);

            _log.Info("Switchblade is initializing");

            _log.Debug("Calling RzSBStart()");

            var result = NativeMethods.RzSBStart();

            if (HRESULT.RZSB_FAILED(result))
            {
                // Try one more time
                result = NativeMethods.RzSBStart();
                if (HRESULT.RZSB_FAILED(result))
                {
                    throw new NativeCallException("RzSBStart", result);
                }
            }

            _log.Debug("Querying SDK for capabilities struct...");

            Capabilities caps;

            result = NativeMethods.RzSBQueryCapabilities(out caps);
            if (HRESULT.RZSB_FAILED(result))
            {
                throw new NativeCallException("RzSBQueryCapabilities", result);
            }

            Capabilities = caps;

            _log.InfoFormat(
                "SDK start successful! Working against SDK ver {0} ({1})",
                Capabilities.Version,
                Capabilities.BEVersion);
            _log.InfoFormat(
                "Number of surfaces: {0}, number of DKs: {1}",
                Capabilities.SurfaceCount,
                Capabilities.DynamicKeyCount);

#if DEBUG
            _log.DebugFormat(
                System.Globalization.CultureInfo.InvariantCulture,
                "HW type: {0}, DK size: {1}x{2}, DK arr: X={3} Y={4}",
                Capabilities.HardwareType,
                Capabilities.DynamicKeySize.X,
                Capabilities.DynamicKeySize.Y,
                Capabilities.DynamicKeyArrangement.X,
                Capabilities.DynamicKeyArrangement.Y);

            for (var i = 0; i < Capabilities.SurfaceCount; i++)
            {
                var pf = Capabilities.Pixelformat[i];
                var sg = Capabilities.Surfacegeometry[i];
                _log.DebugFormat(
                    System.Globalization.CultureInfo.InvariantCulture,
                    "Surface #{0}: PixelFormat={1}, SurfaceGeometry: X={2}, Y={3}",
                    i,
                    pf,
                    sg.X,
                    sg.Y);
            }
#endif

            _log.Debug("Creating new app event callback");
            _appEventCallback = HandleAppEvent;
            _log.Debug("Calling RzSBAppEventSetCallback");
            result = NativeMethods.RzSBAppEventSetCallback(_appEventCallback);
            if (HRESULT.RZSB_FAILED(result))
            {
                throw new NativeCallException("RzSBAppEventSetCallback", result);
            }

            _log.Info("Setting up touchpad");
            _touchpad = SharpBlade.Touchpad.Instance;

            Touchpad.DisableOSGesture(GestureTypes.All);

            _log.Info("Setting up keyboard");

            // Keyboard capture callback
            _log.Debug("Creating keyboard callback");
            _keyboardCallback = HandleKeyboardEvent;
            _log.Debug("Calling RzSBDynamicKeySetCallback");
            result = NativeMethods.RzSBKeyboardCaptureSetCallback(_keyboardCallback);
            if (HRESULT.RZSB_FAILED(result))
            {
                throw new NativeCallException("RzSBKeyboardCaptureSetCallback", result);
            }

            _log.Info("Setting up dynamic keys");
            _dynamicKeys = SharpBlade.DynamicKeys.Instance;

            _log.Debug("Initializing the RzDisplayState file manager");
            _displayStateFile = new DisplayStateFile();
        }