init: 自 zomaintain/backend/rdplib 平移独立成库; module path 从上游 github.com/nakagami/grdp 改为 git.zeroonesoft.cn/golib/rdplib

This commit is contained in:
w11
2026-09-19 18:55:43 +08:00
commit 1096fbce9d
94 changed files with 36790 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
package grdp
import (
"testing"
"git.zeroonesoft.cn/golib/rdplib/protocol/pdu"
)
// 慢路径 Serialize 原样输出 KeyCode;0xE0xx 约定必须拆成
// KBDFLAGS_EXTENDED + 8 位扫描码,否则服务器收到非法扫描码直接丢弃
// (实测症状:远端按 Delete 删不掉文件)。
func TestNewScancodeEventExtended(t *testing.T) {
cases := []struct {
sc int
release bool
flags uint16
key uint16
}{
{0xE053, false, pdu.KBDFLAGS_EXTENDED, 0x53}, // Delete down
{0xE053, true, pdu.KBDFLAGS_EXTENDED | pdu.KBDFLAGS_RELEASE, 0x53}, // Delete up
{0xE048, false, pdu.KBDFLAGS_EXTENDED, 0x48}, // ArrowUp
{0x39, false, 0, 0x39}, // Space:无前缀不动
{0x1C, true, pdu.KBDFLAGS_RELEASE, 0x1C}, // Enter up
{0xE01C, false, pdu.KBDFLAGS_EXTENDED, 0x1C}, // NumpadEnter
}
for _, c := range cases {
p := newScancodeEvent(c.sc, c.release)
if p.KeyboardFlags != c.flags || p.KeyCode != c.key {
t.Fatalf("sc=%#x release=%v: got flags=%#x key=%#x, want flags=%#x key=%#x",
c.sc, c.release, p.KeyboardFlags, p.KeyCode, c.flags, c.key)
}
}
}