summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main.c35
1 files changed, 16 insertions, 19 deletions
diff --git a/main.c b/main.c
index 4afe361..6c38571 100644
--- a/main.c
+++ b/main.c
@@ -71,8 +71,8 @@ PROGMEM const char usbHidReportDescriptor[50] = {
0x09, 0x33, // USAGE (Rx)
0x09, 0x34, // USAGE (Ry)
0x09, 0x35, // USAGE (Rz)
- 0x15, 0x81, // LOGICAL_MINIMUM (-127)
- 0x25, 0x7F, // LOGICAL_MAXIMUM (127)
+ 0x15, 0x00, // LOGICAL_MINIMUM (0)
+ 0x25, 0xFF, // LOGICAL_MAXIMUM (255)
0x75, 0x08, // REPORT_SIZE (8)
0x95, 0x06, // REPORT_COUNT (6)
0x81, 0x02, // INPUT (Data,Var,Abs)
@@ -81,12 +81,12 @@ PROGMEM const char usbHidReportDescriptor[50] = {
};
typedef struct {
- uchar btn1;
- uchar btn2;
- char x;
- char y;
- char cx;
- char cy;
+ uchar buttons;
+ uchar dpad;
+ uchar x;
+ uchar y;
+ uchar cx;
+ uchar cy;
uchar ltrig;
uchar rtrig;
} report_t;
@@ -298,7 +298,6 @@ char decode_byte(char* bufptr)
int main (void)
{
char rand=123;
- char gc_x=3, gc_y=3;
unsigned char ltrig=0, rtrig=0;
DDRC=0x00;
@@ -347,8 +346,6 @@ debug(4);
if(usbInterruptIsReady())
{
- reportBuffer.x = gc_x;
- reportBuffer.y = -gc_y;
usbSetInterrupt((void *)&reportBuffer, sizeof(reportBuffer));
@@ -394,24 +391,24 @@ debug(4);
if (n_received == 64)
{
- gc_y=decode_byte(buffer+24);
- gc_x=decode_byte(buffer+16);
+ reportBuffer.x=decode_byte(buffer+16);
+ reportBuffer.y=~decode_byte(buffer+24);
reportBuffer.cx=decode_byte(buffer+32);
- reportBuffer.cy=decode_byte(buffer+40);
+ reportBuffer.cy=~decode_byte(buffer+40);
reportBuffer.ltrig=decode_byte(buffer+48);
reportBuffer.rtrig=decode_byte(buffer+56);
- reportBuffer.btn1=decode_byte(buffer+0);
- reportBuffer.btn2=decode_byte(buffer+8);
+ char btn1=decode_byte(buffer+0);
+ char btn2=decode_byte(buffer+8);
+
+ reportBuffer.buttons = (btn1 & 0x1F) | ((btn2 & 0x70) << 1);
+ reportBuffer.dpad = (btn2 & 0x0F);
ltrig=decode_byte(buffer+48);
rtrig=decode_byte(buffer+56);
- gc_x = ((signed char)(((unsigned char) gc_x) - 128));
- gc_y = ((signed char)(((unsigned char) gc_y) - 128));
-
}
else
{