pub struct UsageCollection {
    pub pages:&'static [UsagePage],
}
impl UsageCollection {
    pub fn get(&self, id:u16) -> Option<&'static UsagePage>
    {
        for page in self.pages {
            if page.id == id {
                return Some(page);
            }
        }
        None
    }
}

pub struct UsagePage {
    pub id:u16,
    pub name:&'static str,

    pub usages:&'static [Usage],
}
impl UsagePage {
    pub fn get(&self, id:u16) -> Option<&'static Usage>
    {
        for usage in self.usages {
            if usage.id == id {
                return Some(usage);
            }
        }
        None
    }
}

pub struct Usage {
    pub id:u16,
    pub usage_type:UsageType,
    pub name:&'static str,
}

pub enum UsageType {
    Any,
    Physical,
    Application,
    Value,
    Toggle,
    Button,
}

pub const USAGES :UsageCollection = UsageCollection {
    pages:&[
        UsagePage {
            id:0x0001,
            name:"Generic Desktop",
            usages:&[
                Usage {
                    id:0x0001,
                    usage_type:UsageType::Physical,
                    name:"Pointer",
                },
                Usage {
                    id:0x0002,
                    usage_type:UsageType::Application,
                    name:"Mouse",
                },
                Usage {
                    id:0x0004,
                    usage_type:UsageType::Application,
                    name:"Joystick",
                },
                Usage {
                    id:0x0005,
                    usage_type:UsageType::Application,
                    name:"Gamepad",
                },
                Usage {
                    id:0x0006,
                    usage_type:UsageType::Application,
                    name:"Keyboard",
                },
                Usage {
                    id:0x0007,
                    usage_type:UsageType::Application,
                    name:"Keypad",
                },
                Usage {
                    id:0x0008,
                    usage_type:UsageType::Application,
                    name:"Multi-axis Controller",
                },
                Usage {
                    id:0x0009,
                    usage_type:UsageType::Application,
                    name:"Tablet PC",
                },
                Usage {
                    id:0x000E,
                    usage_type:UsageType::Application,
                    name:"Spatial Controller",
                },

                Usage {
                    id:0x0030,
                    usage_type:UsageType::Value,
                    name:"X",
                },
                Usage {
                    id:0x0031,
                    usage_type:UsageType::Value,
                    name:"Y",
                },
                Usage {
                    id:0x0032,
                    usage_type:UsageType::Value,
                    name:"Z",
                },
                Usage {
                    id:0x0033,
                    usage_type:UsageType::Value,
                    name:"Rx",
                },
                Usage {
                    id:0x0034,
                    usage_type:UsageType::Value,
                    name:"Ry",
                },
                Usage {
                    id:0x0035,
                    usage_type:UsageType::Value,
                    name:"Rz",
                },
                Usage {
                    id:0x0036,
                    usage_type:UsageType::Value,
                    name:"Slider",
                },
                Usage {
                    id:0x0037,
                    usage_type:UsageType::Value,
                    name:"Dial",
                },
                Usage {
                    id:0x0038,
                    usage_type:UsageType::Value,
                    name:"Wheel",
                },
                Usage {
                    id:0x0039,
                    usage_type:UsageType::Value,
                    name:"Hat Switch",
                },
                Usage {
                    id:0x003D,
                    usage_type:UsageType::Toggle,
                    name:"Start",
                },
                Usage {
                    id:0x003E,
                    usage_type:UsageType::Toggle,
                    name:"Select",
                },
                Usage {
                    id:0x0040,
                    usage_type:UsageType::Value,
                    name:"Vx",
                },
                Usage {
                    id:0x0041,
                    usage_type:UsageType::Value,
                    name:"Vy",
                },
                Usage {
                    id:0x0042,
                    usage_type:UsageType::Value,
                    name:"Vz",
                },
                Usage {
                    id:0x0043,
                    usage_type:UsageType::Value,
                    name:"Vbx",
                },
                Usage {
                    id:0x0044,
                    usage_type:UsageType::Value,
                    name:"Vby",
                },
                Usage {
                    id:0x0045,
                    usage_type:UsageType::Value,
                    name:"Vbz",
                },
                Usage {
                    id:0x0046,
                    usage_type:UsageType::Value,
                    name:"Vno",
                },
                Usage {
                    id:0x0048,
                    usage_type:UsageType::Value,
                    name:"Resolution Multiplier",
                },
                Usage {
                    id:0x0049,
                    usage_type:UsageType::Value,
                    name:"Qx",
                },
                Usage {
                    id:0x004A,
                    usage_type:UsageType::Value,
                    name:"Qy",
                },
                Usage {
                    id:0x004B,
                    usage_type:UsageType::Value,
                    name:"Qz",
                },
                Usage {
                    id:0x004C,
                    usage_type:UsageType::Value,
                    name:"Qw",
                },
                Usage {
                    id:0x0090,
                    usage_type:UsageType::Toggle,
                    name:"D-pad Up",
                },
                Usage {
                    id:0x0091,
                    usage_type:UsageType::Toggle,
                    name:"D-pad Down",
                },
                Usage {
                    id:0x0092,
                    usage_type:UsageType::Toggle,
                    name:"D-pad Right",
                },
                Usage {
                    id:0x0093,
                    usage_type:UsageType::Toggle,
                    name:"D-pad Left",
                },
            ],
        },

        UsagePage {
            id:0x0002,
            name:"Simulation Controls",
            usages:&[
                Usage {
                    id:0x0001,
                    usage_type:UsageType::Application,
                    name:"Flight Simulation Device",
                },
                Usage {
                    id:0x0002,
                    usage_type:UsageType::Application,
                    name:"Automobile Simulation Device",
                },
                Usage {
                    id:0x0003,
                    usage_type:UsageType::Application,
                    name:"Tank Simulation Device",
                },
                Usage {
                    id:0x0004,
                    usage_type:UsageType::Application,
                    name:"Spaceship Simulation Device",
                },
                Usage {
                    id:0x0005,
                    usage_type:UsageType::Application,
                    name:"Submarine Simulation Device",
                },
                Usage {
                    id:0x0006,
                    usage_type:UsageType::Application,
                    name:"Sailing Simulation Device",
                },
                Usage {
                    id:0x0007,
                    usage_type:UsageType::Application,
                    name:"Motorcycle Simulation Device",
                },
                Usage {
                    id:0x0008,
                    usage_type:UsageType::Application,
                    name:"Sports Simulation Device",
                },
                Usage {
                    id:0x0009,
                    usage_type:UsageType::Application,
                    name:"Airplane Simulation Device",
                },
                Usage {
                    id:0x000A,
                    usage_type:UsageType::Application,
                    name:"Helicopter Simulation Device",
                },
                Usage {
                    id:0x000B,
                    usage_type:UsageType::Application,
                    name:"Magic Carpet Simulation Device",
                },
                Usage {
                    id:0x000C,
                    usage_type:UsageType::Application,
                    name:"Bicycle Simulation Device",
                },

                Usage {
                    id:0x0020,
                    usage_type:UsageType::Application,
                    name:"Flight Control Stick",
                },
                Usage {
                    id:0x0021,
                    usage_type:UsageType::Application,
                    name:"Flight Stick",
                },
                Usage {
                    id:0x0022,
                    usage_type:UsageType::Physical,
                    name:"Cyclic Control",
                },
                Usage {
                    id:0x0023,
                    usage_type:UsageType::Physical,
                    name:"Cyclic Trim",
                },
                Usage {
                    id:0x0034,
                    usage_type:UsageType::Application,
                    name:"Flight Yoke",
                },
                Usage {
                    id:0x0025,
                    usage_type:UsageType::Physical,
                    name:"Track Control",
                },

                Usage {
                    id:0x00B0,
                    usage_type:UsageType::Value,
                    name:"Aileron",
                },
                Usage {
                    id:0x00B1,
                    usage_type:UsageType::Value,
                    name:"Aileron Trim",
                },
                Usage {
                    id:0x00B2,
                    usage_type:UsageType::Value,
                    name:"Anti-Torque Control",
                },
                Usage {
                    id:0x00B3,
                    usage_type:UsageType::Toggle,
                    name:"Autopilot",
                },
                Usage {
                    id:0x00B4,
                    usage_type:UsageType::Button,
                    name:"Chaff Release",
                },
                Usage {
                    id:0x00B5,
                    usage_type:UsageType::Value,
                    name:"Collective Control",
                },
                Usage {
                    id:0x00B6,
                    usage_type:UsageType::Value,
                    name:"Drive Brake",
                },
                Usage {
                    id:0x00B7,
                    usage_type:UsageType::Toggle,
                    name:"Electronic Countermeasures",
                },
                Usage {
                    id:0x00B8,
                    usage_type:UsageType::Value,
                    name:"Elevator",
                },
                Usage {
                    id:0x00B9,
                    usage_type:UsageType::Value,
                    name:"Elevator Trim",
                },
                Usage {
                    id:0x00BA,
                    usage_type:UsageType::Value,
                    name:"Rudder",
                },
                Usage {
                    id:0x00BB,
                    usage_type:UsageType::Value,
                    name:"Throttle",
                },
                Usage {
                    id:0x00BC,
                    usage_type:UsageType::Toggle,
                    name:"Flight Communications",
                },
                Usage {
                    id:0x00BD,
                    usage_type:UsageType::Button,
                    name:"Flare Release",
                },
                Usage {
                    id:0x00BE,
                    usage_type:UsageType::Toggle,
                    name:"Landing Gear",
                },
                Usage {
                    id:0x00BF,
                    usage_type:UsageType::Value,
                    name:"Toe Brake",
                },
                Usage {
                    id:0x00C0,
                    usage_type:UsageType::Button,
                    name:"Trigger",
                },
                Usage {
                    id:0x00C1,
                    usage_type:UsageType::Toggle,
                    name:"Weapons Arm",
                },
                Usage {
                    id:0x00C2,
                    usage_type:UsageType::Button,
                    name:"Weapons Select",
                },
                Usage {
                    id:0x00C3,
                    usage_type:UsageType::Value,
                    name:"Wing Flags",
                },
                Usage {
                    id:0x00C4,
                    usage_type:UsageType::Value,
                    name:"Accelerator",
                },
                Usage {
                    id:0x00C5,
                    usage_type:UsageType::Value,
                    name:"Brake",
                },
                Usage {
                    id:0x00C6,
                    usage_type:UsageType::Value,
                    name:"Clutch",
                },
                Usage {
                    id:0x00C7,
                    usage_type:UsageType::Value,
                    name:"Steering",
                },
                Usage {
                    id:0x00C9,
                    usage_type:UsageType::Value,
                    name:"Turret Direction",
                },
                Usage {
                    id:0x00CA,
                    usage_type:UsageType::Value,
                    name:"Turret Elevation",
                },
                Usage {
                    id:0x00CB,
                    usage_type:UsageType::Value,
                    name:"Dive Plane",
                },
                Usage {
                    id:0x00CC,
                    usage_type:UsageType::Value,
                    name:"Ballast",
                },
                Usage {
                    id:0x00CD,
                    usage_type:UsageType::Value,
                    name:"Bicycle Crank",
                },
                Usage {
                    id:0x00CE,
                    usage_type:UsageType::Value,
                    name:"Handle Bars",
                },
                Usage {
                    id:0x00CF,
                    usage_type:UsageType::Value,
                    name:"Front Brake",
                },
                Usage {
                    id:0x00D0,
                    usage_type:UsageType::Value,
                    name:"Rear Brake",
                },
            ],
        },

        UsagePage {
            id:0x0003,
            name:"Virtual Reality Controls",
            usages:&[
                Usage {
                    id:0x0005,
                    usage_type:UsageType::Physical,
                    name:"Head Tracker",
                },
            ],
        },

        UsagePage {
            id:0x0007,
            name:"Keyboard",
            usages:&[ ],
        },

        UsagePage {
            id:0x0008,
            name:"LED",
            usages:&[
                Usage {
                    id:0x0001,
                    usage_type:UsageType::Toggle,
                    name:"Num Lock",
                },
                Usage {
                    id:0x0002,
                    usage_type:UsageType::Toggle,
                    name:"Caps Lock",
                },
                Usage {
                    id:0x0003,
                    usage_type:UsageType::Toggle,
                    name:"Scroll Lock",
                },
                Usage {
                    id:0x0004,
                    usage_type:UsageType::Toggle,
                    name:"Compose",
                },
                Usage {
                    id:0x0005,
                    usage_type:UsageType::Toggle,
                    name:"Kana",
                },
                Usage {
                    id:0x0006,
                    usage_type:UsageType::Toggle,
                    name:"Power",
                },
                Usage {
                    id:0x0007,
                    usage_type:UsageType::Toggle,
                    name:"Shift",
                },
                Usage {
                    id:0x0008,
                    usage_type:UsageType::Toggle,
                    name:"Do Not Disturb",
                },
                Usage {
                    id:0x0009,
                    usage_type:UsageType::Toggle,
                    name:"Mute",
                },
                Usage {
                    id:0x000A,
                    usage_type:UsageType::Toggle,
                    name:"Tone Enable",
                },
                Usage {
                    id:0x000B,
                    usage_type:UsageType::Toggle,
                    name:"High Cut Filter",
                },
                Usage {
                    id:0x000C,
                    usage_type:UsageType::Toggle,
                    name:"Low Cut Filter",
                },
            ],
        },

        UsagePage {
            id:0x0009,
            name:"Button",
            usages:&[
                Usage {
                    id:0x0001,
                    usage_type:UsageType::Any,
                    name:"Primary",
                },
                Usage {
                    id:0x0002,
                    usage_type:UsageType::Any,
                    name:"Secondary",
                },
                Usage {
                    id:0x0003,
                    usage_type:UsageType::Any,
                    name:"Tertiary",
                },
            ],
        },

        UsagePage {
            id:0x000C,
            name:"Consumer",
            usages:&[
                Usage {
                    id:0x0001,
                    usage_type:UsageType::Application,
                    name:"Consumer Control",
                },
                Usage {
                    id:0x0002,
                    usage_type:UsageType::Any,
                    name:"Numeric Key Pad",
                },
                Usage {
                    id:0x0003,
                    usage_type:UsageType::Any,
                    name:"Programmable Buttons",
                },
                Usage {
                    id:0x0004,
                    usage_type:UsageType::Application,
                    name:"Microphone",
                },
                Usage {
                    id:0x0005,
                    usage_type:UsageType::Application,
                    name:"Headphone",
                },
            ],
        },

        UsagePage {
            id:0x000D,
            name:"Digitizer",
            usages:&[
                Usage {
                    id:0x0001,
                    usage_type:UsageType::Application,
                    name:"Digitizer",
                },
            ],
        },

        /*
        UsagePage {
            id:0x00,
            name:"",
            usages:&[
                Usage {
                    id:0x00,
                    usage_type:UsageType::,
                    name:"",
                },
            ],
        },
        */
    ],
};
