1 /*---------------------------------------------------------------------------*
2 
3   Copyright (C) 2010-2012 Nintendo.  All rights reserved.
4 
5   These coded instructions, statements, and computer programs contain
6   proprietary information of Nintendo of America Inc. and/or Nintendo
7   Company Ltd., and are protected by Federal copyright law.  They may
8   not be disclosed to third parties or copied or duplicated in any form,
9   in whole or in part, without the prior written consent of Nintendo.
10 
11  *---------------------------------------------------------------------------*/
12 
13 #ifndef __DEMOWIN_PERIPHERAL_H_
14 #define __DEMOWIN_PERIPHERAL_H_
15 
16 extern bool gIgnoreBounds;
17 
18 struct Peripheral
19 {
20         // Draw calls
21     virtual void DrawWindowQuad(CVec2 position, CVec2 size, bool active, bool enabled, CVec3 color, const char* title) = 0;
22     virtual void DrawText(const char* text, CVec3 position, CVec2 size, CVec4 color) = 0;
23     virtual void DrawTextCenter(const char* text, CVec3 position, CVec2 size, CVec4 color) = 0;
24     virtual void DrawTextRight(const char* text, CVec3 position, CVec2 size, CVec4 color) = 0;
25     virtual void DrawMultiLineText(const char* text, CVec3 position, CVec2 size, CVec4 color) = 0;
26     virtual void DrawBox(CVec3 position, CVec2 size, CVec4 color, CVec4 color1 = CVec4(0, 0, 0, 1.0)) = 0;
27     virtual void DrawLine(CVec3 position, CVec2 size, CVec4 color) = 0;
28     virtual void DrawFastLine(CVec3 position, CVec2 size, CVec4 color) = 0;
29     virtual void DrawQuad(CVec3 position, CVec2 size, CVec4 color) = 0;
30     virtual void DrawTexQuad(GX2Texture* tex, CVec3 position, CVec2 size, CVec4 color) = 0;
31     virtual void DrawBoxQuad(CVec3 position, CVec2 size, CVec4 color) = 0;
32 
33         // Input calls
34     virtual bool AnyPressed() = 0;
35 
36     virtual bool LeftPressed() = 0;
37     virtual bool RightPressed() = 0;
38     virtual bool UpPressed() = 0;
39     virtual bool DownPressed() = 0;
40     virtual bool PositivePressed() = 0;
41     virtual bool NegativePressed() = 0;
42 
43     virtual bool LeftTriggered() = 0;
44     virtual bool RightTriggered() = 0;
45     virtual bool UpTriggered() = 0;
46     virtual bool DownTriggered() = 0;
47     virtual bool PositiveTriggered() = 0;
48     virtual bool NegativeTriggered() = 0;
49 
50     virtual bool TabLeftTriggered() = 0;
51     virtual bool TabRightTriggered() = 0;
52     virtual bool PauseTriggered() = 0;
53     virtual bool HomeTriggered() = 0;
54 
55     virtual bool& UsingPad() = 0;
UsingWiimotePeripheral56     virtual bool& UsingWiimote() {dummyBool = false; return dummyBool;}
57 
58     virtual float& CursorX() = 0;
59     virtual float& CursorY() = 0;
60 
61         // The best structure that knows about the cursor's location is the peripheral!
62     bool CursorColliding(Window* window, float x, float y, float width, float height, bool ignoreBounds = false)
63     {
64         if (!window->manager->canBeOver)
65             return false;
66 
67         x += window->GetX();
68         y += window->GetY();
69 
70             // If we are outside the window, we are not colliding!
71         if (!gIgnoreBounds && !ignoreBounds && (CursorX() < window->GetLeft() || CursorX() > window->GetRight() || CursorY() > window->GetTop() || CursorY() < window->GetBottom()))
72             return false;
73 
74         return (CursorX() >= x - width / 2 && CursorX() <= x + width / 2 && CursorY() >= y - height / 2 && CursorY() <= y + height / 2);
75     }
76 
77         // The best structure that knows about the cursor's location is the peripheral!
CursorCollidingPeripheral78     bool CursorColliding(float x, float y, float width, float height)
79     {
80         return (CursorX() >= x - width / 2 && CursorX() <= x + width / 2 && CursorY() >= y - height / 2 && CursorY() <= y + height / 2);
81     }
82 
83 private:
84 
85         // Should always be false
86     bool dummyBool;
87 };
88 
89 #endif
90