mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
event: Add Modifier
Modifier keys are selected of a common set of GLFW keys [1] and Web API keys [2]. This change also renames the member Modifiers to Modifer to follow the convension (e.g., [3]). Updates #926 [1] https://www.glfw.org/docs/latest/group__mods.html [2] https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/getModifierState [3] https://godoc.org/golang.org/x/tools/go/packages#Config
This commit is contained in:
parent
06d38790ff
commit
25a2bf3c1f
@ -30,9 +30,8 @@ type Event interface {
|
||||
type KeyboardKeyCharacter struct {
|
||||
// Key is the key code of the key typed.
|
||||
Key Key
|
||||
// Modifiers are the modifiers pressed together with the key.
|
||||
// TODO: this should change later from an int to an enumeration type.
|
||||
Modifiers int
|
||||
// Modifier is the logical-or value of the modifiers pressed together with the key.
|
||||
Modifier Modifier
|
||||
// Character is the character that was typed.
|
||||
Character rune
|
||||
}
|
||||
@ -41,9 +40,8 @@ type KeyboardKeyCharacter struct {
|
||||
type KeyboardKeyDown struct {
|
||||
// Key is the key code of the key pressed or released.
|
||||
Key Key
|
||||
// Modifiers are the modifiers pressed together with the key.
|
||||
// TODO: this should change later from an int to an enumeration type.
|
||||
Modifiers int
|
||||
// Modifier is the logical-or value of the modifiers pressed together with the key.
|
||||
Modifier Modifier
|
||||
}
|
||||
|
||||
// KeyboardKeyUp is an event that occurs when a key is released on the keyboard.
|
||||
|
29
event/modifier.go
Normal file
29
event/modifier.go
Normal file
@ -0,0 +1,29 @@
|
||||
// Copyright 2019 The Ebiten Authors
|
||||
//
|
||||
// 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.
|
||||
|
||||
package event
|
||||
|
||||
import (
|
||||
"github.com/hajimehoshi/ebiten/internal/driver"
|
||||
)
|
||||
|
||||
type Modifier int
|
||||
|
||||
const (
|
||||
ModifierShift Modifier = Modifier(driver.ModifierShift)
|
||||
ModifierControl Modifier = Modifier(driver.ModifierControl)
|
||||
ModifierAlt Modifier = Modifier(driver.ModifierAlt)
|
||||
ModifierCapsLock Modifier = Modifier(driver.ModifierCapsLock)
|
||||
ModifierNumLock Modifier = Modifier(driver.ModifierNumLock)
|
||||
)
|
25
internal/driver/modifier.go
Normal file
25
internal/driver/modifier.go
Normal file
@ -0,0 +1,25 @@
|
||||
// Copyright 2019 The Ebiten Authors
|
||||
//
|
||||
// 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.
|
||||
|
||||
package driver
|
||||
|
||||
type Modifier int
|
||||
|
||||
const (
|
||||
ModifierShift Modifier = 1 << iota
|
||||
ModifierControl
|
||||
ModifierAlt
|
||||
ModifierCapsLock
|
||||
ModifierNumLock
|
||||
)
|
Loading…
Reference in New Issue
Block a user