/// <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);
            }
        }
Esempio n. 3
0
 ///////////////////////////////////////////////////////////////////////
 private void Test_GetExtensionMask()
 {
     TraceMsg("Extension touchring mask:   0x" + CWintabExtensions.GetWTExtensionMask(EWTXExtensionTag.WTX_TOUCHRING).ToString("x") + "\n");
     TraceMsg("Extension touchstring mask: 0x" + CWintabExtensions.GetWTExtensionMask(EWTXExtensionTag.WTX_TOUCHSTRIP).ToString("x") + "\n");
     TraceMsg("Extension express key mask: 0x" + CWintabExtensions.GetWTExtensionMask(EWTXExtensionTag.WTX_EXPKEYS2).ToString("x") + "\n");
 }
Esempio n. 4
0
        private bool InitWintab()
        {
            bool status = false;

            try
            {
                mLogContext = CWintabInfo.GetDefaultDigitizingContext(ECTXOptionValues.CXO_MESSAGES);
                if (mLogContext == null)
                {
                    return(false);
                    //throw new Exception("Oops - FAILED GetDefaultDigitizingContext");
                }

                // Control system cursor.
                mLogContext.Options |= (UInt32)ECTXOptionValues.CXO_SYSTEM;

                // Verify which extensions are available for targeting.
                // Once we know what the tablet supports, we can set up the data packet
                // definition to be sent events from those control types.

                // All tablets should have at least expresskeys.
                mExpKeysMask = CWintabExtensions.GetWTExtensionMask(EWTXExtensionTag.WTX_EXPKEYS2);

                if (mExpKeysMask > 0)
                {
                    mLogContext.PktData |= (WTPKT)mExpKeysMask;
                }
                else
                {
                    Debug.WriteLine("InitWintab: WTX_EXPKEYS2 mask not found!");
                    throw new Exception("Oops - FAILED GetWTExtensionMask for WTX_EXPKEYS2");
                }

                // It's not an error if either / both of these are zero.  It simply means
                // that those control types are not supported.
                mTouchRingMask = CWintabExtensions.GetWTExtensionMask(EWTXExtensionTag.WTX_TOUCHRING);
                if (mTouchRingMask > 0)
                {
                    mLogContext.PktData |= (WTPKT)mTouchRingMask;
                }

                mTouchStripMask = CWintabExtensions.GetWTExtensionMask(EWTXExtensionTag.WTX_TOUCHSTRIP);
                if (mTouchStripMask > 0)
                {
                    mLogContext.PktData |= (WTPKT)mTouchStripMask;
                }

                status = mLogContext.Open();
                if (!status)
                {
                    //throw new Exception("Oops - failed logContext.Open()");
                    return(false);
                }

                // Setup controls and overrides for first tablet.
                SetupControlsForTablet(mTabletIndexDefault);

                // Create a data object and set its WT_PACKET handler.
                m_wtData = new CWintabData(mLogContext);
                m_wtData.SetWTPacketEventHandler(MyWTPacketEventHandler);
            }
            catch (Exception ex)
            {
                MessageBox.Show("FormExtTestApp: InitWintab: " + ex.ToString());
            }

            return(true);
        }
Esempio n. 5
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());
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Remove application overrides for extension.
        /// </summary>
        /// <param name="tabletIndex_I"></param>
        /// <param name="extTagIndex_I"></param>
        void RemoveOverridesForExtension(
            UInt32 tabletIndex_I,
            EWTXExtensionTag extTagIndex_I)
        {
            UInt32 numCtrls     = 0;
            UInt32 numFuncs     = 0;
            UInt32 propOverride = 0;  // false

            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 each control, find its number of functions ...
                for (UInt32 controlIndex = 0; controlIndex < numCtrls; controlIndex++)
                {
                    if (!CWintabExtensions.ControlPropertyGet(
                            mLogContext.HCtx,
                            (byte)extTagIndex_I,
                            (byte)tabletIndex_I,
                            (byte)controlIndex,
                            0, // ignored
                            (ushort)EWTExtensionTabletProperty.TABLET_PROPERTY_FUNCCOUNT,
                            ref numFuncs))
                    {
                        throw new Exception("Oops - Failed ControlPropertyGet for TABLET_PROPERTY_FUNCCOUNT");
                    }

                    // ... and override our setting for each function.
                    for (UInt32 functionIndex = 0; functionIndex < numFuncs; functionIndex++)
                    {
                        if (!CWintabExtensions.ControlPropertySet(
                                mLogContext.HCtx,
                                (byte)extTagIndex_I,
                                (byte)tabletIndex_I,
                                (byte)controlIndex,
                                (byte)functionIndex,
                                (ushort)EWTExtensionTabletProperty.TABLET_PROPERTY_OVERRIDE,
                                propOverride))
                        {
                            throw new Exception("Oops - FAILED ControlPropertySet for TABLET_PROPERTY_OVERRIDE");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }