Skip to content

Commit

Permalink
Interface: Use platform time
Browse files Browse the repository at this point in the history
Fixes: Issue #891
  • Loading branch information
bsxf-47 committed Apr 16, 2017
1 parent cb9d823 commit ac7b3f8
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/gui/Interface.cpp
Expand Up @@ -1673,14 +1673,15 @@ void ArxGame::manageKeyMouse() {
PLAYER_ROTATION = AnimationDuration_ZERO;

Vec2f mouseDiff = Vec2f(GInput->getMousePosRel());
float timeDiff = toMs(g_platformTime.lastFrameDuration());

if(config.input.mouseAcceleration > 0) {
Vec2f speed = mouseDiff / g_framedelay;
if(config.input.mouseAcceleration > 0 && timeDiff > 0.0f) {
Vec2f speed = mouseDiff / timeDiff;
Vec2f sign(speed.x < 0 ? -1.f : 1.f, speed.y < 0 ? -1.f : 1.f);
float exponent = 1.f + config.input.mouseAcceleration * 0.05f;
speed.x = (std::pow(speed.x * sign.x + 1.f, exponent) - 1.f) * sign.x;
speed.y = (std::pow(speed.y * sign.y + 1.f, exponent) - 1.f) * sign.y;
mouseDiff = speed * g_framedelay;
mouseDiff = speed * timeDiff;
}

ARX_Menu_Manage();
Expand Down Expand Up @@ -1812,22 +1813,22 @@ void ArxGame::manageKeyMouse() {

if(distLeft < borderSize) {
float speed = 1.f - float(distLeft) / float(borderSize);
mouseDiff.x -= speed * g_framedelay;
mouseDiff.x -= speed * timeDiff;
}

if(distRight < borderSize) {
float speed = 1.f - float(distRight) / float(borderSize);
mouseDiff.x += speed * g_framedelay;
mouseDiff.x += speed * timeDiff;
}

if(distTop < borderSize) {
float speed = 1.f - float(distTop) / float(borderSize);
mouseDiff.y -= speed * g_framedelay;
mouseDiff.y -= speed * timeDiff;
}

if(distBottom < borderSize) {
float speed = 1.f - float(distBottom) / float(borderSize);
mouseDiff.y += speed * g_framedelay;
mouseDiff.y += speed * timeDiff;
}

if(distLeft >= 3 * borderSize && distRight >= 3 * borderSize
Expand Down

0 comments on commit ac7b3f8

Please sign in to comment.