1 /*---------------------------------------------------------------------------*
2 Project: Horizon
3 File: hid_HidBase.h
4
5 Copyright (C)2009 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: 27736 $
14 *---------------------------------------------------------------------------*/
15
16 /*! @file
17 @brief HidBase クラス を定義します。
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 /*!
37 @brief HID の基底 クラスです。
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 /*!
50 @brief デバイスがサンプリングするのを待ちます。
51 @return なし。
52 */
53 void WaitSampling( );
54
55 /*!
56 @brief デバイスがサンプリングするのをタイムアウトつきで待ちます。
57
58 @param[in] timeout タイムアウト時間を指定します。0 を指定すると即座に処理を返します。
59
60 @return タイムアウト時間までにイベントが発生したかを返します。
61 */
62 bool WaitSampling(nn::fnd::TimeSpan timeout);
63
64 /*!
65 @brief 引数で指定したデバイスのうち一つがサンプリングするのを待ちます。
66
67 @param[in] devices HidBaseの配列を指定します。
68 @param[in] numDevices HidBaseの数を指定します。
69
70 @return 処理の結果を返します。
71 @retval 0以上 サンプリングされたデバイスのインデックスを返します。
72 */
73 static s32 WaitSamplingAny(HidBase* devices[], s32 numDevices);
74
75 /*!
76 @brief 引数で指定したデバイスのうち一つがサンプリングするのをタイムアウトつきで待ちます。
77
78 @param[in] devices HidBaseの配列を指定します。
79 @param[in] numDevices HidBaseの数を指定します。
80
81 @param[in] timeout タイムアウト時間を指定します。
82
83 @return 処理の結果を返します。
84 @retval 0以上 サンプリングされたデバイスのインデックスを返します。
85 @retval 0未満 タイムアウトしたことを意味します。
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 定義
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