Fix direct H.264 issues and optimize UI

feat: support custom mouse wheel speed
fix: prevent direct H.264 stream buffer overflow and replay
style: optimize virtual keyboard layout
style: optimize menu bar and settings styling
This commit is contained in:
wj-xiao
2025-05-22 11:31:08 +08:00
parent ea9068fd0d
commit 01e28f10ae
28 changed files with 439 additions and 342 deletions

View File

@@ -21,9 +21,10 @@ type Frame struct {
}
var (
mutex = sync.Mutex{}
wsMap = make(map[*websocket.Conn]bool)
upgrader = websocket.Upgrader{
mutex = sync.Mutex{}
wsMap = make(map[*websocket.Conn]bool)
isSending = false
upgrader = websocket.Upgrader{
CheckOrigin: func(r *http.Request) bool {
return true
},
@@ -47,7 +48,7 @@ func Connect(c *gin.Context) {
mutex.Lock()
wsMap[ws] = true
if len(wsMap) == 1 {
if len(wsMap) == 1 && !isSending {
go send()
}
mutex.Unlock()
@@ -62,6 +63,7 @@ func Connect(c *gin.Context) {
}
func send() {
isSending = true
screen := common.GetScreen()
common.CheckScreen()
@@ -76,6 +78,7 @@ func send() {
for range ticker.C {
if len(wsMap) == 0 {
isSending = false
return
}

View File

@@ -1,15 +1,15 @@
package vm
import (
"time"
"NanoKVM-Server/common"
"NanoKVM-Server/proto"
"time"
"github.com/gin-gonic/gin"
log "github.com/sirupsen/logrus"
)
// ideally read state from the device
var hdmiEnabled = true
func (s *Service) ResetHdmi(c *gin.Context) {
@@ -53,15 +53,9 @@ func (s *Service) DisableHdmi(c *gin.Context) {
func (s *Service) GetHdmiState(c *gin.Context) {
var rsp proto.Response
if hdmiEnabled {
rsp.OkRspWithData(c, &map[string]string{
"state": "enabled",
})
} else {
rsp.OkRspWithData(c, &map[string]string{
"state": "disabled",
})
}
rsp.OkRspWithData(c, &proto.GetGetHdmiStateRsp{
Enabled: hdmiEnabled,
})
log.Debug("get hdmi state")
}