mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
Add keys_glfw.go and keys_js.go
This commit is contained in:
parent
a1d3815008
commit
a9f1b4f0e9
@ -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
|
||||
|
@ -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 {
|
||||
|
29
internal/ui/keys_glfw.go
Normal file
29
internal/ui/keys_glfw.go
Normal file
@ -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,
|
||||
}
|
25
internal/ui/keys_js.go
Normal file
25
internal/ui/keys_js.go
Normal file
@ -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,
|
||||
}
|
Loading…
Reference in New Issue
Block a user