input: Refactoring: Remove unused arguments

This commit is contained in:
Hajime Hoshi 2018-04-03 01:21:52 +09:00
parent 0f2beab260
commit 76cb43a7f8
2 changed files with 10 additions and 19 deletions

View File

@ -241,19 +241,19 @@ func OnMouseMove(e *js.Object) {
setMouseCursorFromEvent(e) setMouseCursorFromEvent(e)
} }
func OnTouchStart(e *js.Object, scale float64, left, top int) { func OnTouchStart(e *js.Object) {
e.Call("preventDefault") e.Call("preventDefault")
theInput.updateTouches(e, scale, left, top) theInput.updateTouches(e)
} }
func OnTouchEnd(e *js.Object, scale float64, left, top int) { func OnTouchEnd(e *js.Object) {
e.Call("preventDefault") e.Call("preventDefault")
theInput.updateTouches(e, scale, left, top) theInput.updateTouches(e)
} }
func OnTouchMove(e *js.Object, scale float64, left, top int) { func OnTouchMove(e *js.Object) {
e.Call("preventDefault") e.Call("preventDefault")
theInput.updateTouches(e, scale, left, top) theInput.updateTouches(e)
} }
func setMouseCursorFromEvent(e *js.Object) { func setMouseCursorFromEvent(e *js.Object) {
@ -261,7 +261,7 @@ func setMouseCursorFromEvent(e *js.Object) {
theInput.setMouseCursor(x, y) theInput.setMouseCursor(x, y)
} }
func (i *Input) updateTouches(e *js.Object, scale float64, left, top int) { func (i *Input) updateTouches(e *js.Object) {
j := e.Get("targetTouches") j := e.Get("targetTouches")
ts := make([]*Touch, j.Get("length").Int()) ts := make([]*Touch, j.Get("length").Int())
for i := 0; i < len(ts); i++ { for i := 0; i < len(ts); i++ {

View File

@ -279,18 +279,9 @@ func initialize() error {
}) })
// Touch // Touch
canvas.Call("addEventListener", "touchstart", func(e *js.Object) { canvas.Call("addEventListener", "touchstart", input.OnTouchStart)
rect := canvas.Call("getBoundingClientRect") canvas.Call("addEventListener", "touchend", input.OnTouchEnd)
input.OnTouchStart(e, currentUI.getScale(), rect.Get("left").Int(), rect.Get("top").Int()) canvas.Call("addEventListener", "touchmove", input.OnTouchMove)
})
canvas.Call("addEventListener", "touchend", func(e *js.Object) {
rect := canvas.Call("getBoundingClientRect")
input.OnTouchEnd(e, currentUI.getScale(), rect.Get("left").Int(), rect.Get("top").Int())
})
canvas.Call("addEventListener", "touchmove", func(e *js.Object) {
rect := canvas.Call("getBoundingClientRect")
input.OnTouchMove(e, currentUI.getScale(), rect.Get("left").Int(), rect.Get("top").Int())
})
// Gamepad // Gamepad
window.Call("addEventListener", "gamepadconnected", func(e *js.Object) { window.Call("addEventListener", "gamepadconnected", func(e *js.Object) {