1000hz, konami spoof

This commit is contained in:
Nicholas G
2021-07-04 19:38:18 -04:00
parent 0242996c1c
commit 37f3c40ae8
29 changed files with 1398 additions and 1596 deletions
+157 -153
View File
@@ -1,35 +1,35 @@
/*
/*
* Pico SDVX
* @author SpeedyPotato
*
*
* Based off dev_hid_composite and mdxtinkernick/pico_encoders
*/
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "bsp/board.h"
#include "tusb.h"
#include "pico/stdlib.h"
#include "usb_descriptors.h"
#include "hardware/pio.h"
#include "encoders.pio.h"
#include "hardware/dma.h"
#include "hardware/irq.h"
#include "encoders.pio.h"
#include "hardware/pio.h"
#include "pico/stdlib.h"
#include "tusb.h"
#include "usb_descriptors.h"
#define SW_GPIO_SIZE 7 // Number of switches
#define ENC_GPIO_SIZE 2 // Number of encoders
#define SW_GPIO_SIZE 7 // Number of switches
#define ENC_GPIO_SIZE 2 // Number of encoders
// MODIFY KEYBINDS HERE, MAKE SURE LENGTH MATCHES SW_GPIO_SIZE
const uint8_t SW_KEYCODE[] =
{HID_KEY_RETURN, HID_KEY_A, HID_KEY_S, HID_KEY_D, HID_KEY_F, HID_KEY_Z, HID_KEY_X};
const uint8_t SW_GPIO[] = {4, 5, 6, 7, 8, 9, 10}; // MAKE SURE LENGTH MATCHES SW_GPIO_SIZE
const uint8_t LED_GPIO[] = {28, 27, 26, 22, 21, 20, 19}; // MAKE SURE LENGTH MATCHES SW_GPIO_SIZE
const uint8_t ENC_GPIO[] = {0, 2}; // L_ENC(0, 1); R_ENC(2, 3)
const uint8_t ENC_SENS = 1; // Encoder sensitivity multiplier
const uint8_t SW_KEYCODE[] = {HID_KEY_RETURN, HID_KEY_A, HID_KEY_S, HID_KEY_D,
HID_KEY_F, HID_KEY_Z, HID_KEY_X};
const uint8_t SW_GPIO[] = {4, 5, 6, 7,
8, 9, 10}; // MAKE SURE LENGTH MATCHES SW_GPIO_SIZE
const uint8_t LED_GPIO[] = {
28, 27, 26, 22, 21, 20, 19}; // MAKE SURE LENGTH MATCHES SW_GPIO_SIZE
const uint8_t ENC_GPIO[] = {0, 2}; // L_ENC(0, 1); R_ENC(2, 3)
const uint8_t ENC_SENS = 1; // Encoder sensitivity multiplier
PIO pio;
uint32_t enc_val[2];
@@ -43,184 +43,188 @@ bool sw_changed;
* DMA Encoder Logic
**/
void dma_handler() {
uint i = 1;
int interrupt_channel = 0;
while ((i & dma_hw->ints0) == 0) {
i = i << 1;
++interrupt_channel;
}
dma_hw->ints0 = 1u << interrupt_channel;
if (interrupt_channel < 4) {
dma_channel_set_read_addr(interrupt_channel, &pio->rxf[interrupt_channel], true);
}
uint i = 1;
int interrupt_channel = 0;
while ((i & dma_hw->ints0) == 0) {
i = i << 1;
++interrupt_channel;
}
dma_hw->ints0 = 1u << interrupt_channel;
if (interrupt_channel < 4) {
dma_channel_set_read_addr(interrupt_channel, &pio->rxf[interrupt_channel],
true);
}
}
/**
* Initialize Board Pins
**/
void init() {
// LED Pin on when connected
gpio_init(25);
gpio_set_dir(25, GPIO_OUT);
gpio_put(25, 1);
// LED Pin on when connected
gpio_init(25);
gpio_set_dir(25, GPIO_OUT);
gpio_put(25, 1);
// Set up the state machine for encoders
pio = pio0;
uint offset = pio_add_program(pio, &encoders_program);
// Setup Encoders
for (int i = 0; i < ENC_GPIO_SIZE; i++){
enc_val[i] = 0;
prev_enc_val[i] = 0;
encoders_program_init(pio, i, offset, ENC_GPIO[i]);
dma_channel_config c = dma_channel_get_default_config(i);
channel_config_set_read_increment(&c, false);
channel_config_set_write_increment(&c, false);
channel_config_set_dreq(&c, pio_get_dreq(pio, i, false));
dma_channel_configure(i, &c,
&enc_val[i], // Destinatinon pointer
&pio->rxf[i], // Source pointer
0x10, // Number of transfers
true // Start immediately
);
irq_set_exclusive_handler(DMA_IRQ_0, dma_handler);
irq_set_enabled(DMA_IRQ_0, true);
dma_channel_set_irq0_enabled(i, true);
}
// Set up the state machine for encoders
pio = pio0;
uint offset = pio_add_program(pio, &encoders_program);
// Setup Encoders
for (int i = 0; i < ENC_GPIO_SIZE; i++) {
enc_val[i] = 0;
prev_enc_val[i] = 0;
encoders_program_init(pio, i, offset, ENC_GPIO[i]);
// Setup Button GPIO
for (int i = 0; i < SW_GPIO_SIZE; i++) {
sw_val[i] = false;
prev_sw_val[i] = false;
gpio_init(SW_GPIO[i]);
gpio_set_function(SW_GPIO[i], GPIO_FUNC_SIO);
gpio_set_dir(SW_GPIO[i], GPIO_IN);
gpio_pull_up(SW_GPIO[i]);
}
dma_channel_config c = dma_channel_get_default_config(i);
channel_config_set_read_increment(&c, false);
channel_config_set_write_increment(&c, false);
channel_config_set_dreq(&c, pio_get_dreq(pio, i, false));
// Setup LED GPIO
for (int i = 0; i < SW_GPIO_SIZE; i++) {
gpio_init(LED_GPIO[i]);
gpio_set_dir(LED_GPIO[i], GPIO_OUT);
}
dma_channel_configure(i, &c,
&enc_val[i], // Destinatinon pointer
&pio->rxf[i], // Source pointer
0x10, // Number of transfers
true // Start immediately
);
irq_set_exclusive_handler(DMA_IRQ_0, dma_handler);
irq_set_enabled(DMA_IRQ_0, true);
dma_channel_set_irq0_enabled(i, true);
}
// Set listener bools
enc_changed = false;
sw_changed = false;
// Setup Button GPIO
for (int i = 0; i < SW_GPIO_SIZE; i++) {
sw_val[i] = false;
prev_sw_val[i] = false;
gpio_init(SW_GPIO[i]);
gpio_set_function(SW_GPIO[i], GPIO_FUNC_SIO);
gpio_set_dir(SW_GPIO[i], GPIO_IN);
gpio_pull_up(SW_GPIO[i]);
}
// Setup LED GPIO
for (int i = 0; i < SW_GPIO_SIZE; i++) {
gpio_init(LED_GPIO[i]);
gpio_set_dir(LED_GPIO[i], GPIO_OUT);
}
// Set listener bools
enc_changed = false;
sw_changed = false;
}
/**
* Update Class Vars
**/
void update_inputs() {
// Encoder Flag
for (int i = 0; i < ENC_GPIO_SIZE; i++) {
if (enc_val[i] != prev_enc_val[i]) {
enc_changed = true;
break;
}
// Encoder Flag
for (int i = 0; i < ENC_GPIO_SIZE; i++) {
if (enc_val[i] != prev_enc_val[i]) {
enc_changed = true;
break;
}
// Switch Update & Flag
for (int i = 0; i < SW_GPIO_SIZE; i++) {
if (!gpio_get(SW_GPIO[i])) {
sw_val[i] = true;
} else {
sw_val[i] = false;
}
if (!sw_changed && sw_val[i] != prev_sw_val[i]) {
sw_changed = true;
}
}
// Switch Update & Flag
for (int i = 0; i < SW_GPIO_SIZE; i++) {
if (!gpio_get(SW_GPIO[i])) {
sw_val[i] = true;
} else {
sw_val[i] = false;
}
if (!sw_changed && sw_val[i] != prev_sw_val[i]) {
sw_changed = true;
}
}
}
/**
* Keyboard Mode
**/
void key_mode() {
if (tud_hid_ready()) {
/*------------- Keyboard -------------*/
if (sw_changed) {
bool is_pressed = false;
int keycode_idx = 0;
uint8_t keycode[6] = {0}; //looks like we are limited to 6kro?
for (int i = 0; i < SW_GPIO_SIZE; i++) {
if (sw_val[i]) {
// use to avoid send multiple consecutive zero report for keyboard
keycode[keycode_idx] = SW_KEYCODE[i];
keycode_idx = ++keycode_idx % SW_GPIO_SIZE;
is_pressed = true;
if (tud_hid_ready()) {
/*------------- Keyboard -------------*/
if (sw_changed) {
bool is_pressed = false;
int keycode_idx = 0;
uint8_t keycode[6] = {0}; // looks like we are limited to 6kro?
for (int i = 0; i < SW_GPIO_SIZE; i++) {
if (sw_val[i]) {
// use to avoid send multiple consecutive zero report for keyboard
keycode[keycode_idx] = SW_KEYCODE[i];
keycode_idx = ++keycode_idx % SW_GPIO_SIZE;
is_pressed = true;
prev_sw_val[i] = sw_val[i];
// Reactive Lighting On
gpio_put(LED_GPIO[i], 1);
} else {
// Reactive Lighting Off
gpio_put(LED_GPIO[i], 0);
}
}
if (is_pressed) {
// Send key report
tud_hid_keyboard_report(REPORT_ID_KEYBOARD, 0, keycode);
} else {
// Send empty key report if previously has key pressed
tud_hid_keyboard_report(REPORT_ID_KEYBOARD, 0, NULL);
}
sw_changed = false;
}
/*------------- Mouse -------------*/
if (enc_changed) {
// Delay if needed before attempt to send mouse report
while (!tud_hid_ready()) {
board_delay(1);
}
tud_hid_mouse_report(REPORT_ID_MOUSE, 0x00, (enc_val[0] - prev_enc_val[0]) * ENC_SENS,
(enc_val[1] - prev_enc_val[1]) * ENC_SENS, 0, 0);
for (int i = 0; i < ENC_GPIO_SIZE; i++) {
prev_enc_val[i] = enc_val[i];
}
enc_changed = false;
prev_sw_val[i] = sw_val[i];
// Reactive Lighting On
gpio_put(LED_GPIO[i], 1);
} else {
// Reactive Lighting Off
gpio_put(LED_GPIO[i], 0);
}
}
if (is_pressed) {
// Send key report
tud_hid_keyboard_report(REPORT_ID_KEYBOARD, 0, keycode);
} else {
// Send empty key report if previously has key pressed
tud_hid_keyboard_report(REPORT_ID_KEYBOARD, 0, NULL);
}
sw_changed = false;
}
/*------------- Mouse -------------*/
if (enc_changed) {
// Delay if needed before attempt to send mouse report
while (!tud_hid_ready()) {
board_delay(1);
}
tud_hid_mouse_report(REPORT_ID_MOUSE, 0x00,
(enc_val[0] - prev_enc_val[0]) * ENC_SENS,
(enc_val[1] - prev_enc_val[1]) * ENC_SENS, 0, 0);
for (int i = 0; i < ENC_GPIO_SIZE; i++) {
prev_enc_val[i] = enc_val[i];
}
enc_changed = false;
}
}
}
/**
* Main Loop Function
**/
int main(void) {
board_init();
tusb_init();
init();
board_init();
tusb_init();
init();
while (1) {
tud_task(); // tinyusb device task
update_inputs();
key_mode();
}
while (1) {
tud_task(); // tinyusb device task
update_inputs();
key_mode();
}
return 0;
return 0;
}
// Invoked when received GET_REPORT control request
// Application must fill buffer report's content and return its length.
// Return zero will cause the stack to STALL request
uint16_t tud_hid_get_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t *buffer, uint16_t reqlen) {
// TODO not Implemented
(void) report_id;
(void) report_type;
(void) buffer;
(void) reqlen;
uint16_t tud_hid_get_report_cb(uint8_t report_id, hid_report_type_t report_type,
uint8_t *buffer, uint16_t reqlen) {
// TODO not Implemented
(void)report_id;
(void)report_type;
(void)buffer;
(void)reqlen;
return 0;
return 0;
}
// Invoked when received SET_REPORT control request or
// received data on OUT endpoint ( Report ID = 0, Type = 0 )
void tud_hid_set_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t const *buffer, uint16_t bufsize) {
// TODO set LED based on CAPLOCK, NUMLOCK etc...
(void) report_id;
(void) report_type;
(void) buffer;
(void) bufsize;
void tud_hid_set_report_cb(uint8_t report_id, hid_report_type_t report_type,
uint8_t const *buffer, uint16_t bufsize) {
// TODO set LED based on CAPLOCK, NUMLOCK etc...
(void)report_id;
(void)report_type;
(void)buffer;
(void)bufsize;
}
+17 -17
View File
@@ -39,24 +39,24 @@ extern "C" {
#error CFG_TUSB_MCU must be defined
#endif
#if CFG_TUSB_MCU == OPT_MCU_LPC18XX || CFG_TUSB_MCU == OPT_MCU_LPC43XX || CFG_TUSB_MCU == OPT_MCU_MIMXRT10XX || \
CFG_TUSB_MCU == OPT_MCU_NUC505 || CFG_TUSB_MCU == OPT_MCU_CXD56
#define CFG_TUSB_RHPORT0_MODE (OPT_MODE_DEVICE | OPT_MODE_HIGH_SPEED)
#if CFG_TUSB_MCU == OPT_MCU_LPC18XX || CFG_TUSB_MCU == OPT_MCU_LPC43XX || \
CFG_TUSB_MCU == OPT_MCU_MIMXRT10XX || CFG_TUSB_MCU == OPT_MCU_NUC505 || \
CFG_TUSB_MCU == OPT_MCU_CXD56
#define CFG_TUSB_RHPORT0_MODE (OPT_MODE_DEVICE | OPT_MODE_HIGH_SPEED)
#else
#define CFG_TUSB_RHPORT0_MODE OPT_MODE_DEVICE
#define CFG_TUSB_RHPORT0_MODE OPT_MODE_DEVICE
#endif
#ifndef CFG_TUSB_OS
#define CFG_TUSB_OS OPT_OS_PICO
#define CFG_TUSB_OS OPT_OS_PICO
#endif
// CFG_TUSB_DEBUG is defined by compiler in DEBUG build
// #define CFG_TUSB_DEBUG 0
/* USB DMA on some MCUs can only access a specific SRAM region with restriction on alignment.
* Tinyusb use follows macros to declare transferring memory so that they can be put
* into those specific section.
* e.g
/* USB DMA on some MCUs can only access a specific SRAM region with restriction
* on alignment. Tinyusb use follows macros to declare transferring memory so
* that they can be put into those specific section. e.g
* - CFG_TUSB_MEM SECTION : __attribute__ (( section(".usb_ram") ))
* - CFG_TUSB_MEM_ALIGN : __attribute__ ((aligned(4)))
*/
@@ -65,7 +65,7 @@ extern "C" {
#endif
#ifndef CFG_TUSB_MEM_ALIGN
#define CFG_TUSB_MEM_ALIGN __attribute__ ((aligned(4)))
#define CFG_TUSB_MEM_ALIGN __attribute__((aligned(4)))
#endif
//--------------------------------------------------------------------
@@ -73,18 +73,18 @@ extern "C" {
//--------------------------------------------------------------------
#ifndef CFG_TUD_ENDPOINT0_SIZE
#define CFG_TUD_ENDPOINT0_SIZE 64
#define CFG_TUD_ENDPOINT0_SIZE 64
#endif
//------------- CLASS -------------//
#define CFG_TUD_HID 1
#define CFG_TUD_CDC 0
#define CFG_TUD_MSC 0
#define CFG_TUD_MIDI 0
#define CFG_TUD_VENDOR 0
#define CFG_TUD_HID 1
#define CFG_TUD_CDC 0
#define CFG_TUD_MSC 0
#define CFG_TUD_MIDI 0
#define CFG_TUD_VENDOR 0
// HID buffer size Should be sufficient to hold ID (if any) + Data
#define CFG_TUD_HID_BUFSIZE 16
#define CFG_TUD_HID_BUFSIZE 16
#ifdef __cplusplus
}
+78 -75
View File
@@ -1,4 +1,4 @@
/*
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Ha Thach (tinyusb.org)
@@ -23,140 +23,143 @@
*
*/
#include "tusb.h"
#include "usb_descriptors.h"
/* A combination of interfaces must have a unique product id, since PC will save device driver after the first plug.
* Same VID/PID with different interface e.g MSC (first), then CDC (later) will possibly cause system error on PC.
#include "tusb.h"
/* A combination of interfaces must have a unique product id, since PC will save
* device driver after the first plug. Same VID/PID with different interface e.g
* MSC (first), then CDC (later) will possibly cause system error on PC.
*
* Auto ProductID layout's Bitmap:
* [MSB] HID | MSC | CDC [LSB]
*/
#define _PID_MAP(itf, n) ( (CFG_TUD_##itf) << (n) )
#define USB_PID (0x4000 | _PID_MAP(CDC, 0) | _PID_MAP(MSC, 1) | _PID_MAP(HID, 2) | \
_PID_MAP(MIDI, 3) | _PID_MAP(VENDOR, 4) )
// MODIFY SPOOF MODE HERE(0: SDVX | 1: IIDX)
#define con_mode 0
#define sdvx_pid 0x101c
#define iidx_pid 0x8048
#define _PID_MAP(itf, n) ((CFG_TUD_##itf) << (n))
//--------------------------------------------------------------------+
// Device Descriptors
//--------------------------------------------------------------------+
tusb_desc_device_t const desc_device =
{
.bLength = sizeof(tusb_desc_device_t),
.bDescriptorType = TUSB_DESC_DEVICE,
.bcdUSB = 0x0200,
.bDeviceClass = 0x00,
.bDeviceSubClass = 0x00,
.bDeviceProtocol = 0x00,
.bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE,
.idVendor = 0xCafe,
.idProduct = USB_PID,
.bcdDevice = 0x0100,
tusb_desc_device_t const desc_device = {
.bLength = sizeof(tusb_desc_device_t),
.bDescriptorType = TUSB_DESC_DEVICE,
.bcdUSB = 0x0200,
.bDeviceClass = 0x00,
.bDeviceSubClass = 0x00,
.bDeviceProtocol = 0x00,
.bMaxPacketSize0 = CFG_TUD_ENDPOINT0_SIZE,
.iManufacturer = 0x01,
.iProduct = 0x02,
.iSerialNumber = 0x03,
.idVendor = 0x1ccf,
.idProduct = con_mode ? iidx_pid : sdvx_pid,
.bcdDevice = 0x0100,
.bNumConfigurations = 0x01
};
.iManufacturer = 0x01,
.iProduct = 0x02,
.iSerialNumber = 0x03,
.bNumConfigurations = 0x01};
// Invoked when received GET DEVICE DESCRIPTOR
// Application return pointer to descriptor
uint8_t const *tud_descriptor_device_cb(void) {
return (uint8_t const *) &desc_device;
return (uint8_t const *)&desc_device;
}
//--------------------------------------------------------------------+
// HID Report Descriptor
//--------------------------------------------------------------------+
uint8_t const desc_hid_report[] =
{
TUD_HID_REPORT_DESC_KEYBOARD(HID_REPORT_ID(REPORT_ID_KEYBOARD)),
TUD_HID_REPORT_DESC_MOUSE(HID_REPORT_ID(REPORT_ID_MOUSE))
};
uint8_t const desc_hid_report[] = {
TUD_HID_REPORT_DESC_KEYBOARD(HID_REPORT_ID(REPORT_ID_KEYBOARD)),
TUD_HID_REPORT_DESC_MOUSE(HID_REPORT_ID(REPORT_ID_MOUSE))};
// Invoked when received GET HID REPORT DESCRIPTOR
// Application return pointer to descriptor
// Descriptor contents must exist long enough for transfer to complete
uint8_t const *tud_hid_descriptor_report_cb(void) {
return desc_hid_report;
}
uint8_t const *tud_hid_descriptor_report_cb(void) { return desc_hid_report; }
//--------------------------------------------------------------------+
// Configuration Descriptor
//--------------------------------------------------------------------+
enum {
ITF_NUM_HID,
ITF_NUM_TOTAL
};
enum { ITF_NUM_HID, ITF_NUM_TOTAL };
#define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + TUD_HID_DESC_LEN)
#define CONFIG_TOTAL_LEN (TUD_CONFIG_DESC_LEN + TUD_HID_DESC_LEN)
#define EPNUM_HID 0x81
#define EPNUM_HID 0x81
uint8_t const desc_configuration[] =
{
// Config number, interface count, string index, total length, attribute, power in mA
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100),
uint8_t const desc_configuration[] = {
// Config number, interface count, string index, total length, attribute,
// power in mA
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN,
TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100),
// Interface number, string index, protocol, report descriptor len, EP In & Out address, size & polling interval
TUD_HID_DESCRIPTOR(ITF_NUM_HID, 0, HID_PROTOCOL_NONE, sizeof(desc_hid_report), EPNUM_HID,
CFG_TUD_HID_BUFSIZE, 10)
};
// Interface number, string index, protocol, report descriptor len, EP In &
// Out address, size & polling interval
TUD_HID_DESCRIPTOR(ITF_NUM_HID, 0, HID_PROTOCOL_NONE,
sizeof(desc_hid_report), EPNUM_HID, CFG_TUD_HID_BUFSIZE,
1)};
// Invoked when received GET CONFIGURATION DESCRIPTOR
// Application return pointer to descriptor
// Descriptor contents must exist long enough for transfer to complete
uint8_t const *tud_descriptor_configuration_cb(uint8_t index) {
(void) index; // for multiple configurations
return desc_configuration;
(void)index; // for multiple configurations
return desc_configuration;
}
//--------------------------------------------------------------------+
// String Descriptors
//--------------------------------------------------------------------+
#define sdvx_prod "SOUND VOLTEX controller"
#define iidx_prod "beatmania IIDX controller premium model"
// array of pointer to string descriptors
char const *string_desc_arr[] =
{
(const char[]) {0x09, 0x04}, // 0: is supported language is English (0x0409)
"TinyUSB", // 1: Manufacturer
"TinyUSB Device", // 2: Product
"123456", // 3: Serials, should use chip ID
};
char const *string_desc_arr[] = {
(const char[]){0x09, 0x04}, // 0: is supported language is English (0x0409)
"Konami Amusement", // 1: Manufacturer
con_mode ? iidx_prod : sdvx_prod, // 2: Product
"123456", // 3: Serials, should use chip ID
};
static uint16_t _desc_str[32];
// Invoked when received GET STRING DESCRIPTOR request
// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete
// Application return pointer to descriptor, whose contents must exist long
// enough for transfer to complete
uint16_t const *tud_descriptor_string_cb(uint8_t index, uint16_t langid) {
(void) langid;
(void)langid;
uint8_t chr_count;
uint8_t chr_count;
if (index == 0) {
memcpy(&_desc_str[1], string_desc_arr[0], 2);
chr_count = 1;
} else {
// Convert ASCII string into UTF-16
if (index == 0) {
memcpy(&_desc_str[1], string_desc_arr[0], 2);
chr_count = 1;
} else {
// Convert ASCII string into UTF-16
if (!(index < sizeof(string_desc_arr) / sizeof(string_desc_arr[0]))) return NULL;
if (!(index < sizeof(string_desc_arr) / sizeof(string_desc_arr[0])))
return NULL;
const char *str = string_desc_arr[index];
const char *str = string_desc_arr[index];
// Cap at max char
chr_count = strlen(str);
if (chr_count > 31) chr_count = 31;
// Cap at max char
chr_count = strlen(str);
if (chr_count > 31) chr_count = 31;
for (uint8_t i = 0; i < chr_count; i++) {
_desc_str[1 + i] = str[i];
}
for (uint8_t i = 0; i < chr_count; i++) {
_desc_str[1 + i] = str[i];
}
}
// first byte is length (including header), second byte is string type
_desc_str[0] = (TUSB_DESC_STRING << 8) | (2 * chr_count + 2);
// first byte is length (including header), second byte is string type
_desc_str[0] = (TUSB_DESC_STRING << 8) | (2 * chr_count + 2);
return _desc_str;
return _desc_str;
}
+2 -5
View File
@@ -1,4 +1,4 @@
/*
/*
* The MIT License (MIT)
*
* Copyright (c) 2019 Ha Thach (tinyusb.org)
@@ -25,9 +25,6 @@
#ifndef USB_DESCRIPTORS_H_
#define USB_DESCRIPTORS_H_
enum {
REPORT_ID_KEYBOARD = 1,
REPORT_ID_MOUSE
};
enum { REPORT_ID_KEYBOARD = 1, REPORT_ID_MOUSE };
#endif /* USB_DESCRIPTORS_H_ */