Skip to content

Commit

Permalink
internal: driver: mobile: app: android: map gamepad keycodes
Browse files Browse the repository at this point in the history
  • Loading branch information
BogdanTheGeek committed Oct 17, 2023
1 parent 7088d33 commit e3f07a2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
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

0 comments on commit e3f07a2

Please sign in to comment.