added initial support for qemu led state

This commit is contained in:
amit b
2018-08-20 23:03:39 +03:00
parent f19a75749b
commit 2ccc4009f4
5 changed files with 37 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
package encodings
import (
"io"
"vncproxy/common"
"vncproxy/logger"
)
type EncLedStatePseudo struct {
LedState uint8
}
func (pe *EncLedStatePseudo) Type() int32 {
return int32(common.EncLedStatePseudo)
}
func (pe *EncLedStatePseudo) WriteTo(w io.Writer) (n int, err error) {
w.Write([]byte{pe.LedState})
return 1, nil
}
func (pe *EncLedStatePseudo) Read(pf *common.PixelFormat, rect *common.Rectangle, r *common.RfbReadHelper) (common.IEncoding, error) {
if rect.Width*rect.Height == 0 {
return pe, nil
}
u8, err := r.ReadUint8()
pe.LedState = u8
if err != nil {
logger.Error("error while reading led state: ", err)
return pe, err
}
return pe, nil
}