Skip to content

Commit

Permalink
Merge pull request #551 from ZenithMDC/increase-mouse-speed-precision
Browse files Browse the repository at this point in the history
Increase precision for mouse speed options
  • Loading branch information
fgsfdsfgs authored Dec 8, 2024
2 parents 903dd82 + cb449bf commit 2439eb6
Showing 1 changed file with 30 additions and 20 deletions.
50 changes: 30 additions & 20 deletions port/src/optionsmenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,17 @@ static MenuItemHandlerResult menuhandlerMouseSpeedX(s32 operation, struct menuit
if (x < 0.f) {
data->slider.value = 0;
} else if (x > 10.f) {
data->slider.value = 100;
data->slider.value = 1000;
} else {
data->slider.value = x * 10.f + 0.5f;
data->slider.value = x * 100.f + 0.5f;
}
break;
case MENUOP_SET:
inputMouseGetSpeed(&x, &y);
inputMouseSetSpeed((f32)data->slider.value / 10.f, y);
inputMouseSetSpeed((f32)data->slider.value / 100.f, y);
break;
case MENUOP_GETSLIDERLABEL:
sprintf(data->slider.label, "%.2f", (f32)data->slider.value / 100.f);
}

return 0;
Expand All @@ -194,15 +196,17 @@ static MenuItemHandlerResult menuhandlerMouseSpeedY(s32 operation, struct menuit
if (y < 0.f) {
data->slider.value = 0;
} else if (y > 10.f) {
data->slider.value = 100;
data->slider.value = 1000;
} else {
data->slider.value = y * 10.f + 0.5f;
data->slider.value = y * 100.f + 0.5f;
}
break;
case MENUOP_SET:
inputMouseGetSpeed(&x, &y);
inputMouseSetSpeed(x, (f32)data->slider.value / 10.f);
inputMouseSetSpeed(x, (f32)data->slider.value / 100.f);
break;
case MENUOP_GETSLIDERLABEL:
sprintf(data->slider.label, "%.2f", (f32)data->slider.value / 100.f);
}

return 0;
Expand All @@ -215,14 +219,16 @@ static MenuItemHandlerResult menuhandlerMouseAimSpeedX(s32 operation, struct men
if (g_PlayerExtCfg[g_ExtMenuPlayer].mouseaimspeedx < 0.f) {
data->slider.value = 0;
} else if (g_PlayerExtCfg[g_ExtMenuPlayer].mouseaimspeedx > 10.f) {
data->slider.value = 100;
data->slider.value = 1000;
} else {
data->slider.value = g_PlayerExtCfg[g_ExtMenuPlayer].mouseaimspeedx * 10.f + 0.5f;
data->slider.value = g_PlayerExtCfg[g_ExtMenuPlayer].mouseaimspeedx * 100.f + 0.5f;
}
break;
case MENUOP_SET:
g_PlayerExtCfg[g_ExtMenuPlayer].mouseaimspeedx = (f32)data->slider.value / 10.f;
g_PlayerExtCfg[g_ExtMenuPlayer].mouseaimspeedx = (f32)data->slider.value / 100.f;
break;
case MENUOP_GETSLIDERLABEL:
sprintf(data->slider.label, "%.2f", (f32)data->slider.value / 100.f);
}

return 0;
Expand All @@ -235,14 +241,16 @@ static MenuItemHandlerResult menuhandlerMouseAimSpeedY(s32 operation, struct men
if (g_PlayerExtCfg[g_ExtMenuPlayer].mouseaimspeedy < 0.f) {
data->slider.value = 0;
} else if (g_PlayerExtCfg[g_ExtMenuPlayer].mouseaimspeedy > 10.f) {
data->slider.value = 100;
data->slider.value = 1000;
} else {
data->slider.value = g_PlayerExtCfg[g_ExtMenuPlayer].mouseaimspeedy * 10.f + 0.5f;
data->slider.value = g_PlayerExtCfg[g_ExtMenuPlayer].mouseaimspeedy * 100.f + 0.5f;
}
break;
case MENUOP_SET:
g_PlayerExtCfg[g_ExtMenuPlayer].mouseaimspeedy = (f32)data->slider.value / 10.f;
g_PlayerExtCfg[g_ExtMenuPlayer].mouseaimspeedy = (f32)data->slider.value / 100.f;
break;
case MENUOP_GETSLIDERLABEL:
sprintf(data->slider.label, "%.2f", (f32)data->slider.value / 100.f);
}

return 0;
Expand All @@ -255,14 +263,16 @@ static MenuItemHandlerResult menuhandlerRadialMenuSpeed(s32 operation, struct me
if (g_PlayerExtCfg[0].radialmenuspeed < 0.f) {
data->slider.value = 0;
} else if (g_PlayerExtCfg[0].radialmenuspeed > 10.f) {
data->slider.value = 100;
data->slider.value = 1000;
} else {
data->slider.value = g_PlayerExtCfg[0].radialmenuspeed * 10.f + 0.5f;
data->slider.value = g_PlayerExtCfg[0].radialmenuspeed * 100.f + 0.5f;
}
break;
case MENUOP_SET:
g_PlayerExtCfg[0].radialmenuspeed = (f32)data->slider.value / 10.f;
g_PlayerExtCfg[0].radialmenuspeed = (f32)data->slider.value / 100.f;
break;
case MENUOP_GETSLIDERLABEL:
sprintf(data->slider.label, "%.2f", (f32)data->slider.value / 100.f);
}

return 0;
Expand Down Expand Up @@ -314,39 +324,39 @@ struct menuitem g_ExtendedMouseMenuItems[] = {
0,
MENUITEMFLAG_LITERAL_TEXT | MENUITEMFLAG_SLIDER_WIDE,
(uintptr_t)"Mouse Speed X",
100,
1000,
menuhandlerMouseSpeedX,
},
{
MENUITEMTYPE_SLIDER,
0,
MENUITEMFLAG_LITERAL_TEXT | MENUITEMFLAG_SLIDER_WIDE,
(uintptr_t)"Mouse Speed Y",
100,
1000,
menuhandlerMouseSpeedY,
},
{
MENUITEMTYPE_SLIDER,
0,
MENUITEMFLAG_LITERAL_TEXT | MENUITEMFLAG_SLIDER_WIDE,
(uintptr_t)"Crosshair Speed X",
100,
1000,
menuhandlerMouseAimSpeedX,
},
{
MENUITEMTYPE_SLIDER,
0,
MENUITEMFLAG_LITERAL_TEXT | MENUITEMFLAG_SLIDER_WIDE,
(uintptr_t)"Crosshair Speed Y",
100,
1000,
menuhandlerMouseAimSpeedY,
},
{
MENUITEMTYPE_SLIDER,
0,
MENUITEMFLAG_LITERAL_TEXT | MENUITEMFLAG_SLIDER_WIDE,
(uintptr_t)"Radial Menu Speed",
100,
1000,
menuhandlerRadialMenuSpeed,
},
{
Expand Down

0 comments on commit 2439eb6

Please sign in to comment.