Switch from Asuka to MyGo, keeping the API client and the feature set: - servers: saved servers, passwordless and password login, proxy, self-signed certificates, per-server device tokens (Keystore), connect form, instance list sheet with switch/disconnect - sessions: virtualized list, search, new session, rename/archive/delete, running indicator, event stream keeps it live - chat: pushed window with system back bar, streaming Markdown via ui/markdown, reasoning and tool rows with image previews, footer menu (read aloud via a Kotlin TTS plugin, copy, fork), user message menu (copy, revert, fork), context usage ring and detail sheet, attachments (photos/files via the document picker), permissions - release builds allow plain http:// LAN servers (Go's net/http dials directly, no cleartext manifest needed) - a local fork of MyGo (third_party/mygo) lowers the Android host's minSdk to 24 (Android 7.0); Go 1.27.4 via mise Version 0.3.0.
54 lines
1.6 KiB
Go
54 lines
1.6 KiB
Go
//go:build !ios
|
|
|
|
package gamepad
|
|
|
|
import (
|
|
"math"
|
|
"testing"
|
|
|
|
"github.com/ebitengine/purego/objc"
|
|
)
|
|
|
|
// A controller GameController makes for tests, of the extended gamepad
|
|
// profile, reads in this package's layout: its y axes turned to go down.
|
|
func TestGameController(t *testing.T) {
|
|
if !loadGC() {
|
|
t.Skip("no GameController.framework")
|
|
}
|
|
saved := gcPresent
|
|
gcPresent = func(objc.ID) bool { return true }
|
|
defer func() { gcPresent = saved }()
|
|
var d *gcPad
|
|
withPool(func() {
|
|
c := objc.ID(objc.GetClass("GCController")).Send(objc.RegisterName("controllerWithExtendedGamepad"))
|
|
if c == 0 {
|
|
return
|
|
}
|
|
d = &gcPad{ctl: c.Send(selRetain)}
|
|
gp := c.Send(selExtended)
|
|
setValue := objc.RegisterName("setValue:")
|
|
gp.Send(buttonSels[South]).Send(setValue, float32(1))
|
|
gp.Send(buttonSels[RightTrigger]).Send(setValue, float32(0.6))
|
|
setAxes := objc.RegisterName("setValueForXAxis:yAxis:")
|
|
gp.Send(selLeftStick).Send(setAxes, float32(0.5), float32(0.25))
|
|
gp.Send(selDpad).Send(setAxes, float32(0), float32(1))
|
|
})
|
|
if d == nil {
|
|
t.Skip("no controllerWithExtendedGamepad")
|
|
}
|
|
defer d.close()
|
|
var s State
|
|
if !d.read(&s) {
|
|
t.Fatal("read failed")
|
|
}
|
|
if !s.Pressed(South) || s.Pressed(East) || !s.Pressed(Up) || s.Pressed(Down) {
|
|
t.Errorf("buttons %v", s.Buttons)
|
|
}
|
|
if math.Abs(float64(s.Value(RightTrigger))-0.6) > 1e-3 {
|
|
t.Errorf("right trigger %v", s.Value(RightTrigger))
|
|
}
|
|
if math.Abs(float64(s.Axes[LeftX])-0.5) > 1e-3 || math.Abs(float64(s.Axes[LeftY])+0.25) > 1e-3 {
|
|
t.Errorf("left stick %v, %v: y should go down", s.Axes[LeftX], s.Axes[LeftY])
|
|
}
|
|
}
|