Open Shieriker opened 5 months ago
Hi, "toggle mode" is a bit complex to implement, there is no way to toggle mode right now. But if what you need is an always activated gyro mode, you can use a gyro mode as the default mode. In the config file, the first mode is the default mode, replace it with a [gyro] mode like:
[[Mode]]
Mode = '[gyro] -id MouseMode' <-------------------- use [gyro] as the first(default) mode
Rules = [
'[trigger] gyro -> [cursor] -speed 0.03',
...
]
.. other modes
i saw that in the documentation, but when i tired that method i get the panic message and it closes
i just tried that method with the speech mode and it worked, is only when i put the gyro at the first mode on the list when it closes automatically
@Shieriker Can you launch it with terminal, and paste the panic message here?
panic: runtime error: invalid memory address or nil pointer dereference [signal 0xc0000005 code=0x0 addr=0x8 pc=0x7ff77bfa48e2]
goroutine 1 [running]: github.com/aj3423/joy-typing/mode.(GyroMode).OnEnter(0xc00029af90, 0x0) /e/go/joy-typing/mode/mode.go:96 +0x22 github.com/aj3423/joy-typing/mode.(ModeManager).switchTo(0x7ff77c4551a0, {0xc0001194f0, 0x9}, 0x3?) /e/go/joy-typing/mode/mode_manager.go:89 +0xbd github.com/aj3423/joy-typing/mode.(*ModeManager).SetModes(0x7ff77c4551a0, {0xc00010cca0, 0x2, 0x7ff77c0e6d40?}, {0x7ff77c4aab78?, 0x7ff77c0f67c0?, 0xc000097ea0?}) /e/go/joy-typing/mode/mode_manager.go:48 +0x1b0 main.loadConfig() /e/go/joy-typing/main/config.go:64 +0x218 main.main() /e/go/joy-typing/main/main.go:117 +0xaa
I see why it crashes, entering gyro mode is supposed to be triggered by an input event, like a button press, so I can activate the gyro on that particular side. But when it's used as default mode, there is no input yet, which causes the crash:
func (g *GyroMode) OnEnter(in *Input) error {
go in.Jc.EnableGyro(true) <-------- in is nil
return g.Mode.OnEnter(in)
}
There is no simple way to solve this, but I got some new idea:
it worked, ty
i need like a toggle instead of a switch so the gyroscope can be always active for the mouse movement