package input
import (
"fmt"
"strconv"
"time"
"github.com/mailru/easyjson"
"github.com/mailru/easyjson/jlexer"
"github.com/mailru/easyjson/jwriter"
)
type TouchPoint struct {
X float64 `json:"x"`
Y float64 `json:"y"`
RadiusX float64 `json:"radiusX,omitempty"`
RadiusY float64 `json:"radiusY,omitempty"`
RotationAngle float64 `json:"rotationAngle,omitempty"`
Force float64 `json:"force,omitempty"`
TangentialPressure float64 `json:"tangentialPressure,omitempty"`
TiltX float64 `json:"tiltX,omitempty"`
TiltY float64 `json:"tiltY,omitempty"`
Twist int64 `json:"twist,omitempty"`
ID float64 `json:"id,omitempty"`
}
type GestureSourceType string
func (t GestureSourceType ) String () string {
return string (t )
}
const (
GestureDefault GestureSourceType = "default"
GestureTouch GestureSourceType = "touch"
GestureMouse GestureSourceType = "mouse"
)
func (t GestureSourceType ) MarshalEasyJSON (out *jwriter .Writer ) {
out .String (string (t ))
}
func (t GestureSourceType ) MarshalJSON () ([]byte , error ) {
return easyjson .Marshal (t )
}
func (t *GestureSourceType ) UnmarshalEasyJSON (in *jlexer .Lexer ) {
v := in .String ()
switch GestureSourceType (v ) {
case GestureDefault :
*t = GestureDefault
case GestureTouch :
*t = GestureTouch
case GestureMouse :
*t = GestureMouse
default :
in .AddError (fmt .Errorf ("unknown GestureSourceType value: %v" , v ))
}
}
func (t *GestureSourceType ) UnmarshalJSON (buf []byte ) error {
return easyjson .Unmarshal (buf , t )
}
type MouseButton string
func (t MouseButton ) String () string {
return string (t )
}
const (
None MouseButton = "none"
Left MouseButton = "left"
Middle MouseButton = "middle"
Right MouseButton = "right"
Back MouseButton = "back"
Forward MouseButton = "forward"
)
func (t MouseButton ) MarshalEasyJSON (out *jwriter .Writer ) {
out .String (string (t ))
}
func (t MouseButton ) MarshalJSON () ([]byte , error ) {
return easyjson .Marshal (t )
}
func (t *MouseButton ) UnmarshalEasyJSON (in *jlexer .Lexer ) {
v := in .String ()
switch MouseButton (v ) {
case None :
*t = None
case Left :
*t = Left
case Middle :
*t = Middle
case Right :
*t = Right
case Back :
*t = Back
case Forward :
*t = Forward
default :
in .AddError (fmt .Errorf ("unknown MouseButton value: %v" , v ))
}
}
func (t *MouseButton ) UnmarshalJSON (buf []byte ) error {
return easyjson .Unmarshal (buf , t )
}
type TimeSinceEpoch time .Time
func (t TimeSinceEpoch ) Time () time .Time {
return time .Time (t )
}
func (t TimeSinceEpoch ) MarshalEasyJSON (out *jwriter .Writer ) {
v := float64 (time .Time (t ).UnixNano () / int64 (time .Second ))
out .Buffer .EnsureSpace (20 )
out .Buffer .Buf = strconv .AppendFloat (out .Buffer .Buf , v , 'f' , -1 , 64 )
}
func (t TimeSinceEpoch ) MarshalJSON () ([]byte , error ) {
return easyjson .Marshal (t )
}
func (t *TimeSinceEpoch ) UnmarshalEasyJSON (in *jlexer .Lexer ) {
*t = TimeSinceEpoch (time .Unix (0 , int64 (in .Float64 ()*float64 (time .Second ))))
}
func (t *TimeSinceEpoch ) UnmarshalJSON (buf []byte ) error {
return easyjson .Unmarshal (buf , t )
}
type DragDataItem struct {
MimeType string `json:"mimeType"`
Data string `json:"data"`
Title string `json:"title,omitempty"`
BaseURL string `json:"baseURL,omitempty"`
}
type DragData struct {
Items []*DragDataItem `json:"items"`
Files []string `json:"files,omitempty"`
DragOperationsMask int64 `json:"dragOperationsMask"`
}
type Modifier int64
func (t Modifier ) Int64 () int64 {
return int64 (t )
}
const (
ModifierNone Modifier = 0
ModifierAlt Modifier = 1
ModifierCtrl Modifier = 2
ModifierMeta Modifier = 4
ModifierShift Modifier = 8
)
func (t Modifier ) String () string {
switch t {
case ModifierNone :
return "None"
case ModifierAlt :
return "Alt"
case ModifierCtrl :
return "Ctrl"
case ModifierMeta :
return "Meta"
case ModifierShift :
return "Shift"
}
return fmt .Sprintf ("Modifier(%d)" , t )
}
func (t Modifier ) MarshalEasyJSON (out *jwriter .Writer ) {
out .Int64 (int64 (t ))
}
func (t Modifier ) MarshalJSON () ([]byte , error ) {
return easyjson .Marshal (t )
}
func (t *Modifier ) UnmarshalEasyJSON (in *jlexer .Lexer ) {
v := in .Int64 ()
switch Modifier (v ) {
case ModifierNone :
*t = ModifierNone
case ModifierAlt :
*t = ModifierAlt
case ModifierCtrl :
*t = ModifierCtrl
case ModifierMeta :
*t = ModifierMeta
case ModifierShift :
*t = ModifierShift
default :
in .AddError (fmt .Errorf ("unknown Modifier value: %v" , v ))
}
}
func (t *Modifier ) UnmarshalJSON (buf []byte ) error {
return easyjson .Unmarshal (buf , t )
}
const ModifierCommand Modifier = ModifierMeta
type DispatchDragEventType string
func (t DispatchDragEventType ) String () string {
return string (t )
}
const (
DragEnter DispatchDragEventType = "dragEnter"
DragOver DispatchDragEventType = "dragOver"
Drop DispatchDragEventType = "drop"
DragCancel DispatchDragEventType = "dragCancel"
)
func (t DispatchDragEventType ) MarshalEasyJSON (out *jwriter .Writer ) {
out .String (string (t ))
}
func (t DispatchDragEventType ) MarshalJSON () ([]byte , error ) {
return easyjson .Marshal (t )
}
func (t *DispatchDragEventType ) UnmarshalEasyJSON (in *jlexer .Lexer ) {
v := in .String ()
switch DispatchDragEventType (v ) {
case DragEnter :
*t = DragEnter
case DragOver :
*t = DragOver
case Drop :
*t = Drop
case DragCancel :
*t = DragCancel
default :
in .AddError (fmt .Errorf ("unknown DispatchDragEventType value: %v" , v ))
}
}
func (t *DispatchDragEventType ) UnmarshalJSON (buf []byte ) error {
return easyjson .Unmarshal (buf , t )
}
type KeyType string
func (t KeyType ) String () string {
return string (t )
}
const (
KeyDown KeyType = "keyDown"
KeyUp KeyType = "keyUp"
KeyRawDown KeyType = "rawKeyDown"
KeyChar KeyType = "char"
)
func (t KeyType ) MarshalEasyJSON (out *jwriter .Writer ) {
out .String (string (t ))
}
func (t KeyType ) MarshalJSON () ([]byte , error ) {
return easyjson .Marshal (t )
}
func (t *KeyType ) UnmarshalEasyJSON (in *jlexer .Lexer ) {
v := in .String ()
switch KeyType (v ) {
case KeyDown :
*t = KeyDown
case KeyUp :
*t = KeyUp
case KeyRawDown :
*t = KeyRawDown
case KeyChar :
*t = KeyChar
default :
in .AddError (fmt .Errorf ("unknown KeyType value: %v" , v ))
}
}
func (t *KeyType ) UnmarshalJSON (buf []byte ) error {
return easyjson .Unmarshal (buf , t )
}
type MouseType string
func (t MouseType ) String () string {
return string (t )
}
const (
MousePressed MouseType = "mousePressed"
MouseReleased MouseType = "mouseReleased"
MouseMoved MouseType = "mouseMoved"
MouseWheel MouseType = "mouseWheel"
)
func (t MouseType ) MarshalEasyJSON (out *jwriter .Writer ) {
out .String (string (t ))
}
func (t MouseType ) MarshalJSON () ([]byte , error ) {
return easyjson .Marshal (t )
}
func (t *MouseType ) UnmarshalEasyJSON (in *jlexer .Lexer ) {
v := in .String ()
switch MouseType (v ) {
case MousePressed :
*t = MousePressed
case MouseReleased :
*t = MouseReleased
case MouseMoved :
*t = MouseMoved
case MouseWheel :
*t = MouseWheel
default :
in .AddError (fmt .Errorf ("unknown MouseType value: %v" , v ))
}
}
func (t *MouseType ) UnmarshalJSON (buf []byte ) error {
return easyjson .Unmarshal (buf , t )
}
type DispatchMouseEventPointerType string
func (t DispatchMouseEventPointerType ) String () string {
return string (t )
}
const (
Mouse DispatchMouseEventPointerType = "mouse"
Pen DispatchMouseEventPointerType = "pen"
)
func (t DispatchMouseEventPointerType ) MarshalEasyJSON (out *jwriter .Writer ) {
out .String (string (t ))
}
func (t DispatchMouseEventPointerType ) MarshalJSON () ([]byte , error ) {
return easyjson .Marshal (t )
}
func (t *DispatchMouseEventPointerType ) UnmarshalEasyJSON (in *jlexer .Lexer ) {
v := in .String ()
switch DispatchMouseEventPointerType (v ) {
case Mouse :
*t = Mouse
case Pen :
*t = Pen
default :
in .AddError (fmt .Errorf ("unknown DispatchMouseEventPointerType value: %v" , v ))
}
}
func (t *DispatchMouseEventPointerType ) UnmarshalJSON (buf []byte ) error {
return easyjson .Unmarshal (buf , t )
}
type TouchType string
func (t TouchType ) String () string {
return string (t )
}
const (
TouchStart TouchType = "touchStart"
TouchEnd TouchType = "touchEnd"
TouchMove TouchType = "touchMove"
TouchCancel TouchType = "touchCancel"
)
func (t TouchType ) MarshalEasyJSON (out *jwriter .Writer ) {
out .String (string (t ))
}
func (t TouchType ) MarshalJSON () ([]byte , error ) {
return easyjson .Marshal (t )
}
func (t *TouchType ) UnmarshalEasyJSON (in *jlexer .Lexer ) {
v := in .String ()
switch TouchType (v ) {
case TouchStart :
*t = TouchStart
case TouchEnd :
*t = TouchEnd
case TouchMove :
*t = TouchMove
case TouchCancel :
*t = TouchCancel
default :
in .AddError (fmt .Errorf ("unknown TouchType value: %v" , v ))
}
}
func (t *TouchType ) UnmarshalJSON (buf []byte ) error {
return easyjson .Unmarshal (buf , t )
}
The pages are generated with Golds v0.8.2 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .