Index: aktousb/code/Makefile
===================================================================
--- aktousb/code/Makefile	(revision aeff83b5363d0ae150ef2867a4b8825baa296e52)
+++ aktousb/code/Makefile	(revision 8c41328f08c921eac9d8219303b91d8e20376880)
@@ -1,4 +1,4 @@
 #Set vars
-COMPILE = avr-gcc -Wall -Os -Iusbdrv -I. -mmcu=atmega8 -DF_CPU=16000000 
+COMPILE = avr-gcc -Wall -Os -Iusbdrv -I. -std=c99 -mmcu=atmega8 -DF_CPU=16000000 
 
 #Rules
Index: aktousb/code/keyboard.hex
===================================================================
--- aktousb/code/keyboard.hex	(revision aeff83b5363d0ae150ef2867a4b8825baa296e52)
+++ aktousb/code/keyboard.hex	(revision 8c41328f08c921eac9d8219303b91d8e20376880)
@@ -1,3 +1,3 @@
-:10000000A7C0ACC2CAC0BFC0BEC0BDC0BCC0BBC020
+:10000000A7C089C2CAC0BFC0BEC0BDC0BCC0BBC043
 :10001000BAC0B9C0B8C0B7C0B6C0B5C0B4C0B3C02C
 :10002000B2C0B1C0B0C0351E1F2021222324252616
@@ -7,5 +7,5 @@
 :100060003800635F60612C2A2B5828294C0000005F
 :10007000560052514F503A3B3C3D3E3F4041424377
-:100080004A4D54555745000039000000000000005B
+:1000800082835455577500003900000000000000BD
 :10009000000000000000022000010440088005016B
 :1000A0000906A101050719E029E7150025017501D9
@@ -21,7 +21,7 @@
 :100140002101010001223F000705810308000A0088
 :1001500011241FBECFE5D4E0DEBFCDBF10E0A0E686
-:10016000B0E0E2E5FAE002C005900D92A436B107D6
+:10016000B0E0E4E0FAE002C005900D92A436B107D9
 :10017000D9F710E0A4E6B0E001C01D92AC3AB10797
-:10018000E1F728D164C43CCF8C9A949884E591E03F
+:10018000E1F728D13DC43CCF8C9A949884E591E066
 :100190000197F1F7949A8C9808951F920F920FB6D9
 :1001A0000F9211242F933F938F939F9383992CC089
@@ -60,109 +60,104 @@
 :1003B00081E0089580E00895FC0180916400882325
 :1003C00029F0613019F480818093650010926400F7
-:1003D00081E00895FF920F931F93CF93DF932FE057
-:1003E00088E190E00FB6F894A89581BD0FBE21BDBD
-:1003F00085E083BF8E9A88E0E8E6F0E0DF011D9299
-:100400008A95E9F7CCD11ADF789400E0C0E1D0E01A
-:10041000FF24F39401C0012FA895CED180917500DF
-:1004200080917500882391F0F8DE982F969580FDD5
-:1004300003C0892F17DF02C0892F3CDF8091810024
-:1004400084FF04C088E690E068E0DED208B600FED3
-:10045000E3CFF8BE80916600882321F0969A219719
-:1004600019F025C0969823C0109266004091610053
-:1004700022E030E013C0F901E859FF4F8081893351
-:1004800059F404C02F5F3F4F81818193273031059C
-:10049000CCF310926F0041502F5F3F4F842F90E0BC
-:1004A0002817390744F340936100C0E1D0E0109170
-:1004B0006700112309F4B0CF053010F00550ACCF20
-:1004C00080916600882321F082E6F4DE10926600B7
-:1004D0008091810084FF9FCF88E690E068E094D20D
-:1004E0009ACFDF93CF93CDB7DEB728970FB6F894A6
-:1004F000DEBF0FBECDBF982F8091810084FFFCCF5F
-:10050000FE01319688E0DF011D928A95E9F7998313
-:100510006B83CF0168E078D228960FB6F894DEBFDF
-:100520000FBECDBFCF91DF910895A82FB92F80E0E6
-:1005300090E041E050EA609530E009C02D918227BB
-:100540009795879510F084279527305EC8F36F5FE5
-:10055000A8F30895EADF8D939D930895CF93CFB7C5
-:10056000CF93DF93C395859BE9F7859B0BC0859B54
-:1005700009C0859B07C0859B05C0859B03C0859BE3
-:1005800001C08BC06F93C0918F00DD27CA56DF4F2B
-:100590002F9365E5859B03C02F916F91E6CF0F9355
-:1005A0001F934F9320E040E15F9300B3047205FB7B
-:1005B00027F93F9350E03BE039C0147240642F7735
-:1005C000012F5F5F1EC0406810B314722F77525026
-:1005D0001FC0406400B32F770472D1F15F5F00C089
-:1005E00023C0406210B32F77147291F15F5F00C097
-:1005F00025C004721027515012F45D5F00001150A5
-:1006000027952C3F10B3C8F6147201270150279587
-:100610002C3FC8F64227499300B3047210274F734A
-:10062000115027952C3FA8F64695469510B31472A5
-:1006300079F00127015027952C3F98F66B5A60F30B
-:10064000315000B3B0F600C010E41ABF002719C043
-:100650003B503195C31BD04010E41ABF0881033CC6
-:1006600009F10B34F9F020918D001981110F12134B
-:10067000EDCF4A81441F093651F10D3211F0013E90
-:1006800029F7009394003F915F914F911F910F9133
-:100690002F916F91CAB7C6FD65CFDF91CF91CFBFC4
-:1006A000CF91189520919400222369F31091920024
-:1006B000112391F5343092F13093920020938E0003
-:1006C00010918F003BE0311B30938F0027C00091C9
-:1006D000920001300CF50AE54F7049F43091620048
-:1006E00034FD1DC000936200C6E7D0E01CC030910D
-:1006F000810034FD14C000938100C2E8D0E013C033
-:10070000052710E000C0000002BB1AC0052710E05A
-:10071000221F1DC010E021C04AE502C032ED432F68
-:10072000C4E1D0E032E011B31462959A02B311BB78
-:1007300054E220E865E320FF052702BB27951795C3
-:100740001C3FF0F66695B8F7B1F720FF052702BB0E
-:10075000279517951C3FD0F62795179517FF052766
-:1007600000001C3F02BBB0F629913A9519F70B7DAA
-:1007700010919300110FC651D04002BB11F010939D
-:100780008D0010E41ABF006211B31B7D402F4B7D1A
-:1007900054E05A95F1F702BB11BB42BB74CF85B749
-:1007A000836085BF8BB780648BBF8BE480938200AE
-:1007B0008AE58093810008951F93CF93DF93609122
-:1007C0009200635067FDC4C080918F00CCE0D0E000
-:1007D000C81BD109CA56DF4F80918E008D3209F0B7
-:1007E000A4C0683009F0B2C083EC809376008AE53B
-:1007F00080936200109270008881807641F0CE0173
-:100800000E94A101282F8F3F09F47EC084C09A81E5
-:1008100010927F008981882321F41092800022E0C9
-:100820006CC0853019F49093930066C0863009F04F
-:100830004FC08B81813041F48BE191E09093910026
-:100840008093900022E140C0823041F48DE291E03B
-:10085000909391008093900022E236C08330F9F4A7
-:100860008A81882341F48DED90E0909391008093EC
-:10087000900024E029C0813041F481EE90E0909313
-:1008800091008093900024E21FC08230E1F485E063
-:1008900091E0909391008093900026E115C0813201
-:1008A00041F48FE391E0909391008093900029E0D0
-:1008B0000BC0823241F48EE990E0909391008093D6
-:1008C00090002FE301C020E080E48093700023C0FB
-:1008D000883021F421E085E990E011C0893019F4D5
-:1008E0009093950009C08A3011F421E006C08B3046
-:1008F00019F48BE48093820020E08FE790E09093DE
-:1009000091008093900007C0888187FD2E8180E848
-:100910008093700006C08F81882319F48E8182171E
-:1009200008F0822F8093630011C08091700087FFD0
-:100930000DC0CE010E94DC018F3F21F48EE1809337
-:10094000620004C0882311F010926300109292009C
-:100950008091620084FF4AC0809163008F3F09F458
-:1009600045C0182F893008F018E0811B8093630080
-:100970008091760098E8892780937600112341F1D1
-:1009800020919000309191008091700086FF0DC001
-:10099000A7E7B0E080E090E0F901E80FF91FE491EB
-:1009A000ED9301961817C1F708C0912FD901E7E719
-:1009B000F0E08D9181939150E1F71150812F90E0FB
-:1009C0001F5F0196820F931F909391008093900078
-:1009D00087E790E0612F0E94AA02612F6C5F6C3064
-:1009E00019F08FEF809363006093620094E180B30D
-:1009F000847231F49150D9F71092930010928D00C7
-:100A0000DF91CF911F9108951F93DC01162F8091E4
-:100A1000810084FF07C08091820098E88927809335
-:100A2000820003C08AE580938100912FE3E8F0E023
-:100A30008D91819391501916DCF383E890E0612F3A
-:100A40000E94AA021C5F109381001F910895F894E0
-:020A5000FFCFD6
-:040A520001025AFF44
+:1003D00081E00895EF92FF920F931F93CF93DF93E5
+:1003E0002FE088E190E00FB6F894A89581BD0FBE8C
+:1003F00021BD84E083BF8E9A88E0E8E6F0E0DF016B
+:100400001D928A95E9F7A8D119DF789400E0FF24BE
+:1004100010E0C0E1D0E0EE24E394A895AAD1809149
+:10042000750080917500882369F0F7DE982F969506
+:1004300080FD04C0892F16DF969A06C0892F3ADF07
+:10044000FF24F394002361F08091810084FD02C0B9
+:1004500001E006C088E690E068E0B0D2969800E03F
+:1004600008B600FEDACFE8BE80916600882329F145
+:10047000219719F5109266004091610022E030E06A
+:1004800013C0F901E859FF4F8081893359F404C042
+:100490002F5F3F4F8181819327303105CCF310923C
+:1004A0006F0041502F5F3F4F842F90E0281739078E
+:1004B00044F340936100C0E1D0E0812F8F5F85302D
+:1004C00010F01450AACF10916700FF2009F4A5CFB7
+:1004D0008091810084FFA1CF88E690E068E06ED231
+:1004E000FF249BCFA82FB92F80E090E041E050EA95
+:1004F000609530E009C02D9182279795879510F07F
+:1005000084279527305EC8F36F5FA8F30895EADF6C
+:100510008D939D930895CF93CFB7CF93DF93C395DA
+:10052000859BE9F7859B0BC0859B09C0859B07C010
+:10053000859B05C0859B03C0859B01C08BC06F93C5
+:10054000C0918F00DD27CA56DF4F2F9365E5859B4D
+:1005500003C02F916F91E6CF0F931F934F9320E02D
+:1005600040E15F9300B3047205FB27F93F9350E02D
+:100570003BE039C0147240642F77012F5F5F1EC0CB
+:10058000406810B314722F7752501FC0406400B3FC
+:100590002F770472D1F15F5F00C023C0406210B3B7
+:1005A0002F77147291F15F5F00C025C0047210278D
+:1005B000515012F45D5F0000115027952C3F10B38D
+:1005C000C8F614720127015027952C3FC8F6422720
+:1005D000499300B3047210274F73115027952C3F95
+:1005E000A8F64695469510B3147279F0012701508C
+:1005F00027952C3F98F66B5A60F3315000B3B0F654
+:1006000000C010E41ABF002719C03B503195C31B2E
+:10061000D04010E41ABF0881033C09F10B34F9F013
+:1006200020918D001981110F1213EDCF4A81441FC3
+:10063000093651F10D3211F0013E29F70093940073
+:100640003F915F914F911F910F912F916F91CAB779
+:10065000C6FD65CFDF91CF91CFBFCF911895209187
+:100660009400222369F310919200112391F5343004
+:1006700092F13093920020938E0010918F003BE016
+:10068000311B30938F0027C00091920001300CF590
+:100690000AE54F7049F43091620034FD1DC00093AB
+:1006A0006200C6E7D0E01CC03091810034FD14C068
+:1006B00000938100C2E8D0E013C0052710E000C01D
+:1006C000000002BB1AC0052710E0221F1DC010E069
+:1006D00021C04AE502C032ED432FC4E1D0E032E050
+:1006E00011B31462959A02B311BB54E220E865E39A
+:1006F00020FF052702BB279517951C3FF0F666954E
+:10070000B8F7B1F720FF052702BB279517951C3FC7
+:10071000D0F62795179517FF052700001C3F02BB51
+:10072000B0F629913A9519F70B7D10919300110FAE
+:10073000C651D04002BB11F010938D0010E41ABFD7
+:10074000006211B31B7D402F4B7D54E05A95F1F7A9
+:1007500002BB11BB42BB74CF85B7836085BF8BB72B
+:1007600080648BBF8BE4809382008AE58093810054
+:1007700008951F93CF93DF9360919200635067FDBC
+:10078000C2C080918F00CCE0D0E0C81BD109CA560E
+:10079000DF4F80918E008D3209F0A3C0683009F0E0
+:1007A000B0C083EC809376008AE58093620010925B
+:1007B00070008881807639F0CE01C3DD282F8F3F0D
+:1007C00009F47EC084C09A8110927F0089818823B9
+:1007D00021F41092800022E06CC0853019F49093CF
+:1007E000930066C0863009F04FC08B81813041F4A0
+:1007F0008BE191E0909391008093900022E140C0C2
+:10080000823041F48DE291E09093910080939000CA
+:1008100022E236C08330F9F48A81882341F48DEDD9
+:1008200090E0909391008093900024E029C0813063
+:1008300041F481EE90E0909391008093900024E247
+:100840001FC08230E1F485E091E0909391008093A5
+:10085000900026E115C0813241F48FE391E090933E
+:1008600091008093900029E00BC0823241F48EE920
+:1008700090E090939100809390002FE301C020E0DE
+:1008800080E48093700023C0883021F421E085E962
+:1008900090E011C0893019F49093950009C08A3016
+:1008A00011F421E006C08B3019F48BE480938200B0
+:1008B00020E08FE790E0909391008093900007C034
+:1008C000888187FD2E8180E88093700006C08F812B
+:1008D000882319F48E81821708F0822F8093630099
+:1008E00010C08091700087FF0CC0CE0165DD8F3F86
+:1008F00021F48EE18093620004C0882311F01092ED
+:100900006300109292008091620084FF49C0809140
+:1009100063008F3F09F444C0182F893008F018E0B5
+:10092000811B809363008091760098E889278093EB
+:100930007600112341F12091900030919100809137
+:10094000700086FF0DC0A7E7B0E080E090E0F901FD
+:10095000E80FF91FE491ED9301961817C1F708C04D
+:10096000912FD901E7E7F0E08D9181939150E1F764
+:100970001150812F90E01F5F0196820F931F90937B
+:1009800091008093900087E790E0612FC0DD612F98
+:100990006C5F6C3019F08FEF80936300609362009E
+:1009A00094E180B3847231F49150D9F7109293009E
+:1009B00010928D00DF91CF911F9108951F93DC015C
+:1009C000162F8091810084FF07C08091820098E8F3
+:1009D00089278093820003C08AE580938100912F4C
+:1009E000E3E8F0E08D91819391501916DCF383E8F0
+:1009F00090E0612F8CDD1C5F109381001F910895A2
+:040A0000F894FFCF98
+:040A040001025AFF92
 :00000001FF
Index: aktousb/code/main.c
===================================================================
--- aktousb/code/main.c	(revision aeff83b5363d0ae150ef2867a4b8825baa296e52)
+++ aktousb/code/main.c	(revision 8c41328f08c921eac9d8219303b91d8e20376880)
@@ -6,4 +6,5 @@
 
 #include <string.h>
+#include <stdbool.h>
 
 #include "amiga_keyboard/amiga_keyboard.h"
@@ -11,15 +12,19 @@
 #include "keycodes.h"
 
+#define LEDSWAP PORTD ^= (1<<PD6)
+#define LEDON PORTD |= 1<<PD6
+#define LEDOFF PORTD &= ~(1<<PD6)
+
 static uint8_t pressingCaps = 0;
 
 const uint8_t PROGMEM keymatrix[0x70] = {
-// 0         1            2            3            4          5          6           7            8            9              A             B             C             D             E              F
-KEY_grave,   KEY_1,       KEY_2,       KEY_3,       KEY_4,     KEY_5,     KEY_6,      KEY_7,       KEY_8,       KEY_9,         KEY_0,        KEY_minus,    KEY_equals,   KEY_F11,       KEY_Reserved,  KEY_KP0,      //0
-KEY_Q,       KEY_W,       KEY_E,       KEY_R,       KEY_T,     KEY_Y,     KEY_U,      KEY_I,       KEY_O,       KEY_P,         KEY_lbracket, KEY_rbracket, KEY_Reserved, KEY_KP1,       KEY_KP2,       KEY_KP3,      //1
-KEY_A,       KEY_S,       KEY_D,       KEY_F,       KEY_G,     KEY_H,     KEY_J,      KEY_K,       KEY_L,       KEY_semicolon, KEY_apostroph,KEY_hash,     KEY_Reserved, KEY_KP4,       KEY_KP5,       KEY_KP6,      //2
-KEY_Euro,    KEY_Z,       KEY_X,       KEY_C,       KEY_V,     KEY_B,     KEY_N,      KEY_M,       KEY_comma,   KEY_dot,       KEY_slash,    KEY_Reserved, KEY_KPcomma,  KEY_KP7,       KEY_KP8,       KEY_KP9,      //3
+// 0         1            2            3            4          5          6                 7            8            9              A             B             C             D             E              F
+KEY_grave,   KEY_1,       KEY_2,       KEY_3,       KEY_4,     KEY_5,     KEY_6,            KEY_7,       KEY_8,       KEY_9,         KEY_0,        KEY_minus,    KEY_equals,   KEY_F11,       KEY_Reserved,  KEY_KP0,      //0
+KEY_Q,       KEY_W,       KEY_E,       KEY_R,       KEY_T,     KEY_Y,     KEY_U,            KEY_I,       KEY_O,       KEY_P,         KEY_lbracket, KEY_rbracket, KEY_Reserved, KEY_KP1,       KEY_KP2,       KEY_KP3,      //1
+KEY_A,       KEY_S,       KEY_D,       KEY_F,       KEY_G,     KEY_H,     KEY_J,            KEY_K,       KEY_L,       KEY_semicolon, KEY_apostroph,KEY_hash,     KEY_Reserved, KEY_KP4,       KEY_KP5,       KEY_KP6,      //2
+KEY_Euro,    KEY_Z,       KEY_X,       KEY_C,       KEY_V,     KEY_B,     KEY_N,            KEY_M,       KEY_comma,   KEY_dot,       KEY_slash,    KEY_Reserved, KEY_KPcomma,  KEY_KP7,       KEY_KP8,       KEY_KP9,      //3
 KEY_Spacebar,KEY_DELETE,  KEY_Tab,     KEY_KPenter, KEY_Return,KEY_ESCAPE,KEY_DeleteForward,KEY_Reserved,KEY_Reserved,KEY_Reserved,  KEY_KPminus,  KEY_Reserved, KEY_UpArrow,  KEY_DownArrow, KEY_RightArrow,KEY_LeftArrow,//4
-KEY_F1,      KEY_F2,      KEY_F3,      KEY_F4,      KEY_F5,    KEY_F6,    KEY_F7,     KEY_F8,      KEY_F9,      KEY_F10,       KEY_Home, KEY_End, KEY_KPslash,  KEY_KPasterisk,KEY_KPplus,    KEY_F12,     //5
-KEY_Reserved,KEY_Reserved,KEY_capslock,KEY_Reserved,KEY_Reserved,KEY_Reserved,KEY_Reserved,KEY_Reserved,KEY_Reserved,KEY_Reserved,KEY_Reserved,KEY_Reserved,KEY_Reserved,KEY_Reserved,  KEY_Reserved,  KEY_Reserved, //6
+KEY_F1,      KEY_F2,      KEY_F3,      KEY_F4,      KEY_F5,    KEY_F6,    KEY_F7,           KEY_F8,      KEY_F9,      KEY_F10,       KEY_KPLParen, KEY_KPRParen, KEY_KPslash,  KEY_KPasterisk,KEY_KPplus,    KEY_Help,     //5
+KEY_Reserved,KEY_Reserved,KEY_capslock,KEY_Reserved,KEY_Reserved,KEY_Reserved,KEY_Reserved, KEY_Reserved,KEY_Reserved,KEY_Reserved,  KEY_Reserved, KEY_Reserved, KEY_Reserved, KEY_Reserved,  KEY_Reserved,  KEY_Reserved, //6
 };
 
@@ -86,4 +91,5 @@
 
 
+/*
 void usbSendReport(uint8_t mode, uint8_t key) {
     // buffer for HID reports. we use a private one, so nobody gets disturbed
@@ -94,5 +100,5 @@
     usbSetInterrupt(repBuffer, sizeof(repBuffer)); // send
 }
-
+*/
 
 int main() {
@@ -102,6 +108,6 @@
 
 	wdt_enable(WDTO_2S);
-    // configure timer 0 for a rate of 12M/(1024 * 256) = 45.78Hz (~22ms)
-    TCCR0 = 5;          // timer 0 prescaler: 1024
+    // configure timer 0 for a rate of 16M/(256 * 256) = ~244Hz
+    TCCR0 = 4;          // timer 0 prescaler: 256
 
 	//debug LED - output
@@ -116,4 +122,6 @@
 	ak_init_keyboard(); 
 	sei();
+	bool doReport = false;
+	bool doRelease = false;
 
 	while(1) {
@@ -126,10 +134,18 @@
 			key_code = ak_read_scancode();
 			// if an update is needed, send the report
-			if ((key_code & 1) == 0)
+			if ((key_code & 1) == 0) {
 				fillReportBuffer(key_code>>1);
-			else
+				LEDON;
+				doReport = true;
+			} else {
 				emptyReportBuffer(key_code>>1);
-			if (usbInterruptIsReady())
-				usbSetInterrupt(reportBuffer, sizeof(reportBuffer));
+				doRelease = true;
+			}
+		}
+
+		if (doReport && usbInterruptIsReady()) {
+			usbSetInterrupt(reportBuffer, sizeof(reportBuffer));
+			LEDOFF;
+			doReport = false;
 		}
 
@@ -138,10 +154,4 @@
 		if (TIFR & (1 << TOV0)) {
 			TIFR = (1 << TOV0); // reset flag
-
-			// PORTD ^= (1<<PD6); // blink del : we are alive !
-			if (pressingCaps)
-				PORTD |= 1<<PD6;
-			else
-				PORTD &= ~(1<<PD6);
 
 			if (pressingCaps) {
@@ -162,18 +172,20 @@
 			}
 
-			if (idleRate != 0) { // do we need periodic reports?
-				if(idleCounter > 4){ // yes, but not yet
-					idleCounter -= 5; // 22ms in units of 4ms
-				} else { // yes, it is time now
-					idleCounter = idleRate;
-					if (pressingCaps) {
-						emptyReportBuffer(0x62);
-						pressingCaps = 0;
-					}
-					if (usbInterruptIsReady())
-						usbSetInterrupt(reportBuffer, sizeof(reportBuffer));
+			++idleCounter;
+			if(idleCounter > 4){ // yes, but not yet
+				idleCounter -= 5; // 22ms in units of 4ms
+			} else { // yes, it is time now
+				idleCounter = idleRate;
+				/*
+				if (pressingCaps) {
+					emptyReportBuffer(0x62);
+					pressingCaps = 0;
+				}
+				*/
+				if (doRelease && usbInterruptIsReady()) {
+					usbSetInterrupt(reportBuffer, sizeof(reportBuffer));
+					doRelease = false;
 				}
 			}
-
 		}
 	}
