mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
examples/blocks: gamepad configuration didn't work well with PS4 controllers
This commit is contained in:
parent
2ec4e31d60
commit
18d23b5931
@ -90,15 +90,19 @@ func (c *gamepadConfig) Scan(index int, b abstractButton) bool {
|
|||||||
an := ebiten.GamepadAxisNum(index)
|
an := ebiten.GamepadAxisNum(index)
|
||||||
for a := 0; a < an; a++ {
|
for a := 0; a < an; a++ {
|
||||||
v := ebiten.GamepadAxis(index, a)
|
v := ebiten.GamepadAxis(index, a)
|
||||||
// Check v <= 1.0 because there is a bug that a button returns an axis value wrongly and the value may be over 1.
|
// Check |v| < 1.0 because
|
||||||
if threshold <= v && v <= 1.0 {
|
// 1) there is a bug that a button returns an axis value wrongly
|
||||||
|
// and the value may be over 1.
|
||||||
|
// 2) just 1.0 or -1.0 values are ignored since PS4's L2/R2 keys take
|
||||||
|
// -1.0 by default.
|
||||||
|
if threshold <= v && v < 1.0 {
|
||||||
if _, ok := c.assignedAxes[axis{a, true}]; !ok {
|
if _, ok := c.assignedAxes[axis{a, true}]; !ok {
|
||||||
c.axes[b] = axis{a, true}
|
c.axes[b] = axis{a, true}
|
||||||
c.assignedAxes[axis{a, true}] = struct{}{}
|
c.assignedAxes[axis{a, true}] = struct{}{}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if -1.0 <= v && v <= -threshold {
|
if -1.0 < v && v <= -threshold {
|
||||||
if _, ok := c.assignedAxes[axis{a, false}]; !ok {
|
if _, ok := c.assignedAxes[axis{a, false}]; !ok {
|
||||||
c.axes[b] = axis{a, false}
|
c.axes[b] = axis{a, false}
|
||||||
c.assignedAxes[axis{a, false}] = struct{}{}
|
c.assignedAxes[axis{a, false}] = struct{}{}
|
||||||
|
Loading…
Reference in New Issue
Block a user