Revision 250
in-game timer
mouse.c | ||
---|---|---|
43 | 43 |
} |
44 | 44 |
} |
45 | 45 |
|
46 |
struct packet (mouse_parse_packet)(const uint8_t *packet_bytes){ |
|
47 |
struct packet pp; |
|
48 |
pp.bytes[0] = packet_bytes[0]; |
|
49 |
pp.bytes[1] = packet_bytes[1]; |
|
50 |
pp.bytes[2] = packet_bytes[2]; |
|
51 |
pp.rb = pp.bytes[0] & RIGHT_BUTTON; |
|
52 |
pp.mb = pp.bytes[0] & MIDDLE_BUTTON; |
|
53 |
pp.lb = pp.bytes[0] & LEFT_BUTTON; |
|
54 |
pp.delta_x = sign_extend_byte((packet_bytes[0] & MSB_X_DELTA) != 0, pp.bytes[1]); |
|
55 |
pp.delta_y = sign_extend_byte((packet_bytes[0] & MSB_Y_DELTA) != 0, pp.bytes[2]); |
|
56 |
pp.x_ov = pp.bytes[0] & X_OVERFLOW; |
|
57 |
pp.y_ov = pp.bytes[0] & Y_OVERFLOW; |
|
58 |
return pp; |
|
46 |
void (mouse_parse_packet)(const uint8_t *packet_bytes, struct packet *pp){ |
|
47 |
pp->bytes[0] = packet_bytes[0]; |
|
48 |
pp->bytes[1] = packet_bytes[1]; |
|
49 |
pp->bytes[2] = packet_bytes[2]; |
|
50 |
pp->rb = pp->bytes[0] & RIGHT_BUTTON; |
|
51 |
pp->mb = pp->bytes[0] & MIDDLE_BUTTON; |
|
52 |
pp->lb = pp->bytes[0] & LEFT_BUTTON; |
|
53 |
pp->delta_x = sign_extend_byte((packet_bytes[0] & MSB_X_DELTA) != 0, pp->bytes[1]); |
|
54 |
pp->delta_y = sign_extend_byte((packet_bytes[0] & MSB_Y_DELTA) != 0, pp->bytes[2]); |
|
55 |
pp->x_ov = pp->bytes[0] & X_OVERFLOW; |
|
56 |
pp->y_ov = pp->bytes[0] & Y_OVERFLOW; |
|
59 | 57 |
} |
60 | 58 |
|
61 | 59 |
int mouse_poll(struct packet *pp, uint16_t period){ |
... | ... | |
68 | 66 |
if((ret = mouse_poll_byte(&byte, period))) return ret; |
69 | 67 |
packet[i] = byte; |
70 | 68 |
} |
71 |
*pp = mouse_parse_packet(packet);
|
|
69 |
mouse_parse_packet(packet, pp);
|
|
72 | 70 |
return SUCCESS; |
73 | 71 |
} |
74 | 72 |
|
Also available in: Unified diff