...

Source file src/code.rocket9labs.com/tslocum/etk/keybind.go

Documentation: code.rocket9labs.com/tslocum/etk

     1  package etk
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/hajimehoshi/ebiten/v2"
     7  )
     8  
     9  // Shortcuts represents the keyboard, mouse and gamepad input configurations.
    10  type Shortcuts struct {
    11  	DoubleClickThreshold time.Duration
    12  
    13  	MoveLeftKeyboard  []ebiten.Key
    14  	MoveRightKeyboard []ebiten.Key
    15  	MoveDownKeyboard  []ebiten.Key
    16  	MoveUpKeyboard    []ebiten.Key
    17  
    18  	MoveLeftGamepad  []ebiten.StandardGamepadButton
    19  	MoveRightGamepad []ebiten.StandardGamepadButton
    20  	MoveDownGamepad  []ebiten.StandardGamepadButton
    21  	MoveUpGamepad    []ebiten.StandardGamepadButton
    22  
    23  	ConfirmKeyboard []ebiten.Key
    24  	ConfirmMouse    []ebiten.MouseButton
    25  	ConfirmGamepad  []ebiten.StandardGamepadButton
    26  
    27  	// A sentinel rune value may be set for the confirm and back actions.
    28  	// This allows working around on-screen keyboard issues on Android.
    29  	ConfirmRune rune
    30  	BackRune    rune
    31  }
    32  
    33  // Bindings is the current keyboard, mouse and gamepad input configurations.
    34  var Bindings = &Shortcuts{
    35  	DoubleClickThreshold: 200 * time.Millisecond,
    36  
    37  	MoveLeftKeyboard:  []ebiten.Key{ebiten.KeyLeft},
    38  	MoveRightKeyboard: []ebiten.Key{ebiten.KeyRight},
    39  	MoveDownKeyboard:  []ebiten.Key{ebiten.KeyDown},
    40  	MoveUpKeyboard:    []ebiten.Key{ebiten.KeyUp},
    41  
    42  	MoveLeftGamepad:  []ebiten.StandardGamepadButton{ebiten.StandardGamepadButtonLeftLeft},
    43  	MoveRightGamepad: []ebiten.StandardGamepadButton{ebiten.StandardGamepadButtonLeftRight},
    44  	MoveDownGamepad:  []ebiten.StandardGamepadButton{ebiten.StandardGamepadButtonLeftBottom},
    45  	MoveUpGamepad:    []ebiten.StandardGamepadButton{ebiten.StandardGamepadButtonLeftTop},
    46  
    47  	ConfirmKeyboard: []ebiten.Key{ebiten.KeyEnter, ebiten.KeyKPEnter},
    48  	ConfirmMouse:    []ebiten.MouseButton{ebiten.MouseButtonLeft, ebiten.MouseButtonRight},
    49  	ConfirmGamepad:  []ebiten.StandardGamepadButton{ebiten.StandardGamepadButtonRightBottom},
    50  }
    51  

View as plain text