예제 #1
0
        public static bool IsDefinedHIDUsage(HIDElementDescriptor hidElement)
        {
            bool isKnown = false;

            if (PageId.IsDefined(typeof(PageId), hidElement.usagePageID))
            {
                switch ((PageId)hidElement.usagePageID)
                {
                case PageId.GenericDesktopPage:
                {
                    isKnown = GenericDesktopUsage.IsDefined(typeof(GenericDesktopUsage), hidElement.usageID);
                }
                break;

                case PageId.SimulationPage:
                {
                    isKnown = SimulationUsage.IsDefined(typeof(SimulationUsage), hidElement.usageID);
                }
                break;

                case PageId.ButtonPage:
                {
                    isKnown = hidElement.usageID > 0 && hidElement.usageID <= kMaxButtons;
                }
                break;
                }
            }
            return(isKnown);
        }
예제 #2
0
        static string GetUsageName(int pageId, int usageId)
        {
            string usageName = string.Format("Unknown[{0}][{1}]", pageId, usageId);

            switch ((PageId)pageId)
            {
            case PageId.GenericDesktopPage:
            {
                if (GenericDesktopUsage.IsDefined(typeof(GenericDesktopUsage), usageId))
                {
                    usageName = ((GenericDesktopUsage)usageId).ToString();
                }
            }
            break;

            case PageId.SimulationPage:
            {
                if (SimulationUsage.IsDefined(typeof(SimulationUsage), usageId))
                {
                    usageName = ((SimulationUsage)usageId).ToString();
                }
            }
            break;

            case PageId.ButtonPage:
            {
                usageName = string.Format("Button {0}", usageId);
            }
            break;

            default:
                break;
            }
            return(usageName);
        }