Input函数重命名
This commit is contained in:
parent
5ab9d822f3
commit
aa053ad269
|
|
@ -142,14 +142,14 @@ void Input::__updateDeviceState()
|
||||||
ScreenToClient(Window::getHWnd(), &s_MousePosition);
|
ScreenToClient(Window::getHWnd(), &s_MousePosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Input::isKeyDown(KeyCode key)
|
bool Input::isDown(Key key)
|
||||||
{
|
{
|
||||||
if (s_KeyBuffer[static_cast<int>(key)] & 0x80)
|
if (s_KeyBuffer[static_cast<int>(key)] & 0x80)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Input::isKeyPress(KeyCode key)
|
bool Input::isPress(Key key)
|
||||||
{
|
{
|
||||||
if ((s_KeyBuffer[static_cast<int>(key)] & 0x80) &&
|
if ((s_KeyBuffer[static_cast<int>(key)] & 0x80) &&
|
||||||
!(s_KeyRecordBuffer[static_cast<int>(key)] & 0x80))
|
!(s_KeyRecordBuffer[static_cast<int>(key)] & 0x80))
|
||||||
|
|
@ -157,7 +157,7 @@ bool Input::isKeyPress(KeyCode key)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Input::isKeyRelease(KeyCode key)
|
bool Input::isRelease(Key key)
|
||||||
{
|
{
|
||||||
if (!(s_KeyBuffer[static_cast<int>(key)] & 0x80) &&
|
if (!(s_KeyBuffer[static_cast<int>(key)] & 0x80) &&
|
||||||
(s_KeyRecordBuffer[static_cast<int>(key)] & 0x80))
|
(s_KeyRecordBuffer[static_cast<int>(key)] & 0x80))
|
||||||
|
|
@ -165,14 +165,14 @@ bool Input::isKeyRelease(KeyCode key)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Input::isMouseDown(MouseCode code)
|
bool e2d::Input::isDown(Mouse code)
|
||||||
{
|
{
|
||||||
if (s_MouseState.rgbButtons[static_cast<int>(code)] & 0x80)
|
if (s_MouseState.rgbButtons[static_cast<int>(code)] & 0x80)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Input::isMousePress(MouseCode code)
|
bool e2d::Input::isPress(Mouse code)
|
||||||
{
|
{
|
||||||
if ((s_MouseState.rgbButtons[static_cast<int>(code)] & 0x80) &&
|
if ((s_MouseState.rgbButtons[static_cast<int>(code)] & 0x80) &&
|
||||||
!(s_MouseRecordState.rgbButtons[static_cast<int>(code)] & 0x80))
|
!(s_MouseRecordState.rgbButtons[static_cast<int>(code)] & 0x80))
|
||||||
|
|
@ -180,7 +180,7 @@ bool e2d::Input::isMousePress(MouseCode code)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool e2d::Input::isMouseRelease(MouseCode code)
|
bool e2d::Input::isRelease(Mouse code)
|
||||||
{
|
{
|
||||||
if (!(s_MouseState.rgbButtons[static_cast<int>(code)] & 0x80) &&
|
if (!(s_MouseState.rgbButtons[static_cast<int>(code)] & 0x80) &&
|
||||||
(s_MouseRecordState.rgbButtons[static_cast<int>(code)] & 0x80))
|
(s_MouseRecordState.rgbButtons[static_cast<int>(code)] & 0x80))
|
||||||
|
|
|
||||||
|
|
@ -209,7 +209,7 @@ void e2d::Button::onFixedUpdate()
|
||||||
|
|
||||||
if (_enable && _visiable && _normal)
|
if (_enable && _visiable && _normal)
|
||||||
{
|
{
|
||||||
if (Input::isMouseRelease(Input::MouseCode::LEFT))
|
if (Input::isRelease(Input::Mouse::LEFT))
|
||||||
{
|
{
|
||||||
// 鼠标左键抬起时,判断鼠标坐标是否在按钮内部
|
// 鼠标左键抬起时,判断鼠标坐标是否在按钮内部
|
||||||
if (_isSelected &&
|
if (_isSelected &&
|
||||||
|
|
@ -221,7 +221,7 @@ void e2d::Button::onFixedUpdate()
|
||||||
_isSelected = false;
|
_isSelected = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Input::isMousePress(Input::MouseCode::LEFT))
|
if (Input::isPress(Input::Mouse::LEFT))
|
||||||
{
|
{
|
||||||
if (_normal->isPointIn(Input::getMousePos()))
|
if (_normal->isPointIn(Input::getMousePos()))
|
||||||
{
|
{
|
||||||
|
|
@ -231,7 +231,7 @@ void e2d::Button::onFixedUpdate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_isSelected && Input::isMouseDown(Input::MouseCode::LEFT))
|
if (_isSelected && Input::isDown(Input::Mouse::LEFT))
|
||||||
{
|
{
|
||||||
if (_normal->isPointIn(Input::getMousePos()))
|
if (_normal->isPointIn(Input::getMousePos()))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -188,15 +188,16 @@ class Input
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// 鼠标键值
|
// 鼠标键值
|
||||||
enum class MouseCode : int
|
enum class Mouse : int
|
||||||
{
|
{
|
||||||
LEFT, /* 鼠标左键 */
|
LEFT, /* 鼠标左键 */
|
||||||
RIGHT, /* 鼠标右键 */
|
RIGHT, /* 鼠标右键 */
|
||||||
MIDDLE /* 鼠标中键 */
|
MIDDLE /* 鼠标中键 */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// 键盘键值
|
// 键盘键值
|
||||||
enum class KeyCode : int
|
enum class Key : int
|
||||||
{
|
{
|
||||||
UP = 0xC8,
|
UP = 0xC8,
|
||||||
LEFT = 0xCB,
|
LEFT = 0xCB,
|
||||||
|
|
@ -258,33 +259,33 @@ public:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// 检测键盘某按键是否正被按下
|
// 检测键盘某按键是否正被按下
|
||||||
static bool isKeyDown(
|
static bool isDown(
|
||||||
KeyCode key
|
Key key
|
||||||
);
|
);
|
||||||
|
|
||||||
// 检测键盘某按键是否被点击
|
// 检测键盘某按键是否被点击
|
||||||
static bool isKeyPress(
|
static bool isPress(
|
||||||
KeyCode key
|
Key key
|
||||||
);
|
);
|
||||||
|
|
||||||
// 检测键盘某按键是否正在松开
|
// 检测键盘某按键是否正在松开
|
||||||
static bool isKeyRelease(
|
static bool isRelease(
|
||||||
KeyCode key
|
Key key
|
||||||
);
|
);
|
||||||
|
|
||||||
// 检测鼠标按键是否正被按下
|
// 检测鼠标按键是否正被按下
|
||||||
static bool isMouseDown(
|
static bool isDown(
|
||||||
MouseCode code
|
Mouse code
|
||||||
);
|
);
|
||||||
|
|
||||||
// 检测鼠标按键是否被点击
|
// 检测鼠标按键是否被点击
|
||||||
static bool isMousePress(
|
static bool isPress(
|
||||||
MouseCode code
|
Mouse code
|
||||||
);
|
);
|
||||||
|
|
||||||
// 检测鼠标按键是否正在松开
|
// 检测鼠标按键是否正在松开
|
||||||
static bool isMouseRelease(
|
static bool isRelease(
|
||||||
MouseCode code
|
Mouse code
|
||||||
);
|
);
|
||||||
|
|
||||||
// 获得鼠标X轴坐标值
|
// 获得鼠标X轴坐标值
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue