static uint8_t togglecode[256] = {
[0x3A] CAPSLOCK,
[0x45] NUMLOCK,
[0x46] SCROLLLOCK
};
What\'s the meaning of [0x3A]
her
That was introduced in C99 and it's called a designated initialiser.
It basically allows you to set specific values in an array with the rest left as defaults.
In this particular case, the array indexes are the keyboard scan codes. 0x3a
is the scan code in set #1 (see section 10.6) for the CapsLock
key, 0x45
is NumLock
and 0x46 is ScrollLock
.
On the first link above, it states that:
int a[6] = { [4] = 29, [2] = 15 };
is equivalent to:
int a[6] = { 0, 0, 15, 0, 29, 0 };
Interestingly enough, though the link states that =
is necessary, that doesn't appear to be the case here.