Skip to content

Commit

Permalink
Made #22 optional
Browse files Browse the repository at this point in the history
  • Loading branch information
tbocek committed May 29, 2023
1 parent b6fa657 commit 8be8afe
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions dvorak.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,9 @@ void usage(const char *path) {
"Match only the STRING with the USB device name. \n"
"\t\t\tSTRING can contain multiple words, separated by space.\n");
fprintf(stderr, " -t\t\t\t"
"Disable layout toggle feature (press Left-Alt 3 times to switch layout).\n\n");
"Disable layout toggle feature (press Left-Alt 3 times to switch layout).\n");
fprintf(stderr, " -c\t\t\t"
"Disable caps lock as a modifier.\n\n");
fprintf(stderr, "example: %s -u -d /dev/input/by-id/usb-Logitech_USB_Receiver-if02-event-kbd -m \"k750 k350\"\n", basename);
}

Expand All @@ -224,7 +226,7 @@ int main(int argc, char *argv[]) {
struct uinput_setup usetup;
ssize_t n;
int fdi, fdo, i, mod_current, code, name_ret, mod_state = 0, array_qwerty_counter = 0, array_umlaut_counter = 0, lAlt = 0, opt;
bool alt_gr = false, isDvorak = false, isUmlaut = false, lshift = false, rshift = false, noToggle = false;
bool alt_gr = false, isDvorak = false, isUmlaut = false, lshift = false, rshift = false, noToggle = false, noCapsLockAsModifier = false;
int array_qwerty[MAX_LENGTH] = {0}, array_umlaut[MAX_LENGTH] = {0};
char keyboard_name[UINPUT_MAX_NAME_SIZE] = "Unknown";

Expand All @@ -243,6 +245,9 @@ int main(int argc, char *argv[]) {
case 't':
noToggle = true;
break;
case 'c':
noCapsLockAsModifier = true;
break;
case '?':
usage(argv[0]);
return EXIT_FAILURE;
Expand Down Expand Up @@ -448,6 +453,12 @@ int main(int argc, char *argv[]) {
}

mod_current = modifier_bit(ev.code);

//Caps lock is optional (TODO: don't use 16 here, but define as variables in modifier_bit)
if(noCapsLockAsModifier && mod_current == 16) {
mod_current = 0;
}

if (mod_current > 0) {
if (ev.value == 1) { //pressed
mod_state |= mod_current;
Expand Down

0 comments on commit 8be8afe

Please sign in to comment.