Further refactoring of joystick feature (#18437)

This commit is contained in:
Ryan 2022-09-27 18:37:13 +10:00 committed by GitHub
parent fb400f2ac2
commit be8907d634
Failed to generate hash of commit
12 changed files with 248 additions and 309 deletions

View file

@ -1,3 +1,19 @@
/* Copyright 2022
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <stdint.h>
@ -54,7 +70,10 @@ typedef struct {
extern joystick_config_t joystick_axes[JOYSTICK_AXES_COUNT];
enum joystick_status { JS_INITIALIZED = 1, JS_UPDATED = 2 };
enum joystick_status {
JS_INITIALIZED = 1,
JS_UPDATED,
};
typedef struct {
uint8_t buttons[(JOYSTICK_BUTTON_COUNT - 1) / 8 + 1];
@ -65,7 +84,14 @@ typedef struct {
extern joystick_t joystick_status;
void joystick_task(void);
void joystick_flush(void);
void register_joystick_button(uint8_t button);
void unregister_joystick_button(uint8_t button);
int16_t joystick_read_axis(uint8_t axis);
void joystick_read_axes(void);
void joystick_set_axis(uint8_t axis, int16_t value);
void host_joystick_send(joystick_t *joystick);