@@ -100,7 +100,7 @@ func getKeyboardState(b byte) KeyboardState {
100100 }
101101}
102102
103- func (u * UsbGadget ) updateKeyboardState (state byte ) {
103+ func (u * UsbGadget ) updateKeyboardState (state uint8 ) {
104104 u .keyboardStateLock .Lock ()
105105 defer u .keyboardStateLock .Unlock ()
106106
@@ -185,7 +185,7 @@ func (u *UsbGadget) listenKeyboardEvents() {
185185 l .Trace ().Msg ("starting" )
186186
187187 go func () {
188- buf := make ([]byte , hidReadBufferSize )
188+ buf := make ([]uint8 , hidReadBufferSize )
189189 for {
190190 select {
191191 case <- u .keyboardStateCtx .Done ():
@@ -209,7 +209,7 @@ func (u *UsbGadget) listenKeyboardEvents() {
209209 }
210210 u .resetLogSuppressionCounter ("keyboardHidFileRead" )
211211
212- l .Trace ().Int ("n" , n ).Bytes ("buf" , buf ).Msg ("got data from keyboard" )
212+ l .Trace ().Int ("n" , n ).Uints8 ("buf" , buf ).Msg ("got data from keyboard" )
213213 if n != 1 {
214214 l .Trace ().Int ("n" , n ).Msg ("expected 1 byte, got" )
215215 continue
@@ -245,12 +245,12 @@ func (u *UsbGadget) OpenKeyboardHidFile() error {
245245 return u .openKeyboardHidFile ()
246246}
247247
248- func (u * UsbGadget ) keyboardWriteHidFile (modifier byte , keys []byte ) error {
248+ func (u * UsbGadget ) keyboardWriteHidFile (modifier uint8 , keys []uint8 ) error {
249249 if err := u .openKeyboardHidFile (); err != nil {
250250 return err
251251 }
252252
253- _ , err := u .keyboardHidFile .Write (append ([]byte {modifier , 0x00 }, keys [:]... ))
253+ _ , err := u .keyboardHidFile .Write (append ([]uint8 {modifier , 0x00 }, keys [:hidKeyBufferSize ]... ))
254254 if err != nil {
255255 u .logWithSuppression ("keyboardWriteHidFile" , 100 , u .log , err , "failed to write to hidg0" )
256256 u .keyboardHidFile .Close ()
@@ -261,7 +261,7 @@ func (u *UsbGadget) keyboardWriteHidFile(modifier byte, keys []byte) error {
261261 return nil
262262}
263263
264- func (u * UsbGadget ) KeyboardReport (modifier byte , keys []byte ) error {
264+ func (u * UsbGadget ) KeyboardReport (modifier uint8 , keys []uint8 ) error {
265265 u .keyboardLock .Lock ()
266266 defer u .keyboardLock .Unlock ()
267267 defer u .resetUserInputTime ()
@@ -270,7 +270,7 @@ func (u *UsbGadget) KeyboardReport(modifier byte, keys []byte) error {
270270 keys = keys [:hidKeyBufferSize ]
271271 }
272272 if len (keys ) < hidKeyBufferSize {
273- keys = append (keys , make ([]byte , hidKeyBufferSize - len (keys ))... )
273+ keys = append (keys , make ([]uint8 , hidKeyBufferSize - len (keys ))... )
274274 }
275275
276276 return u .keyboardWriteHidFile (modifier , keys )
@@ -289,12 +289,6 @@ const (
289289 RightSuper = 0xE7 // Right GUI (e.g. Windows key, Apple Command key)
290290)
291291
292- // KeyCodeMask maps a key code to its corresponding bit mask
293- type KeyCodeMask struct {
294- KeyCode byte
295- Mask byte
296- }
297-
298292// KeyCodeToMaskMap is a slice of KeyCodeMask for quick lookup
299293var KeyCodeToMaskMap = map [uint8 ]uint8 {
300294 LeftControl : ModifierMaskLeftControl ,
@@ -307,7 +301,7 @@ var KeyCodeToMaskMap = map[uint8]uint8{
307301 RightSuper : ModifierMaskRightSuper ,
308302}
309303
310- func (u * UsbGadget ) KeypressReport (key byte , press bool ) (KeysDownState , error ) {
304+ func (u * UsbGadget ) KeypressReport (key uint8 , press bool ) (KeysDownState , error ) {
311305 u .keyboardLock .Lock ()
312306 defer u .keyboardLock .Unlock ()
313307 defer u .resetUserInputTime ()
@@ -364,7 +358,7 @@ func (u *UsbGadget) KeypressReport(key byte, press bool) (KeysDownState, error)
364358 }
365359
366360 if err := u .keyboardWriteHidFile (modifier , keys ); err != nil {
367- u .log .Warn ().Uint8 ("modifier" , modifier ).Bytes ("keys" , keys ).Msg ("Could not write keypress report to hidg0" )
361+ u .log .Warn ().Uint8 ("modifier" , modifier ).Uints8 ("keys" , keys ).Msg ("Could not write keypress report to hidg0" )
368362 }
369363
370364 state .Modifier = modifier
0 commit comments