@@ -76,7 +76,7 @@ var keyboardReportDesc = []byte{
7676
7777const (
7878 hidReadBufferSize = 8
79- hidKeyBufferSize = 6
79+ HidKeyBufferSize = 6
8080 hidErrorRollOver = 0x01
8181 // https://www.usb.org/sites/default/files/documents/hid1_11.pdf
8282 // https://www.usb.org/sites/default/files/hut1_2.pdf
@@ -342,7 +342,7 @@ func (u *UsbGadget) keyboardWriteHidFile(modifier byte, keys []byte) error {
342342 return err
343343 }
344344
345- _ , err := u .writeWithTimeout (u .keyboardHidFile , append ([]byte {modifier , 0x00 }, keys [:hidKeyBufferSize ]... ))
345+ _ , err := u .writeWithTimeout (u .keyboardHidFile , append ([]byte {modifier , 0x00 }, keys [:HidKeyBufferSize ]... ))
346346 if err != nil {
347347 u .logWithSuppression ("keyboardWriteHidFile" , 100 , u .log , err , "failed to write to hidg0" )
348348 u .keyboardHidFile .Close ()
@@ -386,11 +386,11 @@ func (u *UsbGadget) UpdateKeysDown(modifier byte, keys []byte) KeysDownState {
386386func (u * UsbGadget ) KeyboardReport (modifier byte , keys []byte ) error {
387387 defer u .resetUserInputTime ()
388388
389- if len (keys ) > hidKeyBufferSize {
390- keys = keys [:hidKeyBufferSize ]
389+ if len (keys ) > HidKeyBufferSize {
390+ keys = keys [:HidKeyBufferSize ]
391391 }
392- if len (keys ) < hidKeyBufferSize {
393- keys = append (keys , make ([]byte , hidKeyBufferSize - len (keys ))... )
392+ if len (keys ) < HidKeyBufferSize {
393+ keys = append (keys , make ([]byte , HidKeyBufferSize - len (keys ))... )
394394 }
395395
396396 err := u .keyboardWriteHidFile (modifier , keys )
@@ -473,7 +473,7 @@ func (u *UsbGadget) keypressReport(key byte, press bool) (KeysDownState, error)
473473 // handle other keys that are not modifier keys by placing or removing them
474474 // from the key buffer since the buffer tracks currently pressed keys
475475 overrun := true
476- for i := range hidKeyBufferSize {
476+ for i := range HidKeyBufferSize {
477477 // If we find the key in the buffer the buffer, we either remove it (if press is false)
478478 // or do nothing (if down is true) because the buffer tracks currently pressed keys
479479 // and if we find a zero byte, we can place the key there (if press is true)
@@ -484,7 +484,7 @@ func (u *UsbGadget) keypressReport(key byte, press bool) (KeysDownState, error)
484484 // we are releasing the key, remove it from the buffer
485485 if keys [i ] != 0 {
486486 copy (keys [i :], keys [i + 1 :])
487- keys [hidKeyBufferSize - 1 ] = 0 // Clear the last byte
487+ keys [HidKeyBufferSize - 1 ] = 0 // Clear the last byte
488488 }
489489 }
490490 overrun = false // We found a slot for the key
0 commit comments