mirror of
https://github.com/ApfelTeeSaft/gameBase.git
synced 2026-08-26 19:23:30 +00:00
detecting mouse wheel scrolling
This commit is contained in:
@@ -29,6 +29,7 @@ namespace gameBase {
|
|||||||
virtual void onRawKeyPress(int){}
|
virtual void onRawKeyPress(int){}
|
||||||
virtual void onRawCharPress(unsigned int){}
|
virtual void onRawCharPress(unsigned int){}
|
||||||
virtual void onRawMousePress(int){}
|
virtual void onRawMousePress(int){}
|
||||||
|
virtual void onRawMouseWheelScroll(bool){}
|
||||||
virtual void onRawJoystickMove(int, float){}
|
virtual void onRawJoystickMove(int, float){}
|
||||||
virtual void onRawJoystickPress(int){}
|
virtual void onRawJoystickPress(int){}
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -10,6 +10,12 @@ namespace gameBase{
|
|||||||
double *posX, *posY, strX, strY;
|
double *posX, *posY, strX, strY;
|
||||||
int width, height;
|
int width, height;
|
||||||
StateManager *manager = nullptr;
|
StateManager *manager = nullptr;
|
||||||
|
|
||||||
|
void scroll_callback(GLFWwindow* window, double xOffset, double yOffset) {
|
||||||
|
if(manager)
|
||||||
|
for(AbstractAppState *a : manager->getAppStates())
|
||||||
|
a->onRawMouseWheelScroll(yOffset == 1);
|
||||||
|
}
|
||||||
|
|
||||||
void foo(GLFWwindow *window, double newPosX, double newPosY){
|
void foo(GLFWwindow *window, double newPosX, double newPosY){
|
||||||
strX = (*posX - newPosX) / width, strY = (newPosY - *posY) / height;
|
strX = (*posX - newPosX) / width, strY = (newPosY - *posY) / height;
|
||||||
@@ -118,6 +124,8 @@ namespace gameBase{
|
|||||||
|
|
||||||
glfwSetCursorPosCallback(window, foo);
|
glfwSetCursorPosCallback(window, foo);
|
||||||
|
|
||||||
|
glfwSetScrollCallback(window, scroll_callback);
|
||||||
|
|
||||||
if(glfwJoystickPresent(GLFW_JOYSTICK_1)){
|
if(glfwJoystickPresent(GLFW_JOYSTICK_1)){
|
||||||
for(int i = 0; i < numAxis; i++)
|
for(int i = 0; i < numAxis; i++)
|
||||||
if(abs(axis[i]) == 1)
|
if(abs(axis[i]) == 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user