mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-11 19:48:54 +01:00
input: Move MouseButton and GamepadButton to driver package
This commit is contained in:
parent
35ac61056c
commit
c5a8c88e2d
66
gamepad.go
66
gamepad.go
@ -15,7 +15,7 @@
|
||||
package ebiten
|
||||
|
||||
import (
|
||||
"github.com/hajimehoshi/ebiten/internal/input"
|
||||
"github.com/hajimehoshi/ebiten/internal/driver"
|
||||
)
|
||||
|
||||
// A GamepadButton represents a gamepad button.
|
||||
@ -23,37 +23,37 @@ type GamepadButton int
|
||||
|
||||
// GamepadButtons
|
||||
const (
|
||||
GamepadButton0 GamepadButton = GamepadButton(input.GamepadButton0)
|
||||
GamepadButton1 GamepadButton = GamepadButton(input.GamepadButton1)
|
||||
GamepadButton2 GamepadButton = GamepadButton(input.GamepadButton2)
|
||||
GamepadButton3 GamepadButton = GamepadButton(input.GamepadButton3)
|
||||
GamepadButton4 GamepadButton = GamepadButton(input.GamepadButton4)
|
||||
GamepadButton5 GamepadButton = GamepadButton(input.GamepadButton5)
|
||||
GamepadButton6 GamepadButton = GamepadButton(input.GamepadButton6)
|
||||
GamepadButton7 GamepadButton = GamepadButton(input.GamepadButton7)
|
||||
GamepadButton8 GamepadButton = GamepadButton(input.GamepadButton8)
|
||||
GamepadButton9 GamepadButton = GamepadButton(input.GamepadButton9)
|
||||
GamepadButton10 GamepadButton = GamepadButton(input.GamepadButton10)
|
||||
GamepadButton11 GamepadButton = GamepadButton(input.GamepadButton11)
|
||||
GamepadButton12 GamepadButton = GamepadButton(input.GamepadButton12)
|
||||
GamepadButton13 GamepadButton = GamepadButton(input.GamepadButton13)
|
||||
GamepadButton14 GamepadButton = GamepadButton(input.GamepadButton14)
|
||||
GamepadButton15 GamepadButton = GamepadButton(input.GamepadButton15)
|
||||
GamepadButton16 GamepadButton = GamepadButton(input.GamepadButton16)
|
||||
GamepadButton17 GamepadButton = GamepadButton(input.GamepadButton17)
|
||||
GamepadButton18 GamepadButton = GamepadButton(input.GamepadButton18)
|
||||
GamepadButton19 GamepadButton = GamepadButton(input.GamepadButton19)
|
||||
GamepadButton20 GamepadButton = GamepadButton(input.GamepadButton20)
|
||||
GamepadButton21 GamepadButton = GamepadButton(input.GamepadButton21)
|
||||
GamepadButton22 GamepadButton = GamepadButton(input.GamepadButton22)
|
||||
GamepadButton23 GamepadButton = GamepadButton(input.GamepadButton23)
|
||||
GamepadButton24 GamepadButton = GamepadButton(input.GamepadButton24)
|
||||
GamepadButton25 GamepadButton = GamepadButton(input.GamepadButton25)
|
||||
GamepadButton26 GamepadButton = GamepadButton(input.GamepadButton26)
|
||||
GamepadButton27 GamepadButton = GamepadButton(input.GamepadButton27)
|
||||
GamepadButton28 GamepadButton = GamepadButton(input.GamepadButton28)
|
||||
GamepadButton29 GamepadButton = GamepadButton(input.GamepadButton29)
|
||||
GamepadButton30 GamepadButton = GamepadButton(input.GamepadButton30)
|
||||
GamepadButton31 GamepadButton = GamepadButton(input.GamepadButton31)
|
||||
GamepadButton0 GamepadButton = GamepadButton(driver.GamepadButton0)
|
||||
GamepadButton1 GamepadButton = GamepadButton(driver.GamepadButton1)
|
||||
GamepadButton2 GamepadButton = GamepadButton(driver.GamepadButton2)
|
||||
GamepadButton3 GamepadButton = GamepadButton(driver.GamepadButton3)
|
||||
GamepadButton4 GamepadButton = GamepadButton(driver.GamepadButton4)
|
||||
GamepadButton5 GamepadButton = GamepadButton(driver.GamepadButton5)
|
||||
GamepadButton6 GamepadButton = GamepadButton(driver.GamepadButton6)
|
||||
GamepadButton7 GamepadButton = GamepadButton(driver.GamepadButton7)
|
||||
GamepadButton8 GamepadButton = GamepadButton(driver.GamepadButton8)
|
||||
GamepadButton9 GamepadButton = GamepadButton(driver.GamepadButton9)
|
||||
GamepadButton10 GamepadButton = GamepadButton(driver.GamepadButton10)
|
||||
GamepadButton11 GamepadButton = GamepadButton(driver.GamepadButton11)
|
||||
GamepadButton12 GamepadButton = GamepadButton(driver.GamepadButton12)
|
||||
GamepadButton13 GamepadButton = GamepadButton(driver.GamepadButton13)
|
||||
GamepadButton14 GamepadButton = GamepadButton(driver.GamepadButton14)
|
||||
GamepadButton15 GamepadButton = GamepadButton(driver.GamepadButton15)
|
||||
GamepadButton16 GamepadButton = GamepadButton(driver.GamepadButton16)
|
||||
GamepadButton17 GamepadButton = GamepadButton(driver.GamepadButton17)
|
||||
GamepadButton18 GamepadButton = GamepadButton(driver.GamepadButton18)
|
||||
GamepadButton19 GamepadButton = GamepadButton(driver.GamepadButton19)
|
||||
GamepadButton20 GamepadButton = GamepadButton(driver.GamepadButton20)
|
||||
GamepadButton21 GamepadButton = GamepadButton(driver.GamepadButton21)
|
||||
GamepadButton22 GamepadButton = GamepadButton(driver.GamepadButton22)
|
||||
GamepadButton23 GamepadButton = GamepadButton(driver.GamepadButton23)
|
||||
GamepadButton24 GamepadButton = GamepadButton(driver.GamepadButton24)
|
||||
GamepadButton25 GamepadButton = GamepadButton(driver.GamepadButton25)
|
||||
GamepadButton26 GamepadButton = GamepadButton(driver.GamepadButton26)
|
||||
GamepadButton27 GamepadButton = GamepadButton(driver.GamepadButton27)
|
||||
GamepadButton28 GamepadButton = GamepadButton(driver.GamepadButton28)
|
||||
GamepadButton29 GamepadButton = GamepadButton(driver.GamepadButton29)
|
||||
GamepadButton30 GamepadButton = GamepadButton(driver.GamepadButton30)
|
||||
GamepadButton31 GamepadButton = GamepadButton(driver.GamepadButton31)
|
||||
GamepadButtonMax GamepadButton = GamepadButton31
|
||||
)
|
||||
|
5
input.go
5
input.go
@ -15,6 +15,7 @@
|
||||
package ebiten
|
||||
|
||||
import (
|
||||
"github.com/hajimehoshi/ebiten/internal/driver"
|
||||
"github.com/hajimehoshi/ebiten/internal/input"
|
||||
"github.com/hajimehoshi/ebiten/internal/ui"
|
||||
)
|
||||
@ -67,7 +68,7 @@ func Wheel() (xoff, yoff float64) {
|
||||
// Note that touch events not longer affect IsMouseButtonPressed's result as of 1.4.0-alpha.
|
||||
// Use Touches instead.
|
||||
func IsMouseButtonPressed(mouseButton MouseButton) bool {
|
||||
return input.Get().IsMouseButtonPressed(input.MouseButton(mouseButton))
|
||||
return input.Get().IsMouseButtonPressed(driver.MouseButton(mouseButton))
|
||||
}
|
||||
|
||||
// GamepadIDs returns a slice indicating available gamepad IDs.
|
||||
@ -115,7 +116,7 @@ func GamepadButtonNum(id int) int {
|
||||
//
|
||||
// IsGamepadButtonPressed always returns false on mobiles.
|
||||
func IsGamepadButtonPressed(id int, button GamepadButton) bool {
|
||||
return input.Get().IsGamepadButtonPressed(id, input.GamepadButton(button))
|
||||
return input.Get().IsGamepadButtonPressed(id, driver.GamepadButton(button))
|
||||
}
|
||||
|
||||
// TouchIDs returns the current touch states.
|
||||
|
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package input
|
||||
package driver
|
||||
|
||||
type GamepadButton int
|
||||
|
@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package input
|
||||
package driver
|
||||
|
||||
type MouseButton int
|
||||
|
@ -14,6 +14,10 @@
|
||||
|
||||
package input
|
||||
|
||||
import (
|
||||
"github.com/hajimehoshi/ebiten/internal/driver"
|
||||
)
|
||||
|
||||
var theInput = &Input{}
|
||||
|
||||
func Get() *Input {
|
||||
@ -68,7 +72,7 @@ func (i *Input) GamepadButtonNum(id int) int {
|
||||
return i.gamepads[id].buttonNum
|
||||
}
|
||||
|
||||
func (i *Input) IsGamepadButtonPressed(id int, button GamepadButton) bool {
|
||||
func (i *Input) IsGamepadButtonPressed(id int, button driver.GamepadButton) bool {
|
||||
i.m.RLock()
|
||||
defer i.m.RUnlock()
|
||||
if len(i.gamepads) <= id {
|
||||
|
@ -23,6 +23,7 @@ import (
|
||||
"sync"
|
||||
"unicode"
|
||||
|
||||
"github.com/hajimehoshi/ebiten/internal/driver"
|
||||
"github.com/hajimehoshi/ebiten/internal/glfw"
|
||||
)
|
||||
|
||||
@ -75,7 +76,7 @@ func (i *Input) IsKeyPressed(key Key) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (i *Input) IsMouseButtonPressed(button MouseButton) bool {
|
||||
func (i *Input) IsMouseButtonPressed(button driver.MouseButton) bool {
|
||||
i.m.RLock()
|
||||
defer i.m.RUnlock()
|
||||
if i.mouseButtonPressed == nil {
|
||||
@ -98,10 +99,10 @@ func (i *Input) Wheel() (xoff, yoff float64) {
|
||||
return i.scrollX, i.scrollY
|
||||
}
|
||||
|
||||
var glfwMouseButtonToMouseButton = map[glfw.MouseButton]MouseButton{
|
||||
glfw.MouseButtonLeft: MouseButtonLeft,
|
||||
glfw.MouseButtonRight: MouseButtonRight,
|
||||
glfw.MouseButtonMiddle: MouseButtonMiddle,
|
||||
var glfwMouseButtonToMouseButton = map[glfw.MouseButton]driver.MouseButton{
|
||||
glfw.MouseButtonLeft: driver.MouseButtonLeft,
|
||||
glfw.MouseButtonRight: driver.MouseButtonRight,
|
||||
glfw.MouseButtonMiddle: driver.MouseButtonMiddle,
|
||||
}
|
||||
|
||||
func (i *Input) Update(window *glfw.Window, scale float64) {
|
||||
|
@ -15,7 +15,7 @@
|
||||
package ebiten
|
||||
|
||||
import (
|
||||
"github.com/hajimehoshi/ebiten/internal/input"
|
||||
"github.com/hajimehoshi/ebiten/internal/driver"
|
||||
)
|
||||
|
||||
// A MouseButton represents a mouse button.
|
||||
@ -23,7 +23,7 @@ type MouseButton int
|
||||
|
||||
// MouseButtons
|
||||
const (
|
||||
MouseButtonLeft MouseButton = MouseButton(input.MouseButtonLeft)
|
||||
MouseButtonRight MouseButton = MouseButton(input.MouseButtonRight)
|
||||
MouseButtonMiddle MouseButton = MouseButton(input.MouseButtonMiddle)
|
||||
MouseButtonLeft MouseButton = MouseButton(driver.MouseButtonLeft)
|
||||
MouseButtonRight MouseButton = MouseButton(driver.MouseButtonRight)
|
||||
MouseButtonMiddle MouseButton = MouseButton(driver.MouseButtonMiddle)
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user