Changeset 5a23277 in opengl-game


Ignore:
Timestamp:
Nov 12, 2019, 6:40:39 AM (5 years ago)
Author:
Dmitry Portnoy <dmp1488@…>
Branches:
feature/imgui-sdl, master, points-test
Children:
e3bef3a
Parents:
0ae182f
Message:

Replace the key event in game-gui with distinct key up and key down events

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • game-gui-glfw.cpp

    r0ae182f r5a23277  
    147147void glfw_key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) {
    148148   UIEvent e;
    149    e.type = UI_EVENT_KEY;
     149   e.type = action == GLFW_RELEASE ? UI_EVENT_KEYUP ? UI_EVENT_KEYDOWN;
    150150   e.key.keycode = key;
    151151
  • game-gui-sdl.cpp

    r0ae182f r5a23277  
    101101            }
    102102            break;
     103         case SDL_KEYDOWN:
     104            event->type = UI_EVENT_KEYDOWN;
     105            event->key.keycode = e.key.keysym.scancode;
     106            break;
    103107         case SDL_KEYUP:
    104          case SDL_KEYDOWN:
    105             event->type = UI_EVENT_KEY;
     108            event->type = UI_EVENT_KEYUP;
    106109            event->key.keycode = e.key.keysym.scancode;
    107110            break;
  • game-gui.hpp

    r0ae182f r5a23277  
    1515   UI_EVENT_WINDOW,
    1616   UI_EVENT_WINDOWRESIZE,
    17    UI_EVENT_KEY,
     17   UI_EVENT_KEYDOWN,
     18   UI_EVENT_KEYUP,
    1819   UI_EVENT_MOUSEBUTTONDOWN,
    1920   UI_EVENT_MOUSEBUTTONUP,
  • opengl-game.cpp

    r0ae182f r5a23277  
    172172               quit = true;
    173173               break;
    174             case UI_EVENT_KEY:
     174            case UI_EVENT_KEYDOWN:
    175175               if (e.key.keycode == GLFW_KEY_ESCAPE) {
    176176                  quit = true;
Note: See TracChangeset for help on using the changeset viewer.