2
0
mirror of https://github.com/OrbTools/OrbBind synced 2024-10-31 03:20:26 +00:00
OrbBind/keys/keys.go
2020-12-08 00:07:42 -05:00

46 lines
896 B
Go

package keys
import (
"fyne.io/fyne"
)
var (
//KCToASCII keycode to ascii table
KCToASCII map[Code]rune
)
//GetASCIIForSC Returns Ascii for Scancode
func GetASCIIForSC(r uint16) uint16 {
return uint16(KCToASCII[Code(r)])
}
//GetSCForASCII Returns scancode For Ascii
func GetSCForASCII(r uint16) uint16 {
return uint16(ASCIIToKC[rune(r)])
}
func init() {
KCToASCII = make(map[Code]rune)
for x, y := range ASCIIToKC {
KCToASCII[y] = x
}
}
//CKIFyneKeyMap Control Keys interop
func CKIFyneKeyMap(e fyne.KeyName) uint16 {
if val, ok := FyneToKC[e]; ok {
return uint16(val)
}
return 0
}
//CKIKeyNameFromKC Key Name from Keycode
func CKIKeyNameFromKC(r uint16) string {
return Code(r).String()[4:]
}
//CKIKeyNameFromASCII key name from ascii code
func CKIKeyNameFromASCII(r uint16) string {
return ASCIIToKC[rune(r)].String()[4:]
}