#pragma once #include #include #include "Pointer.h" #include "PointerStream.h" #include #include #include "../AppLayers/AppLayer.h" // Helper class for pointer and gesture control class InputHandler { private: std::unordered_map> streams; std::unordered_map pressure; std::list> onDownCallbacks; void routePointerEvent(PointerEvent event); void routeScrollEvent(SDL_MouseWheelEvent e); static void setPointerPosition(PointerEvent& event, float windowX, float windowY); void onMouseButtonEvent(SDL_MouseButtonEvent e); void onMouseMotionEvent(SDL_MouseMotionEvent e); void onPenAxisEvent(SDL_PenAxisEvent e); void onPenMotionEvent(SDL_PenMotionEvent e); void onPenTouchEvent(SDL_PenTouchEvent e); void onScroll(SDL_Event e); void onMouse(SDL_Event e); void onStylus(SDL_Event e); void onKeyboard(SDL_Event e); public: static std::list KeysHeld; static std::list KeysDown; static double CursorX, CursorY; static double CursorScaledX, CursorScaledY; static bool IsKeyHeld(SDL_Keycode key); static bool IsKeyDown(SDL_Keycode key); // INPUTS bool OnSDLEvent(SDL_Event e); // OUPUTS // When InputHandler recieves an SDL Event equivalent to PointerDirection::Down, registered functions will be called with the PointerStream, and can be accepted by returning true void RegisterOnDown(std::weak_ptr callback) { onDownCallbacks.push_back(callback); } };