ebiten: make some MouseButton definitions explicit

This change redefines named mouse button consts like MouseButtonLeft
to use MouseButton0, so that users can know which enums are the same
and different.

Updates #2445
This commit is contained in:
Hajime Hoshi 2022-11-23 04:40:31 +09:00
parent 6e12fd13e4
commit 9e9cec249a
4 changed files with 21 additions and 24 deletions

View File

@ -149,9 +149,9 @@ func (i *Input) Wheel() (xoff, yoff float64) {
} }
var glfwMouseButtonToMouseButton = map[glfw.MouseButton]MouseButton{ var glfwMouseButtonToMouseButton = map[glfw.MouseButton]MouseButton{
glfw.MouseButtonLeft: MouseButtonLeft, glfw.MouseButtonLeft: MouseButton0,
glfw.MouseButtonRight: MouseButtonRight, glfw.MouseButtonRight: MouseButton1,
glfw.MouseButtonMiddle: MouseButtonMiddle, glfw.MouseButtonMiddle: MouseButton2,
glfw.MouseButton3: MouseButton3, glfw.MouseButton3: MouseButton3,
glfw.MouseButton4: MouseButton4, glfw.MouseButton4: MouseButton4,
} }

View File

@ -126,9 +126,9 @@ func (i *Input) IsKeyPressed(key Key) bool {
} }
var codeToMouseButton = map[int]MouseButton{ var codeToMouseButton = map[int]MouseButton{
0: MouseButtonLeft, 0: MouseButton0, // Left
1: MouseButtonMiddle, 1: MouseButton2, // Middle
2: MouseButtonRight, 2: MouseButton1, // Right
3: MouseButton3, 3: MouseButton3,
4: MouseButton4, 4: MouseButton4,
} }

View File

@ -24,15 +24,11 @@ import (
type MouseButton int type MouseButton int
const ( const (
MouseButton0 MouseButton = iota MouseButton0 MouseButton = iota // The 'left' button
MouseButton1 MouseButton1 // The 'right' button
MouseButton2 MouseButton2 // The 'middle' button
MouseButton3 MouseButton3 // The additional button (usually browser-back)
MouseButton4 MouseButton4 // The additional button (usually browser-forward)
MouseButtonLeft = MouseButton0
MouseButtonRight = MouseButton1
MouseButtonMiddle = MouseButton2
) )
type TouchID int type TouchID int

View File

@ -23,9 +23,10 @@ type MouseButton = ui.MouseButton
// MouseButtons // MouseButtons
const ( const (
MouseButtonLeft MouseButton = ui.MouseButtonLeft MouseButtonLeft MouseButton = MouseButton0
MouseButtonRight MouseButton = ui.MouseButtonRight MouseButtonRight MouseButton = MouseButton1
MouseButtonMiddle MouseButton = ui.MouseButtonMiddle MouseButtonMiddle MouseButton = MouseButton2
MouseButton0 MouseButton = ui.MouseButton0 MouseButton0 MouseButton = ui.MouseButton0
MouseButton1 MouseButton = ui.MouseButton1 MouseButton1 MouseButton = ui.MouseButton1
MouseButton2 MouseButton = ui.MouseButton2 MouseButton2 MouseButton = ui.MouseButton2