tools: add another "action" subcommand to set/get buttons

Like usage() already documented

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer
2015-09-15 23:09:12 +10:00
parent e416722a12
commit 7ff92c4226
2 changed files with 39 additions and 10 deletions

View File

@@ -1342,6 +1342,36 @@ static const struct ratbag_cmd cmd_button_set = {
},
};
static int
ratbag_cmd_button_action(const struct ratbag_cmd *cmd,
struct ratbag *ratbag,
struct ratbag_cmd_options *options,
int argc, char **argv)
{
const char *command;
if (argc < 1)
return ERR_USAGE;
command = argv[0];
return run_subcommand(command,
cmd,
ratbag, options,
argc, argv);
}
static const struct ratbag_cmd cmd_button_action = {
.name = "action",
.cmd = ratbag_cmd_button_action,
.flags = FLAG_NEED_DEVICE | FLAG_NEED_PROFILE | FLAG_NEED_BUTTON,
.subcommands = {
&cmd_button_get,
&cmd_button_set,
NULL,
},
};
static int
ratbag_cmd_button(const struct ratbag_cmd *cmd,
struct ratbag *ratbag,
@@ -1387,8 +1417,7 @@ static const struct ratbag_cmd cmd_button = {
.flags = FLAG_NEED_DEVICE | FLAG_NEED_PROFILE,
.subcommands = {
&cmd_button_count,
&cmd_button_get,
&cmd_button_set,
&cmd_button_action,
NULL,
},
};

View File

@@ -49,14 +49,14 @@ cmds[18]="profile 0 resolution 0 rate get"
cmds[19]="profile 0 resolution 0 rate set 500"
cmds[20]="button count"
cmds[21]="profile 0 button count"
cmds[22]="button 0 get"
cmds[23]="button 0 set button 1"
cmds[24]="profile 0 button 0 get"
cmds[25]="profile 0 button 0 set button 1"
cmds[26]="button 0 set key KEY_ENTER"
cmds[27]="profile 0 button 0 set key KEY_ENTER"
cmds[28]="button 0 set special doubleclick"
cmds[29]="profile 0 button 0 set special doubleclick"
cmds[22]="button 0 action get"
cmds[23]="button 0 action set button 1"
cmds[24]="profile 0 button 0 action get"
cmds[25]="profile 0 button 0 action set button 1"
cmds[26]="button 0 action set key KEY_ENTER"
cmds[27]="profile 0 button 0 action set key KEY_ENTER"
cmds[28]="button 0 action set special doubleclick"
cmds[29]="profile 0 button 0 action set special doubleclick"
for i in "${cmds[@]}"; do
echo "Testing arguments '$i $device'"