2021-11-11 16:33:35 +00:00
|
|
|
package config
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
)
|
|
|
|
|
2021-11-11 17:54:58 +00:00
|
|
|
var (
|
|
|
|
SPECIAL_KEYS = map[string]int{
|
|
|
|
"TAB": 9,
|
|
|
|
"RETURN": 13,
|
|
|
|
"ENTER": 13,
|
|
|
|
"SPACE": 32,
|
2021-11-12 08:33:57 +00:00
|
|
|
"[": 91,
|
|
|
|
"]": 93,
|
|
|
|
"(": 40,
|
|
|
|
")": 41,
|
|
|
|
"{": 123,
|
|
|
|
"}": 125,
|
|
|
|
"<": 60,
|
|
|
|
">": 62,
|
|
|
|
"?": 63,
|
|
|
|
"/": 47,
|
|
|
|
";": 59,
|
|
|
|
":": 58,
|
|
|
|
"'": 39,
|
|
|
|
"\"": 34,
|
2021-11-11 17:54:58 +00:00
|
|
|
}
|
|
|
|
|
2021-11-12 09:02:06 +00:00
|
|
|
// Generating Default KEY_MAP which will then later be changed by GenerateKeyMap
|
|
|
|
|
2021-11-11 17:54:58 +00:00
|
|
|
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",
|
2021-11-15 10:04:41 +00:00
|
|
|
47: "FocusSearch",
|
2021-11-11 17:54:58 +00:00
|
|
|
}
|
|
|
|
)
|
2021-11-11 16:33:35 +00:00
|
|
|
|
|
|
|
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
|
2021-11-12 08:33:57 +00:00
|
|
|
} else if val, ok := SPECIAL_KEYS[s]; ok {
|
|
|
|
return val, nil
|
2021-11-11 16:33:35 +00:00
|
|
|
} else {
|
2021-11-11 19:55:40 +00:00
|
|
|
return -1, errors.New("Not Found in the range")
|
2021-11-11 16:33:35 +00:00
|
|
|
}
|
2021-11-11 17:54:58 +00:00
|
|
|
} else if val, ok := SPECIAL_KEYS[s]; ok {
|
2021-11-11 16:33:35 +00:00
|
|
|
return val, nil
|
|
|
|
} else {
|
|
|
|
return -1, errors.New("Not Found")
|
|
|
|
}
|
|
|
|
}
|