Squashed 'tmk_core/' changes from 8da1898..e5f9940

e5f9940 Merge commit '1bc3dd200b023cecf063a0cb3ba347f77f6d759d' into core_update
da03c50 Add note for L/R side bit being ignored
e80f3c1 Add in basic documentation for Macro system
35e8a76 core: Swap position of PEQL and PENT in unimap
00751f1 Merge pull request #406 from 39aldo39/patch-1
e50d7de V-USB remote wakeup
4340997 core: Fix typo in definition AC_g
958144d core: Debug print for system and consumer keys
e7e1030 core: Fix sleep_led
0866323 core: Change matrix_init and matrix_print
0dbf73d core: Add matrix_clear() and default impl.
3202ca3 core: Add suspend mode options
4cda3aa core: Fix suspend/wake for converters #386
4e15247 core: LUFA_DEBUG_SUART for serial debug
b9cf8e7 core: Fix mechanical locking supoort #390
12aa0fd Merge branch 'nemith-master'
fccb3fa core: Fix OPT_DEFS for mbed build
2e2d2c8 Merge branch 'master' of github.com:leizzer/tmk_keyboard
f1d3634 Change .gitignore for ChibiOS
3aab802 core: Fix build config in protocol.mk
5e43da0 core: Add short names in unimap
7a56998 core: Fix dfu wait in rules.mk
6d9c500 Merge branch 'mediakey-fix'
08382ac core: Fix 'make dfu' message
78cb04e Fix OS X Recognizing keyboard as Mouse/Tablet
a114714 core: 'make dfu' waits for bootloader to start
d0a8f13 core: Fix unimap UNIMAP_NO case
e17abef core: Change lufa NKRO report size 16 to 32 bytes
375b20f core: Fix common.mk for build options
394fdff core: Fix unimap layout comment
912326c core: Add unimap support
00f4011 core: Fix doc/keymap.md for new keymap framework
ddbd7b4 core: Add default implemenation of keymap read
671cacc core: action codes are action_t struct now
b4fdb27 core: Change chibios repo directory names
7daed10 core: Fix keycode.txt
90399d7 core: Fix USB remote wakeup on ATmega32U2 #361
3677e84 usb_usb: Add multiple keyboard support
54d5b26 core: Fix Logical Maximum in report descriptor
bd0d372 core: Fix LUFA report descriptor
95327b5 Merge pull request #355 from papodaca/XT
62bf548 core: change API of adb.c to accept device address
3097c9e Fix function name in host.h
836e209 Merge branch 'core_split_160522'
3918ea2 Merge commit '20b787fc12'
7f87b11 core: Add comment of register 3 of ADB
ef6478a core: Add adb_host_talk()
5c665b4 update macro names in bluefruit
4f2c5bf Merge commit '71381457fa'
53a9c08 Merge pull request #321 from njbair/master
f08a656 core: Fix media/consumer keys
d526de8 Clean up wording in keymap example
0bb3dbb Clarify layer precedence
d915c75 clarify layer documentation
72070d4 ps2_usb: Fix for VUSB configuration
170e2dc Mostly working. Is unstable, will emit bad codes after a while.
c8e45b5 core: Actionmap support
aabaa24 Codes appear to be detected correctly, the break codes are broken.

git-subtree-dir: tmk_core
git-subtree-split: e5f994033cbc8700745ac0c6d12772820492eed0
This commit is contained in:
tmk 2016-12-10 10:29:51 +09:00
parent 20b787fc12
commit 22b6e15a17
55 changed files with 2042 additions and 405 deletions

View file

@ -73,10 +73,10 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] =
HID_RI_OUTPUT(8, HID_IOF_CONSTANT),
HID_RI_USAGE_PAGE(8, 0x07), /* Keyboard */
HID_RI_USAGE_MINIMUM(8, 0x00), /* Reserved (no event indicated) */
HID_RI_USAGE_MAXIMUM(8, 0xFF), /* Keyboard Application */
HID_RI_USAGE_MINIMUM(8, 0x00),
HID_RI_USAGE_MAXIMUM(8, 0xFF), /* Usage ID 0x00-0xFF */
HID_RI_LOGICAL_MINIMUM(8, 0x00),
HID_RI_LOGICAL_MAXIMUM(8, 0xFF),
HID_RI_LOGICAL_MAXIMUM(16, 0x00FF), /* needs 16 bit to indicate positive value */
HID_RI_REPORT_COUNT(8, 0x06),
HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE),
@ -140,9 +140,9 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM ExtrakeyReport[] =
HID_RI_USAGE(8, 0x80), /* System Control */
HID_RI_COLLECTION(8, 0x01), /* Application */
HID_RI_REPORT_ID(8, REPORT_ID_SYSTEM),
HID_RI_LOGICAL_MINIMUM(16, 0x0001),
HID_RI_LOGICAL_MINIMUM(16, 0x0081),
HID_RI_LOGICAL_MAXIMUM(16, 0x00B7),
HID_RI_USAGE_MINIMUM(16, 0x0001), /* System Power Down */
HID_RI_USAGE_MINIMUM(16, 0x0081), /* System Power Down */
HID_RI_USAGE_MAXIMUM(16, 0x00B7), /* System Display LCD Autoscale */
HID_RI_REPORT_SIZE(8, 16),
HID_RI_REPORT_COUNT(8, 1),
@ -172,13 +172,13 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM ConsoleReport[] =
HID_RI_COLLECTION(8, 0x01), /* Application */
HID_RI_USAGE(8, 0x75), /* Vendor Usage 0x75 */
HID_RI_LOGICAL_MINIMUM(8, 0x00),
HID_RI_LOGICAL_MAXIMUM(8, 0xFF),
HID_RI_LOGICAL_MAXIMUM(16, 0x00FF),
HID_RI_REPORT_COUNT(8, CONSOLE_EPSIZE),
HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
HID_RI_USAGE(8, 0x76), /* Vendor Usage 0x76 */
HID_RI_LOGICAL_MINIMUM(8, 0x00),
HID_RI_LOGICAL_MAXIMUM(8, 0xFF),
HID_RI_LOGICAL_MAXIMUM(16, 0x00FF),
HID_RI_REPORT_COUNT(8, CONSOLE_EPSIZE),
HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),

View file

@ -155,7 +155,7 @@ typedef struct
#define MOUSE_EPSIZE 8
#define EXTRAKEY_EPSIZE 8
#define CONSOLE_EPSIZE 32
#define NKRO_EPSIZE 16
#define NKRO_EPSIZE 32
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,

View file

@ -1,4 +1,4 @@
/*
/*
* Copyright 2012 Jun Wako <wakojun@gmail.com>
* This file is based on:
* LUFA-120219/Demos/Device/Lowlevel/KeyboardMouse
@ -50,9 +50,18 @@
#include "suspend.h"
#include "hook.h"
#ifdef LUFA_DEBUG_SUART
#include "avr/suart.h"
#endif
#include "matrix.h"
#include "descriptor.h"
#include "lufa.h"
//#define LUFA_DEBUG
uint8_t keyboard_idle = 0;
/* 0: Boot Protocol, 1: Report Protocol(default) */
uint8_t keyboard_protocol = 1;
@ -100,10 +109,10 @@ static void Console_Task(void)
{
/* Create a temporary buffer to hold the read in report from the host */
uint8_t ConsoleData[CONSOLE_EPSIZE];
/* Read Console Report Data */
Endpoint_Read_Stream_LE(&ConsoleData, sizeof(ConsoleData), NULL);
/* Process Console Report Data */
//ProcessConsoleHIDReport(ConsoleData);
}
@ -164,7 +173,7 @@ void EVENT_USB_Device_Disconnect(void)
print("[D]");
/* For battery powered device */
USB_IsInitialized = false;
/* TODO: This doesn't work. After several plug in/outs can not be enumerated.
/* TODO: This doesn't work. After several plug in/outs can not be enumerated.
if (USB_IsInitialized) {
USB_Disable(); // Disable all interrupts
USB_Controller_Enable();
@ -175,18 +184,24 @@ void EVENT_USB_Device_Disconnect(void)
void EVENT_USB_Device_Reset(void)
{
#ifdef LUFA_DEBUG
print("[R]");
#endif
}
void EVENT_USB_Device_Suspend()
{
#ifdef LUFA_DEBUG
print("[S]");
#endif
hook_usb_suspend_entry();
}
void EVENT_USB_Device_WakeUp()
{
#ifdef LUFA_DEBUG
print("[W]");
#endif
hook_usb_wakeup();
}
@ -217,6 +232,9 @@ void EVENT_USB_Device_StartOfFrame(void)
*/
void EVENT_USB_Device_ConfigurationChanged(void)
{
#ifdef LUFA_DEBUG
print("[c]");
#endif
bool ConfigSuccess = true;
/* Setup Keyboard HID Report Endpoints */
@ -293,6 +311,9 @@ void EVENT_USB_Device_ControlRequest(void)
/* Write the report data to the control endpoint */
Endpoint_Write_Control_Stream_LE(ReportData, ReportSize);
Endpoint_ClearOUT();
#ifdef LUFA_DEBUG
xprintf("[r%d]", USB_ControlRequest.wIndex);
#endif
}
break;
@ -316,6 +337,9 @@ void EVENT_USB_Device_ControlRequest(void)
Endpoint_ClearOUT();
Endpoint_ClearStatusStage();
#ifdef LUFA_DEBUG
xprintf("[L%d]", USB_ControlRequest.wIndex);
#endif
break;
}
@ -332,6 +356,9 @@ void EVENT_USB_Device_ControlRequest(void)
Endpoint_Write_8(keyboard_protocol);
Endpoint_ClearIN();
Endpoint_ClearStatusStage();
#ifdef LUFA_DEBUG
print("[p]");
#endif
}
}
@ -345,6 +372,9 @@ void EVENT_USB_Device_ControlRequest(void)
keyboard_protocol = (USB_ControlRequest.wValue & 0xFF);
clear_keyboard();
#ifdef LUFA_DEBUG
print("[P]");
#endif
}
}
@ -356,6 +386,9 @@ void EVENT_USB_Device_ControlRequest(void)
Endpoint_ClearStatusStage();
keyboard_idle = ((USB_ControlRequest.wValue & 0xFF00) >> 8);
#ifdef LUFA_DEBUG
xprintf("[I%d]%d", USB_ControlRequest.wIndex, (USB_ControlRequest.wValue & 0xFF00) >> 8);
#endif
}
break;
@ -367,6 +400,9 @@ void EVENT_USB_Device_ControlRequest(void)
Endpoint_Write_8(keyboard_idle);
Endpoint_ClearIN();
Endpoint_ClearStatusStage();
#ifdef LUFA_DEBUG
print("[i]");
#endif
}
break;
@ -374,7 +410,7 @@ void EVENT_USB_Device_ControlRequest(void)
}
/*******************************************************************************
* Host driver
* Host driver
******************************************************************************/
static uint8_t keyboard_leds(void)
{
@ -494,6 +530,9 @@ static void send_consumer(uint16_t data)
#define SEND_TIMEOUT 5
int8_t sendchar(uint8_t c)
{
#ifdef LUFA_DEBUG_SUART
xmit(c);
#endif
// Not wait once timeouted.
// Because sendchar() is called so many times, waiting each call causes big lag.
static bool timeouted = false;
@ -551,6 +590,9 @@ ERROR_EXIT:
#else
int8_t sendchar(uint8_t c)
{
#ifdef LUFA_DEBUG_SUART
xmit(c);
#endif
return 0;
}
#endif
@ -578,13 +620,20 @@ static void setup_usb(void)
// for Console_Task
USB_Device_EnableSOFEvents();
print_set_sendchar(sendchar);
}
int main(void) __attribute__ ((weak));
int main(void)
{
setup_mcu();
#ifdef LUFA_DEBUG_SUART
SUART_OUT_DDR |= (1<<SUART_OUT_BIT);
SUART_OUT_PORT |= (1<<SUART_OUT_BIT);
#endif
print_set_sendchar(sendchar);
print("\r\ninit\n");
hook_early_init();
keyboard_setup();
setup_usb();
@ -611,7 +660,9 @@ int main(void)
hook_late_init();
while (1) {
while (USB_DeviceState == DEVICE_STATE_Suspended) {
#ifdef LUFA_DEBUG
print("[s]");
#endif
hook_usb_suspend_loop();
}
@ -631,9 +682,19 @@ void hook_early_init(void) {}
__attribute__((weak))
void hook_late_init(void) {}
static uint8_t _led_stats = 0;
__attribute__((weak))
void hook_usb_suspend_entry(void)
{
// Turn LED off to save power
// Set 0 with putting aside status before suspend and restore
// it after wakeup, then LED is updated at keyboard_task() in main loop
_led_stats = keyboard_led_stats;
keyboard_led_stats = 0;
led_set(keyboard_led_stats);
matrix_clear();
clear_keyboard();
#ifdef SLEEP_LED_ENABLE
sleep_led_enable();
#endif
@ -644,7 +705,7 @@ void hook_usb_suspend_loop(void)
{
suspend_power_down();
if (USB_Device_RemoteWakeupEnabled && suspend_wakeup_condition()) {
USB_Device_SendRemoteWakeup();
USB_Device_SendRemoteWakeup();
}
}
@ -654,7 +715,12 @@ void hook_usb_wakeup(void)
suspend_wakeup_init();
#ifdef SLEEP_LED_ENABLE
sleep_led_disable();
// NOTE: converters may not accept this
led_set(host_keyboard_leds());
#endif
// Restore LED status
// BIOS/grub won't recognize/enumerate if led_set() takes long(around 40ms?)
// Converters fall into the case and miss wakeup event(timeout to reply?) in the end.
//led_set(host_keyboard_leds());
// Instead, restore stats and update at keyboard_task() in main loop
keyboard_led_stats = _led_stats;
}