diff --git a/src/gui/sdlmain.cpp b/src/gui/sdlmain.cpp index 4fd943f7..7df007fc 100644 --- a/src/gui/sdlmain.cpp +++ b/src/gui/sdlmain.cpp @@ -206,7 +206,8 @@ struct SDL_Block { bool autoenable; bool requestlock; bool locked; - Bitu sensitivity; + int xsensitivity; + int ysensitivity; } mouse; SDL_Rect updateRects[1024]; Bitu num_joysticks; @@ -1289,7 +1290,10 @@ static void GUI_StartUp(Section * sec) { sdl.mouse.autoenable=section->Get_bool("autolock"); if (!sdl.mouse.autoenable) SDL_ShowCursor(SDL_DISABLE); sdl.mouse.autolock=false; - sdl.mouse.sensitivity=section->Get_int("sensitivity"); + + Prop_multival* p3 = section->Get_multival("sensitivity"); + sdl.mouse.xsensitivity = p3->GetSection()->Get_int("xsens"); + sdl.mouse.ysensitivity = p3->GetSection()->Get_int("ysens"); std::string output=section->Get_string("output"); /* Setup Mouse correctly if fullscreen */ @@ -1458,10 +1462,10 @@ void Mouse_AutoLock(bool enable) { static void HandleMouseMotion(SDL_MouseMotionEvent * motion) { if (sdl.mouse.locked || !sdl.mouse.autoenable) - Mouse_CursorMoved((float)motion->xrel*sdl.mouse.sensitivity/100.0f, - (float)motion->yrel*sdl.mouse.sensitivity/100.0f, - (float)(motion->x-sdl.clip.x)/(sdl.clip.w-1)*sdl.mouse.sensitivity/100.0f, - (float)(motion->y-sdl.clip.y)/(sdl.clip.h-1)*sdl.mouse.sensitivity/100.0f, + Mouse_CursorMoved((float)motion->xrel*sdl.mouse.xsensitivity/100.0f, + (float)motion->yrel*sdl.mouse.ysensitivity/100.0f, + (float)(motion->x-sdl.clip.x)/(sdl.clip.w-1)*sdl.mouse.xsensitivity/100.0f, + (float)(motion->y-sdl.clip.y)/(sdl.clip.h-1)*sdl.mouse.ysensitivity/100.0f, sdl.mouse.locked); } @@ -1470,7 +1474,7 @@ static void HandleMouseButton(SDL_MouseButtonEvent * button) { case SDL_PRESSED: if (sdl.mouse.requestlock && !sdl.mouse.locked) { GFX_CaptureMouse(); - // Dont pass klick to mouse handler + // Don't pass click to mouse handler break; } if (!sdl.mouse.autoenable && sdl.mouse.autolock && button->button == SDL_BUTTON_MIDDLE) { @@ -1755,9 +1759,13 @@ void Config_Add_SDL() { Pbool = sdl_sec->Add_bool("autolock",Property::Changeable::Always,true); Pbool->Set_help("Mouse will automatically lock, if you click on the screen. (Press CTRL-F10 to unlock)"); - Pint = sdl_sec->Add_int("sensitivity",Property::Changeable::Always,100); - Pint->SetMinMax(1,1000); - Pint->Set_help("Mouse sensitivity."); + Pmulti = sdl_sec->Add_multi("sensitivity",Property::Changeable::Always, ","); + Pmulti->Set_help("Mouse sensitivity. The optional second parameter specifies vertical sensitivity (e.g. 100,-50)."); + Pmulti->SetValue("100"); + Pint = Pmulti->GetSection()->Add_int("xsens",Property::Changeable::Always,100); + Pint->SetMinMax(-1000,1000); + Pint = Pmulti->GetSection()->Add_int("ysens",Property::Changeable::Always,100); + Pint->SetMinMax(-1000,1000); Pbool = sdl_sec->Add_bool("waitonerror",Property::Changeable::Always, true); Pbool->Set_help("Wait before closing the console if dosbox has an error."); diff --git a/src/misc/setup.cpp b/src/misc/setup.cpp index cfac48f4..47946284 100644 --- a/src/misc/setup.cpp +++ b/src/misc/setup.cpp @@ -429,6 +429,9 @@ bool Prop_multival::SetValue(std::string const& input) { Property *p = section->Get_prop(0); //No properties in this section. do nothing if (!p) return false; + Value::Etype prevtype = Value::V_NONE; + string prevargument = ""; + string::size_type loc = string::npos; while( (p = section->Get_prop(i++)) ) { //trim leading separators @@ -443,13 +446,32 @@ bool Prop_multival::SetValue(std::string const& input) { in = local; local = ""; } - //Test Value. If it fails set default - Value valtest (in,p->Get_type()); - if (!p->CheckValue(valtest,true)) { - make_default_value(); - return false; + + if (p->Get_type() == Value::V_STRING) { + //Strings are only checked against the suggested values list. + //Test Value. If it fails set default + Value valtest (in,p->Get_type()); + if (!p->CheckValue(valtest,true)) { + make_default_value(); + return false; + } + p->SetValue(in); + } else { + //Non-strings can have more things, conversion alone is not enough (as invalid values as converted to 0) + bool r = p->SetValue(in); + if (!r) { + if (in.empty() && p->Get_type() == prevtype ) { + //Nothing there, but same type of variable, so repeat it (sensitivity) + in = prevargument; + p->SetValue(in); + } else { + //Something was there to be parsed or not the same type. Invalidate entire property. + make_default_value(); + } + } } - p->SetValue(in); + prevtype = p->Get_type(); + prevargument = in; } return retval;