diff --git a/internal/ui/input_glfw.go b/internal/ui/input_glfw.go index 5c6f5422f..e9ce2d918 100644 --- a/internal/ui/input_glfw.go +++ b/internal/ui/input_glfw.go @@ -33,14 +33,6 @@ func CursorPosition() (x, y int) { return current.input.cursorPosition() } -var glfwKeyCodeToKey = map[glfw.Key]Key{ - glfw.KeySpace: KeySpace, - glfw.KeyLeft: KeyLeft, - glfw.KeyRight: KeyRight, - glfw.KeyUp: KeyUp, - glfw.KeyDown: KeyDown, -} - func (i *input) update(window *glfw.Window, scale int) { for g, u := range glfwKeyCodeToKey { i.keyPressed[u] = window.GetKey(g) == glfw.Press diff --git a/internal/ui/input_js.go b/internal/ui/input_js.go index aaccef39a..b8c378fc5 100644 --- a/internal/ui/input_js.go +++ b/internal/ui/input_js.go @@ -16,14 +16,6 @@ package ui -var keyCodeToKey = map[int]Key{ - 32: KeySpace, - 37: KeyLeft, - 39: KeyRight, - 38: KeyUp, - 40: KeyDown, -} - var currentInput input func IsKeyPressed(key Key) bool { diff --git a/internal/ui/keys_glfw.go b/internal/ui/keys_glfw.go new file mode 100644 index 000000000..2df7ce4b1 --- /dev/null +++ b/internal/ui/keys_glfw.go @@ -0,0 +1,29 @@ +// Copyright 2015 Hajime Hoshi +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build !js + +package ui + +import ( + glfw "github.com/go-gl/glfw3" +) + +var glfwKeyCodeToKey = map[glfw.Key]Key{ + glfw.KeySpace: KeySpace, + glfw.KeyLeft: KeyLeft, + glfw.KeyRight: KeyRight, + glfw.KeyUp: KeyUp, + glfw.KeyDown: KeyDown, +} diff --git a/internal/ui/keys_js.go b/internal/ui/keys_js.go new file mode 100644 index 000000000..29ebf9b27 --- /dev/null +++ b/internal/ui/keys_js.go @@ -0,0 +1,25 @@ +// Copyright 2015 Hajime Hoshi +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build js + +package ui + +var keyCodeToKey = map[int]Key{ + 32: KeySpace, + 37: KeyLeft, + 39: KeyRight, + 38: KeyUp, + 40: KeyDown, +} diff --git a/keys.go b/keys.go index 645fea22f..c77eeb248 100644 --- a/keys.go +++ b/keys.go @@ -21,10 +21,6 @@ import ( // A Key represents a keyboard key. type Key int -// TODO: Add more keys. - -// TODO: Generate this automatically. - // Keys const ( KeyUp = Key(ui.KeyUp)