[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$ - third_party$
- builtin$ - builtin$
- examples$ - examples$

View File

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

View File

@ -326,8 +326,11 @@ func startBacklightTickers() {
dimTicker = time.NewTicker(time.Duration(config.DisplayDimAfterSec) * time.Second) dimTicker = time.NewTicker(time.Duration(config.DisplayDimAfterSec) * time.Second)
go func() { go func() {
for range dimTicker.C { for { //nolint:staticcheck
tick_displayDim() select {
case <-dimTicker.C:
tick_displayDim()
}
} }
}() }()
} }
@ -337,8 +340,11 @@ func startBacklightTickers() {
offTicker = time.NewTicker(time.Duration(config.DisplayOffAfterSec) * time.Second) offTicker = time.NewTicker(time.Duration(config.DisplayOffAfterSec) * time.Second)
go func() { go func() {
for range offTicker.C { for { //nolint:staticcheck
tick_displayOff() 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]...)) _, err := u.writeWithTimeout(u.keyboardHidFile, append([]byte{modifier, 0x00}, keys[:hidKeyBufferSize]...))
if err != nil { if err != nil {
u.logWithSuppression("keyboardWriteHidFile", 100, u.log, err, "failed to write to hidg0") 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 return err
} }
u.resetLogSuppressionCounter("keyboardWriteHidFile") u.resetLogSuppressionCounter("keyboardWriteHidFile")

View File

@ -77,7 +77,8 @@ func (u *UsbGadget) absMouseWriteHidFile(data []byte) error {
_, err := u.writeWithTimeout(u.absMouseHidFile, data) _, err := u.writeWithTimeout(u.absMouseHidFile, data)
if err != nil { if err != nil {
u.logWithSuppression("absMouseWriteHidFile", 100, u.log, err, "failed to write to hidg1") 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 return err
} }
u.resetLogSuppressionCounter("absMouseWriteHidFile") u.resetLogSuppressionCounter("absMouseWriteHidFile")

View File

@ -60,14 +60,15 @@ func (u *UsbGadget) relMouseWriteHidFile(data []byte) error {
var err error var err error
u.relMouseHidFile, err = os.OpenFile("/dev/hidg2", os.O_RDWR, 0666) u.relMouseHidFile, err = os.OpenFile("/dev/hidg2", os.O_RDWR, 0666)
if err != nil { 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) _, err := u.writeWithTimeout(u.relMouseHidFile, data)
if err != nil { if err != nil {
u.logWithSuppression("relMouseWriteHidFile", 100, u.log, err, "failed to write to hidg2") 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 return err
} }
u.resetLogSuppressionCounter("relMouseWriteHidFile") u.resetLogSuppressionCounter("relMouseWriteHidFile")

View File

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