1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     hid_HidBase.h
4 
5   Copyright (C)2009-2012 Nintendo Co., Ltd.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law.  They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Rev: 46347 $
14  *---------------------------------------------------------------------------*/
15 
16 /* Please see man pages for details
17 
18 
19 */
20 
21 #ifndef NN_HID_CTR_HID_HIDBASE_H_
22 #define NN_HID_CTR_HID_HIDBASE_H_
23 
24 #include <nn/Handle.h>
25 #include <nn/Result.h>
26 #include <nn/types.h>
27 #include <nn/fnd/fnd_Timespan.h>
28 #include <nn/os/os_Synchronization.h>
29 #include <nn/os/os_Event.h>
30 
31 namespace nn {
32 namespace hid {
33 namespace CTR {
34 
35 
36 /* Please see man pages for details
37 
38 */
39 class HidBase : public nn::os::EventBase
40 {
41 protected:
HidBase()42     HidBase() : nn::os::EventBase() {}
~HidBase()43     ~HidBase() {}
44 
45 private:
46     uptr            m_pResource;
47 
48 public:
49     /* Please see man pages for details
50 
51 
52     */
53     void WaitSampling( );
54 
55     /* Please see man pages for details
56 
57 
58 
59 
60 
61     */
62     bool WaitSampling(nn::fnd::TimeSpan timeout);
63 
64     /* Please see man pages for details
65 
66 
67 
68 
69 
70 
71 
72     */
73     static s32 WaitSamplingAny(HidBase* devices[], s32 numDevices);
74 
75     /* Please see man pages for details
76 
77 
78 
79 
80 
81 
82 
83 
84 
85 
86     */
87     static s32 WaitSamplingAny(HidBase* devices[], s32 numDevices, nn::fnd::TimeSpan timeout);
88 
89     uptr            GetResource();
90     void            SetResource(uptr resource);
91 };
92 
93 
94 
95 // inline definitions
WaitSampling()96 inline void HidBase::WaitSampling( )
97 {
98     WaitOne();
99 }
100 
WaitSampling(nn::fnd::TimeSpan timeout)101 inline bool HidBase::WaitSampling(nn::fnd::TimeSpan timeout)
102 {
103     return WaitOne(timeout);
104 }
105 
106 
WaitSamplingAny(HidBase * devices[],s32 numDevices)107 inline s32 HidBase::WaitSamplingAny(HidBase* devices[], s32 numDevices)
108 {
109     return nn::os::WaitObject::WaitAny(reinterpret_cast<nn::os::WaitObject**>(devices), numDevices);
110 }
111 
WaitSamplingAny(HidBase * devices[],s32 numDevices,nn::fnd::TimeSpan timeout)112 inline s32 HidBase::WaitSamplingAny(HidBase* devices[], s32 numDevices, nn::fnd::TimeSpan timeout)
113 {
114     return nn::os::WaitObject::WaitAny(reinterpret_cast<nn::os::WaitObject**>(devices), numDevices, timeout);
115 }
116 
GetResource()117 inline uptr HidBase::GetResource()
118 {
119     return m_pResource;
120 }
121 
SetResource(uptr resource)122 inline void HidBase::SetResource(uptr resource)
123 {
124     m_pResource = resource;
125 }
126 
127 } // namespace CTR {
128 } // namespace hid {
129 } // namespace nn {
130 
131 #endif  // #ifndef NN_HID_CTR_HID_HIDBASE_H_
132