mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58: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)
|
||||
for a := 0; a < an; 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.
|
||||
if threshold <= v && v <= 1.0 {
|
||||
// Check |v| < 1.0 because
|
||||
// 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 {
|
||||
c.axes[b] = axis{a, true}
|
||||
c.assignedAxes[axis{a, true}] = struct{}{}
|
||||
return true
|
||||
}
|
||||
}
|
||||
if -1.0 <= v && v <= -threshold {
|
||||
if -1.0 < v && v <= -threshold {
|
||||
if _, ok := c.assignedAxes[axis{a, false}]; !ok {
|
||||
c.axes[b] = axis{a, false}
|
||||
c.assignedAxes[axis{a, false}] = struct{}{}
|
||||
|
Loading…
Reference in New Issue
Block a user