MCPcopy Create free account
hub / github.com/OneLoneCoder/olcPixelGameEngine / mouse_callback

Method mouse_callback

olcPixelGameEngine.h:7896–7933  ·  view source on GitHub ↗

TY Moros

Source from the content-addressed store, hash-verified

7894
7895 //TY Moros
7896 static EM_BOOL mouse_callback(int eventType, const EmscriptenMouseEvent* e, void* userData)
7897 {
7898 //Mouse Movement
7899 if (eventType == EMSCRIPTEN_EVENT_MOUSEMOVE)
7900 ptrPGE->olc_UpdateMouse(e->targetX, e->targetY);
7901
7902
7903 //Mouse button press
7904 if (e->button == 0) // left click
7905 {
7906 if (eventType == EMSCRIPTEN_EVENT_MOUSEDOWN)
7907 ptrPGE->olc_UpdateMouseState(0, true);
7908 else if (eventType == EMSCRIPTEN_EVENT_MOUSEUP)
7909 ptrPGE->olc_UpdateMouseState(0, false);
7910 }
7911
7912 if (e->button == 2) // right click
7913 {
7914 if (eventType == EMSCRIPTEN_EVENT_MOUSEDOWN)
7915 ptrPGE->olc_UpdateMouseState(1, true);
7916 else if (eventType == EMSCRIPTEN_EVENT_MOUSEUP)
7917 ptrPGE->olc_UpdateMouseState(1, false);
7918
7919 }
7920
7921 if (e->button == 1) // middle click
7922 {
7923 if (eventType == EMSCRIPTEN_EVENT_MOUSEDOWN)
7924 ptrPGE->olc_UpdateMouseState(2, true);
7925 else if (eventType == EMSCRIPTEN_EVENT_MOUSEUP)
7926 ptrPGE->olc_UpdateMouseState(2, false);
7927
7928 //at the moment only middle mouse needs to consume events.
7929 return EM_TRUE;
7930 }
7931
7932 return EM_FALSE;
7933 }
7934
7935
7936 virtual olc::rcode SetWindowTitle(const std::string& s) override

Callers

nothing calls this directly

Calls 2

olc_UpdateMouseMethod · 0.80
olc_UpdateMouseStateMethod · 0.80

Tested by

no test coverage detected