scale mouse wheel delta to match web interface (#2052)

This commit is contained in:
Yun Hsiao Wu
2020-01-07 12:09:30 +08:00
committed by pandamicro
parent 12fb16bf0a
commit aa4b516e6c
2 changed files with 14 additions and 16 deletions
+6 -7
View File
@@ -44,14 +44,13 @@ THE SOFTWARE.
#define glDepthRangef glDepthRange
#define glReleaseShaderCompiler(xxx)
#define GL_RGBA32F_EXT 0x8814
#define GL_RGB32F_EXT 0x8815
#define GL_RGBA16F_EXT 0x881A
#define GL_RGB16F_EXT 0x881B
#define GL_HALF_FLOAT_OES 0x8D61
#define GL_RGBA32F_EXT 0x8814
#define GL_RGB32F_EXT 0x8815
#define GL_RGBA16F_EXT 0x881A
#define GL_RGB16F_EXT 0x881B
#define GL_HALF_FLOAT_OES 0x8D61
#define GL_UNSIGNED_INT_24_8_OES 0x84FA
#endif // __PLATFORM_MAC_CCGL_H__
#endif //s CC_TARGET_PLATFORM == CC_PLATFORM_MAC
@@ -1,18 +1,18 @@
/****************************************************************************
Copyright (c) 2018 Xiamen Yaji Software Co., Ltd.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -171,13 +171,12 @@ void EventDispatcher::dispatchMouseEvent(const struct MouseEvent& mouseEvent)
}
const auto& xVal = se::Value(mouseEvent.x);
const auto& yVal = se::Value(mouseEvent.y);
const MouseEvent::Type type = mouseEvent.type;
if (type == MouseEvent::Type::WHEEL)
{
_jsMouseEventObj->setProperty("wheelDeltaX", xVal);
_jsMouseEventObj->setProperty("wheelDeltaY", yVal);
_jsMouseEventObj->setProperty("wheelDeltaY", se::Value(mouseEvent.y * 120.0f)); // scale up to match the web interface
}
else
{
@@ -186,7 +185,7 @@ void EventDispatcher::dispatchMouseEvent(const struct MouseEvent& mouseEvent)
_jsMouseEventObj->setProperty("button", se::Value(mouseEvent.button));
}
_jsMouseEventObj->setProperty("x", xVal);
_jsMouseEventObj->setProperty("y", yVal);
_jsMouseEventObj->setProperty("y", se::Value(mouseEvent.y));
}
const char* eventName = nullptr;
@@ -261,7 +260,7 @@ void EventDispatcher::dispatchKeyboardEvent(const struct KeyboardEvent& keyboard
callbackVal.toObject()->call(args, nullptr);
}
}
void EventDispatcher::dispatchTickEvent(float dt)
{
if (!se::ScriptEngine::getInstance()->isValid())
@@ -449,5 +448,5 @@ void EventDispatcher::dispatchCustomEvent(const CustomEvent& event)
}
}
}
} // end of namespace cocos2d