Changeset View
Changeset View
Standalone View
Standalone View
intern/ghost/intern/GHOST_SystemWin32.cpp
| Context not available. | |||||
| #endif | #endif | ||||
| #include <stdio.h> // [mce] temporary debug, remove soon! | #include <stdio.h> // [mce] temporary debug, remove soon! | ||||
| #include <stdlib.h> // getenv for debug | |||||
| #include "GHOST_SystemWin32.h" | #include "GHOST_SystemWin32.h" | ||||
| #include "GHOST_EventDragnDrop.h" | #include "GHOST_EventDragnDrop.h" | ||||
| Context not available. | |||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| GHOST_EventWheel *GHOST_SystemWin32::processWheelEvent(GHOST_IWindow *window, WPARAM wParam, LPARAM lParam) | GHOST_EventWheel *GHOST_SystemWin32::processWheelEvent(GHOST_IWindow *window, WPARAM wParam, LPARAM lParam) | ||||
| { | { | ||||
| // short fwKeys = LOWORD(wParam); // key flags | GHOST_SystemWin32 *system = ((GHOST_SystemWin32 *)getSystem()); | ||||
| int zDelta = (short) HIWORD(wParam); // wheel rotation | |||||
| const int MAX_TICKS = 999; //temporal value | |||||
| // zDelta /= WHEEL_DELTA; | static int wheel = -1; | ||||
| // temporary fix below: microsoft now has added more precision, making the above division not work | |||||
| if (zDelta <= 0) zDelta = -1; else zDelta = 1; | if (wheel == -1 && getenv("BLENDER_WHEEL")) { | ||||
| wheel = atoi(getenv("BLENDER_WHEEL")); | |||||
| // short xPos = (short) LOWORD(lParam); // horizontal position of pointer | |||||
| // short yPos = (short) HIWORD(lParam); // vertical position of pointer | printf("BLENDER_WHEEL=%d WHEEL_DELTA=%d\n", wheel, WHEEL_DELTA); | ||||
| return new GHOST_EventWheel(getSystem()->getMilliSeconds(), window, zDelta); | } | ||||
| } | |||||
| // disable new code only when BLENDER_WHEEL is set and equals 0 | |||||
brecht: Same here, better use `int`. | |||||
| if (wheel != 0) { | |||||
| static int accum = 0; | |||||
Not Done Inline ActionsSee below, since always 0 is returned, you can get rid of the return value for this method alltogether elubie: See below, since always 0 is returned, you can get rid of the return value for this method… | |||||
| int old_accum = accum; //for debug | |||||
| int zDelta = (short) HIWORD(wParam); // wheel rotation | |||||
| accum += zDelta; | |||||
| int ticks = abs(accum) / WHEEL_DELTA; | |||||
| int direction = (accum >= 0) ? 1 : -1; | |||||
| accum = (abs(accum) % WHEEL_DELTA) * direction; | |||||
| if (wheel >= 5) { | |||||
Not Done Inline ActionsAnd here as well. brecht: And here as well. | |||||
| static GHOST_TUns64 last_t = 0; | |||||
| GHOST_TUns64 t = system->getMilliSeconds(); | |||||
| printf("wheel:\tzDelta=%d (accum %d->%d) ticks=%d", zDelta, old_accum, accum, ticks); | |||||
| printf(" time=%llu msec.(diff=%llu msec.)", t, t - last_t); | |||||
| printf("\n"); | |||||
| last_t = t; | |||||
| } | |||||
| if (ticks > MAX_TICKS) | |||||
| ticks = MAX_TICKS; | |||||
| for (int i=0; i<ticks; i++) { | |||||
| GHOST_TSuccess success = system->pushEvent(new GHOST_EventWheel(system->getMilliSeconds(), window, direction)); | |||||
| if (success != GHOST_kSuccess) { | |||||
| //only when out of memory? | |||||
| printf("GHOST_SystemWin32::processWheelEvent pushEvent failed at %d\n", i); | |||||
| break; | |||||
| } | |||||
| } | |||||
| return (GHOST_EventWheel *)0; | |||||
| } | |||||
| else { //original code | |||||
| // short fwKeys = LOWORD(wParam); // key flags | |||||
| int zDelta = (short) HIWORD(wParam); // wheel rotation | |||||
| // zDelta /= WHEEL_DELTA; | |||||
| // temporary fix below: microsoft now has added more precision, making the above division not work | |||||
| if (zDelta <= 0) zDelta = -1; else zDelta = 1; | |||||
| // short xPos = (short) LOWORD(lParam); // horizontal position of pointer | |||||
| // short yPos = (short) HIWORD(lParam); // vertical position of pointer | |||||
| return new GHOST_EventWheel(getSystem()->getMilliSeconds(), window, zDelta); | |||||
| } | |||||
| } | |||||
| GHOST_EventKey *GHOST_SystemWin32::processKeyEvent(GHOST_IWindow *window, RAWINPUT const& raw) | GHOST_EventKey *GHOST_SystemWin32::processKeyEvent(GHOST_IWindow *window, RAWINPUT const& raw) | ||||
| { | { | ||||
Not Done Inline ActionsThis could be a member variable of GHOST_SystemWin32 I think. brecht: This could be a member variable of GHOST_SystemWin32 I think. | |||||
Not Done Inline ActionsWhy is there a maximum here, to avoid a very high number of mouse wheel events? 5 seems a bit low. brecht: Why is there a maximum here, to avoid a very high number of mouse wheel events? 5 seems a bit… | |||||
Not Done Inline ActionsWith the new behavior only, this check is not necessary since all events are now handled in processWheelEvent. In this case you can probably also get rid of the return value alltogether elubie: With the new behavior only, this check is not necessary since all events are now handled in… | |||||
| Context not available. | |||||
| * since DefWindowProc propagates it up the parent chain | * since DefWindowProc propagates it up the parent chain | ||||
| * until it finds a window that processes it. | * until it finds a window that processes it. | ||||
| */ | */ | ||||
| event = processWheelEvent(window, wParam, lParam); | event = processWheelEvent(window, wParam, lParam); | ||||
| if (!event) | |||||
| eventHandled = true; | |||||
| break; | break; | ||||
| case WM_SETCURSOR: | case WM_SETCURSOR: | ||||
| /* The WM_SETCURSOR message is sent to a window if the mouse causes the cursor | /* The WM_SETCURSOR message is sent to a window if the mouse causes the cursor | ||||
| Context not available. | |||||
Same here, better use int.