-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First working build of "flexible triggers and actions" for Release 2.0
- Loading branch information
1 parent
c3f37ae
commit a6f5b1f
Showing
11 changed files
with
447 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# RemarkableLamyEraser Configuration File~ | ||
# Set up your triggers and effects here | ||
# Any trigger left blank will have no effect. | ||
# Effects are divided into tools and actions : | ||
# Actions are compatible with click-type actions | ||
|
||
# The available actions are: | ||
# toolbar : presses the toolbar panel button | ||
# writing : presses the writing utensil button | ||
# undo : presses the undo button | ||
# redo : presses the redo button | ||
|
||
# Tools are compatible with press&hold type triggers, or with click type triggers as toggles | ||
# The available tools are: | ||
# erase : changes to eraser tool. on deactivation, changes back to writing utensil | ||
# note that on the RM2, this mode uses special features available from the marker plus. | ||
# erase-selection : changes to erase selection tool. on deactivation, changes back to writing utensil | ||
# select : changes to select tool. on deactivation, changes back to writing utensil | ||
|
||
# Example valid configuration lines: | ||
# click erase | ||
# press&hold select | ||
|
||
|
||
|
||
click erase | ||
double-click undo | ||
triple-click | ||
quadruple-click | ||
quintuple-click | ||
|
||
press&hold erase-selection | ||
double-press&hold | ||
triple-press&hold | ||
quadruple-press&hold | ||
quintuple-press&hold |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <fcntl.h> | ||
#include <string.h> | ||
|
||
#include <configuration.h> | ||
|
||
|
||
|
||
int getTriggerConfig(const char *path, struct configuration *config) { | ||
//returns 0 on success | ||
//returns 1 if error in configuration file | ||
// returns -1 if configuration file doesn't exist | ||
FILE *fp; | ||
char* line; | ||
int lineNum = 0; | ||
size_t len =0; | ||
ssize_t read; | ||
char trigger[24] = "--"; | ||
char effect[24] = "--"; | ||
int readTrigger = -1, readEffect = -1; | ||
|
||
fp = fopen(path, "r"); | ||
if (fp == NULL) | ||
return -1; | ||
while ((read = getline(&line, &len, fp)) != -1) { | ||
lineNum++; | ||
if (line[0] == '#' || line[0] == '\n') { | ||
continue; | ||
} | ||
|
||
if ( (sscanf(line, "%s %s", trigger, effect) == 2) ) { | ||
printf("Line %2d: Read trigger <%s> with effect <%s>\n", lineNum, trigger, effect); | ||
} | ||
else { | ||
//printf("Line %2d: Read trigger <%s> has no effect.\n", lineNum, trigger); | ||
strcpy(effect, "null"); | ||
} | ||
|
||
for (int i = 0; i < NUM_TRIGGERS; i++){ | ||
if (!strcmp(trigger, triggers[i])) { | ||
readTrigger = i; | ||
break; | ||
} | ||
} | ||
for (int j = 0; j < NUM_EFFECTS; j++) { | ||
if (!strcmp(effect, effects[j])) { | ||
readEffect = j; | ||
break; | ||
} | ||
} | ||
if (readTrigger == -1) { | ||
printf("Invalid trigger %s in line %d of configuration file at %s\n", trigger, lineNum, path); | ||
return 1; | ||
} | ||
if (readEffect == -1) { | ||
printf("Invalid effect %s in line %d of configuration file at %s\n", effect, lineNum, path); | ||
return 1; | ||
} | ||
|
||
switch(readTrigger) { | ||
case TRIGGER_CLICK_1 : | ||
config->click1Effect = readEffect; | ||
break; | ||
case TRIGGER_CLICK_2 : | ||
config->click2Effect = readEffect; | ||
break; | ||
case TRIGGER_CLICK_3 : | ||
config->click3Effect = readEffect; | ||
break; | ||
case TRIGGER_CLICK_4 : | ||
config->click4Effect = readEffect; | ||
break; | ||
case TRIGGER_CLICK_5 : | ||
config->click5Effect = readEffect; | ||
break; | ||
case TRIGGER_HOLD_1 : | ||
config->hold1Effect = readEffect; | ||
break; | ||
case TRIGGER_HOLD_2 : | ||
config->hold2Effect = readEffect; | ||
break; | ||
case TRIGGER_HOLD_3 : | ||
config->hold3Effect = readEffect; | ||
break; | ||
case TRIGGER_HOLD_4 : | ||
config->hold4Effect = readEffect; | ||
break; | ||
case TRIGGER_HOLD_5 : | ||
config->hold5Effect = readEffect; | ||
break; | ||
} | ||
strcpy(trigger, "--"); | ||
strcpy(effect, "--"); | ||
readTrigger = -1; | ||
readEffect = -1; | ||
} | ||
fclose(fp); | ||
return 0; | ||
} | ||
void printConfig(struct configuration *config) { | ||
printf("click1Effect: %x\n", config->click1Effect); | ||
printf("click2Effect: %x\n", config->click2Effect); | ||
printf("click3Effect: %x\n", config->click3Effect); | ||
printf("click4Effect: %x\n", config->click4Effect); | ||
printf("click5Effect: %x\n", config->click5Effect); | ||
printf("hold1Effect: %x\n", config->hold1Effect); | ||
printf("hold2Effect: %x\n", config->hold2Effect); | ||
printf("hold3Effect: %x\n", config->hold3Effect); | ||
printf("hold4Effect: %x\n", config->hold4Effect); | ||
printf("hold5Effect: %x\n", config->hold5Effect); | ||
} |
Oops, something went wrong.