Use _keyboard_installed and _mouse_installed flags to trigger keyboard and mouse events in directx_wnd_proc().

This commit is contained in:
David Capello 2010-10-30 19:44:39 -03:00
parent 623eab27a8
commit 579d652f07

View File

@ -312,34 +312,38 @@ static LRESULT CALLBACK directx_wnd_proc(HWND wnd, UINT message, WPARAM wparam,
break; break;
case WM_LBUTTONDOWN: case WM_LBUTTONDOWN:
case WM_LBUTTONUP: { case WM_LBUTTONUP:
if (_mouse_installed) {
int mx = GET_X_LPARAM(lparam); int mx = GET_X_LPARAM(lparam);
int my = GET_Y_LPARAM(lparam); int my = GET_Y_LPARAM(lparam);
BOOL down = (message == WM_LBUTTONDOWN); BOOL down = (message == WM_LBUTTONDOWN);
_al_win_mouse_handle_button(wnd, 1, down, mx, my, TRUE); _al_win_mouse_handle_button(wnd, 1, down, mx, my, TRUE);
break;
} }
break;
case WM_MBUTTONDOWN: case WM_MBUTTONDOWN:
case WM_MBUTTONUP: { case WM_MBUTTONUP:
if (_mouse_installed) {
int mx = GET_X_LPARAM(lparam); int mx = GET_X_LPARAM(lparam);
int my = GET_Y_LPARAM(lparam); int my = GET_Y_LPARAM(lparam);
BOOL down = (message == WM_MBUTTONDOWN); BOOL down = (message == WM_MBUTTONDOWN);
_al_win_mouse_handle_button(wnd, 3, down, mx, my, TRUE); _al_win_mouse_handle_button(wnd, 3, down, mx, my, TRUE);
break;
} }
break;
case WM_RBUTTONDOWN: case WM_RBUTTONDOWN:
case WM_RBUTTONUP: { case WM_RBUTTONUP:
if (_mouse_installed) {
int mx = GET_X_LPARAM(lparam); int mx = GET_X_LPARAM(lparam);
int my = GET_Y_LPARAM(lparam); int my = GET_Y_LPARAM(lparam);
BOOL down = (message == WM_RBUTTONDOWN); BOOL down = (message == WM_RBUTTONDOWN);
_al_win_mouse_handle_button(wnd, 2, down, mx, my, TRUE); _al_win_mouse_handle_button(wnd, 2, down, mx, my, TRUE);
break;
} }
break;
case WM_XBUTTONDOWN: case WM_XBUTTONDOWN:
case WM_XBUTTONUP: { case WM_XBUTTONUP:
if (_mouse_installed) {
int mx = GET_X_LPARAM(lparam); int mx = GET_X_LPARAM(lparam);
int my = GET_Y_LPARAM(lparam); int my = GET_Y_LPARAM(lparam);
int button = HIWORD(wparam); int button = HIWORD(wparam);
@ -350,27 +354,34 @@ static LRESULT CALLBACK directx_wnd_proc(HWND wnd, UINT message, WPARAM wparam,
_al_win_mouse_handle_button(wnd, 5, down, mx, my, TRUE); _al_win_mouse_handle_button(wnd, 5, down, mx, my, TRUE);
return TRUE; return TRUE;
} }
break;
case WM_MOUSEWHEEL: { case WM_MOUSEWHEEL:
if (_mouse_installed) {
int d = GET_WHEEL_DELTA_WPARAM(wparam); int d = GET_WHEEL_DELTA_WPARAM(wparam);
_al_win_mouse_handle_wheel(wnd, d / WHEEL_DELTA, FALSE); _al_win_mouse_handle_wheel(wnd, d / WHEEL_DELTA, FALSE);
return TRUE; return TRUE;
} }
break;
case WM_MOUSEMOVE: { case WM_MOUSEMOVE:
if (_mouse_installed) {
POINTS p = MAKEPOINTS(lparam); POINTS p = MAKEPOINTS(lparam);
_al_win_mouse_handle_move(wnd, p.x, p.y); _al_win_mouse_handle_move(wnd, p.x, p.y);
break;
} }
break;
case WM_SYSKEYDOWN: { case WM_SYSKEYDOWN:
if (_keyboard_installed) {
int vcode = wparam; int vcode = wparam;
BOOL repeated = (lparam >> 30) & 0x1; BOOL repeated = (lparam >> 30) & 0x1;
_al_win_kbd_handle_key_press(0, vcode, repeated); _al_win_kbd_handle_key_press(0, vcode, repeated);
return 0; return 0;
} }
break;
case WM_KEYDOWN: { case WM_KEYDOWN:
if (_keyboard_installed) {
int vcode = wparam; int vcode = wparam;
int scode = (lparam >> 16) & 0xff; int scode = (lparam >> 16) & 0xff;
BOOL repeated = (lparam >> 30) & 0x1; BOOL repeated = (lparam >> 30) & 0x1;
@ -379,13 +390,16 @@ static LRESULT CALLBACK directx_wnd_proc(HWND wnd, UINT message, WPARAM wparam,
_al_win_kbd_handle_key_press(scode, vcode, repeated); _al_win_kbd_handle_key_press(scode, vcode, repeated);
return 0; return 0;
} }
break;
case WM_SYSKEYUP: case WM_SYSKEYUP:
case WM_KEYUP: { case WM_KEYUP:
if (_keyboard_installed) {
int vcode = wparam; int vcode = wparam;
_al_win_kbd_handle_key_release(vcode); _al_win_kbd_handle_key_release(vcode);
return 0; return 0;
} }
break;
} }