SDXFrameWork 0.13 SDXFrameWork

- Main Page
- Related Pages
- Classes

All Classes Namespaces Functions Variables Enumerations Enumerator Pages
Mouse.h
1 //Copyright © 2014 SDXFramework
2 //[License]GNU Affero General Public License, version 3
3 //[Contact]http://sourceforge.jp/projects/dxframework/
4 #pragma once
5 #include <Multimedia/SDX.h>
6 #include <Multimedia/Key.h>
7 #include <Framework/Shape.h>
8 #include <Multimedia/Window.h>
9 #include <Utility/EnumArray.h>
10
11 namespace SDX
12 {
14 enum class MouseCode
15 {
16 Left,
17 Right,
18 Middle,
19 _4,
20 _5,
21 _6,
22 _7,
23 _8,
24
25 COUNT,
26 };
27
30 class Mouse
31 {
32 friend class Input;
33 private:
34 MONO_STATE(Mouse)
35
36 int xBuffer;
37 int yBuffer;
38
39 EnumArray<bool, MouseCode> press;
40 public:
41
42 int x = 0;
43 int y = 0;
44
45 int moveX = 0;
46 int moveY = 0;
47
48 int Whell = 0;
49
50 Key Left;
51 Key Right;
52 Key Middle;
53
54 Key Button4;
55 Key Button5;
56 Key Button6;
57 Key Button7;
58 Key Button8;
59
61 void Reset()
62 {
63 x = 0;
64 y = 0;
65 moveX = 0;
66 moveY = 0;
67 Left.Reset();
68 Right.Reset();
69 Middle.Reset();
70 Button4.Reset();
71 Button5.Reset();
72 Button6.Reset();
73 Button7.Reset();
74 Button8.Reset();
75 Whell = 0;
76 }
77
79 void Update()
80 {
81 Left.Update(press[MouseCode::Left]);
82 Right.Update(press[MouseCode::Right]);
83 Middle.Update(press[MouseCode::Middle]);
84
85 Button4.Update(press[MouseCode::_4]);
86 Button5.Update(press[MouseCode::_5]);
87 Button6.Update(press[MouseCode::_6]);
88 Button7.Update(press[MouseCode::_7]);
89 Button8.Update(press[MouseCode::_8]);
90
91 moveX = xBuffer - x;
92 moveY = yBuffer - y;
93
94 x = xBuffer;
95 y = yBuffer;
96
97 Whell = 0;
98 }
99
101 bool SetVisible(bool 表示フラグ)
102 {
103 if (表示フラグ)
104 {
105 SDL_ShowCursor( 1 );
106 }
107 else
108 {
109 SDL_ShowCursor( 0 );
110 }
111
112 return true;
113 }
114
116 bool SetPoint(int 移動先X, int 移動先Y)
117 {
118 SDL_WarpMouseInWindow(Window::activeWindow->handle, x, y);
119 return true;
120 }
121
123 Point GetPoint()
124 {
125 return {x,y};
126 }
127
130 Key& operator[](MouseCode index)
131 {
132 switch (index)
133 {
134 case MouseCode::Left:return Left;
135 case MouseCode::Right:return Right;
136 case MouseCode::Middle:return Middle;
137 case MouseCode::_4:return Button4;
138 case MouseCode::_5:return Button5;
139 case MouseCode::_6:return Button6;
140 case MouseCode::_7:return Button7;
141 case MouseCode::_8:return Button8;
142 default: return Left;
143 }
144 }
145 };
146 }
SDX::Mouse::Middle
Key Middle
マウスホイールクリック
Definition: Mouse.h:52
SDX::Mouse
マウスの状態を表すクラス.
Definition: Mouse.h:30
SDX::Mouse::Button4
Key Button4
4ボタン
Definition: Mouse.h:54
SDX::Mouse::operator[]
Key & operator[](MouseCode index)
MouseCodeでアクセス.
Definition: Mouse.h:130
SDX::Mouse::Button5
Key Button5
5ボタン
Definition: Mouse.h:55
SDX::Mouse::Button6
Key Button6
6ボタン
Definition: Mouse.h:56
SDX::Point
点を表す図形クラス.
Definition: Point.h:22
SDX::Mouse::Right
Key Right
右クリック
Definition: Mouse.h:51
SDX::MouseCode
MouseCode
マウスボタンコード.
Definition: Mouse.h:14
SDX::Mouse::moveY
int moveY
直前の座標からの移動量
Definition: Mouse.h:46
SDX::Mouse::x
int x
現在座標
Definition: Mouse.h:42
SDX::Key::Reset
void Reset()
キーのリセット.
Definition: Key.h:20
SDX::Mouse::Button7
Key Button7
7ボタン
Definition: Mouse.h:57
SDX::Mouse::Reset
void Reset()
状態のリセット.
Definition: Mouse.h:61
SDX::EnumArray< bool, MouseCode >
SDX::Mouse::SetVisible
bool SetVisible(bool 表示フラグ)
カーソルの表示設定.
Definition: Mouse.h:101
SDX::Mouse::moveX
int moveX
直前の座標からの移動量
Definition: Mouse.h:45
SDX::Mouse::y
int y
現在座標
Definition: Mouse.h:43
SDX::Input
キーやマウスによる入力をまとめて管理するクラス.
Definition: Input.h:17
SDX::Mouse::Left
Key Left
左クリック
Definition: Mouse.h:50
SDX::Mouse::SetPoint
bool SetPoint(int 移動先X, int 移動先Y)
カーソル位置を移動.
Definition: Mouse.h:116
SDX::Mouse::Button8
Key Button8
8ボタン
Definition: Mouse.h:58
SDX::Key::Update
void Update(bool 押下フラグ)
押下状態の更新.
Definition: Key.h:29
SDX::Mouse::Update
void Update()
状態の更新.
Definition: Mouse.h:79
SDX::Key
各ボタンとキーを表すクラス.
Definition: Key.h:11
SDX::Window::activeWindow
static SubWindow * activeWindow
現在アクティブなウィンドウ
Definition: Window.h:24
SDX::Mouse::GetPoint
Point GetPoint()
カーソル位置を取得.
Definition: Mouse.h:123
SDX::Mouse::Whell
int Whell
マウスの回転量
Definition: Mouse.h:48