mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-05-02 12:01:34 +00:00
Merge remote-tracking branch 'origin/develop' into xap
This commit is contained in:
commit
80102c0e83
@ -150,3 +150,5 @@ Note that the supported AVR MCUs have a 10-bit ADC, and 12-bit for most STM32 MC
|
|||||||
|
|
||||||
Joystick buttons are normal Quantum keycodes, defined as `JS_BUTTON0` to `JS_BUTTON31`, depending on the number of buttons you have configured.
|
Joystick buttons are normal Quantum keycodes, defined as `JS_BUTTON0` to `JS_BUTTON31`, depending on the number of buttons you have configured.
|
||||||
To trigger a joystick button, just add the corresponding keycode to your keymap.
|
To trigger a joystick button, just add the corresponding keycode to your keymap.
|
||||||
|
|
||||||
|
You can also trigger joystick buttons in code with `register_joystick_button(button)` and `unregister_joystick_button(button)`, where `button` is the 0-based button index (0 = button 1).
|
||||||
|
@ -15,8 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "battleship_gamepad.h"
|
#include "battleship_gamepad.h"
|
||||||
#include "joystick.h"
|
|
||||||
#include "analog.h"
|
|
||||||
|
|
||||||
/* joystick config */
|
/* joystick config */
|
||||||
joystick_config_t joystick_axes[JOYSTICK_AXES_COUNT] = {
|
joystick_config_t joystick_axes[JOYSTICK_AXES_COUNT] = {
|
||||||
|
@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
#include QMK_KEYBOARD_H
|
#include QMK_KEYBOARD_H
|
||||||
|
|
||||||
#include "joystick.h"
|
|
||||||
|
|
||||||
enum layer_names {
|
enum layer_names {
|
||||||
NORMAL_LAYER = 0
|
NORMAL_LAYER = 0
|
||||||
};
|
};
|
||||||
|
@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
#include QMK_KEYBOARD_H
|
#include QMK_KEYBOARD_H
|
||||||
|
|
||||||
#include "joystick.h"
|
|
||||||
|
|
||||||
enum layer_names {
|
enum layer_names {
|
||||||
NORMAL_LAYER = 0
|
NORMAL_LAYER = 0
|
||||||
};
|
};
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
#include QMK_KEYBOARD_H
|
#include QMK_KEYBOARD_H
|
||||||
|
|
||||||
#include "joystick.h"
|
|
||||||
|
|
||||||
#ifndef ADC_PIN
|
#ifndef ADC_PIN
|
||||||
# define ADC_PIN F6
|
# define ADC_PIN F6
|
||||||
#endif
|
#endif
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
#include QMK_KEYBOARD_H
|
#include QMK_KEYBOARD_H
|
||||||
|
|
||||||
#ifdef JOYSTICK_ENABLE
|
#ifdef JOYSTICK_ENABLE
|
||||||
# include "joystick.h"
|
|
||||||
# include "analog.h"
|
# include "analog.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -10,10 +10,10 @@ This was the first 65% keyboard made by the Matrix team, it had the following fe
|
|||||||
|
|
||||||
Keyboard Maintainer: [astro](https://github.com/yulei)
|
Keyboard Maintainer: [astro](https://github.com/yulei)
|
||||||
Hardware Supported: Matrix NOAH keyboard
|
Hardware Supported: Matrix NOAH keyboard
|
||||||
Hardware Availability: [NOAH Keybaord](https://geekhack.org/index.php?topic=102300.0)
|
Hardware Availability: [NOAH Keyboard](https://geekhack.org/index.php?topic=102300.0)
|
||||||
|
|
||||||
Make example for this keyboard (after setting up your build environment):
|
Make example for this keyboard (after setting up your build environment):
|
||||||
|
|
||||||
make matrix/noah:default
|
make matrix/noah:default
|
||||||
|
|
||||||
See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs).
|
See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs).
|
||||||
|
@ -759,9 +759,9 @@ def find_info_json(keyboard):
|
|||||||
|
|
||||||
# Add in parent folders for least specific
|
# Add in parent folders for least specific
|
||||||
for _ in range(5):
|
for _ in range(5):
|
||||||
info_jsons.append(keyboard_parent / 'info.json')
|
if keyboard_parent == base_path:
|
||||||
if keyboard_parent.parent == base_path:
|
|
||||||
break
|
break
|
||||||
|
info_jsons.append(keyboard_parent / 'info.json')
|
||||||
keyboard_parent = keyboard_parent.parent
|
keyboard_parent = keyboard_parent.parent
|
||||||
|
|
||||||
# Return a list of the info.json files that actually exist
|
# Return a list of the info.json files that actually exist
|
||||||
|
@ -1,13 +1,38 @@
|
|||||||
#include "joystick.h"
|
#include "joystick.h"
|
||||||
|
|
||||||
joystick_t joystick_status = {.buttons = {0},
|
// clang-format off
|
||||||
.axes =
|
joystick_t joystick_status = {
|
||||||
{
|
.buttons = {0},
|
||||||
|
.axes = {
|
||||||
#if JOYSTICK_AXES_COUNT > 0
|
#if JOYSTICK_AXES_COUNT > 0
|
||||||
0
|
0
|
||||||
#endif
|
#endif
|
||||||
},
|
},
|
||||||
.status = 0};
|
.status = 0
|
||||||
|
};
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
// array defining the reading of analog values for each axis
|
// array defining the reading of analog values for each axis
|
||||||
__attribute__((weak)) joystick_config_t joystick_axes[JOYSTICK_AXES_COUNT] = {};
|
__attribute__((weak)) joystick_config_t joystick_axes[JOYSTICK_AXES_COUNT] = {};
|
||||||
|
|
||||||
|
// to be implemented in the hid protocol library
|
||||||
|
void send_joystick_packet(joystick_t *joystick);
|
||||||
|
|
||||||
|
void joystick_flush(void) {
|
||||||
|
if ((joystick_status.status & JS_UPDATED) > 0) {
|
||||||
|
send_joystick_packet(&joystick_status);
|
||||||
|
joystick_status.status &= ~JS_UPDATED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void register_joystick_button(uint8_t button) {
|
||||||
|
joystick_status.buttons[button / 8] |= 1 << (button % 8);
|
||||||
|
joystick_status.status |= JS_UPDATED;
|
||||||
|
joystick_flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
void unregister_joystick_button(uint8_t button) {
|
||||||
|
joystick_status.buttons[button / 8] &= ~(1 << (button % 8));
|
||||||
|
joystick_status.status |= JS_UPDATED;
|
||||||
|
joystick_flush();
|
||||||
|
}
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "quantum.h"
|
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include "gpio.h"
|
||||||
|
|
||||||
#ifndef JOYSTICK_BUTTON_COUNT
|
#ifndef JOYSTICK_BUTTON_COUNT
|
||||||
# define JOYSTICK_BUTTON_COUNT 8
|
# define JOYSTICK_BUTTON_COUNT 8
|
||||||
@ -58,5 +57,7 @@ typedef struct {
|
|||||||
|
|
||||||
extern joystick_t joystick_status;
|
extern joystick_t joystick_status;
|
||||||
|
|
||||||
// to be implemented in the hid protocol library
|
void joystick_flush(void);
|
||||||
void send_joystick_packet(joystick_t *joystick);
|
|
||||||
|
void register_joystick_button(uint8_t button);
|
||||||
|
void unregister_joystick_button(uint8_t button);
|
||||||
|
@ -6,41 +6,25 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
bool process_joystick_buttons(uint16_t keycode, keyrecord_t *record);
|
|
||||||
|
|
||||||
bool process_joystick(uint16_t keycode, keyrecord_t *record) {
|
bool process_joystick(uint16_t keycode, keyrecord_t *record) {
|
||||||
if (process_joystick_buttons(keycode, record) && (joystick_status.status & JS_UPDATED) > 0) {
|
switch (keycode) {
|
||||||
send_joystick_packet(&joystick_status);
|
case JS_BUTTON0 ... JS_BUTTON_MAX:
|
||||||
joystick_status.status &= ~JS_UPDATED;
|
if (record->event.pressed) {
|
||||||
|
register_joystick_button(keycode - JS_BUTTON0);
|
||||||
|
} else {
|
||||||
|
unregister_joystick_button(keycode - JS_BUTTON0);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((weak)) void joystick_task(void) {
|
__attribute__((weak)) void joystick_task(void) {
|
||||||
if (process_joystick_analogread() && (joystick_status.status & JS_UPDATED)) {
|
if (process_joystick_analogread()) {
|
||||||
send_joystick_packet(&joystick_status);
|
joystick_flush();
|
||||||
joystick_status.status &= ~JS_UPDATED;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool process_joystick_buttons(uint16_t keycode, keyrecord_t *record) {
|
|
||||||
if (keycode < JS_BUTTON0 || keycode > JS_BUTTON_MAX) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
uint8_t button_idx = (keycode - JS_BUTTON0);
|
|
||||||
if (record->event.pressed) {
|
|
||||||
joystick_status.buttons[button_idx / 8] |= 1 << (button_idx % 8);
|
|
||||||
} else {
|
|
||||||
joystick_status.buttons[button_idx / 8] &= ~(1 << (button_idx % 8));
|
|
||||||
}
|
|
||||||
|
|
||||||
joystick_status.status |= JS_UPDATED;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t savePinState(pin_t pin) {
|
uint16_t savePinState(pin_t pin) {
|
||||||
#ifdef __AVR__
|
#ifdef __AVR__
|
||||||
uint8_t pinNumber = pin & 0xF;
|
uint8_t pinNumber = pin & 0xF;
|
||||||
|
@ -200,6 +200,10 @@ extern layer_state_t layer_state;
|
|||||||
# include "dynamic_keymap.h"
|
# include "dynamic_keymap.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef JOYSTICK_ENABLE
|
||||||
|
# include "joystick.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef XAP_ENABLE
|
#ifdef XAP_ENABLE
|
||||||
# include "xap.h"
|
# include "xap.h"
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user