@@ -593,7 +593,7 @@ func sanitizeName(name string) string {
593593}
594594
595595func approxEq (a , b float64 ) bool {
596- return math .Abs (a - b ) < 0.1
596+ return math .Abs (a - b ) < 0.25
597597}
598598
599599func detectShape (x , w , h , w2 , h2 float64 , stepped , hasW2 bool ) KeyShape {
@@ -674,7 +674,7 @@ func buildCharMap(keys []TransportKey) map[string]HIDCombo {
674674
675675 // Sort a copy by position for deterministic first-occurrence behaviour.
676676 // We must not mutate the original slice — it preserves KLE parse order,
677- // which the scancodes metadata override uses (0-based index) .
677+ // which the scancodes metadata override uses.
678678 sorted := make ([]TransportKey , len (keys ))
679679 copy (sorted , keys )
680680 slices .SortStableFunc (sorted , func (a , b TransportKey ) int {
@@ -683,9 +683,8 @@ func buildCharMap(keys []TransportKey) map[string]HIDCombo {
683683 }
684684 return cmp .Compare (a .X , b .X )
685685 })
686- keys = sorted
687686
688- for _ , key := range keys {
687+ for _ , key := range sorted {
689688 if key .Scancode == 0 {
690689 continue // non-typeable keys and decals don't send HID events
691690 }
@@ -703,7 +702,7 @@ func addChar(m map[string]HIDCombo, legend *string, scancode, mods uint8) {
703702 if legend == nil || * legend == "" {
704703 return
705704 }
706- if ! scancodeProducesText (scancode ) {
705+ if ! ScancodeProducesText (scancode ) {
707706 return
708707 }
709708 if utf8 .RuneCountInString (* legend ) != 1 {
@@ -720,31 +719,6 @@ func addChar(m map[string]HIDCombo, legend *string, scancode, mods uint8) {
720719 }
721720}
722721
723- func scancodeProducesText (scancode uint8 ) bool {
724- // Alphabet keys
725- if scancode >= hidA && scancode <= hidZ {
726- return true
727- }
728- // Number row keys
729- if scancode >= hidN1 && scancode <= hidN0 {
730- return true
731- }
732- // Space and printable punctuation keys. Excludes Enter/Escape/Backspace/Tab.
733- if scancode == hidSpace ||
734- (scancode >= hidMinus && scancode <= hidSlash ) ||
735- scancode == hidHash ||
736- scancode == hidISOKey {
737- return true
738- }
739- // Numpad printable characters. Excludes NumLock and KPEnter.
740- if (scancode >= hidKPSlash && scancode <= hidKPPlus ) ||
741- (scancode >= hidKP1 && scancode <= hidKPDot ) {
742- return true
743- }
744-
745- return false
746- }
747-
748722var controlLegendDisplayMap = map [string ]string {
749723 "␛" : "Esc" ,
750724 "␍" : "⏎" ,
@@ -776,7 +750,7 @@ func normalizeControlLegendsForDisplay(keys []TransportKey) {
776750 if k .Scancode == 0 {
777751 continue
778752 }
779- if scancodeProducesText (k .Scancode ) && k .Scancode != hidSpace {
753+ if ScancodeProducesText (k .Scancode ) && k .Scancode != hidSpace {
780754 continue
781755 }
782756 normalize (& k .Legends .Normal )
0 commit comments