Joystick feature improvements (#19052)

This commit is contained in:
Ryan
2022-11-27 03:14:45 +11:00
committed by GitHub
parent a5a20cc792
commit 1e95f7be8f
27 changed files with 475 additions and 215 deletions

View File

@@ -17,7 +17,7 @@
#include "battleship_gamepad.h"
/* joystick config */
joystick_config_t joystick_axes[JOYSTICK_AXES_COUNT] = {
joystick_config_t joystick_axes[JOYSTICK_AXIS_COUNT] = {
[0] = JOYSTICK_AXIS_IN(F5, 1023, 512, 0),
[1] = JOYSTICK_AXIS_IN(F4, 0, 512, 1023)
};

View File

@@ -28,8 +28,8 @@
/* joystick configuration */
#define JOYSTICK_BUTTON_COUNT 25
#define JOYSTICK_AXES_COUNT 2
#define JOYSTICK_AXES_RESOLUTION 10
#define JOYSTICK_AXIS_COUNT 2
#define JOYSTICK_AXIS_RESOLUTION 10
/* COL2ROW or ROW2COL */
#define DIODE_DIRECTION COL2ROW

View File

@@ -17,5 +17,5 @@
#pragma once
#define JOYSTICK_AXES_COUNT 4
#define JOYSTICK_AXIS_COUNT 4
#define JOYSTICK_BUTTON_COUNT 4

View File

@@ -28,7 +28,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
)
};
joystick_config_t joystick_axes[JOYSTICK_AXES_COUNT] = {
joystick_config_t joystick_axes[JOYSTICK_AXIS_COUNT] = {
[0] = JOYSTICK_AXIS_IN(F4, 0, 512, 1023),
[1] = JOYSTICK_AXIS_IN(F5, 0, 512, 1023),
[2] = JOYSTICK_AXIS_IN(F6, 0, 512, 1023),

View File

@@ -17,5 +17,5 @@
#pragma once
#define JOYSTICK_AXES_COUNT 4
#define JOYSTICK_AXIS_COUNT 4
#define JOYSTICK_BUTTON_COUNT 0

View File

@@ -28,7 +28,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
),
};
joystick_config_t joystick_axes[JOYSTICK_AXES_COUNT] = {
joystick_config_t joystick_axes[JOYSTICK_AXIS_COUNT] = {
[0] = JOYSTICK_AXIS_IN(F4, 0, 512, 1023),
[1] = JOYSTICK_AXIS_IN(F5, 0, 512, 1023),
[2] = JOYSTICK_AXIS_IN(F6, 0, 512, 1023),

View File

@@ -1,4 +1,4 @@
#pragma once
#define JOYSTICK_AXES_COUNT 2
#define JOYSTICK_AXIS_COUNT 2
#define JOYSTICK_BUTTON_COUNT 1

View File

@@ -14,7 +14,7 @@ void matrix_scan_user() {
}
// Joystick config
joystick_config_t joystick_axes[JOYSTICK_AXES_COUNT] = {
joystick_config_t joystick_axes[JOYSTICK_AXIS_COUNT] = {
[0] = JOYSTICK_AXIS_IN(ADC_PIN, 0, 512, 1023),
[1] = JOYSTICK_AXIS_VIRTUAL
};

View File

@@ -0,0 +1,26 @@
/* Copyright 2020 QMK
*
* 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/>.
*/
/*
* This file was auto-generated by:
* `qmk chibios-confmigrate -i keyboards/handwired/onekey/blackpill_f401/halconf.h -r platforms/chibios/common/configs/halconf.h`
*/
#pragma once
#define HAL_USE_ADC TRUE
#include_next <halconf.h>

View File

@@ -0,0 +1,22 @@
/* Copyright 2020 Nick Brassel (tzarc)
*
* 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 3 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 <https://www.gnu.org/licenses/>.
*/
#pragma once
#include_next "mcuconf.h"
#undef STM32_ADC_USE_ADC1
#define STM32_ADC_USE_ADC1 TRUE

View File

@@ -179,7 +179,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
}
/* Joystick axes settings */
joystick_config_t joystick_axes[JOYSTICK_AXES_COUNT] = {
joystick_config_t joystick_axes[JOYSTICK_AXIS_COUNT] = {
[0] = JOYSTICK_AXIS_IN(JOYSTICK_X_PIN, 268, 514, 813),
[1] = JOYSTICK_AXIS_IN(JOYSTICK_Y_PIN, 865, 519, 260)
};

View File

@@ -40,9 +40,9 @@
/* joystick support */
#ifdef JOYSTICK_ENABLE
# define JOYSTICK_AXES_COUNT 2
# define JOYSTICK_AXIS_COUNT 2
# define JOYSTICK_BUTTON_COUNT 1
# define JOYSTICK_AXES_RESOLUTION 8
# define JOYSTICK_AXIS_RESOLUTION 8
#endif
#define TAP_CODE_DELAY 10

View File

@@ -54,5 +54,5 @@
#define BOOTMAGIC_LITE_COLUMN 1
#define JOYSTICK_BUTTON_COUNT 13
#define JOYSTICK_AXES_COUNT 1
#define JOYSTICK_AXES_RESOLUTION 16
#define JOYSTICK_AXIS_COUNT 1
#define JOYSTICK_AXIS_RESOLUTION 16

View File

@@ -16,7 +16,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
int16_t joystick_position = 0;
int16_t pulses_per_revolution = 24; // Depends on encoder model. Usually 18ppr or 24ppr for Bourns EC11s.
int16_t full_joystick_value = 32767; // Equivalent to max value of int16. +full_joystick_value is +1.0 axis output. -full_joystick_value is -1.0 axis output.
joystick_config_t joystick_axes[JOYSTICK_AXES_COUNT] = {
joystick_config_t joystick_axes[JOYSTICK_AXIS_COUNT] = {
[0] = JOYSTICK_AXIS_VIRTUAL
};