Fix for pen proximity put as an option
This commit is contained in:
parent
c5f7cd236e
commit
6cf6789f70
3 changed files with 27 additions and 4 deletions
|
|
@ -220,6 +220,16 @@ nlohmann::json Toolbar::get_config_json() {
|
|||
toRet["useNativeFilePicker"] = useNativeFilePicker;
|
||||
toRet["themeInUse"] = themeData.themeCurrentlyLoaded;
|
||||
toRet["velocityAffectsBrushWidth"] = velocityAffectsBrushWidth;
|
||||
|
||||
json tablet;
|
||||
tablet["pressureAffectsBrushWidth"] = tabletOptions.pressureAffectsBrushWidth;
|
||||
tablet["smoothingSamplingTime"] = tabletOptions.smoothingSamplingTime;
|
||||
tablet["middleClickButton"] = tabletOptions.middleClickButton;
|
||||
tablet["rightClickButton"] = tabletOptions.rightClickButton;
|
||||
tablet["ignoreMouseMovementWhenPenInProximity"] = tabletOptions.ignoreMouseMovementWhenPenInProximity;
|
||||
|
||||
toRet["tablet"] = tablet;
|
||||
|
||||
return toRet;
|
||||
}
|
||||
|
||||
|
|
@ -260,6 +270,12 @@ void Toolbar::set_config_json(const nlohmann::json& j) {
|
|||
j.at("themeInUse").get_to(themeData.themeCurrentlyLoaded);
|
||||
j.at("velocityAffectsBrushWidth").get_to(velocityAffectsBrushWidth);
|
||||
|
||||
j.at("tablet").at("pressureAffectsBrushWidth").get_to(tabletOptions.pressureAffectsBrushWidth);
|
||||
j.at("tablet").at("smoothingSamplingTime").get_to(tabletOptions.smoothingSamplingTime);
|
||||
j.at("tablet").at("middleClickButton").get_to(tabletOptions.middleClickButton);
|
||||
j.at("tablet").at("rightClickButton").get_to(tabletOptions.rightClickButton);
|
||||
j.at("tablet").at("ignoreMouseMovementWhenPenInProximity").get_to(tabletOptions.ignoreMouseMovementWhenPenInProximity);
|
||||
|
||||
main.update_display_names();
|
||||
}
|
||||
|
||||
|
|
@ -1150,6 +1166,9 @@ void Toolbar::options_menu() {
|
|||
gui.slider_scalar_field("smoothing time", "Smoothing sampling time", &tabletOptions.smoothingSamplingTime, 0.001f, 1.0f, 3);
|
||||
gui.input_scalar_field<uint8_t>("middle click", "Middle click pen button", &tabletOptions.middleClickButton, 1, 255);
|
||||
gui.input_scalar_field<uint8_t>("right click", "Right click pen button", &tabletOptions.rightClickButton, 1, 255);
|
||||
#ifdef _WIN32
|
||||
gui.checkbox_field("mouse ignore when pen proximity", "Ignore mouse movement when pen in proximity (may fix some issues on Windows, dont check if not required)", &tabletOptions.ignoreMouseMovementWhenPenInProximity);
|
||||
#endif
|
||||
gui.pop_id();
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ class Toolbar {
|
|||
float smoothingSamplingTime = 0.04f;
|
||||
uint8_t middleClickButton = 1;
|
||||
uint8_t rightClickButton = 2;
|
||||
bool ignoreMouseMovementWhenPenInProximity = false;
|
||||
} tabletOptions;
|
||||
|
||||
Vector4f* colorLeft = nullptr;
|
||||
|
|
|
|||
11
src/main.cpp
11
src/main.cpp
|
|
@ -613,8 +613,12 @@ SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event) {
|
|||
break;
|
||||
case SDL_EVENT_MOUSE_MOTION:
|
||||
mS.m->window.scale = SDL_GetWindowPixelDensity(mS.window);
|
||||
if(!mS.m->input.pen.inProximity)
|
||||
mS.m->input.mouse.set_pos({event->motion.x * mS.m->window.scale, event->motion.y * mS.m->window.scale});
|
||||
#ifdef _WIN32
|
||||
if(!mS.m->toolbar.tabletOptions.ignoreMouseMovementWhenPenInProximity || !mS.m->input.pen.inProximity)
|
||||
#endif
|
||||
{
|
||||
mS.m->input.mouse.set_pos({event->motion.x * mS.m->window.scale, event->motion.y * mS.m->window.scale});
|
||||
}
|
||||
break;
|
||||
case SDL_EVENT_MOUSE_BUTTON_UP:
|
||||
if(event->button.button == 1)
|
||||
|
|
@ -675,8 +679,7 @@ SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event) {
|
|||
}
|
||||
case SDL_EVENT_PEN_MOTION: {
|
||||
mS.m->input.pen.isEraser = event->pmotion.pen_state & SDL_PEN_INPUT_ERASER_TIP;
|
||||
if(mS.m->input.pen.inProximity)
|
||||
mS.m->input.mouse.set_pos({event->pmotion.x, event->pmotion.y});
|
||||
mS.m->input.mouse.set_pos({event->pmotion.x, event->pmotion.y});
|
||||
break;
|
||||
}
|
||||
case SDL_EVENT_PEN_DOWN: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue