Something went wrong. Try again.
art software for the rest of us
drawing paint image sdl art
Something went wrong. Try again.
C
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748#pragma once#include <SDL3/SDL.h>#include <list>#include "Pointer.h"#include "PointerStream.h"#include <unordered_map>#include <memory>#include "../AppLayers/AppLayer.h"
// Helper class for pointer and gesture controlclass InputHandler {private: std::unordered_map<unsigned int, std::shared_ptr<PointerStream>> streams; std::unordered_map<unsigned int, float> pressure; std::list<std::weak_ptr<AppLayer>> 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<SDL_Keycode> KeysHeld; static std::list<SDL_Keycode> 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<AppLayer> callback) { onDownCallbacks.push_back(callback); }};