예제 #1
0
파일: Joystick.cs 프로젝트: vetuomia/rocket
            /// <summary>
            /// Creates the button information for the device.
            /// </summary>
            /// <param name="deviceData">The device data.</param>
            /// <returns>The button information.</returns>
            public static DeviceButtonGroup[] Create(void* deviceData)
            {
                Caps caps;
                GetCaps(deviceData, out caps);

                var list = new List<DeviceButtonGroup>();
                var count = caps.NumberInputButtonCaps;
                var array = new ButtonCaps[count];

                if (GetButtonCaps(ReportType.Input, array, ref count, deviceData) == Result.SUCCESS)
                {
                    for (var i = 0; i < array.Length; i++)
                    {
                        if (array[i].UsagePage == UsagePage.Buttons && array[i].IsRange)
                        {
                            list.Add(new DeviceButtonGroup(ref array[i]));
                        }
                    }
                }

                return list.ToArray();
            }
예제 #2
0
파일: Joystick.cs 프로젝트: vetuomia/rocket
 /// <summary>
 /// Initializes a new instance of the <see cref="DeviceButtonGroup"/> class.
 /// </summary>
 /// <param name="caps">The HID button caps.</param>
 private DeviceButtonGroup(ref ButtonCaps caps)
 {
     this.usagePage = caps.UsagePage;
     this.linkCollection = caps.LinkCollection;
     this.first = caps.Range.UsageMin;
     this.Count = 1 + caps.Range.UsageMax - caps.Range.UsageMin;
     this.Pressed = new BitArray(this.Count);
 }