refine keyboard host demo (added new line for enter key)

This commit is contained in:
hathach 2014-03-02 21:39:18 +07:00
parent b5ce076d8d
commit 90b7ead017
3 changed files with 7 additions and 5 deletions

View File

@ -150,7 +150,7 @@ OSAL_TASK_FUNCTION( cdc_serial_app_task ) (void* p_task_para)
if ( TUSB_ERROR_NONE == error)
{
for(uint8_t i=0; i<received_bytes; i++) printf("%c", serial_in_buffer[i]);
for(uint8_t i=0; i<received_bytes; i++) putchar(serial_in_buffer[i]);
for(uint8_t dev_addr=1; dev_addr <= TUSB_CFG_HOST_DEVICE_MAX; dev_addr++)
{

View File

@ -163,7 +163,9 @@ static inline void process_kbd_report(hid_keyboard_report_t const *p_new_report)
}else
{
// previously non-existed means key is pressed
printf("%c", keycode_to_ascii(p_new_report->modifier, p_new_report->keycode[i]) );
uint8_t ch = keycode_to_ascii(p_new_report->modifier, p_new_report->keycode[i]);
putchar(ch);
if ( ch == '\r' ) putchar('\n'); // added new line for enter key
}
}
// TODO example skips key released

View File

@ -64,12 +64,12 @@
#define TUSB_CFG_HOST_ENUM_BUFFER_SIZE 255
//------------- CLASS -------------//
#define TUSB_CFG_HOST_HUB 0
#define TUSB_CFG_HOST_HID_KEYBOARD 0
#define TUSB_CFG_HOST_HUB 1
#define TUSB_CFG_HOST_HID_KEYBOARD 1
#define TUSB_CFG_HOST_HID_MOUSE 1
#define TUSB_CFG_HOST_HID_GENERIC 0
#define TUSB_CFG_HOST_MSC 1
#define TUSB_CFG_HOST_CDC 0
#define TUSB_CFG_HOST_CDC 1
#define TUSB_CFG_HOST_CDC_RNDIS 0
//--------------------------------------------------------------------+