288 |
|
// Mouse movement (relative) and buttons |
289 |
|
if (mx != 0 || my != 0 || mouse_button[0] != old_mouse_button[0] || mouse_button[1] != old_mouse_button[1] || mouse_button[2] != old_mouse_button[2]) { |
290 |
|
uint32 mouse_base = adb_base + 16; |
291 |
– |
uint8 *mouse_data = Mac2HostAddr(tmp_data); |
291 |
|
|
292 |
|
// Call mouse ADB handler |
293 |
|
if (mouse_reg_3[1] == 4) { |
294 |
|
// Extended mouse protocol |
295 |
< |
mouse_data[0] = 3; |
296 |
< |
mouse_data[1] = (my & 0x7f) | (mouse_button[0] ? 0 : 0x80); |
297 |
< |
mouse_data[2] = (mx & 0x7f) | (mouse_button[1] ? 0 : 0x80); |
298 |
< |
mouse_data[3] = ((my >> 3) & 0x70) | ((mx >> 7) & 0x07) | (mouse_button[2] ? 0x08 : 0x88); |
295 |
> |
WriteMacInt8(tmp_data, 3); |
296 |
> |
WriteMacInt8(tmp_data + 1, (my & 0x7f) | (mouse_button[0] ? 0 : 0x80)); |
297 |
> |
WriteMacInt8(tmp_data + 2, (mx & 0x7f) | (mouse_button[1] ? 0 : 0x80)); |
298 |
> |
WriteMacInt8(tmp_data + 3, ((my >> 3) & 0x70) | ((mx >> 7) & 0x07) | (mouse_button[2] ? 0x08 : 0x88)); |
299 |
|
} else { |
300 |
|
// 100/200 dpi mode |
301 |
< |
mouse_data[0] = 2; |
302 |
< |
mouse_data[1] = (my & 0x7f) | (mouse_button[0] ? 0 : 0x80); |
303 |
< |
mouse_data[2] = (mx & 0x7f) | (mouse_button[1] ? 0 : 0x80); |
301 |
> |
WriteMacInt8(tmp_data, 2); |
302 |
> |
WriteMacInt8(tmp_data + 1, (my & 0x7f) | (mouse_button[0] ? 0 : 0x80)); |
303 |
> |
WriteMacInt8(tmp_data + 2, (mx & 0x7f) | (mouse_button[1] ? 0 : 0x80)); |
304 |
|
} |
305 |
|
r.a[0] = tmp_data; |
306 |
|
r.a[1] = ReadMacInt32(mouse_base); |
331 |
|
// Send mouse button events |
332 |
|
if (mouse_button[0] != old_mouse_button[0]) { |
333 |
|
uint32 mouse_base = adb_base + 16; |
335 |
– |
uint8 *mouse_data = Mac2HostAddr(tmp_data); |
334 |
|
|
335 |
|
// Call mouse ADB handler |
336 |
|
if (mouse_reg_3[1] == 4) { |
337 |
|
// Extended mouse protocol |
338 |
< |
mouse_data[0] = 3; |
339 |
< |
mouse_data[1] = mouse_button[0] ? 0 : 0x80; |
340 |
< |
mouse_data[2] = mouse_button[1] ? 0 : 0x80; |
341 |
< |
mouse_data[3] = mouse_button[2] ? 0x08 : 0x88; |
338 |
> |
WriteMacInt8(tmp_data, 3); |
339 |
> |
WriteMacInt8(tmp_data + 1, mouse_button[0] ? 0 : 0x80); |
340 |
> |
WriteMacInt8(tmp_data + 2, mouse_button[1] ? 0 : 0x80); |
341 |
> |
WriteMacInt8(tmp_data + 3, mouse_button[2] ? 0x08 : 0x88); |
342 |
|
} else { |
343 |
|
// 100/200 dpi mode |
344 |
< |
mouse_data[0] = 2; |
345 |
< |
mouse_data[1] = mouse_button[0] ? 0 : 0x80; |
346 |
< |
mouse_data[2] = mouse_button[1] ? 0 : 0x80; |
344 |
> |
WriteMacInt8(tmp_data, 2); |
345 |
> |
WriteMacInt8(tmp_data + 1, mouse_button[0] ? 0 : 0x80); |
346 |
> |
WriteMacInt8(tmp_data + 2, mouse_button[1] ? 0 : 0x80); |
347 |
|
} |
348 |
|
r.a[0] = tmp_data; |
349 |
|
r.a[1] = ReadMacInt32(mouse_base); |
360 |
|
|
361 |
|
// Process accumulated keyboard events |
362 |
|
uint32 key_base = adb_base + 4; |
365 |
– |
uint8 *key_data = Mac2HostAddr(tmp_data); |
363 |
|
while (key_read_ptr != key_write_ptr) { |
364 |
|
|
365 |
|
// Read keyboard event |
367 |
|
key_read_ptr = (key_read_ptr + 1) % KEY_BUFFER_SIZE; |
368 |
|
|
369 |
|
// Call keyboard ADB handler |
370 |
< |
key_data[0] = 2; |
371 |
< |
key_data[1] = mac_code; |
372 |
< |
key_data[2] = mac_code == 0x7f ? 0x7f : 0xff; // Power key is special |
370 |
> |
WriteMacInt8(tmp_data, 2); |
371 |
> |
WriteMacInt8(tmp_data + 1, mac_code); |
372 |
> |
WriteMacInt8(tmp_data + 2, mac_code == 0x7f ? 0x7f : 0xff); // Power key is special |
373 |
|
r.a[0] = tmp_data; |
374 |
|
r.a[1] = ReadMacInt32(key_base); |
375 |
|
r.a[2] = ReadMacInt32(key_base + 4); |