mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
internal/uidriver/glfw: Add WheelDelta
This commit is contained in:
parent
d4b5d17e75
commit
7d1810b0d7
@ -43,7 +43,7 @@ type Game struct {
|
||||
}
|
||||
|
||||
func (g *Game) Update() error {
|
||||
dx, dy := ebiten.Wheel()
|
||||
dx, dy := ebiten.WheelDelta()
|
||||
g.x += dx
|
||||
g.y += dy
|
||||
return nil
|
||||
|
4
input.go
4
input.go
@ -106,6 +106,10 @@ func Wheel() (xoff, yoff float64) {
|
||||
return uiDriver().Input().Wheel()
|
||||
}
|
||||
|
||||
func WheelDelta() (xoff, yoff float64) {
|
||||
return uiDriver().Input().WheelDelta()
|
||||
}
|
||||
|
||||
// IsMouseButtonPressed returns a boolean indicating whether mouseButton is pressed.
|
||||
//
|
||||
// If you want to know whether the mouseButton started being pressed in the current frame,
|
||||
|
@ -37,4 +37,5 @@ type Input interface {
|
||||
StandardGamepadButtonValue(id GamepadID, button StandardGamepadButton) float64
|
||||
TouchPosition(id TouchID) (x, y int)
|
||||
Wheel() (xoff, yoff float64)
|
||||
WheelDelta() (xoff, yoff float64)
|
||||
}
|
||||
|
@ -260,6 +260,16 @@ func (i *Input) Wheel() (xoff, yoff float64) {
|
||||
return i.scrollX, i.scrollY
|
||||
}
|
||||
|
||||
func (i *Input) WheelDelta() (xoff, yoff float64) {
|
||||
if !i.ui.isRunning() {
|
||||
return 0, 0
|
||||
}
|
||||
|
||||
i.ui.m.RLock()
|
||||
defer i.ui.m.RUnlock()
|
||||
return i.scrollX * wheelFactor, i.scrollY * wheelFactor
|
||||
}
|
||||
|
||||
var glfwMouseButtonToMouseButton = map[glfw.MouseButton]driver.MouseButton{
|
||||
glfw.MouseButtonLeft: driver.MouseButtonLeft,
|
||||
glfw.MouseButtonRight: driver.MouseButtonRight,
|
||||
|
@ -194,3 +194,5 @@ func (u *UserInterface) adjustViewSize() {
|
||||
|
||||
func initializeWindowAfterCreation(w *glfw.Window) {
|
||||
}
|
||||
|
||||
const wheelFactor = 10
|
||||
|
@ -179,3 +179,5 @@ func initializeWindowAfterCreation(w *glfw.Window) {
|
||||
// Apparently the window state is inconsistent just after the window is created, but we are not sure.
|
||||
// For more details, see the discussion in #1829.
|
||||
}
|
||||
|
||||
const wheelFactor = 53
|
||||
|
@ -193,3 +193,5 @@ func (u *UserInterface) adjustViewSize() {
|
||||
|
||||
func initializeWindowAfterCreation(w *glfw.Window) {
|
||||
}
|
||||
|
||||
const wheelFactor = 120
|
||||
|
@ -245,6 +245,10 @@ func (i *Input) Wheel() (xoff, yoff float64) {
|
||||
return i.wheelX, i.wheelY
|
||||
}
|
||||
|
||||
func (i *Input) WheelDelta() (xoff, yoff float64) {
|
||||
return i.wheelX, i.wheelY
|
||||
}
|
||||
|
||||
func (i *Input) keyDown(code js.Value) {
|
||||
if i.keyPressed == nil {
|
||||
i.keyPressed = map[int]bool{}
|
||||
|
@ -195,6 +195,10 @@ func (i *Input) Wheel() (xoff, yoff float64) {
|
||||
return 0, 0
|
||||
}
|
||||
|
||||
func (i *Input) WheelDelta() (xoff, yoff float64) {
|
||||
return 0, 0
|
||||
}
|
||||
|
||||
func (i *Input) IsMouseButtonPressed(key driver.MouseButton) bool {
|
||||
return false
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user