Skip to content

Commit 71065e3

Browse files
committed
Forgotten file :(
1 parent 52bd013 commit 71065e3

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

src/actions/sa_keyboard.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* SC Controller - Special actions - Show Keyboard
3+
*
4+
* Turns controller off.
5+
*/
6+
#include "scc/utils/logging.h"
7+
#include "scc/utils/strbuilder.h"
8+
#include "scc/utils/list.h"
9+
#include "scc/special_action.h"
10+
#include "scc/action.h"
11+
#include <stdlib.h>
12+
#include <stdio.h>
13+
14+
static const char* KW_KEYBOARD = "keyboard";
15+
16+
static char* sa_keyboard_to_string(Action* a) {
17+
return strbuilder_fmt("%s()", a->type);
18+
}
19+
20+
static void sa_keyboard_dealloc(Action* a) {
21+
free(a);
22+
}
23+
24+
static void button_press(Action* a, Mapper* m) {
25+
if ((m->special_action == NULL) || !m->special_action(m, SAT_KEYBOARD, NULL))
26+
DWARN("Mapper lacks support for '%s'", a->type);
27+
}
28+
29+
30+
static ActionOE sa_keyboard_constructor(const char* keyword, ParameterList params) {
31+
if (list_len(params) != 0) {
32+
return (ActionOE)scc_new_action_error(AEC_INVALID_NUMBER_OF_PARAMETERS, "'%s' takes no parameters", keyword);
33+
}
34+
35+
Action* a = malloc(sizeof(Action));
36+
if (a == NULL) return (ActionOE)scc_oom_action_error();
37+
scc_action_init(a, KW_KEYBOARD, AF_SPECIAL_ACTION, &sa_keyboard_dealloc, &sa_keyboard_to_string);
38+
a->button_press = &button_press;
39+
40+
return (ActionOE)a;
41+
}
42+
43+
44+
void scc_actions_init_sa_keyboard() {
45+
scc_action_register(KW_KEYBOARD, &sa_keyboard_constructor);
46+
}
47+

0 commit comments

Comments
 (0)