-
Notifications
You must be signed in to change notification settings - Fork 85
Hotkey event
The Hotkey event has Type = 0x01 and Code = 0x[0-9]D where the first digit of the Code maps to the hot key being used.
There are three types of hotkey events, which are signalled by the rightmost 2 bits of the first byte, bits 5 & 6 signal any modifications made to the selection since the last time the hotkey was set. The first byte reads thus as CCCCBBAA with AA being the hotkey type and BB being the modification mask mode.
Modifications indicate which units are selectable and thus are not always permanent changes to the hotkey. They will be sent every time you trigger a hotkey until you reassign it. If you, for example, hotkey 3 probes mining the Assimilator, the modification overlay will change according to which probes are out of the building (selectable)!
According to type flag (first byte & 0x03)
- 0x00 = set hotkey to current selection.
- 0x01 = add current selection to hotkey.
- 0x02 = push hotkey to current selection
The modification mask mode ((first byte & 0xF) >> 2) is similar to the selection event deselect modes and work the same way. For this the stream must be bitshifted 4 bits (removing the flags and starting with bits 1-4 of the first byte!)
- 0x00 = no modifications
- 0x01 = deselect by bit mask
- 0x02 = deselect by index
- 0x03 = only display units by index (replace selection)
With the first and second bytes having been read, this will read the remaining bytes without introspecting it:
if first & 0x08: bytes.skip(second & 0x0F) else: extras = first >> 3 bytes.skip(extras) if extras == 0: if second & 0x07 > 0x04: bytes.skip(1) if second & 0x08 != 0: bytes.skip(1) else: if first & 0x04 != 0: if second & 0x07 > 0x04: bytes.skip(1) if second & 0x08 != 0: bytes.skip(1)
The first 5 bits of the first byte indicate how many bytes following the second should be skipped.
The remaining logic flows as follows:
extras = first >> 3 #Shift off 3 bits to get the first 5 second = bytes.getBigInt(1) #Get the next byte indicator bytes.skip(extras) #Skip the extra bytes if first & 0x04: bytes.skip(1) if second & 0x06 == 0x06: bytes.skip()