Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion Client/tool_click.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ static void show_help() {
" -r, --repeat=N Repeat entire sequence N times\n"
" -D, --next-delay=N Delay N milliseconds between input events (up/down, "
" a complete click means doubled time)\n"
" -P, --press-release Press & release mouse button to complete a click, (optional)\n"
" -h, --help Display this help and exit\n"
"\n"
"How to specify buttons:\n"
Expand Down Expand Up @@ -77,20 +78,22 @@ int tool_click(int argc, char **argv) {

int repeats = 1;
int next_delay_ms = 25;
bool press_release = 0;

while (1) {
int c;

static struct option long_options[] = {
{"repeat", required_argument, 0, 'r'},
{"next-delay", required_argument, 0, 'D'},
{"press-release", no_argument, 0, 'P'},
{"help", no_argument, 0, 'h'},
{0, 0, 0, 0}
};
/* getopt_long stores the option index here. */
int option_index = 0;

c = getopt_long (argc, argv, "hr:D:",
c = getopt_long (argc, argv, "hPr:D:",
long_options, &option_index);

/* Detect the end of the options. */
Expand All @@ -114,6 +117,10 @@ int tool_click(int argc, char **argv) {
case 'D':
next_delay_ms = strtol(optarg, NULL, 10);
break;

case 'P':
press_release = 1;
break;

case 'h':
show_help();
Expand All @@ -138,6 +145,14 @@ int tool_click(int argc, char **argv) {
int key = strtol(argv[optind++], NULL, 16);
int keycode = (key & 0xf) | 0x110;

if (press_release) {
printf("Click Event %d\n", i);
uinput_emit(EV_KEY, keycode, 1, 1);
uinput_emit(EV_KEY, keycode, 0, 1);
usleep(next_delay_ms * 1000);
continue;
}

if (key & 0x40) {
uinput_emit(EV_KEY, keycode, 1, 1);
usleep(next_delay_ms * 1000);
Expand Down