diff options
| author | Teddy Wing | 2018-09-02 14:12:56 +0200 |
|---|---|---|
| committer | Teddy Wing | 2018-09-02 14:12:56 +0200 |
| commit | 4b31eb9b8412e429949aca73ef475787910e4b0b (patch) | |
| tree | be5e5582ada52cf2e26bd455e91a5a2fb32ce69b /moder.c | |
| parent | 69352361515b16c1ed9646b891ba61ed1781a7a7 (diff) | |
| download | dome-key-map-4b31eb9b8412e429949aca73ef475787910e4b0b.tar.bz2 | |
Test mode finder
Add a new `moder.c` based on `includer.c` to test getting a mode and
then getting an action for a mode mapping.
Doesn't completely work currently. Right now all I get is this output:
$ ./moder
2
Segmentation fault: 11
Clearly I'm messing up something with the pointer in
`c_run_key_action()`. Not sure what it is yet.
Changed `CKeyActionResult.in_mode` to be a `Trigger` instead of a
`HeadphoneButton` list. That allows us to pass it directly into the
second argument of `c_run_key_action()` without converting.
But maybe the pointer value isn't living long enough? Not sure what the
problem is yet.
Diffstat (limited to 'moder.c')
| -rw-r--r-- | moder.c | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -0,0 +1,26 @@ +#include <stdio.h> +#include "dome_key_map.h" + +#define SIZE 2 + +int main() { + HeadphoneButton mode_buttons[SIZE] = {HeadphoneButton_Play, HeadphoneButton_Up}; + Trigger mode_trigger = { + .buttons = mode_buttons, + .length = SIZE + }; + const CKeyActionResult *mode = c_run_key_action(mode_trigger, NULL); + printf("%d\n", *mode->kind); + + HeadphoneButton buttons[] = {HeadphoneButton_Down}; + Trigger trigger = { + .buttons = buttons, + .length = 1 + }; + const CKeyActionResult *result = c_run_key_action(trigger, mode->in_mode); + + printf("%d\n", *result->kind); + printf("%s", result->action); + + return 0; +} |
