gomp/config/kMap.go
aditya-K2 482978897d Added Default Mappings
Following Changes Have been made:

    1.  Rename KMAP -> SPECIAL_KEYS
    2.  Added Default Mappings through KEY_MAPPINGS
	so when the config is read it will change the KEY_MAPPINGS map
	which will be then used by the handler function for events.
2021-11-11 23:24:58 +05:30

51 lines
983 B
Go

package config
import (
"errors"
)
var (
SPECIAL_KEYS = map[string]int{
"TAB": 9,
"RETURN": 13,
"ENTER": 13,
"SPACE": 32,
}
KEY_MAP = map[int]string{
108: "showChildrenContent",
112: "togglePlayBack",
104: "showParentContent",
110: "nextSong",
99: "clearPlaylist",
78: "previousSong",
97: "addToPlaylist",
122: "toggleRandom",
114: "toggleRepeat",
45: "decreaseVolume",
61: "increaseVolume",
50: "navigateToFiles",
49: "navigateToPlaylist",
51: "navigateToMostPlayed",
113: "quit",
115: "stop",
117: "updateDB",
100: "deleteSongFromPlaylist",
}
)
func GetAsciiValue(s string) (int, error) {
if len([]rune(s)) == 1 {
char := []rune(s)[0]
if (int(char) >= 65 && int(char) <= 90) || (int(char) >= 97 && int(char) <= 122) {
return int(char), nil
} else {
return -1, errors.New("Not Found")
}
} else if val, ok := SPECIAL_KEYS[s]; ok {
return val, nil
} else {
return -1, errors.New("Not Found")
}
}