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