forked from qmk/qmk_firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Joystick feature updates (qmk#16732)
* Joystick feature updates * Move new functions to joystick.h * Docs
- Loading branch information
Showing
10 changed files
with
52 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,8 +16,6 @@ | |
|
||
#include QMK_KEYBOARD_H | ||
|
||
#include "joystick.h" | ||
|
||
enum layer_names { | ||
NORMAL_LAYER = 0 | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,8 +16,6 @@ | |
|
||
#include QMK_KEYBOARD_H | ||
|
||
#include "joystick.h" | ||
|
||
enum layer_names { | ||
NORMAL_LAYER = 0 | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
#include QMK_KEYBOARD_H | ||
|
||
#include "joystick.h" | ||
|
||
#ifndef ADC_PIN | ||
# define ADC_PIN F6 | ||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,6 @@ | |
#include QMK_KEYBOARD_H | ||
|
||
#ifdef JOYSTICK_ENABLE | ||
# include "joystick.h" | ||
# include "analog.h" | ||
#endif | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,38 @@ | ||
#include "joystick.h" | ||
|
||
joystick_t joystick_status = {.buttons = {0}, | ||
.axes = | ||
{ | ||
// clang-format off | ||
joystick_t joystick_status = { | ||
.buttons = {0}, | ||
.axes = { | ||
#if JOYSTICK_AXES_COUNT > 0 | ||
0 | ||
0 | ||
#endif | ||
}, | ||
.status = 0}; | ||
}, | ||
.status = 0 | ||
}; | ||
// clang-format on | ||
|
||
// array defining the reading of analog values for each axis | ||
__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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters