Skip to content

Commit

Permalink
correct L2/R2 defaults + rm return error statement
Browse files Browse the repository at this point in the history
  • Loading branch information
Apaczer committed Jul 4, 2023
1 parent 3d7db83 commit bab08ea
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ Remember: all hotkeys will work only in combination with RESET/HOME button (see
| Up | Volume Up |
| Start | Screenshot |
| Select | Force-close app |
| L2 | Soft-close app |
| R2 | Quick shutdown |

## Config
- custom hotkeys config location
`/mnt/.buttons.conf`
- hotkeys config format
`x:a:y:b:up:down:left:right:select:start:l2:r2:hold-x:hold-a:hold-y:hold-b:hold-up:hold-down:hold-left:hold-right:hold-select:hold-start:hold-l2:hold-r2`
- default hotkeys config values and format (the string must match exactly)
`0:0:0:0:3:4:2:1:22:13:0:0:0:0:0:0:0:0:0:0:0:0:0:0`
`0:0:0:0:3:4:2:1:22:13:23:20:0:0:0:0:0:0:0:0:0:0:0:0`
**NOTE**:
- when enabling custom hotkeys an existing ones will be disabled&overwritten by above defaults or any passed by user. However that doesn't apply to hardcoded ones like emulating L1/R1 or other additional buttons.
- you can disable/enable custom hotkey bindings in `/mnt/options.cfg` with HOTKEY_CUSTOM=0 or 1 entry
Expand All @@ -45,7 +47,7 @@ Remember: all hotkeys will work only in combination with RESET/HOME button (see
11 = remount /mnt as rw
12 = remount /mnt as ro
13 = screenshot using fbgrab
20 = kill, sync and shutdown
20 = kill, sync and shutdown (quick shutdown)
21 = kill gui. Does not work on most apps. do not use
22 = kill force app. Work on most apps.
23 = kill soft app. Work on a few apps, guaranties proper closing.
19 changes: 8 additions & 11 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@

#define BUTTON_COUNT 12

unsigned char actionmap[BUTTON_COUNT*2]={0,0,0,0,3,4,2,1,22,13,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int hotkey_custom = 1;

unsigned char actionmap[BUTTON_COUNT*2]={0,0,0,0,3,4,2,1,22,13,23,20,0,0,0,0,0,0,0,0,0,0,0,0};

static void create_daemon(void)
{
Expand Down Expand Up @@ -250,7 +248,8 @@ int main(int argc, char** argv)
char wstr[100];
char lstr[256];
int battery_level;
int hotkeys_enabled = -1;
int hotkeys_enabled=-1;
int hotkey_custom=0;
setvbuf (stdout, NULL, _IONBF, 0);

create_daemon();
Expand Down Expand Up @@ -301,7 +300,6 @@ int main(int argc, char** argv)
fclose(options_file);
} else {
// printf("Could not open the OPTIONS file.\n");
return 1;
}

//check if button file exist for custom hotkeys to apply or either entry in options file to accept default hotkeys.
Expand Down Expand Up @@ -526,7 +524,7 @@ int main(int argc, char** argv)
info_fb0(fb0, lid, vol, 1);
}
break ;
case 11:
case 11:
system("mount -o remount,rw,utf8 /dev/mmcblk0p4");
break;
case 12:
Expand All @@ -537,6 +535,7 @@ int main(int argc, char** argv)
break;
case 20:
{
//printf("quick shutdown\n");
int status;
pid_t son = fork();
if (!son) {
Expand All @@ -546,7 +545,7 @@ int main(int argc, char** argv)
}
case 21:
{
//printf("kill\n");
//printf("kill GUI\n");
int status;
pid_t son = fork();
if (!son) {
Expand All @@ -557,22 +556,20 @@ int main(int argc, char** argv)
}
case 22:
{
//printf("kill\n");
//printf("kill force\n");
int status;
pid_t son = fork();
if (!son) {
//execlp("sh", "sh", "/mnt/kernel/killgui.sh", NULL);
execlp("sh", "sh", "-c", "/bin/kill -9 $(/bin/ps -al | /bin/grep \"/mnt/\")", NULL);
}
break;
}
case 23:
{
//printf("kill\n");
//printf("kill soft\n");
int status;
pid_t son = fork();
if (!son) {
//execlp("sh", "sh", "/mnt/kernel/killgui.sh", NULL);
execlp("sh", "sh", "-c", "/bin/kill -2 $(/bin/ps -al | /bin/grep \"/mnt/\")", NULL);
}
break;
Expand Down

0 comments on commit bab08ea

Please sign in to comment.