Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/mobile key codes #4326

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions driver/mobile/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import (
)

const (
// KeyBack represents the back button which may be hardware or software
KeyBack fyne.KeyName = "Back"
//
// Since: 2.5
KeyBack fyne.KeyName = "Back"
KeyDPadLeft fyne.KeyName = "DPadLeft"
KeyDPadRight fyne.KeyName = "DPadRight"
KeyDPadUp fyne.KeyName = "DPadUp"
KeyDPadDown fyne.KeyName = "DPadDown"
KeyDPadCenter fyne.KeyName = "DPadCenter"
)
11 changes: 6 additions & 5 deletions internal/driver/mobile/app/android.go
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,12 @@ var androidKeycoe = map[int32]key.Code{
C.AKEYCODE_NUMPAD_ENTER: key.CodeKeypadEnter,
C.AKEYCODE_NUMPAD_EQUALS: key.CodeKeypadEqualSign,
C.AKEYCODE_VOLUME_MUTE: key.CodeMute,

C.AKEYCODE_DPAD_UP: key.CodeDPadUp,
C.AKEYCODE_DPAD_DOWN: key.CodeDPadDown,
C.AKEYCODE_DPAD_LEFT: key.CodeDPadLeft,
C.AKEYCODE_DPAD_RIGHT: key.CodeDPadRight,
C.AKEYCODE_DPAD_CENTER: key.CodeDPadCenter,
}

func convAndroidKeyCode(aKeyCode int32) key.Code {
Expand All @@ -767,11 +773,6 @@ func convAndroidKeyCode(aKeyCode int32) key.Code {
C.AKEYCODE_ENDCALL
C.AKEYCODE_STAR
C.AKEYCODE_POUND
C.AKEYCODE_DPAD_UP
C.AKEYCODE_DPAD_DOWN
C.AKEYCODE_DPAD_LEFT
C.AKEYCODE_DPAD_RIGHT
C.AKEYCODE_DPAD_CENTER
C.AKEYCODE_POWER
C.AKEYCODE_CAMERA
C.AKEYCODE_CLEAR
Expand Down
5 changes: 5 additions & 0 deletions internal/driver/mobile/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,11 @@ var keyCodeMap = map[key.Code]fyne.KeyName{
key.CodeGraveAccent: fyne.KeyBackTick,

key.CodeBackButton: mobile.KeyBack,
key.CodeDPadUp: mobile.KeyDPadUp,
key.CodeDPadDown: mobile.KeyDPadDown,
key.CodeDPadLeft: mobile.KeyDPadLeft,
key.CodeDPadRight: mobile.KeyDPadRight,
key.CodeDPadCenter: mobile.KeyDPadCenter,
}

func keyToName(code key.Code) fyne.KeyName {
Expand Down
5 changes: 5 additions & 0 deletions internal/driver/mobile/event/key/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@ const (
CodeRightGUI Code = 231

CodeBackButton Code = 301 // anything above 255 is not used in the USB spec
CodeDPadUp Code = 302
CodeDPadDown Code = 303
CodeDPadLeft Code = 304
CodeDPadRight Code = 305
CodeDPadCenter Code = 306

// The following codes are not part of the standard USB HID Usage IDs for
// keyboards. See http://www.usb.org/developers/hidpage/Hut1_12v2.pdf
Expand Down