Skip to content

package hid

import "kaiju/hid"

Constants

ControllerButtonUp

iota

ControllerButtonDown

ControllerButtonLeft

ControllerButtonRight

ControllerButtonStart

ControllerButtonSelect

ControllerButtonLeftStick

ControllerButtonRightStick

ControllerButtonLeftBumper

ControllerButtonRightBumper

ControllerButtonEx1

TODO

Name

this

correctly

ControllerButtonEx2

TODO

Name

this

correctly

ControllerButtonA

ControllerButtonB

ControllerButtonX

ControllerButtonY

ControllerButtonMax

ControllerAxisLeftVertical

iota

ControllerAxisLeftHorizontal

ControllerAxisRightVertical

ControllerAxisRightHorizontal

ControllerAxisLeftTrigger

ControllerAxisRightTrigger

ControllerAxisMax

MouseButtonLeft

iota

MouseButtonMiddle

MouseButtonRight

MouseButtonX1

MouseButtonX2

MouseButtonLast

MouseInvalid

-1

MouseRelease

iota

MousePress

MouseRepeat

MouseButtonStateInvalid

-1

AMotionEventActionIdle

99

AMotionEventActionHeld

100

AMotionEventActionHoverEnter

1 + iota

AMotionEventActionHoverMove

AMotionEventActionHoverExit

AMotionEventActionHover

AMotionEventActionDown

AMotionEventActionMove

AMotionEventActionUp

ControllerMaxDevices

8

MaxTouchPointersAvailable

10

Types

Controller

struct

type Controller struct {
    // Has unexported fields.
}

NewController

func NewController() Controller

NewController creates a new controller. This is called automatically by the system and should not be called by the end-developer

Controller.Available

func (c *Controller) Available(id int) bool

Available returns true if the controller is available. This is called automatically by the system and should not be called by the end-developer

Controller.Axis

func (c *Controller) Axis(id, stick int) float32

Axis returns the axis value for the given controller and stick

Controller.Connected

func (c *Controller) Connected(id int)

Connected returns true if the controller is connected. This is called automatically by the system and should not be called by the end-developer

Controller.Disconnected

func (c *Controller) Disconnected(id int)

Disconnected returns true if the controller is disconnected. This is called automatically by the system and should not be called by the end-developer

Controller.EndUpdate

func (c *Controller) EndUpdate()

EndUpdate is called at the end of the frame. It updates the state of each controller for the next frame. This is called automatically by the system and should not be called by the end-developer

Controller.IsButtonDown

func (c *Controller) IsButtonDown(id, button int) bool

IsButtonDown returns true if the button is down

Controller.IsButtonHeld

func (c *Controller) IsButtonHeld(id, button int) bool

IsButtonHeld returns true if the button is held

Controller.IsButtonUp

func (c *Controller) IsButtonUp(id, button int) bool

IsButtonUp returns true if the button is up

Controller.Reset

func (c *Controller) Reset()

Reset will completely wipe the state of all controllers

Controller.SetAxis

func (c *Controller) SetAxis(id, stick int, axis float32)

SetAxis sets the axis on the given controller. This is called automatically by the system and should not be called by the end-developer

Controller.SetButtonDown

func (c *Controller) SetButtonDown(id, button int)

SetButtonDown sets the button down on the given controller. This is called automatically by the system and should not be called by the end-developer

Controller.SetButtonUp

func (c *Controller) SetButtonUp(id, button int)

SetButtonUp sets the button up on the given controller. This is called automatically by the system and should not be called by the end-developer

ControllerDevice

struct

type ControllerDevice struct {
    // Has unexported fields.
}

Cursor

struct

type Cursor struct {
    // Has unexported fields.
}

NewCursor

func NewCursor(mouse *Mouse, touch *Touch, stylus *Stylus) Cursor

Cursor.DragData

func (c *Cursor) DragData() (any, bool)

Cursor.HasDragData

func (c *Cursor) HasDragData() bool

Cursor.Held

func (c *Cursor) Held() bool

Cursor.Moved

func (c *Cursor) Moved() bool

Cursor.Poll

func (c *Cursor) Poll()

Cursor.Position

func (c *Cursor) Position() matrix.Vec2

Cursor.Pressed

func (c *Cursor) Pressed() bool

Cursor.Released

func (c *Cursor) Released() bool

Cursor.ScreenPosition

func (c *Cursor) ScreenPosition() matrix.Vec2

Cursor.UIPosition

func (c *Cursor) UIPosition(uiSize, windowSize matrix.Vec2) matrix.Vec2

DragData

interface

type DragData interface {
    DragUpdate()
}

KeyState

uint8

type KeyState = uint8

const ( KeyStateIdle KeyState = iota KeyStateDown KeyStateHeld KeyStateUp KeyStatePressedAndReleased )

Keyboard

struct

type Keyboard struct {
    // Has unexported fields.
}

NewKeyboard

func NewKeyboard() Keyboard

Keyboard.AddKeyCallback

func (k *Keyboard) AddKeyCallback(cb func(keyId int, keyState KeyState)) int

Keyboard.EndUpdate

func (k *Keyboard) EndUpdate()

Keyboard.HasAlt

func (k Keyboard) HasAlt() bool

Keyboard.HasCtrl

func (k Keyboard) HasCtrl() bool

Keyboard.HasShift

func (k Keyboard) HasShift() bool

Keyboard.KeyDown

func (k Keyboard) KeyDown(key KeyboardKey) bool

Keyboard.KeyHeld

func (k Keyboard) KeyHeld(key KeyboardKey) bool

Keyboard.KeyToRune

func (k *Keyboard) KeyToRune(key KeyboardKey) rune

Keyboard.KeyUp

func (k Keyboard) KeyUp(key KeyboardKey) bool

Keyboard.RemoveKeyCallback

func (k *Keyboard) RemoveKeyCallback(id int)

Keyboard.Reset

func (k *Keyboard) Reset()

Keyboard.SetKeyDown

func (k *Keyboard) SetKeyDown(key KeyboardKey)

Keyboard.SetKeyDownUp

func (k *Keyboard) SetKeyDownUp(key KeyboardKey)

Keyboard.SetKeyUp

func (k *Keyboard) SetKeyUp(key KeyboardKey)

KeyboardKey

int

type KeyboardKey = int

const ( KeyBoardKeyInvalid KeyboardKey = -1 + iota KeyboardKeyLeftAlt KeyboardKeyRightAlt KeyboardKeyLeftCtrl KeyboardKeyRightCtrl KeyboardKeyLeftShift KeyboardKeyRightShift KeyboardKeyA KeyboardKeyB KeyboardKeyC KeyboardKeyD KeyboardKeyE KeyboardKeyF KeyboardKeyG KeyboardKeyH KeyboardKeyI KeyboardKeyJ KeyboardKeyK KeyboardKeyL KeyboardKeyM KeyboardKeyN KeyboardKeyO KeyboardKeyP KeyboardKeyQ KeyboardKeyR KeyboardKeyS KeyboardKeyT KeyboardKeyU KeyboardKeyV KeyboardKeyW KeyboardKeyX KeyboardKeyY KeyboardKeyZ KeyboardKeyLeft KeyboardKeyUp KeyboardKeyRight KeyboardKeyDown KeyboardKeyEscape KeyboardKeyTab KeyboardKeySpace KeyboardKeyBackspace KeyboardKeyBackQuote KeyboardKeyDelete KeyboardKeyReturn KeyboardKeyEnter KeyboardKeyComma KeyboardKeyPeriod KeyboardKeyBackSlash KeyboardKeyForwardSlash KeyboardKeyOpenBracket KeyboardKeyCloseBracket KeyboardKeySemicolon KeyboardKeyQuote KeyboardKeyEqual KeyboardKeyMinus KeyboardKey0 KeyboardKey1 KeyboardKey2 KeyboardKey3 KeyboardKey4 KeyboardKey5 KeyboardKey6 KeyboardKey7 KeyboardKey8 KeyboardKey9 KeyboardNumKey0 KeyboardNumKey1 KeyboardNumKey2 KeyboardNumKey3 KeyboardNumKey4 KeyboardNumKey5 KeyboardNumKey6 KeyboardNumKey7 KeyboardNumKey8 KeyboardNumKey9 KeyboardKeyF1 KeyboardKeyF2 KeyboardKeyF3 KeyboardKeyF4 KeyboardKeyF5 KeyboardKeyF6 KeyboardKeyF7 KeyboardKeyF8 KeyboardKeyF9 KeyboardKeyF10 KeyboardKeyF11 KeyboardKeyF12 KeyboardKeyCapsLock KeyboardKeyScrollLock KeyboardKeyNumLock KeyboardKeyPrintScreen KeyboardKeyPause KeyboardKeyInsert KeyboardKeyHome KeyboardKeyPageUp KeyboardKeyPageDown KeyboardKeyEnd KeyboardKeyMaximum )

ToKeyboardKey

func ToKeyboardKey(nativeKey int) KeyboardKey

Mouse

struct

type Mouse struct {
    X, Y             float32
    SX, SY           float32
    CX, CY           float32
    ScrollX, ScrollY float32

    OnDragStop events.Event

    // Has unexported fields.
}

NewMouse

func NewMouse() Mouse

Mouse.ButtonChanged

func (m Mouse) ButtonChanged() bool

Mouse.ButtonState

func (m Mouse) ButtonState(index int) int

Mouse.CenteredPosition

func (m Mouse) CenteredPosition() matrix.Vec2

Mouse.DragData

func (m Mouse) DragData() any

Mouse.EndUpdate

func (m *Mouse) EndUpdate()

Mouse.Held

func (m Mouse) Held(index int) bool

Mouse.Moved

func (m Mouse) Moved() bool

Mouse.Position

func (m Mouse) Position() matrix.Vec2

Mouse.Pressed

func (m Mouse) Pressed(index int) bool

Mouse.Released

func (m Mouse) Released(index int) bool

Mouse.Reset

func (m *Mouse) Reset()

Mouse.ScreenPosition

func (m Mouse) ScreenPosition() matrix.Vec2

Mouse.Scroll

func (m Mouse) Scroll() matrix.Vec2

Mouse.Scrolled

func (m Mouse) Scrolled() bool

Mouse.SetDown

func (m *Mouse) SetDown(index int)

Mouse.SetDragData

func (m *Mouse) SetDragData(data DragData)

Mouse.SetPosition

func (m *Mouse) SetPosition(x, y, windowWidth, windowHeight float32)

Mouse.SetScroll

func (m *Mouse) SetScroll(x, y float32)

Mouse.SetUp

func (m *Mouse) SetUp(index int)

Stylus

struct

type Stylus struct {
    X        float32
    Y        float32
    IY       float32
    Pressure float32
    Distance float32
    // Has unexported fields.
}

NewStylus

func NewStylus() Stylus

Stylus.ActionState

func (s *Stylus) ActionState() int

Stylus.EndUpdate

func (s *Stylus) EndUpdate()

Stylus.Held

func (s *Stylus) Held() bool

Stylus.IsActive

func (s *Stylus) IsActive() bool

Stylus.Moved

func (s *Stylus) Moved() bool

Stylus.Pressed

func (s *Stylus) Pressed() bool

Stylus.Released

func (s *Stylus) Released() bool

Stylus.Reset

func (s *Stylus) Reset()

Stylus.Set

func (s *Stylus) Set(x, y, windowHeight, pressure float32)

Stylus.SetActionState

func (s *Stylus) SetActionState(state StylusActionState)

Stylus.SetDistance

func (s *Stylus) SetDistance(distance float32)

StylusActionState

int

type StylusActionState = int

const ( StylusActionNone StylusActionState = AMotionEventActionIdle StylusActionHoverEnter StylusActionState = AMotionEventActionHoverEnter StylusActionHoverMove StylusActionState = AMotionEventActionHoverMove StylusActionHoverExit StylusActionState = AMotionEventActionHoverExit StylusActionDown StylusActionState = AMotionEventActionDown StylusActionMove StylusActionState = AMotionEventActionMove StylusActionUp StylusActionState = AMotionEventActionUp StylusActionHeld StylusActionState = AMotionEventActionHeld StylusActionHover StylusActionState = AMotionEventActionHover )

Touch

struct

type Touch struct {
    Pointers []*TouchPointer
    Pool     [MaxTouchPointersAvailable]TouchPointer
}

NewTouch

func NewTouch() Touch

Touch.Cancel

func (t *Touch) Cancel()

Touch.Cancelled

func (t *Touch) Cancelled() bool

Touch.EndUpdate

func (t *Touch) EndUpdate()

Touch.Held

func (t *Touch) Held() bool

Touch.Moved

func (t *Touch) Moved() bool

Touch.Pointer

func (t *Touch) Pointer(index int) *TouchPointer

Touch.Pressed

func (t *Touch) Pressed() bool

Touch.Released

func (t *Touch) Released() bool

Touch.Reset

func (t *Touch) Reset()

Touch.SetDown

func (t *Touch) SetDown(id int64, x, y, windowHeight float32)

Touch.SetMoved

func (t *Touch) SetMoved(id int64, x, y, windowHeight float32)

Touch.SetPressure

func (t *Touch) SetPressure(id int64, pressure float32)

Touch.SetUp

func (t *Touch) SetUp(id int64, x, y, windowHeight float32)

TouchAction

int

type TouchAction = int

const ( TouchActionNone TouchAction = -1 TouchActionDown TouchAction = internalTouchActionDown TouchActionUp TouchAction = internalTouchActionUp TouchActionMove TouchAction = internalTouchActionMove TouchActionCancel TouchAction = -2 TouchActionHeld TouchAction = -3 )

TouchPointer

struct

type TouchPointer struct {
    Pressure float32
    X        float32
    Y        float32
    IY       float32
    State    TouchAction
    Id       int64
}