2
0
mirror of https://github.com/OrbTools/OrbBind synced 2024-10-31 03:20:26 +00:00
This commit is contained in:
Minizbot2012 2021-05-03 15:00:08 -04:00
parent a076297776
commit 80b68f1c39
6 changed files with 355 additions and 355 deletions

6
.github/FUNDING.yml vendored
View File

@ -1,3 +1,3 @@
# These are supported funding model platforms
github: [minizbot2012]
# These are supported funding model platforms
github: [minizbot2012]

View File

@ -1,2 +1,2 @@
Orbweaver Mapping utility for orbmap
Orbweaver Mapping utility for orbmap
```go get github.com/OrbTools/orbbind```

View File

@ -1,131 +1,131 @@
package keys
// Common Interface 2, natified go
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/driver/desktop"
)
//ASCIIToKC -- ASCII Value to a KBD Scancode
var ASCIIToKC = map[rune]Code{
'a': CodeA,
'b': CodeB,
'c': CodeC,
'd': CodeD,
'e': CodeE,
'f': CodeF,
'g': CodeG,
'h': CodeH,
'i': CodeI,
'k': CodeK,
'l': CodeL,
'm': CodeM,
'n': CodeN,
'o': CodeO,
'p': CodeP,
'q': CodeQ,
'r': CodeR,
's': CodeS,
't': CodeT,
'u': CodeU,
'v': CodeV,
'w': CodeW,
'x': CodeX,
'y': CodeY,
'z': CodeZ,
'0': Code0,
'1': Code1,
'2': Code2,
'3': Code3,
'4': Code4,
'5': Code5,
'6': Code6,
'7': Code7,
'8': Code8,
'9': Code9,
' ': CodeSpace,
'-': CodeMinus,
'=': CodeEqual,
'[': CodeLeftBrack,
']': CodeRightBrace,
'\\': CodeBackslash,
';': CodeSemicolon,
'\'': CodeApostrophe,
'`': CodeGrave,
',': CodeComma,
'.': CodeDot,
'/': CodeSlash,
}
//FyneToKC - conversion between fyne to ode
var FyneToKC = map[fyne.KeyName]Code{
fyne.Key0: Code0,
fyne.Key1: Code1,
fyne.Key2: Code2,
fyne.Key3: Code3,
fyne.Key4: Code4,
fyne.Key5: Code5,
fyne.Key6: Code6,
fyne.Key7: Code7,
fyne.Key8: Code8,
fyne.Key9: Code9,
fyne.KeyA: CodeA,
fyne.KeyB: CodeB,
fyne.KeyC: CodeC,
fyne.KeyD: CodeD,
fyne.KeyE: CodeE,
fyne.KeyF: CodeF,
fyne.KeyG: CodeG,
fyne.KeyH: CodeH,
fyne.KeyI: CodeI,
fyne.KeyJ: CodeJ,
fyne.KeyK: CodeK,
fyne.KeyL: CodeL,
fyne.KeyM: CodeM,
fyne.KeyN: CodeN,
fyne.KeyO: CodeO,
fyne.KeyP: CodeP,
fyne.KeyQ: CodeQ,
fyne.KeyR: CodeR,
fyne.KeyS: CodeS,
fyne.KeyT: CodeT,
fyne.KeyU: CodeU,
fyne.KeyV: CodeV,
fyne.KeyW: CodeW,
fyne.KeyX: CodeX,
fyne.KeyY: CodeY,
fyne.KeyZ: CodeZ,
fyne.KeyUp: CodeUpArrow,
fyne.KeyDown: CodeDownArrow,
fyne.KeyRight: CodeRightArrow,
fyne.KeyLeft: CodeLeftArrow,
fyne.KeyEnd: CodeEnd,
fyne.KeyHome: CodeHome,
fyne.KeyInsert: CodeInsert,
fyne.KeyDelete: CodeDelete,
fyne.KeyEnter: CodeEnter,
fyne.KeyTab: CodeTab,
fyne.KeyEscape: CodeESC,
fyne.KeyF1: CodeF1,
fyne.KeyF2: CodeF2,
fyne.KeyF3: CodeF3,
fyne.KeyF4: CodeF4,
fyne.KeyF5: CodeF5,
fyne.KeyF6: CodeF6,
fyne.KeyF7: CodeF7,
fyne.KeyF8: CodeF8,
fyne.KeyF9: CodeF9,
fyne.KeyF10: CodeF10,
fyne.KeyF11: CodeF11,
fyne.KeyF12: CodeF12,
fyne.KeyPageDown: CodePageDown,
fyne.KeyPageUp: CodePageUp,
fyne.KeySpace: CodeSpace,
fyne.KeyBackTick: CodeGrave,
desktop.KeyAltLeft: CodeLeftAlt,
desktop.KeyAltRight: CodeRightAlt,
desktop.KeyControlLeft: CodeLeftCntl,
desktop.KeyControlRight: CodeRightControl,
desktop.KeyShiftLeft: CodeLeftShift,
desktop.KeyShiftRight: CodeRightShift,
}
package keys
// Common Interface 2, natified go
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/driver/desktop"
)
//ASCIIToKC -- ASCII Value to a KBD Scancode
var ASCIIToKC = map[rune]Code{
'a': CodeA,
'b': CodeB,
'c': CodeC,
'd': CodeD,
'e': CodeE,
'f': CodeF,
'g': CodeG,
'h': CodeH,
'i': CodeI,
'k': CodeK,
'l': CodeL,
'm': CodeM,
'n': CodeN,
'o': CodeO,
'p': CodeP,
'q': CodeQ,
'r': CodeR,
's': CodeS,
't': CodeT,
'u': CodeU,
'v': CodeV,
'w': CodeW,
'x': CodeX,
'y': CodeY,
'z': CodeZ,
'0': Code0,
'1': Code1,
'2': Code2,
'3': Code3,
'4': Code4,
'5': Code5,
'6': Code6,
'7': Code7,
'8': Code8,
'9': Code9,
' ': CodeSpace,
'-': CodeMinus,
'=': CodeEqual,
'[': CodeLeftBrack,
']': CodeRightBrace,
'\\': CodeBackslash,
';': CodeSemicolon,
'\'': CodeApostrophe,
'`': CodeGrave,
',': CodeComma,
'.': CodeDot,
'/': CodeSlash,
}
//FyneToKC - conversion between fyne to ode
var FyneToKC = map[fyne.KeyName]Code{
fyne.Key0: Code0,
fyne.Key1: Code1,
fyne.Key2: Code2,
fyne.Key3: Code3,
fyne.Key4: Code4,
fyne.Key5: Code5,
fyne.Key6: Code6,
fyne.Key7: Code7,
fyne.Key8: Code8,
fyne.Key9: Code9,
fyne.KeyA: CodeA,
fyne.KeyB: CodeB,
fyne.KeyC: CodeC,
fyne.KeyD: CodeD,
fyne.KeyE: CodeE,
fyne.KeyF: CodeF,
fyne.KeyG: CodeG,
fyne.KeyH: CodeH,
fyne.KeyI: CodeI,
fyne.KeyJ: CodeJ,
fyne.KeyK: CodeK,
fyne.KeyL: CodeL,
fyne.KeyM: CodeM,
fyne.KeyN: CodeN,
fyne.KeyO: CodeO,
fyne.KeyP: CodeP,
fyne.KeyQ: CodeQ,
fyne.KeyR: CodeR,
fyne.KeyS: CodeS,
fyne.KeyT: CodeT,
fyne.KeyU: CodeU,
fyne.KeyV: CodeV,
fyne.KeyW: CodeW,
fyne.KeyX: CodeX,
fyne.KeyY: CodeY,
fyne.KeyZ: CodeZ,
fyne.KeyUp: CodeUpArrow,
fyne.KeyDown: CodeDownArrow,
fyne.KeyRight: CodeRightArrow,
fyne.KeyLeft: CodeLeftArrow,
fyne.KeyEnd: CodeEnd,
fyne.KeyHome: CodeHome,
fyne.KeyInsert: CodeInsert,
fyne.KeyDelete: CodeDelete,
fyne.KeyEnter: CodeEnter,
fyne.KeyTab: CodeTab,
fyne.KeyEscape: CodeESC,
fyne.KeyF1: CodeF1,
fyne.KeyF2: CodeF2,
fyne.KeyF3: CodeF3,
fyne.KeyF4: CodeF4,
fyne.KeyF5: CodeF5,
fyne.KeyF6: CodeF6,
fyne.KeyF7: CodeF7,
fyne.KeyF8: CodeF8,
fyne.KeyF9: CodeF9,
fyne.KeyF10: CodeF10,
fyne.KeyF11: CodeF11,
fyne.KeyF12: CodeF12,
fyne.KeyPageDown: CodePageDown,
fyne.KeyPageUp: CodePageUp,
fyne.KeySpace: CodeSpace,
fyne.KeyBackTick: CodeGrave,
desktop.KeyAltLeft: CodeLeftAlt,
desktop.KeyAltRight: CodeRightAlt,
desktop.KeyControlLeft: CodeLeftCntl,
desktop.KeyControlRight: CodeRightControl,
desktop.KeyShiftLeft: CodeLeftShift,
desktop.KeyShiftRight: CodeRightShift,
}

View File

@ -1,45 +1,45 @@
package keys
import (
"fyne.io/fyne/v2"
)
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:]
}
package keys
import (
"fyne.io/fyne/v2"
)
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:]
}

View File

@ -1,109 +1,109 @@
//go:generate stringer --type Code
//Package keys provides back end keymapping
package keys
//Code ScanCode object
type Code uint16
const (
CodeNone Code = 0
CodeESC Code = 1
Code1 Code = 2
Code2 Code = 3
Code3 Code = 4
Code4 Code = 5
Code5 Code = 6
Code6 Code = 7
Code7 Code = 8
Code8 Code = 9
Code9 Code = 10
Code0 Code = 11
CodeMinus Code = 12
CodeEqual Code = 13
CodeBackspace Code = 14
CodeTab Code = 15
CodeQ Code = 16
CodeW Code = 17
CodeE Code = 18
CodeR Code = 19
CodeT Code = 20
CodeY Code = 21
CodeU Code = 22
CodeI Code = 23
CodeO Code = 24
CodeP Code = 25
CodeLeftBrack Code = 26
CodeRightBrace Code = 27
CodeEnter Code = 28
CodeLeftCntl Code = 29
CodeA Code = 30
CodeS Code = 31
CodeD Code = 32
CodeF Code = 33
CodeG Code = 34
CodeH Code = 35
CodeJ Code = 36
CodeK Code = 37
CodeL Code = 38
CodeSemicolon Code = 39
CodeApostrophe Code = 40
CodeGrave Code = 41
CodeLeftShift Code = 42
CodeBackslash Code = 43
CodeZ Code = 44
CodeX Code = 45
CodeC Code = 46
CodeV Code = 47
CodeB Code = 48
CodeN Code = 49
CodeM Code = 50
CodeComma Code = 51
CodeDot Code = 52
CodeSlash Code = 53
CodeRightShift Code = 54
CodeKPAsterisk Code = 55
CodeLeftAlt Code = 56
CodeSpace Code = 57
CodeCapsLock Code = 58
CodeF1 Code = 59
CodeF2 Code = 60
CodeF3 Code = 61
CodeF4 Code = 62
CodeF5 Code = 63
CodeF6 Code = 64
CodeF7 Code = 65
CodeF8 Code = 66
CodeF9 Code = 67
CodeF10 Code = 68
CodeNumlock Code = 69
CodeScrollLock Code = 70
CodeKP7 Code = 71
CodeKP8 Code = 72
CodeKP9 Code = 73
CodeKPMinus Code = 74
CodeKP4 Code = 75
CodeKP5 Code = 76
CodeKP6 Code = 77
CodeKPPlus Code = 78
CodeKP1 Code = 79
CodeKP2 Code = 80
CodeKP3 Code = 81
CodeKP0 Code = 82
CodeKPDot Code = 83
CodeF11 Code = 87
CodeF12 Code = 88
CodeKPEnter Code = 96
CodeRightControl Code = 97
CodeKPSlash Code = 98
CodeRightAlt Code = 100
CodeHome Code = 102
CodeUpArrow Code = 103
CodePageUp Code = 104
CodeLeftArrow Code = 105
CodeRightArrow Code = 106
CodeEnd Code = 107
CodeDownArrow Code = 108
CodePageDown Code = 109
CodeInsert Code = 110
CodeDelete Code = 111
)
//go:generate stringer --type Code
//Package keys provides back end keymapping
package keys
//Code ScanCode object
type Code uint16
const (
CodeNone Code = 0
CodeESC Code = 1
Code1 Code = 2
Code2 Code = 3
Code3 Code = 4
Code4 Code = 5
Code5 Code = 6
Code6 Code = 7
Code7 Code = 8
Code8 Code = 9
Code9 Code = 10
Code0 Code = 11
CodeMinus Code = 12
CodeEqual Code = 13
CodeBackspace Code = 14
CodeTab Code = 15
CodeQ Code = 16
CodeW Code = 17
CodeE Code = 18
CodeR Code = 19
CodeT Code = 20
CodeY Code = 21
CodeU Code = 22
CodeI Code = 23
CodeO Code = 24
CodeP Code = 25
CodeLeftBrack Code = 26
CodeRightBrace Code = 27
CodeEnter Code = 28
CodeLeftCntl Code = 29
CodeA Code = 30
CodeS Code = 31
CodeD Code = 32
CodeF Code = 33
CodeG Code = 34
CodeH Code = 35
CodeJ Code = 36
CodeK Code = 37
CodeL Code = 38
CodeSemicolon Code = 39
CodeApostrophe Code = 40
CodeGrave Code = 41
CodeLeftShift Code = 42
CodeBackslash Code = 43
CodeZ Code = 44
CodeX Code = 45
CodeC Code = 46
CodeV Code = 47
CodeB Code = 48
CodeN Code = 49
CodeM Code = 50
CodeComma Code = 51
CodeDot Code = 52
CodeSlash Code = 53
CodeRightShift Code = 54
CodeKPAsterisk Code = 55
CodeLeftAlt Code = 56
CodeSpace Code = 57
CodeCapsLock Code = 58
CodeF1 Code = 59
CodeF2 Code = 60
CodeF3 Code = 61
CodeF4 Code = 62
CodeF5 Code = 63
CodeF6 Code = 64
CodeF7 Code = 65
CodeF8 Code = 66
CodeF9 Code = 67
CodeF10 Code = 68
CodeNumlock Code = 69
CodeScrollLock Code = 70
CodeKP7 Code = 71
CodeKP8 Code = 72
CodeKP9 Code = 73
CodeKPMinus Code = 74
CodeKP4 Code = 75
CodeKP5 Code = 76
CodeKP6 Code = 77
CodeKPPlus Code = 78
CodeKP1 Code = 79
CodeKP2 Code = 80
CodeKP3 Code = 81
CodeKP0 Code = 82
CodeKPDot Code = 83
CodeF11 Code = 87
CodeF12 Code = 88
CodeKPEnter Code = 96
CodeRightControl Code = 97
CodeKPSlash Code = 98
CodeRightAlt Code = 100
CodeHome Code = 102
CodeUpArrow Code = 103
CodePageUp Code = 104
CodeLeftArrow Code = 105
CodeRightArrow Code = 106
CodeEnd Code = 107
CodeDownArrow Code = 108
CodePageDown Code = 109
CodeInsert Code = 110
CodeDelete Code = 111
)

View File

@ -1,66 +1,66 @@
package bind
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/driver/desktop"
"fyne.io/fyne/v2/layout"
"fyne.io/fyne/v2/widget"
"fyne.io/fyne/v2/container"
"github.com/OrbTools/OrbBind/keys"
)
//BindingInfo Genral data to use in a channel
type BindingInfo struct {
Bindid int
Bound uint16
}
//Page Binding UI
type Page struct {
dev map[string]fyne.CanvasObject
Bind BindingInfo
window fyne.Window
}
//TypeKey event on key
func (bp *Page) TypeKey(e *fyne.KeyEvent) {
bp.Bind.Bound = keys.CKIFyneKeyMap(e.Name)
kp := keys.CKIKeyNameFromKC(bp.Bind.Bound)
bp.dev["BL"].(*widget.Label).SetText(kp)
}
func (bp *Page) createGrid() *fyne.Container {
cont := fyne.NewContainerWithLayout(layout.NewGridLayoutWithColumns(4))
cont.AddObject(widget.NewButton("Clear", func() {
bp.Bind.Bound = 0x0
bp.dev["BL"].(*widget.Label).SetText(keys.CKIKeyNameFromKC(bp.Bind.Bound))
}))
k1 := widget.NewButton("Tab", func() { bp.TypeKey(&fyne.KeyEvent{Name: fyne.KeyTab}) })
k3 := widget.NewButton("Left Alt", func() { bp.TypeKey(&fyne.KeyEvent{Name: desktop.KeyAltLeft}) })
k5 := widget.NewButton("Left Control", func() { bp.TypeKey(&fyne.KeyEvent{Name: desktop.KeyControlLeft}) })
k7 := widget.NewButton("Left Shift", func() { bp.TypeKey(&fyne.KeyEvent{Name: desktop.KeyShiftLeft}) })
//k8 := widget.NewButton("Grave (`)", func() { bp.TypeKey(&fyne.KeyEvent{Name: fyne.KeyBackTick}) })
cont.AddObject(k1)
cont.AddObject(k3)
cont.AddObject(k5)
cont.AddObject(k7)
return cont
}
//Create the binding page popup
func (bp *Page) Create(bid string) fyne.CanvasObject {
bp.dev = make(map[string]fyne.CanvasObject)
bp.dev["BL"] = widget.NewLabel(keys.CKIKeyNameFromKC(bp.Bind.Bound))
pop := container.NewVBox(bp.dev["BL"], bp.createGrid())
bp.window.Canvas().SetOnTypedKey(bp.TypeKey)
return pop
}
//NewBindPage Create a new bind popup
func NewBindPage(bid int, w fyne.Window, def uint16) *Page {
p := new(Page)
p.window = w
p.Bind.Bindid = bid
p.Bind.Bound = def
return p
}
package bind
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/driver/desktop"
"fyne.io/fyne/v2/layout"
"fyne.io/fyne/v2/widget"
"fyne.io/fyne/v2/container"
"github.com/OrbTools/OrbBind/keys"
)
//BindingInfo Genral data to use in a channel
type BindingInfo struct {
Bindid int
Bound uint16
}
//Page Binding UI
type Page struct {
dev map[string]fyne.CanvasObject
Bind BindingInfo
window fyne.Window
}
//TypeKey event on key
func (bp *Page) TypeKey(e *fyne.KeyEvent) {
bp.Bind.Bound = keys.CKIFyneKeyMap(e.Name)
kp := keys.CKIKeyNameFromKC(bp.Bind.Bound)
bp.dev["BL"].(*widget.Label).SetText(kp)
}
func (bp *Page) createGrid() *fyne.Container {
cont := fyne.NewContainerWithLayout(layout.NewGridLayoutWithColumns(4))
cont.AddObject(widget.NewButton("Clear", func() {
bp.Bind.Bound = 0x0
bp.dev["BL"].(*widget.Label).SetText(keys.CKIKeyNameFromKC(bp.Bind.Bound))
}))
k1 := widget.NewButton("Tab", func() { bp.TypeKey(&fyne.KeyEvent{Name: fyne.KeyTab}) })
k3 := widget.NewButton("Left Alt", func() { bp.TypeKey(&fyne.KeyEvent{Name: desktop.KeyAltLeft}) })
k5 := widget.NewButton("Left Control", func() { bp.TypeKey(&fyne.KeyEvent{Name: desktop.KeyControlLeft}) })
k7 := widget.NewButton("Left Shift", func() { bp.TypeKey(&fyne.KeyEvent{Name: desktop.KeyShiftLeft}) })
//k8 := widget.NewButton("Grave (`)", func() { bp.TypeKey(&fyne.KeyEvent{Name: fyne.KeyBackTick}) })
cont.AddObject(k1)
cont.AddObject(k3)
cont.AddObject(k5)
cont.AddObject(k7)
return cont
}
//Create the binding page popup
func (bp *Page) Create(bid string) fyne.CanvasObject {
bp.dev = make(map[string]fyne.CanvasObject)
bp.dev["BL"] = widget.NewLabel(keys.CKIKeyNameFromKC(bp.Bind.Bound))
pop := container.NewVBox(bp.dev["BL"], bp.createGrid())
bp.window.Canvas().SetOnTypedKey(bp.TypeKey)
return pop
}
//NewBindPage Create a new bind popup
func NewBindPage(bid int, w fyne.Window, def uint16) *Page {
p := new(Page)
p.window = w
p.Bind.Bindid = bid
p.Bind.Bound = def
return p
}