/// <summary>
        /// Iterate through and setup all functions on this control.
        /// </summary>
        /// </summary>
        /// <param name="tabletIndex_I">tablet index</param>
        /// <param name="extTagIndex_I">extension index tag</param>
        /// <param name="controlIndex_I">control index</param>
        /// <param name="setupFunc_I">function called to setup extension control layout</param>
        public void SetupFunctionsForControl(
            UInt32 tabletIndex_I,
            EWTXExtensionTag extTagIndex_I,
            UInt32 controlIndex_I,
            UInt32 numControls_I,
            DrawControlsSetupFunction setupFunc_I)
        {
            UInt32 numFuncs = 0;

            // Get the number of functions for this control.
            if (!CWintabExtensions.ControlPropertyGet(
                    mLogContext.HCtx,
                    (byte)extTagIndex_I,
                    (byte)tabletIndex_I,
                    (byte)controlIndex_I,
                    0,             // ignored
                    (ushort)EWTExtensionTabletProperty.TABLET_PROPERTY_FUNCCOUNT,
                    ref numFuncs))
            {
                throw new Exception("Oops - Failed ControlPropertyGet for TABLET_PROPERTY_FUNCCOUNT");
            }

            Debug.Assert(numFuncs > 0);

            for (UInt32 funcIdx = 0; funcIdx < numFuncs; funcIdx++)
            {
                SetupPropertiesForFunctions(tabletIndex_I, extTagIndex_I, controlIndex_I, funcIdx, numControls_I, setupFunc_I);
            }
        }
        /// <summary>
        /// Iterate through and setup all controls on this extension.
        /// </summary>
        /// <param name="tabletIndex_I">tablet index</param>
        /// <param name="extTagIndex_I">extension index tag</param>
        /// <param name="setupFunc_I">function called to setup extension control layout</param>
        public void SetupControlsForExtension(
            UInt32 tabletIndex_I,
            EWTXExtensionTag extTagIndex_I,
            DrawControlsSetupFunction setupFunc_I)
        {
            UInt32 numCtrls = 0;

            // Get number of controls of this type.
            if (!CWintabExtensions.ControlPropertyGet(
                    mLogContext.HCtx,
                    (byte)extTagIndex_I,
                    (byte)tabletIndex_I,
                    0,             // ignored
                    0,             // ignored
                    (ushort)EWTExtensionTabletProperty.TABLET_PROPERTY_CONTROLCOUNT,
                    ref numCtrls))
            {
                throw new Exception("Oops - Failed ControlPropertyGet for TABLET_PROPERTY_CONTROLCOUNT");
            }

            // All tablets should have ExpressKeys (we assume).
            if (numCtrls == 0 && EWTXExtensionTag.WTX_EXPKEYS2 == extTagIndex_I)
            {
                throw new Exception("Oops - SetupControlsForExtension didn't find any ExpressKeys!");
            }

            for (UInt32 idx = 0; idx < numCtrls; idx++)
            {
                SetupFunctionsForControl(tabletIndex_I, extTagIndex_I, idx, numCtrls, setupFunc_I);
            }
        }
예제 #3
0
        /// <summary>
        /// Iterate through all functions on this control.
        /// </summary>
        /// </summary>
        /// <param name="tabletIndex_I">tablet index</param>
        /// <param name="extTagIndex_I">extension index tag</param>
        /// <param name="controlIndex_I">control index</param>
        /// <param name="functionIndex_I">control function index</param>
        /// <param name="setupFunc_I">function called to setup extension control layout</param>
        public void SetupPropertiesForFunctions(
            UInt32 tabletIndex_I,
            EWTXExtensionTag extTagIndex_I,
            UInt32 controlIndex_I,
            UInt32 functionIndex_I,
            UInt32 numControls_I,
            DrawControlsSetupFunction setupFunc_I)
        {
            bool bIsAvailable = false;

            try
            {
                WTPKT  propOverride  = 1; // true
                UInt32 ctrlAvailable = 0;
                UInt32 ctrlLocation  = 0;
                UInt32 ctrlMinRange  = 0;
                UInt32 ctrlMaxRange  = 0;
                String indexStr      = extTagIndex_I == EWTXExtensionTag.WTX_EXPKEYS2 ?
                                       Convert.ToString(controlIndex_I) :
                                       Convert.ToString(functionIndex_I);

                // NOTE - you can use strings in any language here.
                // The strings will be encoded to UTF8 before sent to the driver.
                // For example, you could use the string: "付録A" to indicate "EK" in Japanese.
                String ctrlname =
                    extTagIndex_I == EWTXExtensionTag.WTX_EXPKEYS2 ?   "EK: " + indexStr :
                    extTagIndex_I == EWTXExtensionTag.WTX_TOUCHRING ?  "TR: " + indexStr :
                    extTagIndex_I == EWTXExtensionTag.WTX_TOUCHSTRIP ? "TS: " + indexStr :
                    /* unknown control */ "UK: " + indexStr;

                do
                {
                    // Ask if control is available for override.
                    if (!CWintabExtensions.ControlPropertyGet(
                            mLogContext.HCtx,
                            (byte)extTagIndex_I,
                            (byte)tabletIndex_I,
                            (byte)controlIndex_I,
                            (byte)functionIndex_I,
                            (ushort)EWTExtensionTabletProperty.TABLET_PROPERTY_AVAILABLE,
                            ref ctrlAvailable))
                    {
                        throw new Exception("Oops - FAILED ControlPropertyGet for TABLET_PROPERTY_AVAILABLE");
                    }

                    bIsAvailable = (ctrlAvailable > 0);

                    if (!bIsAvailable)
                    {
                        Debug.WriteLine("Cannot override control");
                        break;
                    }

                    // Set flag indicating we're overriding the control.
                    if (!CWintabExtensions.ControlPropertySet(
                            mLogContext.HCtx,
                            (byte)extTagIndex_I,
                            (byte)tabletIndex_I,
                            (byte)controlIndex_I,
                            (byte)functionIndex_I,
                            (ushort)EWTExtensionTabletProperty.TABLET_PROPERTY_OVERRIDE,
                            propOverride))
                    {
                        throw new Exception("Oops - FAILED ControlPropertySet for TABLET_PROPERTY_OVERRIDE");
                    }

                    // Set the control name.
                    if (!CWintabExtensions.ControlPropertySet(
                            mLogContext.HCtx,
                            (byte)extTagIndex_I,
                            (byte)tabletIndex_I,
                            (byte)controlIndex_I,
                            (byte)functionIndex_I,
                            (ushort)EWTExtensionTabletProperty.TABLET_PROPERTY_OVERRIDE_NAME,
                            ctrlname))
                    {
                        throw new Exception("Oops - FAILED ControlPropertySet for TABLET_PROPERTY_OVERRIDE_NAME");
                    }

                    // Get the location of the control
                    if (!CWintabExtensions.ControlPropertyGet(
                            mLogContext.HCtx,
                            (byte)extTagIndex_I,
                            (byte)tabletIndex_I,
                            (byte)controlIndex_I,
                            (byte)functionIndex_I,
                            (ushort)EWTExtensionTabletProperty.TABLET_PROPERTY_LOCATION,
                            ref ctrlLocation))
                    {
                        throw new Exception("Oops - FAILED ControlPropertyGet for TABLET_PROPERTY_LOCATION");
                    }

                    if (!CWintabExtensions.ControlPropertyGet(
                            mLogContext.HCtx,
                            (byte)extTagIndex_I,
                            (byte)tabletIndex_I,
                            (byte)controlIndex_I,
                            (byte)functionIndex_I,
                            (ushort)EWTExtensionTabletProperty.TABLET_PROPERTY_MIN,
                            ref ctrlMinRange))
                    {
                        throw new Exception("Oops - FAILED ControlPropertyGet for TABLET_PROPERTY_MIN");
                    }

                    if (!CWintabExtensions.ControlPropertyGet(
                            mLogContext.HCtx,
                            (byte)extTagIndex_I,
                            (byte)tabletIndex_I,
                            (byte)controlIndex_I,
                            (byte)functionIndex_I,
                            (ushort)EWTExtensionTabletProperty.TABLET_PROPERTY_MAX,
                            ref ctrlMaxRange))
                    {
                        throw new Exception("Oops - FAILED ControlPropertyGet for TABLET_PROPERTY_MAX");
                    }

                    // Set tablet OLED with icon (if supported by the tablet).
                    // Ignore return value for now.
                    CWintabExtensions.SetDisplayProperty(
                        mLogContext,
                        extTagIndex_I,
                        tabletIndex_I,
                        controlIndex_I,
                        functionIndex_I,
                        mTestImageIconPath);

                    // Finally, call function to setup control layout for rendering.
                    // Control will be updated when WT_PACKETEXT packets received.
                    setupFunc_I(
                        (int)tabletIndex_I,
                        (int)controlIndex_I,
                        (int)functionIndex_I,
                        bIsAvailable,
                        (int)ctrlLocation,
                        (int)ctrlMinRange,
                        (int)ctrlMaxRange);

                    SetControlProperties(tabletIndex_I, extTagIndex_I, controlIndex_I, functionIndex_I, numControls_I, ctrlname);
                } while (false);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
예제 #4
0
        /// <summary>
        /// Iterate through all functions on this control.
        /// </summary>
        /// </summary>
        /// <param name="tabletIndex_I">tablet index</param>
        /// <param name="extTagIndex_I">extension index tag</param>
        /// <param name="controlIndex_I">control index</param>
        /// <param name="functionIndex_I">control function index</param>
        /// <param name="setupFunc_I">function called to setup extension control layout</param>
        public void SetupPropertiesForFunctions(
            UInt32 tabletIndex_I,
            EWTXExtensionTag extTagIndex_I,
            UInt32 controlIndex_I,
            UInt32 functionIndex_I,
            UInt32 numControls_I,
            DrawControlsSetupFunction setupFunc_I)
        {
            bool bIsAvailable = false;

            try
            {
                WTPKT propOverride = 1;  // true
                UInt32 ctrlAvailable = 0;
                UInt32 ctrlLocation = 0;
                UInt32 ctrlMinRange = 0;
                UInt32 ctrlMaxRange = 0;
                String indexStr = extTagIndex_I == EWTXExtensionTag.WTX_EXPKEYS2 ?
                    Convert.ToString(controlIndex_I) :
                    Convert.ToString(functionIndex_I);

                // NOTE - you can use strings in any language here.
                // The strings will be encoded to UTF8 before sent to the driver.
                // For example, you could use the string: "付録A" to indicate "EK" in Japanese.
                String ctrlname =
                    extTagIndex_I == EWTXExtensionTag.WTX_EXPKEYS2 ?   "EK: " + indexStr :
                    extTagIndex_I == EWTXExtensionTag.WTX_TOUCHRING ?  "TR: " + indexStr :
                    extTagIndex_I == EWTXExtensionTag.WTX_TOUCHSTRIP ? "TS: " + indexStr :
                    /* unknown control */                              "UK: " + indexStr;

                do
                {
                    // Ask if control is available for override.
                    if (!CWintabExtensions.ControlPropertyGet(
                        mLogContext.HCtx,
                        (byte)extTagIndex_I,
                        (byte)tabletIndex_I,
                        (byte)controlIndex_I,
                        (byte)functionIndex_I,
                        (ushort)EWTExtensionTabletProperty.TABLET_PROPERTY_AVAILABLE,
                        ref ctrlAvailable))
                    { throw new Exception("Oops - FAILED ControlPropertyGet for TABLET_PROPERTY_AVAILABLE"); }

                    bIsAvailable = (ctrlAvailable > 0);

                    if (!bIsAvailable)
                    {
                        Debug.WriteLine("Cannot override control");
                        break;
                    }

                    // Set flag indicating we're overriding the control.
                    if (!CWintabExtensions.ControlPropertySet(
                        mLogContext.HCtx,
                        (byte)extTagIndex_I,
                        (byte)tabletIndex_I,
                        (byte)controlIndex_I,
                        (byte)functionIndex_I,
                        (ushort)EWTExtensionTabletProperty.TABLET_PROPERTY_OVERRIDE,
                        propOverride))
                    { throw new Exception("Oops - FAILED ControlPropertySet for TABLET_PROPERTY_OVERRIDE"); }

                    // Set the control name.
                    if (!CWintabExtensions.ControlPropertySet(
                        mLogContext.HCtx,
                        (byte)extTagIndex_I,
                        (byte)tabletIndex_I,
                        (byte)controlIndex_I,
                        (byte)functionIndex_I,
                        (ushort)EWTExtensionTabletProperty.TABLET_PROPERTY_OVERRIDE_NAME,
                        ctrlname))
                    { throw new Exception("Oops - FAILED ControlPropertySet for TABLET_PROPERTY_OVERRIDE_NAME"); }

                    // Get the location of the control
                    if (!CWintabExtensions.ControlPropertyGet(
                        mLogContext.HCtx,
                        (byte)extTagIndex_I,
                        (byte)tabletIndex_I,
                        (byte)controlIndex_I,
                        (byte)functionIndex_I,
                        (ushort)EWTExtensionTabletProperty.TABLET_PROPERTY_LOCATION,
                        ref ctrlLocation))
                    { throw new Exception("Oops - FAILED ControlPropertyGet for TABLET_PROPERTY_LOCATION"); }

                    if (!CWintabExtensions.ControlPropertyGet(
                        mLogContext.HCtx,
                        (byte)extTagIndex_I,
                        (byte)tabletIndex_I,
                        (byte)controlIndex_I,
                        (byte)functionIndex_I,
                        (ushort)EWTExtensionTabletProperty.TABLET_PROPERTY_MIN,
                        ref ctrlMinRange))
                    { throw new Exception("Oops - FAILED ControlPropertyGet for TABLET_PROPERTY_MIN"); }

                    if (!CWintabExtensions.ControlPropertyGet(
                        mLogContext.HCtx,
                        (byte)extTagIndex_I,
                        (byte)tabletIndex_I,
                        (byte)controlIndex_I,
                        (byte)functionIndex_I,
                        (ushort)EWTExtensionTabletProperty.TABLET_PROPERTY_MAX,
                        ref ctrlMaxRange))
                    { throw new Exception("Oops - FAILED ControlPropertyGet for TABLET_PROPERTY_MAX"); }

                    // Set tablet OLED with icon (if supported by the tablet).
                    // Ignore return value for now.
                    CWintabExtensions.SetDisplayProperty(
                        mLogContext,
                        extTagIndex_I,
                        tabletIndex_I,
                        controlIndex_I,
                        functionIndex_I,
                        mTestImageIconPath);

                    // Finally, call function to setup control layout for rendering.
                    // Control will be updated when WT_PACKETEXT packets received.
                    setupFunc_I(
                        (int)tabletIndex_I,
                        (int)controlIndex_I,
                        (int)functionIndex_I,
                        bIsAvailable,
                        (int)ctrlLocation,
                        (int)ctrlMinRange,
                        (int)ctrlMaxRange);

                    SetControlProperties(tabletIndex_I, extTagIndex_I, controlIndex_I, functionIndex_I, numControls_I, ctrlname);
                } while (false);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
예제 #5
0
        /// <summary>
        /// Iterate through and setup all functions on this control.
        /// </summary>
        /// </summary>
        /// <param name="tabletIndex_I">tablet index</param>
        /// <param name="extTagIndex_I">extension index tag</param>
        /// <param name="controlIndex_I">control index</param>
        /// <param name="setupFunc_I">function called to setup extension control layout</param>
        public void SetupFunctionsForControl(
            UInt32 tabletIndex_I,
            EWTXExtensionTag extTagIndex_I,
            UInt32 controlIndex_I,
            UInt32 numControls_I,
            DrawControlsSetupFunction setupFunc_I)
        {
            UInt32 numFuncs = 0;

            try
            {
                // Get the number of functions for this control.
                if (!CWintabExtensions.ControlPropertyGet(
                    mLogContext.HCtx,
                    (byte)extTagIndex_I,
                    (byte)tabletIndex_I,
                    (byte)controlIndex_I,
                    0, // ignored
                    (ushort)EWTExtensionTabletProperty.TABLET_PROPERTY_FUNCCOUNT,
                    ref numFuncs))
                { throw new Exception("Oops - Failed ControlPropertyGet for TABLET_PROPERTY_FUNCCOUNT"); }

                Debug.Assert(numFuncs > 0);

                for (UInt32 funcIdx = 0; funcIdx < numFuncs; funcIdx++)
                {
                    SetupPropertiesForFunctions(tabletIndex_I, extTagIndex_I, controlIndex_I, funcIdx, numControls_I, setupFunc_I);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #6
0
        /// <summary>
        /// Iterate through and setup all controls on this extension. 
        /// </summary>
        /// <param name="tabletIndex_I">tablet index</param>
        /// <param name="extTagIndex_I">extension index tag</param>
        /// <param name="setupFunc_I">function called to setup extension control layout</param>
        public void SetupControlsForExtension(
            UInt32 tabletIndex_I,
            EWTXExtensionTag extTagIndex_I,
            DrawControlsSetupFunction setupFunc_I)
        {
            UInt32 numCtrls = 0;

            try
            {
                // Get number of controls of this type.
                if ( !CWintabExtensions.ControlPropertyGet(
                    mLogContext.HCtx,
                    (byte)extTagIndex_I,
                    (byte)tabletIndex_I,
                    0, // ignored
                    0, // ignored
                    (ushort)EWTExtensionTabletProperty.TABLET_PROPERTY_CONTROLCOUNT,
                    ref numCtrls) )
                { throw new Exception("Oops - Failed ControlPropertyGet for TABLET_PROPERTY_CONTROLCOUNT"); }

                // All tablets should have ExpressKeys (we assume).
                if (numCtrls == 0 && EWTXExtensionTag.WTX_EXPKEYS2 == extTagIndex_I)
                { throw new Exception("Oops - SetupControlsForExtension didn't find any ExpressKeys!"); }

                for (UInt32 idx = 0; idx < numCtrls; idx++)
                {
                    SetupFunctionsForControl(tabletIndex_I, extTagIndex_I, idx, numCtrls, setupFunc_I);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }