mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-11-17 23:25:15 -06:00
Add cursor condition to check if mouse button is held down
This commit is contained in:
@@ -390,6 +390,7 @@ AdvSceneSwitcher.condition.cursor="Cursor"
|
||||
AdvSceneSwitcher.condition.cursor.type.region="is in region"
|
||||
AdvSceneSwitcher.condition.cursor.type.moving="is moving"
|
||||
AdvSceneSwitcher.condition.cursor.type.click="clicked"
|
||||
AdvSceneSwitcher.condition.cursor.type.held="button is held down"
|
||||
AdvSceneSwitcher.condition.cursor.button.left="Left mouse button"
|
||||
AdvSceneSwitcher.condition.cursor.button.middle="Middle mouse button"
|
||||
AdvSceneSwitcher.condition.cursor.button.right="Right mouse button"
|
||||
|
||||
@@ -25,6 +25,8 @@ const static std::map<MacroConditionCursor::Condition, std::string>
|
||||
#ifdef _WIN32 // Not implemented for MacOS and Linux
|
||||
{MacroConditionCursor::Condition::CLICK,
|
||||
"AdvSceneSwitcher.condition.cursor.type.click"},
|
||||
{MacroConditionCursor::Condition::HELD,
|
||||
"AdvSceneSwitcher.condition.cursor.type.held"},
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -50,6 +52,19 @@ bool MacroConditionCursor::CheckClick()
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MacroConditionCursor::CheckHeld()
|
||||
{
|
||||
switch (_button) {
|
||||
case MacroConditionCursor::Button::LEFT:
|
||||
return IsMouseLeftButtonDown() || CheckClick();
|
||||
case MacroConditionCursor::Button::MIDDLE:
|
||||
return IsMouseMiddleButtonDown() || CheckClick();
|
||||
case MacroConditionCursor::Button::RIGHT:
|
||||
return IsMouseRightButtonDown() || CheckClick();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MacroConditionCursor::CheckCondition()
|
||||
{
|
||||
bool ret = false;
|
||||
@@ -68,6 +83,9 @@ bool MacroConditionCursor::CheckCondition()
|
||||
case Condition::CLICK:
|
||||
ret = CheckClick();
|
||||
break;
|
||||
case Condition::HELD:
|
||||
ret = CheckHeld();
|
||||
break;
|
||||
}
|
||||
|
||||
_lastCheckTime = std::chrono::high_resolution_clock::now();
|
||||
@@ -351,7 +369,9 @@ void MacroConditionCursorEdit::SetWidgetVisibility()
|
||||
}
|
||||
|
||||
_buttons->setVisible(_entryData->_condition ==
|
||||
MacroConditionCursor::Condition::CLICK);
|
||||
MacroConditionCursor::Condition::CLICK ||
|
||||
_entryData->_condition ==
|
||||
MacroConditionCursor::Condition::HELD);
|
||||
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ public:
|
||||
REGION,
|
||||
MOVING,
|
||||
CLICK,
|
||||
HELD,
|
||||
};
|
||||
|
||||
enum class Button {
|
||||
@@ -41,6 +42,7 @@ private:
|
||||
void SetupTempVars();
|
||||
|
||||
bool CheckClick();
|
||||
bool CheckHeld();
|
||||
std::chrono::high_resolution_clock::time_point _lastCheckTime{};
|
||||
int _lastX = 0;
|
||||
int _lastY = 0;
|
||||
|
||||
@@ -17,6 +17,18 @@ std::chrono::high_resolution_clock::time_point GetLastMouseRightClickTime()
|
||||
{
|
||||
return {};
|
||||
}
|
||||
bool IsMouseLeftButtonDown()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool IsMouseMiddleButtonDown()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool IsMouseRightButtonDown()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace advss
|
||||
|
||||
@@ -6,5 +6,8 @@ namespace advss {
|
||||
std::chrono::high_resolution_clock::time_point GetLastMouseLeftClickTime();
|
||||
std::chrono::high_resolution_clock::time_point GetLastMouseMiddleClickTime();
|
||||
std::chrono::high_resolution_clock::time_point GetLastMouseRightClickTime();
|
||||
bool IsMouseLeftButtonDown();
|
||||
bool IsMouseMiddleButtonDown();
|
||||
bool IsMouseRightButtonDown();
|
||||
|
||||
} // namespace advss
|
||||
|
||||
@@ -278,6 +278,21 @@ std::chrono::high_resolution_clock::time_point GetLastMouseRightClickTime()
|
||||
return lastMouseRightClickTime;
|
||||
}
|
||||
|
||||
bool IsMouseLeftButtonDown()
|
||||
{
|
||||
return GetAsyncKeyState(VK_LBUTTON) & 0x8000;
|
||||
}
|
||||
|
||||
bool IsMouseMiddleButtonDown()
|
||||
{
|
||||
return GetAsyncKeyState(VK_MBUTTON) & 0x8000;
|
||||
}
|
||||
|
||||
bool IsMouseRightButtonDown()
|
||||
{
|
||||
return GetAsyncKeyState(VK_RBUTTON) & 0x8000;
|
||||
}
|
||||
|
||||
static void handleRawMouseInput(LPARAM lParam)
|
||||
{
|
||||
UINT dwSize;
|
||||
|
||||
Reference in New Issue
Block a user