mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-02-24 08:50:09 +01:00
internal/gamepaddb: refactoring
This commit is contained in:
parent
047858aa59
commit
209dc50f72
@ -120,8 +120,8 @@ const (
|
|||||||
type mapping struct {
|
type mapping struct {
|
||||||
Type mappingType
|
Type mappingType
|
||||||
Index int
|
Index int
|
||||||
AxisScale int
|
AxisScale float64
|
||||||
AxisOffset int
|
AxisOffset float64
|
||||||
HatState int
|
HatState int
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,8 +222,8 @@ func parseMappingElement(str string) (*mapping, error) {
|
|||||||
tilda = true
|
tilda = true
|
||||||
}
|
}
|
||||||
|
|
||||||
min := -1
|
min := -1.0
|
||||||
max := 1
|
max := 1.0
|
||||||
numstr := str[1:]
|
numstr := str[1:]
|
||||||
|
|
||||||
if str[0] == '+' {
|
if str[0] == '+' {
|
||||||
@ -429,7 +429,7 @@ func StandardAxisValue(id string, axis StandardAxis, state GamepadState) float64
|
|||||||
|
|
||||||
switch mapping.Type {
|
switch mapping.Type {
|
||||||
case mappingTypeAxis:
|
case mappingTypeAxis:
|
||||||
v := state.Axis(mapping.Index)*float64(mapping.AxisScale) + float64(mapping.AxisOffset)
|
v := state.Axis(mapping.Index)*mapping.AxisScale + mapping.AxisOffset
|
||||||
if v > 1 {
|
if v > 1 {
|
||||||
return 1
|
return 1
|
||||||
} else if v < -1 {
|
} else if v < -1 {
|
||||||
@ -484,7 +484,7 @@ func standardButtonValue(id string, button StandardButton, state GamepadState) f
|
|||||||
|
|
||||||
switch mapping.Type {
|
switch mapping.Type {
|
||||||
case mappingTypeAxis:
|
case mappingTypeAxis:
|
||||||
v := state.Axis(mapping.Index)*float64(mapping.AxisScale) + float64(mapping.AxisOffset)
|
v := state.Axis(mapping.Index)*mapping.AxisScale + mapping.AxisOffset
|
||||||
if v > 1 {
|
if v > 1 {
|
||||||
v = 1
|
v = 1
|
||||||
} else if v < -1 {
|
} else if v < -1 {
|
||||||
|
Loading…
Reference in New Issue
Block a user