Skip to content

Commit

Permalink
[USB] 添加鼠标/NKRO功能编译开关
Browse files Browse the repository at this point in the history
  • Loading branch information
jim-kirisame committed Mar 25, 2020
1 parent 0b94482 commit cfe2841
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions usb/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ static void uart_data_parser(void)
// 通常键盘数据包
KeyboardGenericUpload(&recv_buff[2], kplen);
last_success = true;
} else if (index == 1 || index == 2 || index == 3 || index == 0x80) {
// system, consumer, mouse数据包
} else {
// 附加数据包
// 发过来的包的id和reportID一致,不用处理
KeyboardExtraUpload(&recv_buff[1], kplen + 1);
last_success = true;
Expand Down
2 changes: 1 addition & 1 deletion usb/usb.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ USB_SOURCE_DIR := ./
endif

SDCC := sdcc
SDCC_CFLAGS += -mmcs51 --model-small --stack-auto --std-c11 -o $(OBJ_DIR)/ --opt-code-size -I .
SDCC_CFLAGS += -mmcs51 --model-small --stack-auto --std-c11 -o $(OBJ_DIR)/ --opt-code-size -I . $(OPT_DEFS)
SDCC_LDFLAGS := --xram-size 1024 --iram-size 256 --code-size 14336 --out-fmt-ihx --xram-loc 0

USB_SOURCES := $(USB_SOURCE_DIR)/main.c \
Expand Down
13 changes: 9 additions & 4 deletions usb/usb_descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,12 @@ const uint8_t InterfaceStringDesc[] = {
'p',0x00,'p',0x00,'o',0x00,'r',0x00,'t',0x00,

// String index7, Interface String
32, // Length of this string descriptor
40, // Length of this string descriptor
3, // bDescriptorType
'K',0x00,'e',0x00,'y',0x00,'b',0x00,'o',0x00,'a',0x00,
'r',0x00,'d',0x00,' ',0x00,'K',0x00,'e',0x00,'y',0x00,
'm',0x00,'a',0x00,'p',0x00,
'L',0x00,'o',0x00,'t',0x00,'l',0x00,'a',0x00,'b',0x00,
' ',0x00,'C',0x00,'o',0x00,'n',0x00,'f',0x00,'i',0x00,
'g',0x00,'u',0x00,'r',0x00,'a',0x00,'t',0x00,'o',0x00,
'r',0x00,
#ifdef ONBOARD_CMSIS_DAP
// String index 7, Interface String
20, // Length of this string descriptor
Expand Down Expand Up @@ -378,6 +379,7 @@ uint8_t const report_desc_HID1[]=
0x95, 0x01, // REPORT_COUNT (1)
0x81, 0x00, // INPUT (Data,Array,Abs)
0xc0, // END_COLLECTION
#ifdef NKRO_ENABLE
/* nkro */
0x05, 0x01, // Usage Page (Generic Desktop),
0x09, 0x06, // Usage (Keyboard),
Expand All @@ -402,6 +404,8 @@ uint8_t const report_desc_HID1[]=
0x29, (NKRO_REPORT_KEYS * 8 - 1) & 0xFF, // Usage Maximum (),
0x81, 0x02, // Input (Data, Variable, Absolute),
0xc0, // End Collection
#endif
#ifdef MOUSE_ENABLE
/* mouse */
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x02, // USAGE (Mouse)
Expand Down Expand Up @@ -449,6 +453,7 @@ uint8_t const report_desc_HID1[]=
0x81, 0x06, // INPUT (Data,Var,Rel)
0xc0, // END_COLLECTION
0xc0, // END_COLLECTION
#endif
};

uint8_t const report_desc_HID2[]=
Expand Down

0 comments on commit cfe2841

Please sign in to comment.