emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.56k stars 3.27k forks source link

Mouse wheel direction wrong for glut and glfw #3171

Open ghost opened 9 years ago

ghost commented 9 years ago

The mouse wheel direction is upside down for glfw3 with every browser I tested and glut with chromium. sdl2 appears to be correct.

Test results for scrolling down and up once with code: https://gist.github.com/00v1/0ddc40dec5d395456193#file-mousewheel-txt

Xubuntu Desktop

    glfw3 down -1.000000
    glfw3 up 1.00000

    glut down button = 4, state = 0
    glut down button = 4, state = 1
    glut up button = 3, state = 0
    glut up button = 3, state = 1

    sdl2 down -1
    sdl2 up 1

Linux Firefox

    glfw3 up 3.000000 // wrong direction
    glfw3 down -3.000000 // wrong direction

    glut down button = 4, state = 0
    // missing state = 1
    glut up button = 3, state = 0
    // missing state = 1

    sdl2 down -3
    sdl2 up 3

Linux Chromium

    glfw3 up 53.000000 // wrong direction
    glfw3 down -53.000000 // wrong direction

    glut up button = 3, state = 0 // wrong direction
    // missing state = 1
    glut down button = 4, state = 0 // wrong direction
    // missing state = 1

    sdl2 down -53
    sdl2 up 53

Windows Firefox // Same as on Linux

    glfw3 up 3.000000
    glfw3 down -3.000000

    glut down button = 4, state = 0
    glut up button = 3, state = 0

    sdl2 down -3
    sdl2 up 3

Windows Chrome // Same as on Linux, different scaling

    glfw3 up 100.000000
    glfw3 down -100.000000

    glut up button = 3, state = 0
    glut down button = 4, state = 0

    sdl2 down -100
    sdl2 up 100

Windows Opera // Same as Chrome

    glfw3 up 100.000000
    glfw3 down -100.000000

    glut up button = 3, state = 0
    glut down button = 4, state = 0

    sdl2 down -100
    sdl2 up 100

Compile with

emcc glfw3.cpp -o glfw3.html -s USE_GLFW=3
emcc  glut.cpp -o  glut.html
emcc  sdl2.cpp -o  sdl2.html -s USE_SDL=2

Relevant function: https://github.com/kripken/emscripten/search?utf8=%E2%9C%93&q=getMouseWheelDelta

To avoid confusion: "Down" is when the upper side of the mouse wheel travels towards you, or when you scroll "down" a website.

onqtam commented 7 years ago

Any update on this? I seem to have hit the same problem with GLFW3

juj commented 7 years ago

I think we have flipped the wheel directions already twice because of reports of them being wrong. There are at least the following related reports about this:

perhaps since we share some code across SDL, GLUT and GLFW, it means that fixing one API has regressed another in the past, which has caused the problem. We can't go flipping the wheel around anymore without testing. Do we have existing tests in the interactive suite that would showcase the problem? Happy to merge fixes for this, but we need to ensure that the breakage and fix can be verified consistently.

MusorGaming commented 6 years ago

The sign for scroll values is wrong on GLFW!

I can at least work around the deltas being flipped by #ifdef EMSCRIPTEN How am I supposed to scale the deltas on Chrome? I need some way to detect which browser this is running on. How to do this?

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant.

Francesco149 commented 2 years ago

i know this is an old issue, but I would just like to add that switching between legacy opengl emulation to FULL_ES2 changes scroll behaviour. legacy opengl has flipped, extremely big scroll deltas while ES2 behaves normally. this is with glfw3