Index: starkadroid/code/main.c
===================================================================
--- starkadroid/code/main.c	(revision 86824a6476a211f61c05083b04b253bef85e2473)
+++ starkadroid/code/main.c	(revision de0f65fe9ace8b7a24d5c453a603d2367a2031cc)
@@ -17,11 +17,9 @@
 #define PORTOUT PORTC
 
-static uint8_t reportBuffer[6]; 
+static uint8_t reportBuffer[5];
+static uint8_t buttons[6];
 static uint8_t idleRate;
 
 void main() {
-	bool which = false;
-	uint8_t idleCounter = 0;
-
 	wdt_enable(WDTO_2S);
 
@@ -34,5 +32,6 @@
 	PORTOUT = 255; // Enable pull up
 		// We put all pins as input then output a 0 in only one at a time.
-		// All the other pins are high-Z to avoid short circuits when many buttons are pressed.
+		// All the other pins are high-Z to avoid short circuits when many
+		// buttons are pressed.
 	DDRIN = 0; // Keyboard matrix in
 	PORTIN = 255; // Enable pull up
@@ -41,18 +40,38 @@
     TCCR0 = 4;          // timer 0 prescaler: 256
 
+	reportBuffer[0] = 0;
+	doReport = false;
+
 	while(1) {
 		wdt_reset();
 		usbPoll();
 
-		doReport = false;
-		for(char i = 0; i != 6; i++) {
+		for(int i = 0; i != 6; i++) {
 			DDROUT = 1<<i;
 			PORTOUT = ~(1<<i);
-			if (reportBuffer[i] != ((~PININ)&0x3F))
+			_delay_us(63);
+			if (buttons[i] != ((~PININ)&0x3F))
+			{
 				doReport = true;
-			reportBuffer[i] = (~PININ)&0x3F;
+				buttons[i] = (~PININ)&0x3F;
+			}
 		}
 		DDROUT = 0;
 		PORTOUT = 255;
+
+		// Copy lines 1 to 3 to the same lines in the report
+		for(int i=1; i != 4; i++) {
+			reportBuffer[i] = buttons[i];
+		}
+
+		// Dispatch line 0 to report 1,2,3 (2 buttons each)
+		reportBuffer[1] |= (buttons[0] << 4)&0xC0;
+		reportBuffer[2] |= (buttons[0] << 2)&0xC0;
+		reportBuffer[3] |= (buttons[0])&0xC0;
+
+		// Copy part line 6
+		reportBuffer[4] = buttons[5]; // 2 btns left here
+		//reportBuffer[0] = buttons[4]; // this line is unused anyway, report as
+									  // axis
 
 		if (doReport && usbInterruptIsReady()) {
@@ -70,14 +89,25 @@
 char PROGMEM usbHidReportDescriptor[USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH] = {
 	0x05, 0x01,                    // USAGE_PAGE (Generic Desktop)
-    0x09, 0x05,                    // USAGE (Game Pad)
+    0x09, 0x04,                    // USAGE (Joystick)
     0xa1, 0x01,                    // COLLECTION (Application)
-    0xa1, 0x00,                    //   COLLECTION (Physical)
+    0xa1, 0x02,                    //   COLLECTION (Logical)
+
+    0x75, 0x04,	                   //     REPORT_SIZE (8)
+    0x95, 0x02,                    //     REPORT_COUNT (2)
+    0x15, 0x00,                    //     LOGICAL_MINIMUM (0)
+    0x25, 0x0F,                    //     LOGICAL_MAXIMUM (15)
+    0x35, 0x00,                    //     PHYS_MINIMUM (0)
+    0x45, 0x0F,                    //     PHYS_MAXIMUM (15)
+    0x09, 0x30,                    //     USAGE (X)
+    0x09, 0x31,                    //     USAGE (Y)
+    0x81, 0x02,                    //     INPUT (Data,Var,Abs)
+
+    0x75, 0x01,                    //     REPORT_SIZE (1)
+    0x95, 0x20,                    //     REPORT_COUNT (32)
+    0x25, 0x01,                    //     LOGICAL_MAXIMUM (1)
+    0x45, 0x01,                    //     PHYSMAX (1)
     0x05, 0x09,                    //     USAGE_PAGE (Button)
     0x19, 0x01,                    //     USAGE_MINIMUM (Button 1)
-    0x29, 0x30,                    //     USAGE_MAXIMUM (Button 40)
-    0x15, 0x00,                    //     LOGICAL_MINIMUM (0)
-    0x25, 0x01,                    //     LOGICAL_MAXIMUM (1)
-    0x95, 0x30,                    //     REPORT_COUNT (40)
-    0x75, 0x01,                    //     REPORT_SIZE (1)
+    0x29, 0x20,                    //     USAGE_MAXIMUM (Button 32)
     0x81, 0x02,                    //     INPUT (Data,Var,Abs)
     0xc0,                          //   END_COLLECTION
Index: starkadroid/code/starkadroid.hex
===================================================================
--- starkadroid/code/starkadroid.hex	(revision 86824a6476a211f61c05083b04b253bef85e2473)
+++ starkadroid/code/starkadroid.hex	(revision de0f65fe9ace8b7a24d5c453a603d2367a2031cc)
@@ -1,3 +1,3 @@
-:1000000062C059C17BC07AC079C078C077C076C061
+:1000000062C052C17BC07AC079C078C077C076C068
 :1000100075C074C073C072C071C070C06FC06EC054
 :100020006DC06CC06BC005010904A101A10275047B
@@ -12,7 +12,7 @@
 :1000B000000103000000092101010001222C0007BA
 :1000C00005810308001411241FBECFE5D4E0DEBF74
-:1000D000CDBF10E0A0E6B0E0ECE6F7E002C005908E
+:1000D000CDBF10E0A0E6B0E0EEE5F7E002C005908D
 :1000E0000D92A436B107D9F710E0A4E6B0E001C044
-:1000F0001D92A83AB107E1F741D036C381CFFC0188
+:1000F0001D92A83AB107E1F741D02FC381CFFC018F
 :1001000085E690E090938D0080938C0080818076CE
 :10011000803271F58181813011F485E00895893054
@@ -22,100 +22,99 @@
 :100150008381882369F41092600008958B3041F404
 :1001600080E690E090938D0080938C0081E008956C
-:1001700080E008951092640081E00895DF92EF928C
-:10018000FF920F931F93CF93DF932FE088E190E0CE
-:100190000FB6F894A89581BD0FBE21BDADD178945E
-:1001A00014BA8FEF85BB17BA88BB84E083BF109267
-:1001B000650000E0F1E0EF2EF12CCCEFD0E0DD2483
-:1001C000DA9401C0012FA895A4D1EAE6F0E0102F3F
-:1001D00040E050E0C701042E02C0880F991F0A9426
-:1001E000E2F784BB809585BBCE010197F1F786B31A
-:1001F000208130E090E0809590958F739070281763
-:10020000390729F086B380958F73808311E04F5FA3
-:100210005F4F319646305105E9F614BAD5BA509180
-:100220006B0060916C0070916D0040916A00242F0A
-:1002300030E0C901E4E0880F991FEA95E1F7807C7E
-:10024000852B80936600220F331F220F331F207CE3
-:10025000262B20936700407C472B409368008091B9
-:100260006F0080936900002309F4ACCF112309F0DB
-:10027000A9CF80917D0084FFA5CF85E690E065E061
-:1002800051D2A0CFA82FB92F80E090E041E050EAF2
-:10029000609530E009C02D9182279795879510F0E1
-:1002A00084279527305EC8F36F5FA8F30895EADFCF
-:1002B0008D939D930895CF93CFB7CF93DF93C3953D
-:1002C000859BE9F7859B0BC0859B09C0859B07C073
-:1002D000859B05C0859B03C0859B01C08BC06F9328
-:1002E000C0918B00DD27CE56DF4F2F9365E5859BB0
-:1002F00003C02F916F91E6CF0F931F934F9320E090
-:1003000040E15F9300B3047205FB27F93F9350E08F
-:100310003BE039C0147240642F77012F5F5F1EC02D
-:10032000406810B314722F7752501FC0406400B35E
-:100330002F770472D1F15F5F00C023C0406210B319
-:100340002F77147291F15F5F00C025C004721027EF
-:10035000515012F45D5F0000115027952C3F10B3EF
-:10036000C8F614720127015027952C3FC8F6422782
-:10037000499300B3047210274F73115027952C3FF7
-:10038000A8F64695469510B3147279F001270150EE
-:1003900027952C3F98F66B5A60F3315000B3B0F6B6
-:1003A00000C010E41ABF002719C03B503195C31B91
-:1003B000D04010E41ABF0881033C09F10B34F9F076
-:1003C000209189001981110F1213EDCF4A81441F2A
-:1003D000093651F10D3211F0013E29F700939000DA
-:1003E0003F915F914F911F910F912F916F91CAB7DC
-:1003F000C6FD65CFDF91CF91CFBFCF9118952091EA
-:100400009000222369F310918E00112391F534306E
-:1004100092F130938E0020938A0010918B003BE084
-:10042000311B30938B0027C000918E0001300CF5FA
-:100430000AE54F7049F43091610034FD1DC000930E
-:100440006100C2E7D0E01CC030917D0034FD14C0D3
-:1004500000937D00CEE7D0E013C0052710E000C078
-:10046000000002BB1AC0052710E0221F1DC010E0CB
-:1004700021C04AE502C032ED432FC4E1D0E032E0B2
-:1004800011B31462959A02B311BB54E220E865E3FC
-:1004900020FF052702BB279517951C3FF0F66695B0
-:1004A000B8F7B1F720FF052702BB279517951C3F2A
-:1004B000D0F62795179517FF052700001C3F02BBB4
-:1004C000B0F629913A9519F70B7D10918F00110F15
-:1004D000C651D04002BB11F01093890010E41ABF3E
-:1004E000006211B31B7D402F4B7D54E05A95F1F70C
-:1004F00002BB11BB42BB74CF85B7836085BF8BB78E
-:1005000080648BBF8BE480937E008AE580937D00BE
-:1005100008951F93CF93DF9390918E00935097FD92
-:10052000A6C020918B0080918A008D3209F09DC079
-:10053000983009F09AC0CCE0D0E0C21BD109CE5669
-:10054000DF4F83EC809372008AE580936100109204
-:1005500071008881807621F0CE01D1DD282F7CC00A
-:100560009A8110927B008981882321F410927C006B
-:1005700022E06CC0853019F490938F0066C08630FD
-:1005800009F04FC08B81813041F482E990E0909373
-:100590008D0080938C0022E140C0823041F484EAD7
-:1005A00090E090938D0080938C0022E236C08330DF
-:1005B000F9F48A81882341F482E590E090938D00DC
-:1005C00080938C0024E029C0813041F486E590E0DE
-:1005D00090938D0080938C0024E21FC08230E1F460
-:1005E0008AE790E090938D0080938C0028E115C0FD
-:1005F000813241F486EB90E090938D0080938C00E3
-:1006000029E00BC0823241F486E290E090938D00A5
-:1006100080938C002CE201C020E080E48093710084
-:100620001BC0883021F421E081E990E011C08930BD
-:1006300019F49093910009C08A3011F421E006C0AA
-:100640008B3019F48BE480937E0020E08BE790E000
-:1006500090938D0080938C008F81882321F48E816C
-:10066000821708F4282F2093620010928E00809148
-:10067000610084FF49C0809162008F3F09F444C04B
-:10068000182F893008F018E0811B80936200809158
-:10069000720098E8892780937200112341F120911C
-:1006A0008C0030918D008091710086FF0DC0A3E712
-:1006B000B0E080E090E0F901E80FF91FE491ED93DC
-:1006C00001961817C1F708C0912FD901E3E7F0E0B0
-:1006D0008D9181939150E1F71150812F90E01F5F30
-:1006E0000196820F931F90938D0080938C0083E777
-:1006F00090E0612FDCDD612F6C5F6C3019F08FEFC3
-:10070000809362006093610094E180B3847231F45D
-:100710009150D9F710928F0010928900DF91CF91FC
-:100720001F9108951F93DC01162F80917D0084FF97
-:1007300007C080917E0098E8892780937E0003C0DF
-:100740008AE580937D00912FEFE7F0E08D91819312
-:1007500091501916DCF38FE790E0612FA8DD1C5F44
-:0C07600010937D001F910895F894FFCFC6
-:04076C00015AFF002F
+:1001700080E008951092640081E00895EF92FF926C
+:100180000F931F93CF93DF932FE088E190E00FB69A
+:10019000F894A89581BD0FBE21BDA7D1789414BA5B
+:1001A0008FEF85BB17BA88BB84E083BF10926500D0
+:1001B00010E0F1E0EF2EF12CCCEFD0E00FEFA8959E
+:1001C000A1D1EAE6F0E040E050E0C701042E02C011
+:1001D000880F991F0A94E2F784BB809585BBCE01F6
+:1001E0000197F1F786B3208130E090E080959095FB
+:1001F0008F7390702817390729F086B380958F7315
+:10020000808311E04F5F5F4F319646305105E9F62C
+:1002100014BA05BB50916B0060916C0070916D0039
+:1002200040916A00242F30E0C901E4E0880F991F53
+:10023000EA95E1F7807C852B80936600220F331FBF
+:10024000220F331F207C262B20936700407C472BF6
+:100250004093680080916F0080936900112309F436
+:10026000AECF80917D0084FFAACF85E690E065E067
+:1002700052D210E0A4CFA82FB92F80E090E041E047
+:1002800050EA609530E009C02D91822797958795B7
+:1002900010F084279527305EC8F36F5FA8F30895A8
+:1002A000EADF8D939D930895CF93CFB7CF93DF93DC
+:1002B000C395859BE9F7859B0BC0859B09C0859BF2
+:1002C00007C0859B05C0859B03C0859B01C08BC073
+:1002D0006F93C0918B00DD27CE56DF4F2F9365E5DE
+:1002E000859B03C02F916F91E6CF0F931F934F9380
+:1002F00020E040E15F9300B3047205FB27F93F93D0
+:1003000050E03BE039C0147240642F77012F5F5FEB
+:100310001EC0406810B314722F7752501FC0406443
+:1003200000B32F770472D1F15F5F00C023C0406239
+:1003300010B32F77147291F15F5F00C025C0047273
+:100340001027515012F45D5F0000115027952C3F8B
+:1003500010B3C8F614720127015027952C3FC8F638
+:100360004227499300B3047210274F731150279509
+:100370002C3FA8F64695469510B3147279F00127E4
+:10038000015027952C3F98F66B5A60F3315000B31B
+:10039000B0F600C010E41ABF002719C03B503195D9
+:1003A000C31BD04010E41ABF0881033C09F10B3491
+:1003B000F9F0209189001981110F1213EDCF4A81B4
+:1003C000441F093651F10D3211F0013E29F7009317
+:1003D00090003F915F914F911F910F912F916F91DD
+:1003E000CAB7C6FD65CFDF91CF91CFBFCF9118952A
+:1003F00020919000222369F310918E00112391F532
+:10040000343092F130938E0020938A0010918B004B
+:100410003BE0311B30938B0027C000918E000130F0
+:100420000CF50AE54F7049F43091610034FD1DC0B0
+:1004300000936100C2E7D0E01CC030917D0034FD24
+:1004400014C000937D00CEE7D0E013C0052710E074
+:1004500000C0000002BB1AC0052710E0221F1DC00B
+:1004600010E021C04AE502C032ED432FC4E1D0E0E4
+:1004700032E011B31462959A02B311BB54E220E842
+:1004800065E320FF052702BB279517951C3FF0F673
+:100490006695B8F7B1F720FF052702BB279517959A
+:1004A0001C3FD0F62795179517FF052700001C3F26
+:1004B00002BBB0F629913A9519F70B7D10918F0088
+:1004C000110FC651D04002BB11F01093890010E407
+:1004D0001ABF006211B31B7D402F4B7D54E05A952B
+:1004E000F1F702BB11BB42BB74CF85B7836085BFF8
+:1004F0008BB780648BBF8BE480937E008AE580930A
+:100500007D0008951F93CF93DF9390918E009350B9
+:1005100097FDA6C020918B0080918A008D3209F052
+:100520009DC0983009F09AC0CCE0D0E0C21BD10940
+:10053000CE56DF4F83EC809372008AE58093610092
+:10054000109271008881807621F0CE01D8DD282FAD
+:100550007CC09A8110927B008981882321F41092BB
+:100560007C0022E06CC0853019F490938F0066C047
+:10057000863009F04FC08B81813041F482E990E0F0
+:1005800090938D0080938C0022E140C0823041F432
+:1005900084EA90E090938D0080938C0022E236C034
+:1005A0008330F9F48A81882341F482E590E09093C6
+:1005B0008D0080938C0024E029C0813041F486E5D1
+:1005C00090E090938D0080938C0024E21FC08230D5
+:1005D000E1F48AE790E090938D0080938C0028E10D
+:1005E00015C0813241F486EB90E090938D008093AA
+:1005F0008C0029E00BC0823241F486E290E09093B7
+:100600008D0080938C002CE201C020E080E4809378
+:1006100071001BC0883021F421E081E990E011C015
+:10062000893019F49093910009C08A3011F421E0C7
+:1006300006C08B3019F48BE480937E0020E08BE7BA
+:1006400090E090938D0080938C008F81882321F41B
+:100650008E81821708F4282F2093620010928E005A
+:100660008091610084FF49C0809162008F3F09F44E
+:1006700044C0182F893008F018E0811B8093620075
+:100680008091720098E8892780937200112341F1CC
+:1006900020918C0030918D008091710086FF0DC0FB
+:1006A000A3E7B0E080E090E0F901E80FF91FE491E2
+:1006B000ED9301961817C1F708C0912FD901E3E710
+:1006C000F0E08D9181939150E1F71150812F90E0EE
+:1006D0001F5F0196820F931F90938D0080938C0073
+:1006E00083E790E0612FDCDD612F6C5F6C3019F0E7
+:1006F0008FEF809362006093610094E180B3847215
+:1007000031F49150D9F710928F0010928900DF9147
+:10071000CF911F9108951F93DC01162F80917D00CA
+:1007200084FF07C080917E0098E8892780937E002F
+:1007300003C08AE580937D00912FEFE7F0E08D9173
+:10074000819391501916DCF38FE790E0612FA8DDBB
+:0E0750001C5F10937D001F910895F894FFCF59
+:04075E00015AFF003D
 :00000001FF
