Skip to content

Consecutive touchpad clicks are perceived as one #3137

@sedyh

Description

@sedyh

Ebitengine Version

2.8+ (6452cbc)

Operating System

  • Windows
  • macOS
  • Linux
  • FreeBSD
  • OpenBSD
  • Android
  • iOS
  • Nintendo Switch
  • PlayStation 5
  • Xbox
  • Web Browsers

Go Version (go version)

go version go1.23.1 linux/amd64

What steps will reproduce the problem?

Run the example:

package main

import (
	"fmt"
	"log"
	"github.com/hajimehoshi/ebiten/v2"
	"github.com/hajimehoshi/ebiten/v2/ebitenutil"
	"github.com/hajimehoshi/ebiten/v2/inpututil"
)

type Game struct{}

func NewGame() *Game {
	return &Game{}
}

func (g *Game) Update() error {
	just := inpututil.IsMouseButtonJustPressed(ebiten.MouseButtonLeft)
	pressed := ebiten.IsMouseButtonPressed(ebiten.MouseButtonLeft)
	if just {
		log.Printf("just: %t, press: %t\n", just, pressed)
	}
	return nil
}

func (g *Game) Draw(screen *ebiten.Image) {
	ebitenutil.DebugPrint(screen, fmt.Sprintf("FPS: %0.2f", ebiten.ActualFPS()))
}

func (g *Game) Layout(w, h int) (int, int) {
	return w, h
}

func main() {
	log.SetFlags(log.Ltime)
	ebiten.SetWindowSize(480, 320)
	ebiten.SetWindowResizingMode(ebiten.WindowResizingModeEnabled)
	if err := ebiten.RunGame(NewGame()); err != nil {
		panic(err)
	}
}

Run the input monitor with your device id (xinput without flags will list device ids):

#!/usr/bin/bash

xinput test-xi2 --root 12 | while read -r line; do
    timestamp=$(date +%s%3N)
    if [[ "$line" == *"RawButtonPress"* ]]; then
        echo "[$timestamp] $line"
    fi
    if [[ "$line" == *"RawButtonRelease"* ]]; then
        echo "[$timestamp] $line"
    fi
done

What is the expected result?

Every times xinput fires, ebitengine example should fire a log too.

What happens instead?

The engine perceives frequent clicks (>2 cps) as single press:

ebitengine-real-fail.mp4

Anything else you feel useful to add?

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions