// Button returns the current state of a button on a game controller.
// (https://wiki.libsdl.org/SDL_GameControllerGetButton)
434993
func (ctrl *GameController) Button(btn GameControllerButton) byte {
	return byte(C.SDL_GameControllerGetButton(ctrl.cptr(), btn.c()))
}
1250793
func Click(args ...interface{}) {
	var (
		button C.MMMouseButton = C.LEFT_BUTTON
		double C.bool
	)

	if len(args) > 0 {
		button = CheckMouse(args[0].(string))
	}

	if len(args) > 1 {
		double = C.bool(args[1].(bool))
	}

	C.mouse_click(button, double)
}
184193
func (w *Window) Pressed(button Button) bool {
	return w.currInp.buttons[button]
}
1158668
func (b Button) String() string {
	name, ok := buttonNames[b]
	if !ok {
		return "Invalid"
	}
	return name
}
2916
func Button(name string, text string) *Field {
	ret := FieldWithType(name, formcommon.BUTTON)
	ret.SetText(text)
	return ret
}
1053579
func (w *Window) JoystickPressed(js Joystick, button int) bool {
	return w.currJoy.getButton(js, button)
}
654172
func (ctrl *GameController) BindForAxis(axis GameControllerAxis) GameControllerButtonBind {
	return GameControllerButtonBind(C.SDL_GameControllerGetBindForAxis(ctrl.cptr(), axis.c()))
}
398531
func (a *DispatchMouseEventArgs) SetButton(button string) *DispatchMouseEventArgs {
	a.Button = &button
	return a
}
12057
func (b *MakeyButtonDriver) Start() (err error) {
	state := 1
	go func() {
		timer := time.NewTimer(b.interval)
		timer.Stop()
		for {
			newValue, err := b.connection.DigitalRead(b.Pin())
			if err != nil {
				b.Publish(Error, err)
			} else if newValue != state && newValue != -1 {
				state = newValue
				if newValue == 0 {
					b.Active = true
					b.Publish(ButtonPush, newValue)
				} else {
					b.Active = false
					b.Publish(ButtonRelease, newValue)
				}
			}
			timer.Reset(b.interval)
			select {
			case <-timer.C:
			case <-b.halt:
				return
			}
		}
	}()
	return
}
1310958
func (ctrl *GameController) BindForButton(btn GameControllerButton) GameControllerButtonBind {
	return GameControllerButtonBind(C.SDL_GameControllerGetBindForButton(ctrl.cptr(), btn.c()))
}
1324949
func GameControllerMappingForIndex(index int) string {
	mappingString := C.SDL_GameControllerMappingForIndex(C.int(index))
	defer C.free(unsafe.Pointer(mappingString))
	return C.GoString(mappingString)
}
364980
func actionDefinition() (*design.ActionDefinition, bool) {
	a, ok := dslengine.CurrentDefinition().(*design.ActionDefinition)
	if !ok {
		dslengine.IncompatibleDSL()
	}
	return a, ok
}
175096
func (btn Button) String() string {
	ret := "<button" + btn.Attrs()
	if len(btn.PostBack) > 0 {
		ret += " onclick=\"sendEvent(" + params(btn.PostBack) + ")\""
	}
	ret += ">"
	if btn.HTMLEncode {
		ret += html.EscapeString(btn.Text)
	} else {
		ret += btn.Text
	}
	ret += "</button>"
	return ret
}
442389
func (b *Button) Draw(p *Painter) {
	style := "button"
	if b.IsFocused() {
		style += ".focused"
	}
	p.WithStyle(style, func(p *Painter) {
		lines := strings.Split(b.text, "\n")
		for i, line := range lines {
			p.FillRect(0, i, b.Size().X, 1)
			p.DrawText(0, i, line)
		}
	})
}
167621
func (c *Context) EditInlineButton(om *OutgoingMessage, kbState string, buttonData string, newButtonText string) error {
	return c.EditInlineStateButton(om, kbState, 0, buttonData, 0, newButtonText)

}
968882
func (w *Window) JoystickJustPressed(js Joystick, button int) bool {
	return w.currJoy.getButton(js, button) && !w.prevJoy.getButton(js, button)
}
713258
func ResetButton(name string, text string) *Field {
	ret := FieldWithType(name, formcommon.RESET)
	ret.SetText(text)
	return ret
}