gcc error in keyboard handler
Posted: Wed Mar 31, 2010 7:44 pm
Okay, gcc returns this error:
I have no idea why it's doing this. It's probably something simple. I'm still sort of new to ASM and C.
Here's my source:
Code: Select all
kb.c:14: error: expected '}' before ':' token
kb.c:25: error: expected '}' before ':' token
kb.c:36: error: expected '}' before ':' token
kb.c:47: error: expected '}' before ':' token
Here's my source:
Code: Select all
#include <system.h>
char kbdus[256] =
{0x28:'\'', 0x0C:'-', 0x33:',', 0x34:'.', 0x35:'/', 0x27:';', 0x1A:'[', 0x2B:'\\',
0x1B:']' , 0x29:'`', 0x0D:'=', 0x0B:'0', 0x02:'1', 0x03:'2', 0x04:'3', 0x05:'4',
0x06:'5' , 0x07:'6', 0x08:'7', 0x09:'8', 0x0A:'9', 0x1E:'a', 0x30:'b', 0x2E:'c',
0x20:'d' , 0x12:'e', 0x21:'f', 0x22:'g', 0x23:'h', 0x17:'i', 0x24:'j', 0x25:'k',
0x26:'l' , 0x32:'m', 0x31:'n', 0x18:'o', 0x19:'p', 0x10:'q', 0x13:'r', 0x1F:'s',
0x14:'t' , 0x16:'u', 0x2F:'v', 0x11:'w', 0x2D:'x', 0x15:'y', 0x2C:'z', 0x52:'0',
0x4F:'1' , 0x50:'2', 0x51:'3', 0x4B:'4', 0x4C:'5', 0x4D:'6', 0x47:'7', 0x48:'8',
0x49:'9' , 0x4A:'-', 0x37:'*', 0x53:'.', 0x1C:'\n',0x4E:'+', 0x39:' ', 0x0F:'\t',
};
char kbdus_up[256] =
{0x28:'"', 0x0C:'_', 0x33:'<', 0x34:'>', 0x35:'?', 0x27:':', 0x1A:'{', 0x2B:'|',
0x1B:'}' , 0x29:'~', 0x0D:'+', 0x0B:')', 0x02:'!', 0x03:'@', 0x04:'#', 0x05:'$',
0x06:'%' , 0x07:'^', 0x08:'&', 0x09:'*', 0x0A:'(', 0x1E:'A', 0x30:'B', 0x2E:'C',
0x20:'D' , 0x12:'E', 0x21:'F', 0x22:'G', 0x23:'H', 0x17:'I', 0x24:'J', 0x25:'K',
0x26:'L' , 0x32:'M', 0x31:'N', 0x18:'O', 0x19:'P', 0x10:'Q', 0x13:'R', 0x1F:'S',
0x14:'T' , 0x16:'U', 0x2F:'V', 0x11:'W', 0x2D:'X', 0x15:'Y', 0x2C:'Z', 0x52:'0',
0x4F:'1' , 0x50:'2', 0x51:'3', 0x4B:'4', 0x4C:'5', 0x4D:'6', 0x47:'7', 0x48:'8',
0x49:'9' , 0x4A:'-', 0x37:'*', 0x53:'.', 0x1C:'\n',0x4E:'+', 0x39:' ', 0x0F:'\t',
};
char kbdus_caps[256] =
{0x28:'\'', 0x0C:'-', 0x33:',', 0x34:'.', 0x35:'/', 0x27:';', 0x1A:'[', 0x2B:'\\',
0x1B:']' , 0x29:'`', 0x0D:'=', 0x0B:'0', 0x02:'1', 0x03:'2', 0x04:'3', 0x05:'4',
0x06:'5' , 0x07:'6', 0x08:'7', 0x09:'8', 0x0A:'9', 0x1E:'A', 0x30:'B', 0x2E:'C',
0x20:'D' , 0x12:'E', 0x21:'F', 0x22:'G', 0x23:'H', 0x17:'I', 0x24:'J', 0x25:'K',
0x26:'L' , 0x32:'M', 0x31:'N', 0x18:'O', 0x19:'P', 0x10:'Q', 0x13:'R', 0x1F:'S',
0x14:'T' , 0x16:'U', 0x2F:'V', 0x11:'W', 0x2D:'X', 0x15:'Y', 0x2C:'Z', 0x52:'0',
0x4F:'1' , 0x50:'2', 0x51:'3', 0x4B:'4', 0x4C:'5', 0x4D:'6', 0x47:'7', 0x48:'8',
0x49:'9' , 0x4A:'-', 0x37:'*', 0x53:'.', 0x1C:'\n',0x4E:'+', 0x39:' ', 0x0F:'\t',
};
char kbdus_caps_up[256] =
{0x28:'"', 0x0C:'_', 0x33:'<', 0x34:'>', 0x35:'?', 0x27:':', 0x1A:'{', 0x2B:'|',
0x1B:'}' , 0x29:'~', 0x0D:'+', 0x0B:')', 0x02:'!', 0x03:'@', 0x04:'#', 0x05:'$',
0x06:'%' , 0x07:'^', 0x08:'&', 0x09:'*', 0x0A:'(', 0x1E:'a', 0x30:'b', 0x2E:'c',
0x20:'d' , 0x12:'e', 0x21:'f', 0x22:'g', 0x23:'h', 0x17:'i', 0x24:'j', 0x25:'k',
0x26:'l' , 0x32:'m', 0x31:'n', 0x18:'o', 0x19:'p', 0x10:'q', 0x13:'r', 0x1F:'s',
0x14:'t' , 0x16:'u', 0x2F:'v', 0x11:'w', 0x2D:'x', 0x15:'y', 0x2C:'z', 0x52:'0',
0x4F:'1' , 0x50:'2', 0x51:'3', 0x4B:'4', 0x4C:'5', 0x4D:'6', 0x47:'7', 0x48:'8',
0x49:'9' , 0x4A:'-', 0x37:'*', 0x53:'.', 0x1C:'\n',0x4E:'+', 0x39:' ', 0x0F:'\t',
};
unsigned caps_lock = 0;
unsigned shift_state = 0;
unsigned escaped = 0;
/* Handles the keyboard interrupt */
void keyboard_handler(struct regs *r)
{
unsigned char scancode;
unsigned char new_char;
/* Read from the keyboard's data buffer */
scancode = inportb(0x60);
if(escaped) scancode += 256; escaped = 0;
switch(scancode) {
case 0x2a:
shift_state = 1;
break;
case 0xaa:
shift_state = 0;
break;
case 0x3a:
if(caps_lock == 0)
{
caps_lock = 1;
}
else
{
caps_lock = 0;
}
break;
case 0xE0:
escaped = 1;
break;
default:
if (scancode & 0x80) {
/* Ignore the break code */
} else {
if(caps_lock != 1)
{
new_char = (shift_state ? kbdus_up:kbdus)[scancode];
putch(new_char);
} else {
new_char = (shift_state ? kbdus_caps_up:kbdus_caps)[scancode];
putch(new_char);
}
}
break;
}
}
/* Installs the keyboard handler into IRQ1 */
void keyboard_install()
{
irq_install_handler(1, keyboard_handler);
}