static uint8_t togglecode[256] = {
[0x3A] CAPSLOCK,
[0x45] NUMLOCK,
[0x46] SCROLLLOCK
};
What\'s the meaning of [0x3A]
her
It means initialise the n-th element of the array. The example you've given will mean that:
togglecode[0x3A] == CAPSLOCK
togglecode[0x45] == NUMLOCK
togglecode[0x46] == SCROLLLOCK
These are called "designated initializers", and are actually part of the C99 standard. However, the syntax without the =
is not. From that page:
An alternative syntax for this which has been obsolete since GCC 2.5 but GCC still accepts is to write
[index]
before the element value, with no=
.