aj3423 / joy-typing

Use computer with Voice Typing and Joy-Con controller
MIT License
14 stars 1 forks source link

is there a way to make the gyrscope always active? #2

Open Shieriker opened 5 months ago

Shieriker commented 5 months ago

i need like a toggle instead of a switch so the gyroscope can be always active for the mouse movement

aj3423 commented 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
Shieriker commented 5 months ago

i saw that in the documentation, but when i tired that method i get the panic message and it closes

Shieriker commented 5 months ago

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

aj3423 commented 5 months ago

@Shieriker Can you launch it with terminal, and paste the panic message here?

Shieriker commented 5 months ago

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

aj3423 commented 5 months ago

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:

  1. There is actually an REPL shell, try the command "gyro" in the terminal, it should toggle the gyro mode for all connected joycons, type "gyro" again to disable it. image
  2. Use an elastic string, wrap around the joycon, keep a button pressed down :)
Shieriker commented 5 months ago

it worked, ty