Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NeatMouseWtl/logic/include/logic/MouseActioner.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ struct KeyboardButtonsStatus
bool isRightBtnPressed = false;
bool isMiddleBtnPressed = false;
bool isUnbindBtnPressed = false;
volatile UINT moveStepCount = 0;
};

/**
Expand Down
1 change: 1 addition & 0 deletions NeatMouseWtl/logic/include/logic/MouseParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ struct MouseParams

LONG delta = 20;
LONG adelta = 1;
std::vector<int> accelerationCurve = { 10, 20, 30, 50, 70, 90 };

KeyboardUtils::VirtualKey_t VKEnabler = VK_SCROLL;
KeyboardUtils::VirtualKey_t VKMoveUp = VK_NUMPAD8;
Expand Down
16 changes: 14 additions & 2 deletions NeatMouseWtl/logic/src/logic/MouseActioner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,12 @@ MouseActioner::processAction(const KBDLLHOOKSTRUCT & event, bool isKeyUp)
const KeyboardButtonsStatus oldStatus = _keyboardStatus;
const bool result = isKeyUp ? processKeyUp(vk) : processKeyDown(vk);

// figure out the movement vector
const LONG d = _isAlternativeSpeedButtonPressed ? _mouseParams.adelta : _mouseParams.delta;
// figure out the movement vector
const LONG d = _isAlternativeSpeedButtonPressed
? _mouseParams.adelta
: _keyboardStatus.moveStepCount < _mouseParams.accelerationCurve.size()
? _mouseParams.accelerationCurve[_keyboardStatus.moveStepCount++] * _mouseParams.delta / 100
: _mouseParams.delta;
const LONG dx =
((_keyboardStatus.isLeftPressed || _keyboardStatus.isLeftUpPressed || _keyboardStatus.isLeftDownPressed) ? - d : 0) +
((_keyboardStatus.isRightPressed || _keyboardStatus.isRightUpPressed || _keyboardStatus.isRightDownPressed) ? d : 0);
Expand Down Expand Up @@ -269,41 +273,49 @@ MouseActioner::processKeyUp(KeyboardUtils::VirtualKey_t vk)
{
_rampUpCursorMover.stopMove();
_keyboardStatus.isRightPressed = false;
_keyboardStatus.moveStepCount = 0;
} else
if (vk == _mouseParams.VKMoveLeft)
{
_rampUpCursorMover.stopMove();
_keyboardStatus.isLeftPressed = false;
_keyboardStatus.moveStepCount = 0;
} else
if (vk == _mouseParams.VKMoveUp)
{
_rampUpCursorMover.stopMove();
_keyboardStatus.isUpPressed = false;
_keyboardStatus.moveStepCount = 0;
} else
if (vk == _mouseParams.VKMoveDown)
{
_rampUpCursorMover.stopMove();
_keyboardStatus.isDownPressed = false;
_keyboardStatus.moveStepCount = 0;
} else
if (vk == _mouseParams.VKMoveLeftDown)
{
_rampUpCursorMover.stopMove();
_keyboardStatus.isLeftDownPressed = false;
_keyboardStatus.moveStepCount = 0;
} else
if (vk == _mouseParams.VKMoveRightDown)
{
_rampUpCursorMover.stopMove();
_keyboardStatus.isRightDownPressed = false;
_keyboardStatus.moveStepCount = 0;
} else
if (vk == _mouseParams.VKMoveLeftUp)
{
_rampUpCursorMover.stopMove();
_keyboardStatus.isLeftUpPressed = false;
_keyboardStatus.moveStepCount = 0;
} else
if (vk == _mouseParams.VKMoveRightUp)
{
_rampUpCursorMover.stopMove();
_keyboardStatus.isRightUpPressed = false;
_keyboardStatus.moveStepCount = 0;
}
else
// left button up -------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions NeatMouseWtl/logic/src/logic/MouseParams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ bool MouseParams::Save(const std::wstring & fileName)

mif.writeIntValue(L"General", L"Delta", this->delta);
mif.writeIntValue(L"General", L"ADelta", this->adelta);
mif.writeIntVector(L"General", L"AccelerationCurve", this->accelerationCurve);

mif.writeIntValue(L"General", L"VKEnabler", this->VKEnabler);
mif.writeIntValue(L"General", L"VKAccelerated", this->VKAccelerated);
Expand Down Expand Up @@ -90,6 +91,7 @@ bool MouseParams::Load(const std::wstring & fileName)

this->delta = mif.readIntValue(L"General", L"Delta", 20);
this->adelta = mif.readIntValue(L"General", L"ADelta", 1);
this->accelerationCurve = mif.readIntVector(L"General", L"AccelerationCurve", { 100 });

this->VKEnabler = mif.readIntValue(L"General", L"VKEnabler", VK_SCROLL);
this->VKAccelerated = mif.readIntValue(L"General", L"VKAccelerated", kVKNone);
Expand Down
40 changes: 39 additions & 1 deletion NeatMouseWtl/neatcommon/include/neatcommon/system/Helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#pragma once

#include <sstream>
#include<vector>
#include <string>


namespace neatcommon {
Expand All @@ -19,7 +21,6 @@ bool wstring2string(const std::wstring & wVal, std::string & outValue);
bool string2wstring(const std::string & value, std::wstring & outValue);
bool wstring2utf8string(const std::wstring & value, std::string & outValue);


//----------------------------------------------------------------------------
template < class T >
inline T from_string_def( const std::wstring & s, T def )
Expand All @@ -39,6 +40,43 @@ inline T from_string_def( const std::wstring & s, T def )
}


//----------------------------------------------------------------------------
template < class T >
inline std::vector<T> vec_from_string_def(const std::wstring& s, std::vector<T> def)
{
T value;
std::vector<T> result;
std::wstringstream ss(s);
try
{
while (ss >> value)
{
result.push_back(value);
}
}
catch (...)
{
return def;
}
return result;
}


//----------------------------------------------------------------------------
template < class T >
inline std::wstring vector2wstring(const std::vector<T>& v)
{
std::wstringstream ss;
for (size_t i = 0; i < v.size(); ++i)
{
if (i != 0)
ss << " ";
ss << v[i];
}
return ss.str();
}


//----------------------------------------------------------------------------
struct ProductInfo
{
Expand Down
2 changes: 2 additions & 0 deletions NeatMouseWtl/neatcommon/include/neatcommon/system/IniFiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ class MyIniFile
void writeBoolValue(const std::wstring & section, const std::wstring & name, bool value);
void writeIntValue(const std::wstring & section, const std::wstring & name, int value);
void writeUIntValue(const std::wstring & section, const std::wstring & name, unsigned int value);
void writeIntVector(const std::wstring & section, const std::wstring & name, std::vector<int> value);

std::string readUtf8Value(const std::wstring & section, const std::wstring & name, const std::string & defaultValue = "");
std::wstring readStringValue(const std::wstring & section, const std::wstring & name, const std::wstring & defaultValue = L"");
bool readBoolValue(const std::wstring & section, const std::wstring & name, bool defaultValue = false);
int readIntValue(const std::wstring & section, const std::wstring & name, int defaultValue = 0);
unsigned int readUIntValue(const std::wstring & section, const std::wstring & name, unsigned int defaultValue = 0);
std::vector<int> readIntVector(const std::wstring & section, const std::wstring & name, std::vector<int> defaultValue = { 100 });

const IniValueMap & getSection(const std::wstring & section);
void enumerateSections(std::vector<std::wstring> & sections);
Expand Down
17 changes: 17 additions & 0 deletions NeatMouseWtl/neatcommon/src/system/IniFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <fstream>

#include "neatcommon/system/IniFiles.h"
#include "neatcommon/system/Helpers.h"


namespace neatcommon {
Expand Down Expand Up @@ -107,6 +108,13 @@ void MyIniFile::writeIntValue(const std::wstring & section, const std::wstring &
}


//---------------------------------------------------------------------------------------------------------------------
void MyIniFile::writeIntVector(const std::wstring & section, const std::wstring & name, std::vector<int> value)
{
writeStringValue(section, name, vector2wstring(value));
}


//---------------------------------------------------------------------------------------------------------------------
std::string
MyIniFile::readUtf8Value(const std::wstring & section, const std::wstring & name, const std::string & defaultValue)
Expand Down Expand Up @@ -154,6 +162,15 @@ MyIniFile::readUIntValue(const std::wstring & section, const std::wstring & name
}


//---------------------------------------------------------------------------------------------------------------------
std::vector<int>
MyIniFile::readIntVector(const std::wstring & section, const std::wstring & name, std::vector<int> defaultValue)
{
const std::wstring & sValue = readStringValue(section, name);
return vec_from_string_def<int>(sValue, defaultValue);
}


//---------------------------------------------------------------------------------------------------------------------
int
MyIniFile::readIntValue(const std::wstring & section, const std::wstring & name, int defaultValue)
Expand Down