Merge branch 'master' into group-boards-into-family
This commit is contained in:
0
examples/device/cdc_msc_freertos/.skip.MCU_MKL25ZXX
Normal file
0
examples/device/cdc_msc_freertos/.skip.MCU_MKL25ZXX
Normal file
0
examples/device/msc_dual_lun/.skip.MCU_MKL25ZXX
Normal file
0
examples/device/msc_dual_lun/.skip.MCU_MKL25ZXX
Normal file
59
examples/host/cdc_msc_hid/src/keyboard_helper.h
Normal file
59
examples/host/cdc_msc_hid/src/keyboard_helper.h
Normal file
@@ -0,0 +1,59 @@
|
||||
#ifndef KEYBOARD_HELPER_H
|
||||
#define KEYBAORD_HELPER_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "tusb.h"
|
||||
|
||||
// look up new key in previous keys
|
||||
inline bool find_key_in_report(hid_keyboard_report_t const *p_report, uint8_t keycode)
|
||||
{
|
||||
for(uint8_t i = 0; i < 6; i++)
|
||||
{
|
||||
if (p_report->keycode[i] == keycode) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
inline uint8_t keycode_to_ascii(uint8_t modifier, uint8_t keycode)
|
||||
{
|
||||
return keycode > 128 ? 0 :
|
||||
hid_keycode_to_ascii_tbl [keycode][modifier & (KEYBOARD_MODIFIER_LEFTSHIFT | KEYBOARD_MODIFIER_RIGHTSHIFT) ? 1 : 0];
|
||||
}
|
||||
|
||||
void print_kbd_report(hid_keyboard_report_t *prev_report, hid_keyboard_report_t const *new_report)
|
||||
{
|
||||
|
||||
printf("Report: ");
|
||||
uint8_t c;
|
||||
|
||||
// I assume it's possible to have up to 6 keypress events per report?
|
||||
for (uint8_t i = 0; i < 6; i++)
|
||||
{
|
||||
// Check for key presses
|
||||
if (new_report->keycode[i])
|
||||
{
|
||||
// If not in prev report then it is newly pressed
|
||||
if ( !find_key_in_report(prev_report, new_report->keycode[i]) )
|
||||
c = keycode_to_ascii(new_report->modifier, new_report->keycode[i]);
|
||||
printf("press %c ", c);
|
||||
}
|
||||
|
||||
// Check for key depresses (i.e. was present in prev report but not here)
|
||||
if (prev_report->keycode[i])
|
||||
{
|
||||
// If not present in the current report then depressed
|
||||
if (!find_key_in_report(new_report, prev_report->keycode[i]))
|
||||
{
|
||||
c = keycode_to_ascii(prev_report->modifier, prev_report->keycode[i]);
|
||||
printf("depress %c ", c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
#endif
|
@@ -54,9 +54,14 @@ CXX = $(CROSS_COMPILE)g++
|
||||
OBJCOPY = $(CROSS_COMPILE)objcopy
|
||||
SIZE = $(CROSS_COMPILE)size
|
||||
MKDIR = mkdir
|
||||
ifeq ($(CMDEXE),1)
|
||||
CP = copy
|
||||
RM = del
|
||||
else
|
||||
SED = sed
|
||||
CP = cp
|
||||
RM = rm
|
||||
endif
|
||||
|
||||
#-------------- Source files and compiler flags --------------
|
||||
|
||||
|
@@ -95,7 +95,11 @@ uf2: $(BUILD)/$(BOARD)-firmware.uf2
|
||||
OBJ_DIRS = $(sort $(dir $(OBJ)))
|
||||
$(OBJ): | $(OBJ_DIRS)
|
||||
$(OBJ_DIRS):
|
||||
ifeq ($(CMDEXE),1)
|
||||
@$(MKDIR) $(subst /,\,$@)
|
||||
else
|
||||
@$(MKDIR) -p $@
|
||||
endif
|
||||
|
||||
$(BUILD)/$(BOARD)-firmware.elf: $(OBJ)
|
||||
@echo LINK $@
|
||||
@@ -121,13 +125,6 @@ vpath %.c . $(TOP)
|
||||
$(BUILD)/obj/%.o: %.c
|
||||
@echo CC $(notdir $@)
|
||||
@$(CC) $(CFLAGS) -c -MD -o $@ $<
|
||||
@# The following fixes the dependency file.
|
||||
@# See http://make.paulandlesley.org/autodep.html for details.
|
||||
@# Regex adjusted from the above to play better with Windows paths, etc.
|
||||
@$(CP) $(@:.o=.d) $(@:.o=.P); \
|
||||
$(SED) -e 's/#.*//' -e 's/^.*: *//' -e 's/ *\\$$//' \
|
||||
-e '/^$$/ d' -e 's/$$/ :/' < $(@:.o=.d) >> $(@:.o=.P); \
|
||||
$(RM) $(@:.o=.d)
|
||||
|
||||
# ASM sources lower case .s
|
||||
vpath %.s . $(TOP)
|
||||
@@ -148,7 +145,11 @@ size: $(BUILD)/$(BOARD)-firmware.elf
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
ifeq ($(CMDEXE),1)
|
||||
rd /S /Q $(subst /,\,$(BUILD))
|
||||
else
|
||||
$(RM) -rf $(BUILD)
|
||||
endif
|
||||
|
||||
# Print out the value of a make variable.
|
||||
# https://stackoverflow.com/questions/16467718/how-to-print-out-a-variable-in-makefile
|
||||
|
Reference in New Issue
Block a user