diff options
| author | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2022-09-27 17:03:06 +0200 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2022-11-01 16:26:16 +0100 |
| commit | 9e1f1069cc6ff2e247c378a23952b67eadd18ab3 (patch) | |
| tree | 3a8578b628be661fff7f4a98a7585269937a3086 /src/peripheral | |
| parent | 28d624a7b821a3cc726413fe53b60fe8fe83394e (diff) | |
| download | rts-9e1f1069cc6ff2e247c378a23952b67eadd18ab3.tar.gz | |
WIP
Diffstat (limited to 'src/peripheral')
| -rw-r--r-- | src/peripheral/inc/peripheral.h | 1 | ||||
| -rw-r--r-- | src/peripheral/src/peripheral.c | 11 |
2 files changed, 11 insertions, 1 deletions
diff --git a/src/peripheral/inc/peripheral.h b/src/peripheral/inc/peripheral.h index 8f8f73b..2895f54 100644 --- a/src/peripheral/inc/peripheral.h +++ b/src/peripheral/inc/peripheral.h @@ -55,6 +55,7 @@ UTIL_STATIC_ASSERT(!offsetof(struct peripheral_pad, common), UTIL_STATIC_ASSERT(!offsetof(struct peripheral_kbm, common), "unexpected offsetof for struct peripheral_kbm"); +int peripheral_get_default(struct peripheral_cfg *cfg); void peripheral_init(const struct peripheral_cfg *cfg, union peripheral *p); void peripheral_input_set(union peripheral *p, void (*cb)(char, void *)); void peripheral_update(union peripheral *p); diff --git a/src/peripheral/src/peripheral.c b/src/peripheral/src/peripheral.c index eeec4fa..71f81f8 100644 --- a/src/peripheral/src/peripheral.c +++ b/src/peripheral/src/peripheral.c @@ -62,5 +62,14 @@ void peripheral_init(const struct peripheral_cfg *const cfg, int peripheral_get_default(struct peripheral_cfg *const cfg) { - return -1; + *cfg = (const struct peripheral_cfg){0}; + + if (pad_count()) + cfg->type = PERIPHERAL_TYPE_PAD; + else if (keyboard_available() && mouse_available()) + cfg->type = PERIPHERAL_TYPE_KEYBOARD_MOUSE; + else + return -1; + + return 0; } |
