forked from mirrors/qmk_userspace
Joystick feature improvements (#19052)
This commit is contained in:
parent
a5a20cc792
commit
1e95f7be8f
27 changed files with 475 additions and 215 deletions
|
@ -35,6 +35,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
# include "raw_hid.h"
|
||||
#endif
|
||||
|
||||
#ifdef JOYSTICK_ENABLE
|
||||
# include "joystick.h"
|
||||
#endif
|
||||
|
||||
#if defined(CONSOLE_ENABLE)
|
||||
# define RBUF_SIZE 128
|
||||
# include "ring_buffer.h"
|
||||
|
@ -275,6 +279,14 @@ static void send_extra(report_extra_t *report) {
|
|||
#endif
|
||||
}
|
||||
|
||||
void send_joystick(report_joystick_t *report) {
|
||||
#ifdef JOYSTICK_ENABLE
|
||||
if (usbInterruptIsReadyShared()) {
|
||||
usbSetInterruptShared((void *)report, sizeof(report_joystick_t));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void send_digitizer(report_digitizer_t *report) {
|
||||
#ifdef DIGITIZER_ENABLE
|
||||
if (usbInterruptIsReadyShared()) {
|
||||
|
@ -526,6 +538,65 @@ const PROGMEM uchar shared_hid_report[] = {
|
|||
0xC0, // End Collection
|
||||
#endif
|
||||
|
||||
#ifdef JOYSTICK_ENABLE
|
||||
// Joystick report descriptor
|
||||
0x05, 0x01, // Usage Page (Generic Desktop)
|
||||
0x09, 0x04, // Usage (Joystick)
|
||||
0xA1, 0x01, // Collection (Application)
|
||||
0x85, REPORT_ID_JOYSTICK, // Report ID
|
||||
0xA1, 0x00, // Collection (Physical)
|
||||
# if JOYSTICK_AXIS_COUNT > 0
|
||||
0x05, 0x01, // Usage Page (Generic Desktop)
|
||||
0x09, 0x30, // Usage (X)
|
||||
# if JOYSTICK_AXIS_COUNT > 1
|
||||
0x09, 0x31, // Usage (Y)
|
||||
# endif
|
||||
# if JOYSTICK_AXIS_COUNT > 2
|
||||
0x09, 0x32, // Usage (Z)
|
||||
# endif
|
||||
# if JOYSTICK_AXIS_COUNT > 3
|
||||
0x09, 0x33, // Usage (Rx)
|
||||
# endif
|
||||
# if JOYSTICK_AXIS_COUNT > 4
|
||||
0x09, 0x34, // Usage (Ry)
|
||||
# endif
|
||||
# if JOYSTICK_AXIS_COUNT > 5
|
||||
0x09, 0x35, // Usage (Rz)
|
||||
# endif
|
||||
# if JOYSTICK_AXIS_RESOLUTION == 8
|
||||
0x15, -JOYSTICK_MAX_VALUE, // Logical Minimum
|
||||
0x25, JOYSTICK_MAX_VALUE, // Logical Maximum
|
||||
0x95, JOYSTICK_AXIS_COUNT, // Report Count
|
||||
0x75, 0x08, // Report Size (8)
|
||||
# else
|
||||
0x16, HID_VALUE_16(-JOYSTICK_MAX_VALUE), // Logical Minimum
|
||||
0x26, HID_VALUE_16(JOYSTICK_MAX_VALUE), // Logical Maximum
|
||||
0x95, JOYSTICK_AXIS_COUNT, // Report Count
|
||||
0x75, 0x10, // Report Size (16)
|
||||
# endif
|
||||
0x81, 0x02, // Input (Data, Variable, Absolute)
|
||||
# endif
|
||||
|
||||
# if JOYSTICK_BUTTON_COUNT > 0
|
||||
0x05, 0x09, // Usage Page (Button)
|
||||
0x19, 0x01, // Usage Minimum (Button 1)
|
||||
0x29, JOYSTICK_BUTTON_COUNT, // Usage Maximum
|
||||
0x15, 0x00, // Logical Minimum (0)
|
||||
0x25, 0x01, // Logical Maximum (1)
|
||||
0x95, JOYSTICK_BUTTON_COUNT, // Report Count
|
||||
0x75, 0x01, // Report Size (1)
|
||||
0x81, 0x02, // Input (Data, Variable, Absolute)
|
||||
|
||||
# if (JOYSTICK_BUTTON_COUNT % 8) != 0
|
||||
0x95, 8 - (JOYSTICK_BUTTON_COUNT % 8), // Report Count
|
||||
0x75, 0x01, // Report Size (1)
|
||||
0x81, 0x03, // Input (Constant)
|
||||
# endif
|
||||
# endif
|
||||
0xC0, // End Collection
|
||||
0xC0, // End Collection
|
||||
#endif
|
||||
|
||||
#ifdef DIGITIZER_ENABLE
|
||||
// Digitizer report descriptor
|
||||
0x05, 0x0D, // Usage Page (Digitizers)
|
||||
|
@ -587,9 +658,9 @@ const PROGMEM uchar shared_hid_report[] = {
|
|||
|
||||
#ifdef RAW_ENABLE
|
||||
const PROGMEM uchar raw_hid_report[] = {
|
||||
0x06, RAW_USAGE_PAGE_LO, RAW_USAGE_PAGE_HI, // Usage Page (Vendor Defined)
|
||||
0x09, RAW_USAGE_ID, // Usage (Vendor Defined)
|
||||
0xA1, 0x01, // Collection (Application)
|
||||
0x06, HID_VALUE_16(RAW_USAGE_PAGE), // Usage Page (Vendor Defined)
|
||||
0x09, RAW_USAGE_ID, // Usage (Vendor Defined)
|
||||
0xA1, 0x01, // Collection (Application)
|
||||
// Data to host
|
||||
0x09, 0x62, // Usage (Vendor Defined)
|
||||
0x15, 0x00, // Logical Minimum (0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue