diff options
Diffstat (limited to 'drivers/sensors/analog_joystick.h')
| -rw-r--r-- | drivers/sensors/analog_joystick.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/drivers/sensors/analog_joystick.h b/drivers/sensors/analog_joystick.h new file mode 100644 index 000000000..6892a0881 --- /dev/null +++ b/drivers/sensors/analog_joystick.h | |||
| @@ -0,0 +1,51 @@ | |||
| 1 | /* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com> | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #pragma once | ||
| 18 | |||
| 19 | #include <stdbool.h> | ||
| 20 | #include <stdint.h> | ||
| 21 | |||
| 22 | #ifndef ANALOG_JOYSTICK_X_AXIS_PIN | ||
| 23 | # error No pin specified for X Axis | ||
| 24 | #endif | ||
| 25 | #ifndef ANALOG_JOYSTICK_Y_AXIS_PIN | ||
| 26 | # error No pin specified for Y Axis | ||
| 27 | #endif | ||
| 28 | |||
| 29 | #ifndef ANALOG_JOYSTICK_AXIS_MIN | ||
| 30 | # define ANALOG_JOYSTICK_AXIS_MIN 0 | ||
| 31 | #endif | ||
| 32 | #ifndef ANALOG_JOYSTICK_AXIS_MAX | ||
| 33 | # define ANALOG_JOYSTICK_AXIS_MAX 1023 | ||
| 34 | #endif | ||
| 35 | #ifndef ANALOG_JOYSTICK_SPEED_REGULATOR | ||
| 36 | # define ANALOG_JOYSTICK_SPEED_REGULATOR 20 | ||
| 37 | #endif | ||
| 38 | #ifndef ANALOG_JOYSTICK_READ_INTERVAL | ||
| 39 | # define ANALOG_JOYSTICK_READ_INTERVAL 10 | ||
| 40 | #endif | ||
| 41 | #ifndef ANALOG_JOYSTICK_SPEED_MAX | ||
| 42 | # define ANALOG_JOYSTICK_SPEED_MAX 2 | ||
| 43 | #endif | ||
| 44 | |||
| 45 | typedef struct { | ||
| 46 | int8_t x; | ||
| 47 | int8_t y; | ||
| 48 | bool button; | ||
| 49 | } report_analog_joystick_t; | ||
| 50 | report_analog_joystick_t analog_joystick_read(void); | ||
| 51 | void analog_joystick_init(void); | ||
