ebiten: add additional MouseButtons (#2467)

Closes #2445
This commit is contained in:
Kacper Drobny 2022-11-22 20:28:34 +01:00 committed by GitHub
parent 5356b44286
commit 6e12fd13e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 22 additions and 8 deletions

View File

@ -101,11 +101,7 @@ func (i *inputState) update() {
}
// Mouse
for _, b := range []ebiten.MouseButton{
ebiten.MouseButtonLeft,
ebiten.MouseButtonRight,
ebiten.MouseButtonMiddle,
} {
for b := ebiten.MouseButton(0); b <= ebiten.MouseButtonMax; b++ {
i.prevMouseButtonDurations[b] = i.mouseButtonDurations[b]
if ebiten.IsMouseButtonPressed(b) {
i.mouseButtonDurations[b]++

View File

@ -54,6 +54,8 @@ const (
MouseButtonLeft = MouseButton(0)
MouseButtonRight = MouseButton(1)
MouseButtonMiddle = MouseButton(2)
MouseButton3 = MouseButton(3)
MouseButton4 = MouseButton(4)
)
const (

View File

@ -152,6 +152,8 @@ var glfwMouseButtonToMouseButton = map[glfw.MouseButton]MouseButton{
glfw.MouseButtonLeft: MouseButtonLeft,
glfw.MouseButtonRight: MouseButtonRight,
glfw.MouseButtonMiddle: MouseButtonMiddle,
glfw.MouseButton3: MouseButton3,
glfw.MouseButton4: MouseButton4,
}
// update must be called from the main thread.

View File

@ -129,6 +129,8 @@ var codeToMouseButton = map[int]MouseButton{
0: MouseButtonLeft,
1: MouseButtonMiddle,
2: MouseButtonRight,
3: MouseButton3,
4: MouseButton4,
}
func (i *Input) IsMouseButtonPressed(button MouseButton) bool {

View File

@ -24,9 +24,15 @@ import (
type MouseButton int
const (
MouseButtonLeft MouseButton = iota
MouseButtonRight
MouseButtonMiddle
MouseButton0 MouseButton = iota
MouseButton1
MouseButton2
MouseButton3
MouseButton4
MouseButtonLeft = MouseButton0
MouseButtonRight = MouseButton1
MouseButtonMiddle = MouseButton2
)
type TouchID int

View File

@ -26,4 +26,10 @@ const (
MouseButtonLeft MouseButton = ui.MouseButtonLeft
MouseButtonRight MouseButton = ui.MouseButtonRight
MouseButtonMiddle MouseButton = ui.MouseButtonMiddle
MouseButton0 MouseButton = ui.MouseButton0
MouseButton1 MouseButton = ui.MouseButton1
MouseButton2 MouseButton = ui.MouseButton2
MouseButton3 MouseButton = ui.MouseButton3
MouseButton4 MouseButton = ui.MouseButton4
MouseButtonMax MouseButton = MouseButton4
)