mirror of
https://github.com/glfw/glfw.git
synced 2026-09-18 22:55:46 +00:00
Made scrolling deltas floating point.
This commit is contained in:
@@ -75,8 +75,6 @@ typedef struct _GLFWwindowNS
|
||||
id window;
|
||||
id delegate;
|
||||
unsigned int modifierFlags;
|
||||
double fracScrollX;
|
||||
double fracScrollY;
|
||||
} _GLFWwindowNS;
|
||||
|
||||
|
||||
|
||||
+1
-8
@@ -479,14 +479,7 @@ static int convertMacKeyCode(unsigned int macKeyCode)
|
||||
|
||||
- (void)scrollWheel:(NSEvent *)event
|
||||
{
|
||||
double deltaX = window->NS.fracScrollX + [event deltaX];
|
||||
double deltaY = window->NS.fracScrollY + [event deltaY];
|
||||
|
||||
if ((int) deltaX || (int) deltaY)
|
||||
_glfwInputScroll(window, (int) deltaX, (int) deltaY);
|
||||
|
||||
window->NS.fracScrollX = (int) (deltaX - floor(deltaX));
|
||||
window->NS.fracScrollY = (int) (deltaY - floor(deltaY));
|
||||
_glfwInputScroll(window, [event deltaX], [event deltaY]);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
+2
-2
@@ -200,7 +200,7 @@ void _glfwInputChar(_GLFWwindow* window, int character)
|
||||
// Register scroll events
|
||||
//========================================================================
|
||||
|
||||
void _glfwInputScroll(_GLFWwindow* window, int xoffset, int yoffset)
|
||||
void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset)
|
||||
{
|
||||
window->scrollX += xoffset;
|
||||
window->scrollY += yoffset;
|
||||
@@ -476,7 +476,7 @@ GLFWAPI void glfwSetMousePos(GLFWwindow handle, int xpos, int ypos)
|
||||
// Returns the scroll offset for the specified window
|
||||
//========================================================================
|
||||
|
||||
GLFWAPI void glfwGetScrollOffset(GLFWwindow handle, int* xoffset, int* yoffset)
|
||||
GLFWAPI void glfwGetScrollOffset(GLFWwindow handle, double* xoffset, double* yoffset)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
|
||||
+2
-2
@@ -186,7 +186,7 @@ struct _GLFWwindow
|
||||
GLboolean systemKeys; // system keys enabled flag
|
||||
int cursorPosX, cursorPosY;
|
||||
int cursorMode;
|
||||
int scrollX, scrollY;
|
||||
double scrollX, scrollY;
|
||||
char mouseButton[GLFW_MOUSE_BUTTON_LAST + 1];
|
||||
char key[GLFW_KEY_LAST + 1];
|
||||
|
||||
@@ -343,7 +343,7 @@ void _glfwInputWindowDamage(_GLFWwindow* window);
|
||||
// Input event notification (input.c)
|
||||
void _glfwInputKey(_GLFWwindow* window, int key, int action);
|
||||
void _glfwInputChar(_GLFWwindow* window, int character);
|
||||
void _glfwInputScroll(_GLFWwindow* window, int x, int y);
|
||||
void _glfwInputScroll(_GLFWwindow* window, double x, double y);
|
||||
void _glfwInputMouseClick(_GLFWwindow* window, int button, int action);
|
||||
void _glfwInputCursorMotion(_GLFWwindow* window, int x, int y);
|
||||
void _glfwInputCursorEnter(_GLFWwindow* window, int entered);
|
||||
|
||||
+2
-2
@@ -1022,7 +1022,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
||||
|
||||
case WM_MOUSEWHEEL:
|
||||
{
|
||||
_glfwInputScroll(window, 0, (((int) wParam) >> 16) / WHEEL_DELTA);
|
||||
_glfwInputScroll(window, 0.0, (SHORT) HIWORD(wParam) / (double) WHEEL_DELTA);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1030,7 +1030,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
||||
{
|
||||
// This message is only sent on Windows Vista and later
|
||||
|
||||
_glfwInputScroll(window, (((int) wParam) >> 16) / WHEEL_DELTA, 0);
|
||||
_glfwInputScroll(window, (SHORT) HIWORD(wParam) / (double) WHEEL_DELTA, 0.0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -1144,14 +1144,14 @@ static void processSingleEvent(void)
|
||||
// XFree86 3.3.2 and later translates mouse wheel up/down into
|
||||
// mouse button 4 & 5 presses
|
||||
else if (event.xbutton.button == Button4)
|
||||
_glfwInputScroll(window, 0, 1);
|
||||
_glfwInputScroll(window, 0.0, 1.0);
|
||||
else if (event.xbutton.button == Button5)
|
||||
_glfwInputScroll(window, 0, -1);
|
||||
_glfwInputScroll(window, 0.0, -1.0);
|
||||
|
||||
else if (event.xbutton.button == Button6)
|
||||
_glfwInputScroll(window, -1, 0);
|
||||
_glfwInputScroll(window, -1.0, 0.0);
|
||||
else if (event.xbutton.button == Button7)
|
||||
_glfwInputScroll(window, 1, 0);
|
||||
_glfwInputScroll(window, 1.0, 0.0);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user