SDXFrameWork  0.04
SDXFrameWork
 全て クラス ネームスペース 関数 変数 ページ
Mouse.h
1 #pragma once
2 #include <Multimedia/SDX.h>
3 #include <Multimedia/Key.h>
4 #include <Framework/Shape.h>
5 #include <Multimedia/InputEnum.h>
6 #include <Multimedia/Window.h>
7 
8 namespace SDX
9 {
11 class Mouse
13 {
14 private:
15  Mouse(const Mouse &mouse){};
16  Mouse operator =(const Mouse &mouse){};
17 public:
18  Mouse()
19  {
20  Reset();
21  }
22 
23  int x;
24  int y;
25 
26  int moveX;
27  int moveY;
28 
29  int Whell;
30 
31  bool press[8];
32 
33  Key Left;
34  Key Right;
35  Key Middle;
36 
37  Key Button4;
38  Key Button5;
39  Key Button6;
40  Key Button7;
41  Key Button8;
42 
43  int maxButton;
44 
46  void Reset()
47  {
48  x = 0;
49  y = 0;
50  moveX = 0;
51  moveY = 0;
52  Left.Reset();
53  Right.Reset();
54  Middle.Reset();
55  Button4.Reset();
56  Button5.Reset();
57  Button6.Reset();
58  Button7.Reset();
59  Button8.Reset();
60  Whell = 0;
61  }
62 
64  void Update()
65  {
66  int X,Y;
67  #ifdef DXLIB
68  DxLib::GetMousePoint(&X,&Y);
69  int N = DxLib::GetMouseInput();
70 
71  Left.Update( N & (int)MouseCode::Left );
72  Right.Update( N & (int)MouseCode::Right );
73  Middle.Update( N & (int)MouseCode::Middle );
74 
75  Button4.Update( N & (int)MouseCode::_4 );
76  Button5.Update( N & (int)MouseCode::_5 );
77  Button6.Update( N & (int)MouseCode::_6 );
78  Button7.Update( N & (int)MouseCode::_7 );
79  Button8.Update( N & (int)MouseCode::_8 );
80  #elif defined(SDL)
81  SDL_GetMouseState(&X, &Y);
82  Left.Update( press[(int)MouseCode::Left] );
83  Right.Update( press[(int)MouseCode::Right] );
84  Middle.Update( press[(int)MouseCode::Middle] );
85 
86  Button4.Update( press[(int)MouseCode::_4] );
87  Button5.Update( press[(int)MouseCode::_5] );
88  Button6.Update( press[(int)MouseCode::_6] );
89  Button7.Update( press[(int)MouseCode::_7] );
90  Button8.Update( press[(int)MouseCode::_8] );
91  #endif
92  moveX = X - x;
93  moveY = Y - y;
94 
95  x = X;
96  y = Y;
97  }
98 
100  bool SetVisible(bool 表示フラグ)
101  {
102  #ifdef DXLIB
103  return !SetMouseDispFlag(表示フラグ);
104  #elif defined(SDL)
105  return false;
106  #endif
107  }
108 
110  bool SetPoint( int 移動先X , int 移動先Y )
111  {
112  #ifdef DXLIB
113  return !SetMousePoint(移動先X, 移動先Y);
114  #elif defined(SDL)
115  SDL_WarpMouseInWindow(Window::Single().handle, x, y);
116  return true;
117  #endif
118  }
119 };
120 }
void Reset()
キーのリセット.
Definition: Key.h:17
void Update(int 押下フラグ)
押下状態の更新.
Definition: Key.h:26
void Reset()
状態のリセット.
Definition: Mouse.h:46
bool SetVisible(bool 表示フラグ)
カーソルの表示設定.
Definition: Mouse.h:100
bool SetPoint(int 移動先X, int 移動先Y)
カーソル位置を移動.
Definition: Mouse.h:110
void Update()
状態の更新.
Definition: Mouse.h:64