Skip to content

Commit 6daa5ca

Browse files
committed
replaced default trigger key code with unspecified key code; updated readme
1 parent 58a337a commit 6daa5ca

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Scroll without a scroll wheel by moving a pointer (mouse, trackball, touchpad, trackpoint). Enables scrolling with devices without a scroll wheel (e.g. Logitech Marble Trackball). General ergnonomics utility. Command line tool.
44

5-
Activation:
5+
Activation (see -s option):
66
- hold keyboard key (combo)
77
- toggle with keyboard key (combo) on/off
88

@@ -20,3 +20,8 @@ Activation:
2020

2121
### Fedora / Redhat:
2222
`sudo dnf install libXi libXtst libXfixes`
23+
24+
# Help
25+
- exec with option -h to see the options
26+
- -s option is the shortcut key code. You need to set this, for it to work, although it starts without it.
27+
- to find the (xorg) key code to be used with the -s option: start with -d, then press a button. The debug output will print the key code that can be used with -s option.

main.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ struct Config {
6262
static const char* PROGRAM_VERSION = "1.0";
6363
static const int NANOSECOND_TO_MILLISECOND_DIV = 1000000;
6464
static const int SCROLL_TRIGGER_SPEED_LIMIT_MS = 30; // don't allow scrolling in too quick succession, it can't handle them so fast, so they queue up an play back, also causing more CPU load
65+
static const int UNSPECIFIED_KEY_CODE = -1;
66+
6567
static int is_active = False;
6668
static int scrolls_since_active = 0;
6769
static enum LogLevel log_level = LOG_INFO;
6870
static struct timespec last_scroll_time;
6971

70-
#define CAPSLOCK_KEY_CODE 66
71-
7272
void logg(enum LogLevel level, const char* fmt, ...)
7373
{
7474
va_list args;
@@ -94,7 +94,7 @@ struct Config create_default_config()
9494
.show_debug_output = False,
9595
.is_toggle_mode_on = False,
9696
.release_trigger_button = True,
97-
.trigger_key_code = CAPSLOCK_KEY_CODE,
97+
.trigger_key_code = UNSPECIFIED_KEY_CODE,
9898
.trigger_key_modifiers = 0,
9999
};
100100
return cfg;
@@ -163,7 +163,7 @@ void parse_args_into_config(int argc, char** argv, struct Config* cfg) {
163163
case 'h': // print help
164164
printf("Converts X pointer movement (mouse, touchpad, trackpoint, trackball) to scroll wheel events.\n\n");
165165
printf("Options:\n");
166-
printf("-s [keycode:int] ([modifiers:int])\tshortcut\n");
166+
printf("-s [xorg keycode:int] ([modifiers:int])\tshortcut\n");
167167
printf("-c [d:int]\tconversion distance (speed): pointer travel distance (in pixels) required to trigger a scroll. Determines how frequently scrolling occurs. A lower number means more frequent scroll events.\n");
168168
printf("-r\t\treleases trigger button before first scroll. Example: if ctrl is the trigger key, a scroll would often resize/scale in a program. Releasing it prevents that.\n");
169169
printf("-t\t\ttoggle mode: scrolling-mode stays enabled until the combo is pressed again\n");
@@ -449,6 +449,9 @@ int main(int argc, char **argv)
449449
if (cfg.show_debug_output)
450450
print_cfg(&cfg);
451451

452+
if (cfg.trigger_key_code == UNSPECIFIED_KEY_CODE)
453+
logg(LOG_WARN, "warning: no trigger key code was specified\n");
454+
452455
Display* display = open_display_or_exit();
453456
int xi_opcode = ensure_xinput2_or_exit(display);
454457

0 commit comments

Comments
 (0)