mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
inpututil: Admit some functions to return nil
This commit is contained in:
parent
e33ca9a4c1
commit
c9a244f498
@ -227,9 +227,11 @@ func MouseButtonPressDuration(button ebiten.MouseButton) int {
|
|||||||
|
|
||||||
// JustConnectedGamepadIDs returns gamepad IDs that are connected just in the current frame.
|
// JustConnectedGamepadIDs returns gamepad IDs that are connected just in the current frame.
|
||||||
//
|
//
|
||||||
|
// JustConnectedGamepadIDs might return nil when there is no connected gamepad.
|
||||||
|
//
|
||||||
// JustConnectedGamepadIDs is concurrent safe.
|
// JustConnectedGamepadIDs is concurrent safe.
|
||||||
func JustConnectedGamepadIDs() []int {
|
func JustConnectedGamepadIDs() []int {
|
||||||
ids := []int{}
|
var ids []int
|
||||||
theInputState.m.RLock()
|
theInputState.m.RLock()
|
||||||
for id := range theInputState.gamepadIDs {
|
for id := range theInputState.gamepadIDs {
|
||||||
if _, ok := theInputState.prevGamepadIDs[id]; !ok {
|
if _, ok := theInputState.prevGamepadIDs[id]; !ok {
|
||||||
@ -243,9 +245,11 @@ func JustConnectedGamepadIDs() []int {
|
|||||||
|
|
||||||
// JustDisconnectedGamepadIDs returns gamepad IDs that are disconnected just in the current frame.
|
// JustDisconnectedGamepadIDs returns gamepad IDs that are disconnected just in the current frame.
|
||||||
//
|
//
|
||||||
|
// JustDisconnectedGamepadIDs might return nil when there is no disconnected gamepad.
|
||||||
|
//
|
||||||
// JustDisconnectedGamepadIDs is concurrent safe.
|
// JustDisconnectedGamepadIDs is concurrent safe.
|
||||||
func JustDisconnectedGamepadIDs() []int {
|
func JustDisconnectedGamepadIDs() []int {
|
||||||
ids := []int{}
|
var ids []int
|
||||||
theInputState.m.RLock()
|
theInputState.m.RLock()
|
||||||
for id := range theInputState.prevGamepadIDs {
|
for id := range theInputState.prevGamepadIDs {
|
||||||
if _, ok := theInputState.gamepadIDs[id]; !ok {
|
if _, ok := theInputState.gamepadIDs[id]; !ok {
|
||||||
@ -298,9 +302,11 @@ func GamepadButtonPressDuration(id int, button ebiten.GamepadButton) int {
|
|||||||
|
|
||||||
// JustPressedTouches returns touch IDs that are created just in the current frame.
|
// JustPressedTouches returns touch IDs that are created just in the current frame.
|
||||||
//
|
//
|
||||||
|
// JustPressedTouches might return nil when there is not touch.
|
||||||
|
//
|
||||||
// JustPressedTouches is concurrent safe.
|
// JustPressedTouches is concurrent safe.
|
||||||
func JustPressedTouches() []int {
|
func JustPressedTouches() []int {
|
||||||
ids := []int{}
|
var ids []int
|
||||||
theInputState.m.RLock()
|
theInputState.m.RLock()
|
||||||
for id, s := range theInputState.touchDurations {
|
for id, s := range theInputState.touchDurations {
|
||||||
if s == 1 {
|
if s == 1 {
|
||||||
|
Loading…
Reference in New Issue
Block a user