diff options
| author | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2022-06-12 22:34:23 +0200 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2022-06-12 23:18:57 +0200 |
| commit | 0f9e2d89589f05847fb7dc808da1594f0961b5b4 (patch) | |
| tree | f80da866fdf50aae44009ccd1c858d2013b0a3d0 /src/player/inc | |
| parent | 5794dbf40364ae442a22b6ac6c4732edd0e61f84 (diff) | |
| download | rts-0f9e2d89589f05847fb7dc808da1594f0961b5b4.tar.gz | |
Split peripheral-related logic into its own component
This has several advantages:
- `camera` no longer needs to define public functions for each
peripheral type.
- Peripheral-related is now no longer tighly coupled to human_player,
so peripheral logic can be reused elsewhere e.g.: on menus.
- Makes camera_update_touch consistent compared to equivalent functions,
since now `pan` has now been moved to `camera` (as it should be).
Diffstat (limited to 'src/player/inc')
| -rw-r--r-- | src/player/inc/human_player.h | 25 |
1 files changed, 4 insertions, 21 deletions
diff --git a/src/player/inc/human_player.h b/src/player/inc/human_player.h index 08f47d9..ca52112 100644 --- a/src/player/inc/human_player.h +++ b/src/player/inc/human_player.h @@ -6,6 +6,7 @@ #include <instance.h> #include <mouse.h> #include <pad.h> +#include <peripheral.h> #include <player.h> #include <stdbool.h> #include <stddef.h> @@ -19,35 +20,17 @@ enum {MAX_SELECTED_INSTANCES = 4}; struct human_player_cfg { - enum human_player_periph - { - HUMAN_PLAYER_PERIPH_PAD, - HUMAN_PLAYER_PERIPH_TOUCH, - HUMAN_PLAYER_PERIPH_KEYBOARD_MOUSE - } sel_periph; - + enum peripheral_type sel_periph; struct player_cfg pl; int padn; + struct camera_dim dim; }; struct human_player { struct player pl; struct camera cam; - enum human_player_periph sel_periph; - - union - { - struct pad pad; - - struct human_player_kbm - { - struct mouse mouse; - struct keyboard keyboard; - bool long_press, pan; - unsigned int lp_t; - } kbm; - } periph; + union peripheral periph; struct sel_instance { |
