add led state pseudo encoding

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2020-01-23 01:52:23 +03:00
parent 457798b0e3
commit aa2ac23130
2 changed files with 25 additions and 0 deletions

View File

@ -61,6 +61,7 @@ const (
EncQEMUPointerMotionChangePseudo EncodingType = -257 EncQEMUPointerMotionChangePseudo EncodingType = -257
EncQEMUExtendedKeyEventPseudo EncodingType = -258 EncQEMUExtendedKeyEventPseudo EncodingType = -258
EncTightPng EncodingType = -260 EncTightPng EncodingType = -260
EncLedStatePseudo EncodingType = -261
EncDesktopNamePseudo EncodingType = -307 EncDesktopNamePseudo EncodingType = -307
EncExtendedDesktopSizePseudo EncodingType = -308 EncExtendedDesktopSizePseudo EncodingType = -308
EncXvpPseudo EncodingType = -309 EncXvpPseudo EncodingType = -309

24
encoding_ledstate.go Normal file
View File

@ -0,0 +1,24 @@
package rfb
import "encoding/binary"
type LedStatePseudoEncoding struct {
State uint8
}
func (*LedStatePseudoEncoding) Supported(Conn) bool {
return true
}
func (*LedStatePseudoEncoding) Type() EncodingType { return EncLedStatePseudo }
func (enc *LedStatePseudoEncoding) Read(c Conn, rect *Rectangle) error {
if err := binary.Read(c, binary.BigEndian, &enc.State); err != nil {
return err
}
return nil
}
func (enc *LedStatePseudoEncoding) Write(c Conn, rect *Rectangle) error {
return binary.Write(c, binary.BigEndian, []byte{enc.State})
}