--- BasiliskII/src/adb.cpp 2001/07/03 15:59:45 1.6 +++ BasiliskII/src/adb.cpp 2003/05/13 12:34:09 1.9 @@ -1,7 +1,7 @@ /* * adb.cpp - ADB emulation (mouse/keyboard) * - * Basilisk II (C) 1997-2001 Christian Bauer + * Basilisk II (C) 1997-2002 Christian Bauer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -57,7 +57,7 @@ static uint8 mouse_reg_3[2] = {0x63, 0x0 static uint8 key_reg_2[2] = {0xff, 0xff}; // Keyboard ADB register 2 static uint8 key_reg_3[2] = {0x62, 0x05}; // Keyboard ADB register 3 -// ADB mouse input state lock (for platforms that use separate input thread) +// ADB mouse motion lock (for platforms that use separate input thread) static B2_mutex *mouse_lock; @@ -231,6 +231,8 @@ void ADBMouseMoved(int x, int y) mouse_x = x; mouse_y = y; } B2_unlock_mutex(mouse_lock); + SetInterruptFlag(INTFLAG_ADB); + TriggerInterrupt(); } @@ -240,21 +242,21 @@ void ADBMouseMoved(int x, int y) void ADBMouseDown(int button) { - B2_lock_mutex(mouse_lock); mouse_button[button] = true; - B2_unlock_mutex(mouse_lock); + SetInterruptFlag(INTFLAG_ADB); + TriggerInterrupt(); } /* - * First mouse button released + * Mouse button released */ void ADBMouseUp(int button) { - B2_lock_mutex(mouse_lock); mouse_button[button] = false; - B2_unlock_mutex(mouse_lock); + SetInterruptFlag(INTFLAG_ADB); + TriggerInterrupt(); } @@ -264,7 +266,10 @@ void ADBMouseUp(int button) void ADBSetRelMouseMode(bool relative) { - relative_mouse = relative; + if (relative_mouse != relative) { + relative_mouse = relative; + mouse_x = mouse_y = 0; + } } @@ -280,6 +285,10 @@ void ADBKeyDown(int code) // Set key in matrix key_states[code >> 3] |= (1 << (~code & 7)); + + // Trigger interrupt + SetInterruptFlag(INTFLAG_ADB); + TriggerInterrupt(); } @@ -295,6 +304,10 @@ void ADBKeyUp(int code) // Clear key in matrix key_states[code >> 3] &= ~(1 << (~code & 7)); + + // Trigger interrupt + SetInterruptFlag(INTFLAG_ADB); + TriggerInterrupt(); } @@ -359,13 +372,13 @@ void ADBInterrupt(void) // Update mouse position (absolute) if (mx != old_mouse_x || my != old_mouse_y) { #ifdef POWERPC_ROM - static const uint16 proc[] = { - 0x2f08, // move.l a0,-(sp) - 0x2f00, // move.l d0,-(sp) - 0x2f01, // move.l d1,-(sp) - 0x7001, // moveq #1,d0 (MoveTo) - 0xaadb, // CursorDeviceDispatch - M68K_RTS + static const uint8 proc[] = { + 0x2f, 0x08, // move.l a0,-(sp) + 0x2f, 0x00, // move.l d0,-(sp) + 0x2f, 0x01, // move.l d1,-(sp) + 0x70, 0x01, // moveq #1,d0 (MoveTo) + 0xaa, 0xdb, // CursorDeviceDispatch + M68K_RTS >> 8, M68K_RTS & 0xff }; r.a[0] = ReadMacInt32(mouse_base + 4); r.d[0] = mx;