@@ -1385,48 +1385,34 @@ public void EditAnalogProgrammatically(KeyEventArgs e)
13851385 }
13861386
13871387 string prevTyped = _axisTypedValue ;
1388+ AxisSpec axis = ControllerType . Axes [ AxisEditColumn ] ;
13881389
1389- var range = ControllerType . Axes [ AxisEditColumn ] ;
1390-
1391- // feos: typing past max digits overwrites existing value, not touching the sign
1392- // but doesn't handle situations where the range is like -50 through 100, where minimum is negative and has less digits
1393- // it just uses 3 as maxDigits there too, leaving room for typing impossible values (that are still ignored by the game and then clamped)
1394- int maxDigits = range . MaxDigits ;
1395- int curDigits = _axisTypedValue . Length ;
1396- string curMinus ;
1397- if ( _axisTypedValue . StartsWith ( '-' ) )
1390+ int charToType = - 1 ;
1391+ if ( e . KeyCode is >= Keys . D0 and <= Keys . D9 )
13981392 {
1399- curDigits -= 1 ;
1400- curMinus = "-" ;
1393+ charToType = e . KeyCode - Keys . D0 ;
14011394 }
1402- else
1395+ else if ( e . KeyCode is >= Keys . NumPad0 and <= Keys . NumPad9 )
14031396 {
1404- curMinus = "" ;
1397+ charToType = e . KeyCode - Keys . NumPad0 ;
14051398 }
14061399
1407- if ( e . KeyCode is >= Keys . D0 and <= Keys . D9 )
1400+ if ( charToType != - 1 )
14081401 {
1409- if ( curDigits >= maxDigits )
1402+ if ( ( _axisTypedValue . StartsWith ( '-' ) && _axisTypedValue . Length < axis . Min . ToString ( ) . Length )
1403+ || ( ! _axisTypedValue . StartsWith ( '-' ) && _axisTypedValue . Length < axis . Max . ToString ( ) . Length ) )
14101404 {
1411- _axisTypedValue = curMinus ;
1405+ _axisTypedValue += charToType ;
14121406 }
1413-
1414- _axisTypedValue += e . KeyCode - Keys . D0 ;
14151407 }
1416- else if ( e . KeyCode is >= Keys . NumPad0 and <= Keys . NumPad9 )
1408+ else if ( e . KeyCode is Keys . OemMinus or Keys . Subtract )
14171409 {
1418- if ( curDigits >= maxDigits )
1410+ if ( axis . Min < 0 )
14191411 {
1420- _axisTypedValue = curMinus ;
1412+ _axisTypedValue = _axisTypedValue . StartsWith ( '-' )
1413+ ? _axisTypedValue . Substring ( startIndex : 1 )
1414+ : $ "-{ _axisTypedValue } ";
14211415 }
1422-
1423- _axisTypedValue += e . KeyCode - Keys . NumPad0 ;
1424- }
1425- else if ( e . KeyCode is Keys . OemMinus or Keys . Subtract )
1426- {
1427- _axisTypedValue = _axisTypedValue . StartsWith ( '-' )
1428- ? _axisTypedValue . Substring ( startIndex : 1 )
1429- : $ "-{ _axisTypedValue } ";
14301416 }
14311417 else if ( e . KeyCode == Keys . Back )
14321418 {
@@ -1458,13 +1444,13 @@ public void EditAnalogProgrammatically(KeyEventArgs e)
14581444 int value ;
14591445 if ( _axisTypedValue . Length is 0 )
14601446 {
1461- value = ControllerType . Axes [ AxisEditColumn ] . Neutral ;
1447+ value = axis . Neutral ;
14621448 }
14631449 else
14641450 {
14651451 if ( int . TryParse ( _axisTypedValue , NumberStyles . Float , NumberFormatInfo . InvariantInfo , out value ) ) // String "-" can't be parsed.
14661452 {
1467- value = value . ConstrainWithin ( range . Range ) ;
1453+ value = value . ConstrainWithin ( axis . Range ) ;
14681454 }
14691455 else
14701456 {
0 commit comments