[WIP] Updates: reduce PR complexity

This commit is contained in:
Alex P 2025-10-01 21:20:30 +03:00
parent 6ccd9fdf19
commit 4c12783107
7 changed files with 18 additions and 16 deletions

View File

@ -42,4 +42,3 @@ formatters:
- third_party$
- builtin$
- examples$

View File

@ -3,6 +3,5 @@
"cva",
"cx"
],
"git.ignoreLimitWarning": true,
"cmake.ignoreCMakeListsMissing": true
"git.ignoreLimitWarning": true
}

View File

@ -326,8 +326,11 @@ func startBacklightTickers() {
dimTicker = time.NewTicker(time.Duration(config.DisplayDimAfterSec) * time.Second)
go func() {
for range dimTicker.C {
tick_displayDim()
for { //nolint:staticcheck
select {
case <-dimTicker.C:
tick_displayDim()
}
}
}()
}
@ -337,8 +340,11 @@ func startBacklightTickers() {
offTicker = time.NewTicker(time.Duration(config.DisplayOffAfterSec) * time.Second)
go func() {
for range offTicker.C {
tick_displayOff()
for { //nolint:staticcheck
select {
case <-offTicker.C:
tick_displayOff()
}
}
}()
}

View File

@ -321,7 +321,8 @@ func (u *UsbGadget) keyboardWriteHidFile(modifier byte, keys []byte) error {
_, err := u.writeWithTimeout(u.keyboardHidFile, append([]byte{modifier, 0x00}, keys[:hidKeyBufferSize]...))
if err != nil {
u.logWithSuppression("keyboardWriteHidFile", 100, u.log, err, "failed to write to hidg0")
// Keep file open on write errors to reduce I/O overhead
u.keyboardHidFile.Close()
u.keyboardHidFile = nil
return err
}
u.resetLogSuppressionCounter("keyboardWriteHidFile")

View File

@ -77,7 +77,8 @@ func (u *UsbGadget) absMouseWriteHidFile(data []byte) error {
_, err := u.writeWithTimeout(u.absMouseHidFile, data)
if err != nil {
u.logWithSuppression("absMouseWriteHidFile", 100, u.log, err, "failed to write to hidg1")
// Keep file open on write errors to reduce I/O overhead
u.absMouseHidFile.Close()
u.absMouseHidFile = nil
return err
}
u.resetLogSuppressionCounter("absMouseWriteHidFile")

View File

@ -60,14 +60,15 @@ func (u *UsbGadget) relMouseWriteHidFile(data []byte) error {
var err error
u.relMouseHidFile, err = os.OpenFile("/dev/hidg2", os.O_RDWR, 0666)
if err != nil {
return fmt.Errorf("failed to open hidg2: %w", err)
return fmt.Errorf("failed to open hidg1: %w", err)
}
}
_, err := u.writeWithTimeout(u.relMouseHidFile, data)
if err != nil {
u.logWithSuppression("relMouseWriteHidFile", 100, u.log, err, "failed to write to hidg2")
// Keep file open on write errors to reduce I/O overhead
u.relMouseHidFile.Close()
u.relMouseHidFile = nil
return err
}
u.resetLogSuppressionCounter("relMouseWriteHidFile")

View File

@ -6,7 +6,6 @@ import (
"io"
"os"
"os/exec"
"runtime"
"github.com/creack/pty"
"github.com/pion/webrtc/v4"
@ -34,10 +33,6 @@ func handleTerminalChannel(d *webrtc.DataChannel) {
}
go func() {
// Lock to OS thread to isolate PTY I/O
runtime.LockOSThread()
defer runtime.UnlockOSThread()
buf := make([]byte, 1024)
for {
n, err := ptmx.Read(buf)