Exemplo n.º 1
0
        private void DoAttachWindowClientCallback(WacomMTCapability deviceCapability_I, IntPtr userData_I)
        {
            try
            {
                // This will add the device to our configuration only if not already added.
                mWacomMTConfig.AddDevice(deviceCapability_I);

                //MessageBox.Show("DeviceID: " + deviceCapability_I.DeviceID + " has attached");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 2
0
        private void DoAttachWindowClientCallback(WacomMTCapability deviceCapability_I, IntPtr userData_I)
        {
            try
            {
                // This will add the device to our configuration only if not already added.
                mWacomMTConfig.AddDevice(deviceCapability_I);

                //MessageBox.Show("DeviceID: " + deviceCapability_I.DeviceID + " has attached");

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        /// <summary>
        /// Find capabilities for all attached touch devices.
        /// If successful, this will populate mDeviceCapsMap.
        /// </summary>
        /// <returns> true if all device capabilities updated</returns>
        private bool UpdateDeviceCaps()
        {
            IntPtr devBuf = IntPtr.Zero;

            try
            {
                if (mNumDevices > 0)
                {
                    for (int idx = 0; idx < mNumDevices; idx++)
                    {
                        Int32             devID   = mDeviceIDArray.data[idx];
                        WacomMTCapability devCaps = new WacomMTCapability();

                        devBuf = CMemUtils.AllocUnmanagedBuf(devCaps);
                        Marshal.StructureToPtr(devCaps, devBuf, false);

                        if (WacomMTError.WMTErrorSuccess == CWacomMTInterface.WacomMTGetDeviceCapabilities(devID, devBuf))
                        {
                            devCaps = (WacomMTCapability)Marshal.PtrToStructure(devBuf, typeof(WacomMTCapability));
                            mDeviceCapsMap[devID] = devCaps;
                            DumpDeviceCaps(devID);

                            CMemUtils.FreeUnmanagedBuf(ref devBuf);;
                        }
                        else
                        {
                            throw new Exception("Oops - failed WacomMTGetDeviceCapabilities");
                        }
                    }

                    return(true);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (devBuf != IntPtr.Zero)
                {
                    CMemUtils.FreeUnmanagedBuf(ref devBuf);
                }
            }

            return(false);
        }
        ////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Returns a string listing MTAPI capabilities for the specified device.
        /// </summary>
        /// <param name="devID_I">Touch device identifier</param>
        /// <returns>A newline-separated string of device capabilities</returns>
        public String GetDeviceCapsString(Int32 devID_I)
        {
            String devCapsStr = "";

            if (UpdateDeviceCaps())
            {
                if (mDeviceCapsMap.ContainsKey(devID_I))
                {
                    WacomMTCapability devCaps = mDeviceCapsMap[devID_I];

                    devCapsStr += "Capabilities for device: " + devID_I + "\n";
                    devCapsStr += "  Version:         " + devCaps.Version + "\n";
                    devCapsStr += "  DeviceID:        " + devCaps.DeviceID + "\n";
                    devCapsStr += "  Type:            " + devCaps.Type + "\n";
                    devCapsStr += "  LogOriginX:      " + devCaps.LogicalOriginX + "\n";
                    devCapsStr += "  LogOriginY:      " + devCaps.LogicalOriginY + "\n";
                    devCapsStr += "  LogWidth:        " + devCaps.LogicalWidth + "\n";
                    devCapsStr += "  LogHeight:       " + devCaps.LogicalHeight + "\n";
                    devCapsStr += "  PhysSizeX:       " + devCaps.PhysicalSizeX + "\n";
                    devCapsStr += "  PhysSizeY:       " + devCaps.PhysicalSizeY + "\n";
                    devCapsStr += "  ReportedSizeX:   " + devCaps.ReportedSizeX + "\n";
                    devCapsStr += "  ReportedSizeY:   " + devCaps.ReportedSizeY + "\n";
                    devCapsStr += "  ScanSizeX:       " + devCaps.ScanSizeX + "\n";
                    devCapsStr += "  ScanSizeY:       " + devCaps.ScanSizeY + "\n";
                    devCapsStr += "  FingerMax:       " + devCaps.FingerMax + "\n";
                    devCapsStr += "  BlobMax:         " + devCaps.BlobMax + "\n";
                    devCapsStr += "  BlobPointsMax:   " + devCaps.BlobPointsMax + "\n";

                    {
                        String rawAvail  = (devCaps.CapabilityFlags & WacomMTCapabilityFlags.WMTCapabilityFlagsRawAvailable) > 0 ? "T" : "F";
                        String blobAvail = (devCaps.CapabilityFlags & WacomMTCapabilityFlags.WMTCapabilityFlagsBlobAvailable) > 0 ? "T" : "F";
                        String sensAvail = (devCaps.CapabilityFlags & WacomMTCapabilityFlags.WMTCapabilityFlagsSensitivityAvailable) > 0 ? "T" : "F";
                        devCapsStr += "  CapabilityFlags: [Raw|Blob|Sensitivity] = [" + rawAvail + "|" + blobAvail + "|" + sensAvail + "]";
                    }
                }
                else
                {
                    devCapsStr = "No capabilities found for key: " + devID_I;
                }
            }

            return(devCapsStr);
        }
        ////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Adds touch device with the specified device capability to the current
        /// list of attached devices.
        /// </summary>
        /// <param name="deviceCapability_I"></param>
        public void AddDevice(WacomMTCapability deviceCapability_I)
        {
            IntPtr devBuf = IntPtr.Zero;

            try
            {
                Int32 deviceID = deviceCapability_I.DeviceID;

                // Only add device if not already added.
                if (!mDeviceCapsMap.ContainsKey(deviceID))
                {
                    mDeviceCapsMap[deviceID] = deviceCapability_I;

                    // Make sure we're in sync with system's view of #attached devices.
                    devBuf = CMemUtils.AllocUnmanagedBuf(mDeviceIDArray);
                    Marshal.StructureToPtr(mDeviceIDArray, devBuf, false);

                    if (mNumDevices > WacomMTConstants.MAX_NUMBER_TOUCH_DEVICES)
                    {
                        throw new Exception("Too many touch devices attached");
                    }

                    mNumDevices = CWacomMTInterface.WacomMTGetAttachedDeviceIDs(devBuf, mMaxNumTouchDevices * sizeof(Int32));

                    if (mNumDevices > 0)
                    {
                        mDeviceIDArray = (WacomMTDeviceIDArray)Marshal.PtrToStructure(devBuf, typeof(WacomMTDeviceIDArray));
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                CMemUtils.FreeUnmanagedBuf(ref devBuf);
            }
        }
        static void Main(string[] args)
        {
            CursorVisible = false;
            try {
                WacomMTError error = WacomMTAPI.WacomMTInitialize();

                if (error == WacomMTError.WMTErrorSuccess)
                {
                    _Ids = WacomMTAPI.WacomMTGetAttachedDeviceIDs();

                    foreach (int id in _Ids)
                    {
                        WriteLine("Tablet Device #" + id);
                        WacomMTCapability capability = WacomMTAPI.WacomMTGetDeviceCapabilities(id);
                        WriteLine("Virsion : " + capability.Version);
                        WriteLine("DeviceID : " + capability.DeviceID);
                        WriteLine("Type : " + capability.Type);
                        WriteLine("LogicalOriginX : " + capability.LogicalOriginX);
                        WriteLine("LogicalOriginY : " + capability.LogicalOriginY);
                        WriteLine("LogicalWidth : " + capability.LogicalWidth);
                        WriteLine("LogicalHeight : " + capability.LogicalHeight);
                        WriteLine("PhysicalSizeX : " + capability.PhysicalSizeX);
                        WriteLine("PhysicalSizeY : " + capability.PhysicalSizeY);
                        WriteLine("ReportedSizeX : " + capability.ReportedSizeX);
                        WriteLine("ReportedSizeY : " + capability.ReportedSizeY);
                        WriteLine("ScanSizeX : " + capability.ScanSizeX);
                        WriteLine("ScanSizeY : " + capability.ScanSizeY);
                        WriteLine("FingerMax : " + capability.FingerMax);
                        WriteLine("BlobMax : " + capability.BlobMax);
                        WriteLine("BlobPointsMax : " + capability.BlobPointsMax);
                        WriteLine("CapabilityFlags : " + capability.CapabilityFlags);
                        WriteLine();
                    }

                    error = WacomMTAPI.WacomMTRegisterFingerReadCallback(_Ids[0], IntPtr.Zero, WacomMTProcessingMode.WMTProcessingModeNone, FingerCallback, IntPtr.Zero);

                    if (error != WacomMTError.WMTErrorSuccess)
                    {
                        throw new Exception("Errpr WacomMTRegisterFingerReadCallback : " + error);
                    }
                }
                else
                {
                    throw new Exception("Error WacomMTInitialize : " + error);
                }
            } catch (Exception e) {
                SetCursorPosition(0, CursorTop + 2);
                WriteLine(e.Message);
            }

            using (GrandSlider slider = new GrandSlider()) {
                slider.Run(60);
            }

            /**
             * do {
             *      Thread.Sleep(10);
             * } while (!Keyboard.IsKeyDown(Key.Enter));
             */
            WacomMTAPI.WacomMTQuit();
        }