GaitGeneration by Graph Search
読み取り中…
検索中…
一致する文字列を見つけられません
mouse.h
[詳解]
1
3
4// Copyright(c) 2023-2025 Design Engineering Laboratory, Saitama University
5// Released under the MIT license
6// https://opensource.org/licenses/mit-license.php
7
8#ifndef DESIGNLAB_MOUSE_H_
9#define DESIGNLAB_MOUSE_H_
10
11#include <array>
12#include <map>
13
14
15namespace designlab
16{
17
20class Mouse final
21{
22public:
23 Mouse();
24
27 void Update();
28
34 [[nodiscard]] int GetPressingCount(int mouse_code) const;
35
41 [[nodiscard]] int GetReleasingCount(int mouse_code) const;
42
47 [[nodiscard]] constexpr int GetCursorPosX() const noexcept
48 {
49 return cursor_pos_x_;
50 };
51
56 [[nodiscard]] int GetDiffPosX() const;
57
62 [[nodiscard]] constexpr int GetCursorPosY() const noexcept
63 {
64 return cursor_pos_y_;
65 };
66
71 [[nodiscard]] int GetDiffPosY() const;
72
75 [[nodiscard]] double GetDiffPos() const;
76
82 [[nodiscard]] constexpr int GetWheelRot() const noexcept
83 {
84 return wheel_rot_;
85 };
86
87private:
89 constexpr static int kMouseKeyNum{ 8 };
90
92 const std::array<int, kMouseKeyNum> kMouseKeyCodes;
93
95 int cursor_pos_x_, cursor_pos_y_;
96
98 int cursor_past_pos_x_, cursor_past_pos_y_;
99
100
102 std::map<int, int> pushing_counter_;
103
105 std::map<int, int> releasing_counter_;
106
109 int wheel_rot_;
110};
111
112} // namespace designlab
113
114
115#endif // DESIGNLAB_MOUSE_H_
Dxlibでマウス入力を取得するクラス.
Definition mouse.h:21
int GetDiffPosX() const
マウスカーソルの移動量を取得する. X座標は画面の左端を0として,右向きが正. これは Dxlib の仕様なので変更不能.
Definition mouse.cpp:94
int GetPressingCount(int mouse_code) const
ボタンが押されているフレーム数を取得する.
Definition mouse.cpp:72
int GetReleasingCount(int mouse_code) const
ボタンが離されているフレーム数を取得する.
Definition mouse.cpp:84
constexpr int GetWheelRot() const noexcept
マウスのホイールの回転量を取得する. 1フレームで回転した量を取得する. 手前に回した分はマイナスの値として、 奥に回した分はプラスの値として返る
Definition mouse.h:82
void Update()
マウス入力を更新する.これを毎フレーム実行しないと, マウス入力を取得できない.
Definition mouse.cpp:42
constexpr int GetCursorPosX() const noexcept
マウスカーソルの位置を取得する. X座標は画面の左端を0として,右向きが正. これは Dxlib の仕様なので変更不能.
Definition mouse.h:47
int GetDiffPosY() const
マウスカーソルの移動量を取得する. Y座標は画面の上端を0として,下向きが正. これは Dxlib の仕様なので変更不能.
Definition mouse.cpp:99
constexpr int GetCursorPosY() const noexcept
マウスカーソルの位置を取得する. Y座標は画面の上端を0として,下向きが正. これは Dxlib の仕様なので変更不能.
Definition mouse.h:62
double GetDiffPos() const
マウスカーソルの移動量を取得する.
Definition mouse.cpp:104