Hid/HidUtils.cs
author StephaneLenclud
Tue, 17 Mar 2015 15:35:58 +0100
changeset 83 2d5955694057
parent 77 fb9ea5ad8c2d
permissions -rw-r--r--
Switch solution to 2013.
Event repeat now a Handler option.
Handler now deregisters devices when disposed.
Adding Thinkpad custom usages.
     1 //
     2 // Copyright (C) 2014-2015 Stéphane Lenclud.
     3 //
     4 // This file is part of SharpLibHid.
     5 //
     6 // SharpDisplayManager is free software: you can redistribute it and/or modify
     7 // it under the terms of the GNU General Public License as published by
     8 // the Free Software Foundation, either version 3 of the License, or
     9 // (at your option) any later version.
    10 //
    11 // SharpDisplayManager is distributed in the hope that it will be useful,
    12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
    13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    14 // GNU General Public License for more details.
    15 //
    16 // You should have received a copy of the GNU General Public License
    17 // along with SharpDisplayManager.  If not, see <http://www.gnu.org/licenses/>.
    18 //
    19 
    20 using System;
    21 using System.Collections.Generic;
    22 using System.Text;
    23 
    24 namespace SharpLib.Hid
    25 {
    26     static class Utils
    27     {
    28         /// <summary>
    29         /// Provide the type for the usage collection corresponding to the given usage page.
    30         /// </summary>
    31         /// <param name="aUsagePage"></param>
    32         /// <returns></returns>
    33         public static Type UsageCollectionType(UsagePage aUsagePage)
    34         {
    35             switch (aUsagePage)
    36             {
    37                 case UsagePage.GenericDesktopControls:
    38                     return typeof(UsageCollection.GenericDesktop);
    39 
    40                 case UsagePage.Consumer:
    41                     return typeof(UsageCollection.Consumer);
    42 
    43                 case UsagePage.WindowsMediaCenterRemoteControl:
    44                     return typeof(UsageCollection.WindowsMediaCenter);
    45 
    46                 default:
    47                     return null;
    48             }
    49         }
    50 
    51         /// <summary>
    52         /// Provide the type for the usage corresponding to the given usage page.
    53         /// </summary>
    54         /// <param name="aUsagePage"></param>
    55         /// <returns></returns>
    56         public static Type UsageType(UsagePage aUsagePage)
    57         {
    58             switch (aUsagePage)
    59             {
    60                 case UsagePage.GenericDesktopControls:
    61                     return typeof(Usage.GenericDesktop);
    62 
    63                 case UsagePage.Consumer:
    64                     return typeof(Usage.ConsumerControl);
    65 
    66                 case UsagePage.WindowsMediaCenterRemoteControl:
    67                     return typeof(Usage.WindowsMediaCenterRemoteControl);
    68 
    69                 case UsagePage.Telephony:
    70                     return typeof(Usage.TelephonyDevice);
    71 
    72                 case UsagePage.SimulationControls:
    73                     return typeof(Usage.SimulationControl);
    74 
    75                 case UsagePage.GameControls:
    76                     return typeof(Usage.GameControl);
    77 
    78                 default:
    79                     return null;
    80             }
    81         }
    82 
    83     }
    84 }