mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:27:45 +00:00
Keymap: Clean up source a bit
This commit is contained in:
parent
a1f2a7eaa8
commit
0b3f1e70ca
1 changed files with 15 additions and 15 deletions
|
@ -16,18 +16,17 @@ char* read_map(const JsonObject& json, const String& name)
|
|||
char* map = new char[80];
|
||||
|
||||
auto map_arr = json.get(name).as_array();
|
||||
for(int i=0; i<map_arr.size(); i++)
|
||||
{
|
||||
for (int i = 0; i < map_arr.size(); i++) {
|
||||
auto key_value = map_arr.at(i).as_string();
|
||||
char character = 0;
|
||||
if( key_value.length() == 0) {
|
||||
if (key_value.length() == 0) {
|
||||
;
|
||||
} else if(key_value.length() == 1){
|
||||
} else if (key_value.length() == 1) {
|
||||
character = key_value.characters()[0];
|
||||
} else if(key_value.length() == 4){
|
||||
if(key_value == "0x08"){
|
||||
} else if (key_value.length() == 4) {
|
||||
if (key_value == "0x08") {
|
||||
character = 0x08;
|
||||
}else if(key_value == "0x33"){
|
||||
} else if (key_value == "0x33") {
|
||||
character = 0x33;
|
||||
}
|
||||
} else {
|
||||
|
@ -41,7 +40,8 @@ char* read_map(const JsonObject& json, const String& name)
|
|||
return map;
|
||||
}
|
||||
|
||||
int read_map_from_file(String filename){
|
||||
int read_map_from_file(String filename)
|
||||
{
|
||||
auto file = CFile::construct(filename);
|
||||
if (!file->open(CIODevice::ReadOnly)) {
|
||||
fprintf(stderr, "Failed to open %s: %s\n", filename.characters(), file->error_string());
|
||||
|
@ -68,10 +68,10 @@ int main(int argc, char** argv)
|
|||
String filename = argv[1];
|
||||
int ret_val = read_map_from_file(filename);
|
||||
|
||||
if(ret_val == -EPERM)
|
||||
if (ret_val == -EPERM)
|
||||
fprintf(stderr, "Permission denied.\n");
|
||||
|
||||
if(ret_val == 0)
|
||||
if (ret_val == 0)
|
||||
fprintf(stderr, "New keymap loaded from \"%s\".\n", filename.characters());
|
||||
|
||||
return ret_val;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue