summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego Roversi <diegor@tiscali.it>2018-03-11 11:36:20 +0100
committerDiego Roversi <diegor@tiscali.it>2018-03-11 11:36:20 +0100
commitd7b39eed5194f0bfe7f5c8713abb6f99607f5081 (patch)
tree54084741c95217da8e984073eafa24b3d398cf7a
parent91bc0cd5909007bb3608cb37880af8447c7ac877 (diff)
add serial ACM handling
-rw-r--r--TERES-HID/Descriptors.c124
-rw-r--r--TERES-HID/Descriptors.h33
-rw-r--r--TERES-HID/KeyboardMouse.c171
-rw-r--r--TERES-HID/KeyboardMouse.h2
4 files changed, 267 insertions, 63 deletions
diff --git a/TERES-HID/Descriptors.c b/TERES-HID/Descriptors.c
index 213e230..2d04b49 100644
--- a/TERES-HID/Descriptors.c
+++ b/TERES-HID/Descriptors.c
@@ -108,8 +108,9 @@ const USB_Descriptor_Device_t PROGMEM DeviceDescriptor = {
const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = {
.Config = {
.Header = {.Size =
- sizeof(USB_Descriptor_Configuration_Header_t),.
- Type = DTYPE_Configuration}
+ sizeof
+ (USB_Descriptor_Configuration_Header_t),.Type =
+ DTYPE_Configuration}
,
.TotalConfigurationSize =
@@ -124,11 +125,109 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = {
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
}
,
+ .CDC_IAD =
+ {
+ .Header = {.Size = sizeof(USB_Descriptor_Interface_Association_t), .Type = DTYPE_InterfaceAssociation},
+
+ .FirstInterfaceIndex = INTERFACE_ID_CDC_CCI,
+ .TotalInterfaces = 2,
+
+ .Class = CDC_CSCP_CDCClass,
+ .SubClass = CDC_CSCP_ACMSubclass,
+ .Protocol = CDC_CSCP_ATCommandProtocol,
+
+ .IADStrIndex = NO_DESCRIPTOR
+ },
+ .CDC_CCI_Interface =
+ {
+ .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
+
+ .InterfaceNumber = INTERFACE_ID_CDC_CCI,
+ .AlternateSetting = 0,
+
+ .TotalEndpoints = 1,
+
+ .Class = CDC_CSCP_CDCClass,
+ .SubClass = CDC_CSCP_ACMSubclass,
+ .Protocol = CDC_CSCP_ATCommandProtocol,
+
+ .InterfaceStrIndex = NO_DESCRIPTOR
+ },
+ .CDC_Functional_Header =
+ {
+ .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalHeader_t), .Type = DTYPE_CSInterface},
+ .Subtype = CDC_DSUBTYPE_CSInterface_Header,
+
+ .CDCSpecification = VERSION_BCD(1,1,0),
+ },
+
+ .CDC_Functional_ACM =
+ {
+ .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t), .Type = DTYPE_CSInterface},
+ .Subtype = CDC_DSUBTYPE_CSInterface_ACM,
+
+ .Capabilities = 0x06,
+ },
+
+ .CDC_Functional_Union =
+ {
+ .Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalUnion_t), .Type = DTYPE_CSInterface},
+ .Subtype = CDC_DSUBTYPE_CSInterface_Union,
+
+ .MasterInterfaceNumber = INTERFACE_ID_CDC_CCI,
+ .SlaveInterfaceNumber = INTERFACE_ID_CDC_DCI,
+ },
+
+ .CDC_NotificationEndpoint =
+ {
+ .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
+
+ .EndpointAddress = CDC_NOTIFICATION_EPADDR,
+ .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
+ .EndpointSize = CDC_NOTIFICATION_EPSIZE,
+ .PollingIntervalMS = 0xFF
+ },
+
+ .CDC_DCI_Interface =
+ {
+ .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
+
+ .InterfaceNumber = INTERFACE_ID_CDC_DCI,
+ .AlternateSetting = 0,
+
+ .TotalEndpoints = 2,
+
+ .Class = CDC_CSCP_CDCDataClass,
+ .SubClass = CDC_CSCP_NoDataSubclass,
+ .Protocol = CDC_CSCP_NoDataProtocol,
+
+ .InterfaceStrIndex = NO_DESCRIPTOR
+ },
+
+ .CDC_DataOutEndpoint =
+ {
+ .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
+
+ .EndpointAddress = CDC_RX_EPADDR,
+ .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
+ .EndpointSize = CDC_TXRX_EPSIZE,
+ .PollingIntervalMS = 0x05
+ },
+
+ .CDC_DataInEndpoint =
+ {
+ .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
+
+ .EndpointAddress = CDC_TX_EPADDR,
+ .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
+ .EndpointSize = CDC_TXRX_EPSIZE,
+ .PollingIntervalMS = 0x05
+ },
.HID1_KeyboardInterface = {
.Header = {.Size =
sizeof
- (USB_Descriptor_Interface_t),.
- Type = DTYPE_Interface}
+ (USB_Descriptor_Interface_t),.Type
+ = DTYPE_Interface}
,
.InterfaceNumber = INTERFACE_ID_Keyboard,
@@ -145,8 +244,8 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = {
.HID1_KeyboardHID = {
.Header = {.Size =
- sizeof(USB_HID_Descriptor_HID_t),.
- Type = HID_DTYPE_HID}
+ sizeof(USB_HID_Descriptor_HID_t),.Type
+ = HID_DTYPE_HID}
,
.HIDSpec = VERSION_BCD(1, 1, 1),
@@ -160,8 +259,8 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = {
.HID1_ReportINEndpoint = {
.Header = {.Size =
sizeof
- (USB_Descriptor_Endpoint_t),.
- Type = DTYPE_Endpoint}
+ (USB_Descriptor_Endpoint_t),.Type
+ = DTYPE_Endpoint}
,
.EndpointAddress = KEYBOARD_IN_EPADDR,
@@ -174,8 +273,9 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = {
.HID2_MouseInterface = {
.Header = {.Size =
- sizeof(USB_Descriptor_Interface_t),.
- Type = DTYPE_Interface}
+ sizeof
+ (USB_Descriptor_Interface_t),.Type =
+ DTYPE_Interface}
,
.InterfaceNumber = INTERFACE_ID_Mouse,
@@ -207,8 +307,8 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = {
.HID2_ReportINEndpoint = {
.Header = {.Size =
sizeof
- (USB_Descriptor_Endpoint_t),.
- Type = DTYPE_Endpoint}
+ (USB_Descriptor_Endpoint_t),.Type
+ = DTYPE_Endpoint}
,
.EndpointAddress = MOUSE_IN_EPADDR,
diff --git a/TERES-HID/Descriptors.h b/TERES-HID/Descriptors.h
index 045c5ac..4dd4a3e 100644
--- a/TERES-HID/Descriptors.h
+++ b/TERES-HID/Descriptors.h
@@ -116,8 +116,23 @@
HID_RI_END_COLLECTION(0)
+ /* Macros: */
+ /** Endpoint address of the CDC device-to-host notification IN endpoint. */
+ #define CDC_NOTIFICATION_EPADDR (ENDPOINT_DIR_IN | 2)
- /* Type Defines: */
+ /** Endpoint address of the CDC device-to-host data IN endpoint. */
+ #define CDC_TX_EPADDR (ENDPOINT_DIR_IN | 3)
+
+ /** Endpoint address of the CDC host-to-device data OUT endpoint. */
+ #define CDC_RX_EPADDR (ENDPOINT_DIR_OUT | 4)
+
+ /** Size in bytes of the CDC device-to-host notification IN endpoint. */
+ #define CDC_NOTIFICATION_EPSIZE 8
+
+ /** Size in bytes of the CDC data IN and OUT endpoints. */
+ #define CDC_TXRX_EPSIZE 16
+
+ /* Type Defines: */
/** Type define for the device configuration descriptor structure. This must be defined in the
* application code, as the configuration descriptor contains several sub-descriptors which
* vary between devices, and which describe the device's usage to the host.
@@ -125,6 +140,20 @@
typedef struct
{
USB_Descriptor_Configuration_Header_t Config;
+
+ // CDC Control Interface
+ USB_Descriptor_Interface_Association_t CDC_IAD;
+ USB_Descriptor_Interface_t CDC_CCI_Interface;
+ USB_CDC_Descriptor_FunctionalHeader_t CDC_Functional_Header;
+ USB_CDC_Descriptor_FunctionalACM_t CDC_Functional_ACM;
+ USB_CDC_Descriptor_FunctionalUnion_t CDC_Functional_Union;
+ USB_Descriptor_Endpoint_t CDC_NotificationEndpoint;
+
+ // CDC Data Interface
+ USB_Descriptor_Interface_t CDC_DCI_Interface;
+ USB_Descriptor_Endpoint_t CDC_DataOutEndpoint;
+ USB_Descriptor_Endpoint_t CDC_DataInEndpoint;
+
// Keyboard HID Interface
USB_Descriptor_Interface_t HID1_KeyboardInterface;
@@ -146,6 +175,8 @@
INTERFACE_ID_Keyboard = 0, /**< Keyboard interface descriptor ID */
INTERFACE_ID_Mouse = 1, /**< Mouse interface descriptor ID */
+ INTERFACE_ID_CDC_CCI = 2, /**< CDC CCI interface descriptor ID */
+ INTERFACE_ID_CDC_DCI = 3, /**< CDC DCI interface descriptor ID */
diff --git a/TERES-HID/KeyboardMouse.c b/TERES-HID/KeyboardMouse.c
index 19d6aa9..673b194 100644
--- a/TERES-HID/KeyboardMouse.c
+++ b/TERES-HID/KeyboardMouse.c
@@ -49,11 +49,11 @@
uint16_t MagicBootKey ATTR_NO_INIT;
/** Buffer to hold the previously generated Keyboard HID report, for comparison purposes inside the HID class driver. */
-static uint8_t
+static uint8_t
PrevKeyboardHIDReportBuffer[sizeof(USB_KeyboardReport_Data_t)];
/** Buffer to hold the previously generated Mouse HID report, for comparison purposes inside the HID class driver. */
-static uint8_t
+static uint8_t
PrevMouseHIDReportBuffer[sizeof(USB_WheelMouseReport_Data_t)];
int
@@ -70,6 +70,36 @@ limited(int value)
return value;
}
+/** LUFA CDC Class driver interface configuration and state information. This structure is
+ * passed to all CDC Class driver functions, so that multiple instances of the same class
+ * within a device can be differentiated from one another.
+ */
+USB_ClassInfo_CDC_Device_t VirtualSerial_CDC_Interface = {
+ .Config = {
+ .ControlInterfaceNumber = INTERFACE_ID_CDC_CCI,
+ .DataINEndpoint = {
+ .Address = CDC_TX_EPADDR,
+ .Size = CDC_TXRX_EPSIZE,
+ .Banks = 1,
+ }
+ ,
+ .DataOUTEndpoint = {
+ .Address = CDC_RX_EPADDR,
+ .Size = CDC_TXRX_EPSIZE,
+ .Banks = 1,
+ }
+ ,
+ .NotificationEndpoint = {
+ .Address = CDC_NOTIFICATION_EPADDR,
+ .Size = CDC_NOTIFICATION_EPSIZE,
+ .Banks = 1,
+ }
+ ,
+ }
+ ,
+};
+
+
/** LUFA HID Class driver interface configuration and state information. This structure is
* passed to all HID Class driver functions, so that multiple instances of the same class
* within a device can be differentiated from one another. This is for the keyboard HID
@@ -150,7 +180,16 @@ main(void)
PORTE = 0xff;
PORTB = 0xfd;
DDRB = 0xff;
+
HID_Device_USBTask(&Mouse_HID_Interface);
+
+ /*
+ * Must throw away unused bytes from the host, or it will lock up
+ * while waiting for the device
+ */
+ CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface);
+ CDC_Device_USBTask(&VirtualSerial_CDC_Interface);
+
USB_USBTask();
if ((PINE & (1 << 2)) == 0) {
@@ -264,6 +303,9 @@ EVENT_USB_Device_ConfigurationChanged(void)
ConfigSuccess &=
HID_Device_ConfigureEndpoints(&Keyboard_HID_Interface);
ConfigSuccess &= HID_Device_ConfigureEndpoints(&Mouse_HID_Interface);
+ ConfigSuccess &=
+ CDC_Device_ConfigureEndpoints(&VirtualSerial_CDC_Interface);
+
USB_Device_EnableSOFEvents();
}
@@ -273,6 +315,7 @@ EVENT_USB_Device_ControlRequest(void)
{
HID_Device_ProcessControlRequest(&Keyboard_HID_Interface);
HID_Device_ProcessControlRequest(&Mouse_HID_Interface);
+ HID_Device_ProcessControlRequest(&Mouse_HID_Interface);
}
/** Event handler for the USB device Start Of Frame event. */
@@ -283,8 +326,30 @@ EVENT_USB_Device_StartOfFrame(void)
HID_Device_MillisecondElapsed(&Mouse_HID_Interface);
}
+/** CDC class driver callback function the processing of changes to the virtual
+ * control lines sent from the host..
+ *
+ * \param[in] CDCInterfaceInfo Pointer to the CDC class interface configuration structure being referenced
+ */
+void
+EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t *
+ const CDCInterfaceInfo)
+{
+ /*
+ * You can get changes to the virtual CDC lines in this callback; a
+ * common use-case is to use the Data Terminal Ready (DTR) flag to
+ * enable and disable CDC communications in your application when set
+ * to avoid the application blocking while waiting for a host to
+ * become ready and read in the pending data from the USB endpoints.
+ */
+ bool HostReady =
+ (CDCInterfaceInfo->State.ControlLineStates.
+ HostToDevice & CDC_CONTROL_LINE_OUT_DTR) != 0;
+}
+
+
void
-reset_key(USB_KeyboardReport_Data_t *report)
+reset_key(USB_KeyboardReport_Data_t * report)
{
keyc = 0;
report->Modifier = 0;
@@ -333,7 +398,7 @@ CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t *
uint8_t x = 0;
uint8_t fn = 0;
- reset_key( KeyboardReport );
+ reset_key(KeyboardReport);
if (itsDone) {
itsDone = false;
@@ -350,22 +415,23 @@ CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t *
DDRB = 0xff;
- for (colmn = 0; colmn < 8; colmn++) { // y ?
+ for (colmn = 0; colmn < 8; colmn++) { // y ?
uint8_t keynow = 0;
-
- // that's crazy... here we set d4=1 (x14-15) and then read from port B (y0..y7)
+
+ // that's crazy... here we set d4=1 (x14-15) and then read
+ // from port B (y0..y7)
// even if we are supposed to set Y0 and then read along X
if (colmn == 0) {
cli();
- DDRB = 0x00; // all input
- PORTB = 0x00; // pull up off
- DDRD = (1 << 4); // d4 output
- PORTD = (1 << 4); // d4 = 1 -> x14-15
+ DDRB = 0x00; // all input
+ PORTB = 0x00; // pull up off
+ DDRD = (1 << 4); // d4 output
+ PORTD = (1 << 4); // d4 = 1 -> x14-15
Delay_MS(2);
- if (PINB & 0x40) { //b6(y6) == 1 -> Fn Key
+ if (PINB & 0x40) { // b6(y6) == 1 -> Fn Key
fn = 112;
// tp_guarder();
if (PINB & 0x01) {
@@ -373,60 +439,65 @@ CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t *
}
if (PINB & 0x02) {
KeyboardReport->Modifier |=
- HID_KEYBOARD_MODIFIER_LEFTSHIFT;
- add_key(KeyboardReport,HID_KEYBOARD_SC_LEFT_SHIFT);
+ HID_KEYBOARD_MODIFIER_LEFTSHIFT;
+ add_key(KeyboardReport,
+ HID_KEYBOARD_SC_LEFT_SHIFT);
}
if (PINB & 0x20) {
- add_key(KeyboardReport,HID_KEYBOARD_SC_HOME);
+ add_key(KeyboardReport, HID_KEYBOARD_SC_HOME);
}
if (PINB & 0x80) {
KeyboardReport->Modifier |=
HID_KEYBOARD_MODIFIER_RIGHTSHIFT;
- add_key(KeyboardReport,HID_KEYBOARD_SC_RIGHT_SHIFT);
+ add_key(KeyboardReport,
+ HID_KEYBOARD_SC_RIGHT_SHIFT);
}
} else {
if (PINB & 0x01) {
- add_key(KeyboardReport,HID_KEYBOARD_SC_UP_ARROW);
+ add_key(KeyboardReport, HID_KEYBOARD_SC_UP_ARROW);
}
if (PINB & 0x02) {
KeyboardReport->Modifier |=
HID_KEYBOARD_MODIFIER_LEFTSHIFT;
- add_key(KeyboardReport,HID_KEYBOARD_SC_LEFT_SHIFT);
+ add_key(KeyboardReport,
+ HID_KEYBOARD_SC_LEFT_SHIFT);
}
if (PINB & 0x20) {
- add_key(KeyboardReport,HID_KEYBOARD_SC_LEFT_ARROW);
+ add_key(KeyboardReport,
+ HID_KEYBOARD_SC_LEFT_ARROW);
}
if (PINB & 0x80) {
KeyboardReport->Modifier |=
HID_KEYBOARD_MODIFIER_RIGHTSHIFT;
- add_key(KeyboardReport,HID_KEYBOARD_SC_RIGHT_SHIFT);
+ add_key(KeyboardReport,
+ HID_KEYBOARD_SC_RIGHT_SHIFT);
}
}
#if 0
// x0
- DDRD = (1 << 6); // d6 output (x0)
- PORTD = (1 << 6);// d6 =1
- DDRB = 0x00; // input
- PORTB = 0x00; // no pullup
+ DDRD = (1 << 6); // d6 output (x0)
+ PORTD = (1 << 6); // d6 =1
+ DDRB = 0x00; // input
+ PORTB = 0x00; // no pullup
Delay_MS(2);
if (PINB & 0x10) {
KeyboardReport->Modifier |=
HID_KEYBOARD_MODIFIER_RIGHTCTRL;
- add_key(KeyboardReport,HID_KEYBOARD_SC_RIGHT_CONTROL);
+ add_key(KeyboardReport, HID_KEYBOARD_SC_RIGHT_CONTROL);
}
if (PINB & 0x40) {
KeyboardReport->Modifier |=
HID_KEYBOARD_MODIFIER_LEFTCTRL;
- add_key(KeyboardReport,HID_KEYBOARD_SC_LEFT_CONTROL);
+ add_key(KeyboardReport, HID_KEYBOARD_SC_LEFT_CONTROL);
}
if (PINB & 0x08) {
if (fn == 112)
- add_key(KeyboardReport,HID_KEYBOARD_SC_VOLUME_UP);
+ add_key(KeyboardReport, HID_KEYBOARD_SC_VOLUME_UP);
else
- add_key(KeyboardReport,HID_KEYBOARD_SC_F5);
+ add_key(KeyboardReport, HID_KEYBOARD_SC_F5);
}
#endif
PORTB = rowY[colmn];
@@ -435,7 +506,7 @@ CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t *
PORTD = 0xfc;
Delay_MS(3);
sei();
- } // if colmn==0
+ } // if colmn==0
PORTB = rowY[colmn];
while (PINB != rowY[colmn]);
@@ -445,7 +516,7 @@ CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t *
// tp_guarder();
keynow = keys[colmn * 14 + x + fn];
KeyboardReport->Modifier |= keym[colmn * 14 + x];
- add_key(KeyboardReport,keynow);
+ add_key(KeyboardReport, keynow);
}
x = 1; // 1
@@ -453,14 +524,14 @@ CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t *
// tp_guarder();
keynow = keys[colmn * 14 + x + fn];
KeyboardReport->Modifier |= keym[colmn * 14 + x];
- add_key(KeyboardReport,keynow);
+ add_key(KeyboardReport, keynow);
}
x++; // 2
if ((PINC & (1 << 6)) == 0) {
// tp_guarder();
keynow = keys[colmn * 14 + x + fn];
KeyboardReport->Modifier |= keym[colmn * 14 + x];
- add_key(KeyboardReport,keynow);
+ add_key(KeyboardReport, keynow);
}
x++; // 3
if ((PIND & (1 << 7)) == 0) {
@@ -472,7 +543,7 @@ CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t *
TouchPadLocked = !TouchPadLocked;
while ((PIND & (1 << 7)) == 0);
}
- add_key(KeyboardReport,keynow);
+ add_key(KeyboardReport, keynow);
}
x++; // 4
// Delay_MS(5);
@@ -480,63 +551,63 @@ CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t *
// tp_guarder();
keynow = keys[colmn * 14 + x + fn];
KeyboardReport->Modifier |= keym[colmn * 14 + x];
- add_key(KeyboardReport,keynow);
+ add_key(KeyboardReport, keynow);
}
x++; // 5
if ((PINF & (1 << 1)) == 0) {
// tp_guarder();
keynow = keys[colmn * 14 + x + fn];
KeyboardReport->Modifier |= keym[colmn * 14 + x];
- add_key(KeyboardReport,keynow);
+ add_key(KeyboardReport, keynow);
}
x++; // 6
if ((PINF & (1 << 6)) == 0) {
// tp_guarder();
keynow = keys[colmn * 14 + x + fn];
KeyboardReport->Modifier |= keym[colmn * 14 + x];
- add_key(KeyboardReport,keynow);
+ add_key(KeyboardReport, keynow);
}
x++; // 7
if ((PINE & (1 << 6)) == 0) {
// tp_guarder();
keynow = keys[colmn * 14 + x + fn];
KeyboardReport->Modifier |= keym[colmn * 14 + x];
- add_key(KeyboardReport,keynow);
+ add_key(KeyboardReport, keynow);
}
x++; // 8
if ((PINF & (1 << 4)) == 0) {
// tp_guarder();
keynow = keys[colmn * 14 + x + fn];
KeyboardReport->Modifier |= keym[colmn * 14 + x];
- add_key(KeyboardReport,keynow);
+ add_key(KeyboardReport, keynow);
}
x++; // 9
if ((PIND & (1 << 5)) == 0) {
// tp_guarder();
keynow = keys[colmn * 14 + x + fn];
KeyboardReport->Modifier |= keym[colmn * 14 + x];
- add_key(KeyboardReport,keynow);
+ add_key(KeyboardReport, keynow);
}
x++; // 10
if ((PINF & (1 << 5)) == 0) {
// tp_guarder();
keynow = keys[colmn * 14 + x + fn];
KeyboardReport->Modifier |= keym[colmn * 14 + x];
- add_key(KeyboardReport,keynow);
+ add_key(KeyboardReport, keynow);
}
x++; // 11
if ((PINF & (1 << 7)) == 0) {
// tp_guarder();
keynow = keys[colmn * 14 + x + fn];
KeyboardReport->Modifier |= keym[colmn * 14 + x];
- add_key(KeyboardReport,keynow);
+ add_key(KeyboardReport, keynow);
}
x++; // 12
if ((PINE & (1 << 2)) == 0) {
// tp_guarder();
keynow = keys[colmn * 14 + x + fn];
KeyboardReport->Modifier |= keym[colmn * 14 + x];
- add_key(KeyboardReport,keynow);
+ add_key(KeyboardReport, keynow);
}
DDRD = 0;
PORTD = 0xfc;
@@ -548,7 +619,7 @@ CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t *
*ReportSize = sizeof(USB_KeyboardReport_Data_t);
return true; // return false;
}
-
+
if (HIDInterfaceInfo == &Mouse_HID_Interface) {
USB_WheelMouseReport_Data_t *MouseReport =
(USB_WheelMouseReport_Data_t *) ReportData;
@@ -607,21 +678,21 @@ CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t *
default:
break;
}
-
+
if (lastfingers != 1) {
time_one = 0;
startposX = posx1;
startposY = posy1;
lastfingers = 1;
}
-
+
lastposX = posx1;
lastposY = posy1;
if (speedlimit != 0x80)
speedlimit += 0x04;
break;
-
+
case 2:
if (lastfingers == 0)
touch_to = TOUCH_TO;
@@ -665,7 +736,7 @@ CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t *
*ReportSize = sizeof(USB_WheelMouseReport_Data_t);
return true;
}
-
+
return false;
}
@@ -697,7 +768,7 @@ ISR(ADC_vect)
{
ADCSRA |= (1 << ADIF);
button = ADCH;
-
+
if (button == oldbutton) {
if (button < 0xe8) {
if (button > 0xa0)
@@ -710,8 +781,8 @@ ISR(ADC_vect)
mouse = 0;
} else
oldbutton = button;
-
- mouse=0; // temporary fix: disable button
+
+ mouse = 0; // temporary fix: disable button
}
diff --git a/TERES-HID/KeyboardMouse.h b/TERES-HID/KeyboardMouse.h
index 52267ff..5470496 100644
--- a/TERES-HID/KeyboardMouse.h
+++ b/TERES-HID/KeyboardMouse.h
@@ -59,6 +59,8 @@
#include <LUFA/Platform/Platform.h>
#include <LUFA/Drivers/Peripheral/TWI.h>
#include <LUFA/Drivers/Peripheral/ADC.h>
+
+
/** Magic bootloader key to unlock forced application start mode. */
#define MAGIC_BOOT_KEY 0xDC42