Revision 70
implemented remote, working on fixing issues
lab4.c | ||
---|---|---|
5 | 5 |
|
6 | 6 |
#include "mouse.h" |
7 | 7 |
#include "kbc.h" |
8 |
#include "errors.h" |
|
9 |
#include "mouse_macros.h" |
|
8 | 10 |
|
9 | 11 |
int main(int argc, char *argv[]) { |
10 | 12 |
// sets the language of LCF messages (can be either EN-US or PT-PT) |
... | ... | |
80 | 82 |
} |
81 | 83 |
|
82 | 84 |
int (mouse_test_remote)(uint16_t period, uint8_t cnt) { |
83 |
/* To be completed */ |
|
84 |
printf("%s(%u, %u): under construction\n", __func__, period, cnt); |
|
85 |
return 1; |
|
85 |
|
|
86 |
// Mouse packets data |
|
87 |
uint8_t packet[3]; |
|
88 |
int sz = 0; |
|
89 |
uint8_t data = 0; |
|
90 |
// Cycle |
|
91 |
int packetCounter = 0; |
|
92 |
int good = 1; |
|
93 |
// return value |
|
94 |
int ret; |
|
95 |
|
|
96 |
while (good) { |
|
97 |
|
|
98 |
if ((ret = mouse_read_data(&data))) return ret; |
|
99 |
|
|
100 |
if ((data & FIRST_BYTE_ID) || sz) { |
|
101 |
packet[sz] = data; |
|
102 |
sz++; |
|
103 |
} |
|
104 |
|
|
105 |
if (sz == 3) { |
|
106 |
struct packet pp = mouse_parse_packet(packet); |
|
107 |
mouse_print_packet(&pp); |
|
108 |
packetCounter++; |
|
109 |
sz = 0; |
|
110 |
if (packetCounter == cnt) good = 0; |
|
111 |
} |
|
112 |
|
|
113 |
tickdelay(micros_to_ticks(period*1e3)); |
|
114 |
} |
|
115 |
|
|
116 |
// Set Stream mode |
|
117 |
if ((ret = mouse_issue_cmd(SET_STREAM_MD))) return ret; |
|
118 |
// Disable data reporting |
|
119 |
if ((ret = mouse_issue_cmd(DIS_DATA_REP))) return ret; |
|
120 |
|
|
121 |
uint8_t cmd_byte = minix_get_dflt_kbc_cmd_byte(); |
|
122 |
if ((ret = kbc_change_cmd(cmd_byte))) return ret; |
|
123 |
|
|
124 |
return SUCCESS; |
|
86 | 125 |
} |
87 | 126 |
|
88 | 127 |
int (mouse_test_async)(uint8_t idle_time) { |
Also available in: Unified diff