Adding missing public keyword for some of our usage enumerations.
     2 // Copyright (C) 2014-2015 Stéphane Lenclud.
 
     4 // This file is part of SharpLibHid.
 
     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.
 
    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.
 
    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/>.
 
    22 using System.Windows.Forms;
 
    23 using System.Runtime.InteropServices;
 
    24 using System.Diagnostics;
 
    26 using Microsoft.Win32.SafeHandles;
 
    28 using System.Collections.Generic;
 
    31 namespace SharpLib.Hid
 
    34     /// Our HID handler manages raw input registrations, processes WM_INPUT messages and broadcasts HID events in return.
 
    36     public class Handler : IDisposable
 
    38         public delegate void HidEventHandler(object aSender, Event aHidEvent);
 
    39         public event HidEventHandler OnHidEvent;
 
    40         List<Event> iHidEvents;
 
    41         RAWINPUTDEVICE[] iRawInputDevices;
 
    44         public bool IsRegistered { get; private set; }
 
    45         public bool ManageRepeats { get; private set; }
 
    47         public Handler(RAWINPUTDEVICE[] aRawInputDevices, bool aManageRepeats=false)
 
    49             iRawInputDevices = aRawInputDevices;
 
    50             iHidEvents = new List<Event>();
 
    51             IsRegistered = Function.RegisterRawInputDevices(iRawInputDevices, (uint)iRawInputDevices.Length, (uint)Marshal.SizeOf(iRawInputDevices[0]));
 
    52             ManageRepeats = aManageRepeats;
 
    56         /// Will de-register devices.
 
    60             //Setup device removal
 
    61             for (int i=0; i<iRawInputDevices.Length; i++)
 
    63                 iRawInputDevices[i].dwFlags = Const.RIDEV_REMOVE;
 
    64                 iRawInputDevices[i].hwndTarget = IntPtr.Zero;
 
    68             Function.RegisterRawInputDevices(iRawInputDevices, (uint)iRawInputDevices.Length, (uint)Marshal.SizeOf(iRawInputDevices[0]));
 
    73         /// Process a WM_INPUT message.
 
    75         /// <param name="aMessage"></param>
 
    76         public void ProcessInput(ref Message aMessage)
 
    78             if (aMessage.Msg != Const.WM_INPUT)
 
    80                 //We only process WM_INPUT messages
 
    84             Event hidEvent = new Event(aMessage, OnHidEventRepeat, ManageRepeats);
 
    85             hidEvent.DebugWrite();
 
    87             if (!hidEvent.IsValid || !hidEvent.IsGeneric)
 
    89                 Debug.WriteLine("Skipping HID message.");
 
    93             //We want to repeat only a single event at a time.
 
    94             //Any other event will interrupt the current repeat.
 
    97                 //Discard all outstanding repeats, though we should only ever have only one
 
    98                 for (int i = (iHidEvents.Count - 1); i >= 0; i--)
 
   100                         iHidEvents[i].Dispose();
 
   101                         iHidEvents.RemoveAt(i);
 
   103                 //Add our newly created event in our repeat list
 
   104                 //TODO: instead of a list we could now have a single event since we only support one repeat at a time
 
   105                 iHidEvents.Add(hidEvent);
 
   108             //Broadcast our events
 
   109             OnHidEvent(this, hidEvent);    
 
   112         public void OnHidEventRepeat(Event aHidEvent)
 
   114             //Broadcast our events
 
   115             OnHidEvent(this, aHidEvent);