1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     hid_TouchPanelReader.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: 17553 $
14  *---------------------------------------------------------------------------*/
15 
16 /*! @file
17     @brief      TouchPanelReader クラスを定義します。
18 
19 */
20 #ifndef NN_HID_CTR_HID_TOUCHPANELREADER_H_
21 #define NN_HID_CTR_HID_TOUCHPANELREADER_H_
22 
23 #include <nn/Handle.h>
24 #include <nn/Result.h>
25 #include <nn/types.h>
26 #include <nn/hid/CTR/hid_Result.h>
27 #include <nn/hid/CTR/hid_Api.h>
28 #include <nn/hid/CTR/hid_TouchPanel.h>
29 #include <nn/hid/CTR/hid_DeviceStatus.h>
30 #include <nn/util/util_NonCopyable.h>
31 
32 namespace nn {
33 namespace hid {
34 namespace CTR {
35 
36 
37 /*! @brief タッチパネルのサンプリングデータを読み込むクラスです。
38 
39               タッチパネルは 4 msec 周期でサンプリングされます。
40 
41 */
42 class TouchPanelReader : private nn::util::NonCopyable<TouchPanelReader>
43 {
44 public:
45     /*!
46       @brief          コンストラクタです。
47 
48 
49       インスタンスを生成する前に @ref nn::hid::CTR::Initialize( ) で初期化してください。
50 
51     */
52     TouchPanelReader(TouchPanel& touchPanel = GetTouchPanel( ))
m_TouchPanel(touchPanel)53         : m_TouchPanel(touchPanel)
54         , m_IndexOfRead(-1)
55         , m_TickOfRead(-1)
56         {};
57 
58     /*!
59       @brief          デストラクタです。
60 
61     */
~TouchPanelReader()62     ~TouchPanelReader( ) {};
63 
64     // TODO : 改善後にサンプリング周期を記載する。
65     /*!
66       @brief        タッチパネルのサンプリングデータを新しいものから順に読み込みます。以前に読み込んだデータは読み込まれません。
67 
68       @param[out]   pBufs       新しいものから順にサンプリングデータが読み込まれます。
69       @param[out]   pReadLen    読み込んだサンプリングデータの数です。
70       @param[in]    bufLen      pBufs に読み込めるサンプリングデータの数を指定します。
71       @return       なし。
72 
73     */
74     void Read(TouchPanelStatus* pBufs, s32* pReadLen, s32 bufLen);
75 
76     /*!
77       @brief        最新のゲームパッドのサンプリングデータを読み込みます。 nn::hid::CTR::TouchPanelReader::Read( ) とちがい同じサンプリングデータを読み込むことが出来ます。
78 
79       @param[out]   pBuf        サンプリングデータが読み込まれます。
80       @return       サンプリングデータの読み込み結果を返します。<BR>
81                       true ・・・ 読み込めました。<BR>
82                       false ・・・ 読み込めませんでした。(システム起動後あるいはスリープ復帰後の最初のサンプリングが行われ次第、読み込めます。)
83 
84     */
85     bool ReadLatest(TouchPanelStatus* pBuf);
86 
87 protected:
88     TouchPanel&             m_TouchPanel;
89     s32                     m_IndexOfRead;
90     s64                     m_TickOfRead;
91 };
92 
93 } // namespace CTR {
94 } // namespace hid {
95 } // namespace nn {
96 
97 #endif  // #ifndef NN_HID_CTR_HID_TOUCHPANELREADER_H_
98