Skip to content

Commit

Permalink
Adding MouseButton= option
Browse files Browse the repository at this point in the history
this allows using diffrent mouse buttons to trigger the actions
  • Loading branch information
NighthawkSLO committed May 1, 2016
1 parent 2961bd2 commit 2aa23e6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
29 changes: 26 additions & 3 deletions Plugin/PluginSlider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.

struct Measure
{
std::wstring MouseButton;
std::wstring ClickAction;
std::wstring DragAction;
std::wstring ReleaseAction;
Expand All @@ -25,14 +26,16 @@ struct Measure

int x;
int y;
int key;

void* skin;
void* rm;

Measure() :
MouseButton(),
ClickAction(), DragAction(), ReleaseAction(),
isEnabled(), isMouseDown(false), isRelativeToSkin(),
x(), y(),
x(), y(), key(),
skin(), rm()
{ }
};
Expand Down Expand Up @@ -73,13 +76,33 @@ PLUGIN_EXPORT void Reload(void* data, void* rm, double* maxValue)
{
Measure* measure = (Measure*)data;

measure->MouseButton = RmReadString(rm, L"MouseButton", L"Left");

measure->ClickAction = RmReadString(rm, L"ClickAction", L"");
measure->DragAction = RmReadString(rm, L"DragAction", L"");
measure->ReleaseAction = RmReadString(rm, L"ReleaseAction", L"");
measure->isEnabled = RmReadInt(rm, L"Enabled", 0) == 0 && RmReadInt(rm, L"Paused", 0) == 0;

measure->isRelativeToSkin = RmReadInt(rm, L"RelativeToSkin", 1) == 1;

if (_wcsnicmp(measure->MouseButton.c_str(), L"left", 4) == 0)
{
measure->key = VK_LBUTTON;
}
else if (_wcsnicmp(measure->MouseButton.c_str(), L"right", 5) == 0)
{
measure->key = VK_RBUTTON;
}
else if (_wcsnicmp(measure->MouseButton.c_str(), L"middle", 6) == 0)
{
measure->key = VK_MBUTTON;
}
else
{
RmLogF(rm, LOG_ERROR, L"Slider.dll: MouseButton=%s not valid", measure->MouseButton);
return;
}

if (std::find(g_Measures.begin(), g_Measures.end(), measure) == g_Measures.end())
{
g_Measures.push_back(measure);
Expand Down Expand Up @@ -153,7 +176,7 @@ void MouseThread()
x -= rect.left; y -= rect.top;
}
std::string str_x = std::to_string(x); std::string str_y = std::to_string(y);
if ((GetKeyState(VK_LBUTTON) & 0x100) != 0 && !measure->isMouseDown)
if ((GetAsyncKeyState(measure->key) != 0) && !measure->isMouseDown)
{
measure->isMouseDown = true;
RmExecute(measure->skin, wstringReplace(wstringReplace(measure->ClickAction, "$mouseX$", str_x), "$mouseY$", str_y).c_str());
Expand All @@ -162,7 +185,7 @@ void MouseThread()
{
RmExecute(measure->skin, wstringReplace(wstringReplace(measure->DragAction, "$mouseX$", str_x), "$mouseY$", str_y).c_str());
}
if (!((GetKeyState(VK_LBUTTON) & 0x100) != 0) && measure->isMouseDown)
if ((GetAsyncKeyState(measure->key) == 0) && measure->isMouseDown)
{
measure->isMouseDown = false;
RmExecute(measure->skin, wstringReplace(wstringReplace(measure->ReleaseAction, "$mouseX$", str_x), "$mouseY$", str_y).c_str());
Expand Down
4 changes: 2 additions & 2 deletions Plugin/PluginSlider.rc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,0,1,25
FILEVERSION 2,1,0,26
PRODUCTVERSION 3,3,1,2601
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
Expand All @@ -24,7 +24,7 @@ BEGIN
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "FileVersion", "2.0.1.25"
VALUE "FileVersion", "2.1.0.26"
VALUE "LegalCopyright", "� 2016 - NighthawkSLO"

// Don't change the entries below!
Expand Down

0 comments on commit 2aa23e6

Please sign in to comment.