2025-07-06 20:43:53 +03:00
|
|
|
#pragma once
|
|
|
|
|
#include <Eigen/Dense>
|
2026-03-05 23:34:30 +03:00
|
|
|
#include <SDL3/SDL_keyboard.h>
|
|
|
|
|
#include <SDL3/SDL_properties.h>
|
2026-03-05 21:09:30 +03:00
|
|
|
#include <SDL3/SDL_touch.h>
|
2025-07-06 20:43:53 +03:00
|
|
|
#include <array>
|
2025-11-10 14:45:51 +03:00
|
|
|
#include "RichText/TextStyleModifier.hpp"
|
|
|
|
|
#include "RichText/TextBox.hpp"
|
2025-07-06 20:43:53 +03:00
|
|
|
#include "TimePoint.hpp"
|
|
|
|
|
#include <Helpers/Hashes.hpp>
|
|
|
|
|
#include <unordered_map>
|
|
|
|
|
#include <nlohmann/json.hpp>
|
|
|
|
|
#include <queue>
|
2026-02-28 22:47:35 +03:00
|
|
|
#include <Helpers/CallbackManager.hpp>
|
2025-11-12 11:36:14 +03:00
|
|
|
#include "UndoManager.hpp"
|
2025-07-06 20:43:53 +03:00
|
|
|
|
|
|
|
|
#include <SDL3/SDL.h>
|
|
|
|
|
#include <SDL3/SDL_events.h>
|
|
|
|
|
#include <SDL3/SDL_keycode.h>
|
|
|
|
|
|
2026-03-05 23:34:30 +03:00
|
|
|
#include <Helpers/SCollision.hpp>
|
|
|
|
|
|
2025-07-06 20:43:53 +03:00
|
|
|
using namespace Eigen;
|
2026-03-01 17:28:43 +03:00
|
|
|
class MainProgram;
|
2025-07-06 20:43:53 +03:00
|
|
|
|
|
|
|
|
struct InputManager {
|
2026-03-01 17:28:43 +03:00
|
|
|
InputManager(MainProgram& initMain);
|
2025-07-06 20:43:53 +03:00
|
|
|
|
2026-03-05 12:03:10 +03:00
|
|
|
void update();
|
2025-07-06 20:43:53 +03:00
|
|
|
void frame_reset(const Vector2i& windowSize);
|
2025-11-11 22:21:25 +03:00
|
|
|
|
2025-07-06 20:43:53 +03:00
|
|
|
// Just renamed SDL3 cursor types, but if we need to change to a different backend we can
|
|
|
|
|
// translate this enum to different commands in main.cpp
|
|
|
|
|
enum class SystemCursorType : unsigned {
|
|
|
|
|
DEFAULT = 0,
|
|
|
|
|
TEXT,
|
|
|
|
|
WAIT,
|
|
|
|
|
CROSSHAIR,
|
|
|
|
|
PROGRESS,
|
|
|
|
|
NWSE_RESIZE,
|
|
|
|
|
NESW_RESIZE,
|
|
|
|
|
EW_RESIZE,
|
|
|
|
|
NS_RESIZE,
|
|
|
|
|
MOVE,
|
|
|
|
|
NOT_ALLOWED,
|
|
|
|
|
POINTER,
|
|
|
|
|
NW_RESIZE,
|
|
|
|
|
N_RESIZE,
|
|
|
|
|
NE_RESIZE,
|
|
|
|
|
E_RESIZE,
|
|
|
|
|
SE_RESIZE,
|
|
|
|
|
S_RESIZE,
|
|
|
|
|
SW_RESIZE,
|
|
|
|
|
W_RESIZE
|
|
|
|
|
} cursorIcon;
|
|
|
|
|
bool hideCursor = false;
|
|
|
|
|
|
|
|
|
|
bool toggleFullscreen = false;
|
|
|
|
|
|
|
|
|
|
struct KeyData {
|
|
|
|
|
bool held = false;
|
|
|
|
|
std::chrono::steady_clock::time_point lastPressTime;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct Mouse {
|
|
|
|
|
void set_pos(const Vector2f& newPos);
|
|
|
|
|
Vector2f pos = {0, 0};
|
|
|
|
|
bool leftDown = false;
|
|
|
|
|
bool rightDown = false;
|
|
|
|
|
bool middleDown = false;
|
|
|
|
|
} mouse;
|
|
|
|
|
|
2026-02-27 16:16:51 +03:00
|
|
|
struct Touch {
|
2026-03-07 14:12:11 +03:00
|
|
|
uint8_t leftClicksSaved = 0;
|
|
|
|
|
uint8_t fingerTapsSaved = 0;
|
2026-02-27 16:16:51 +03:00
|
|
|
std::chrono::steady_clock::time_point lastLeftClickTime;
|
2026-03-05 21:09:30 +03:00
|
|
|
std::chrono::steady_clock::time_point lastFingerTapTime;
|
2026-03-05 12:03:10 +03:00
|
|
|
std::vector<SDL_TouchFingerEvent> fingers;
|
|
|
|
|
enum TypeOfTouchEvent {
|
|
|
|
|
NO_TOUCH_EVENT,
|
|
|
|
|
ONE_FINGER_EVENT,
|
|
|
|
|
TWO_FINGER_EVENT,
|
|
|
|
|
EVENT_DONE
|
|
|
|
|
} touchEventType = EVENT_DONE;
|
2026-02-27 16:16:51 +03:00
|
|
|
} touch;
|
|
|
|
|
|
2025-07-06 20:43:53 +03:00
|
|
|
struct Pen {
|
|
|
|
|
bool inProximity = false;
|
|
|
|
|
bool isDown = false;
|
|
|
|
|
bool isEraser = false;
|
|
|
|
|
float pressure = 0.0f;
|
2026-03-07 14:12:11 +03:00
|
|
|
uint8_t leftClicksSaved = 0;
|
2026-03-03 14:59:18 +03:00
|
|
|
Vector2f previousPos;
|
|
|
|
|
|
2025-09-29 17:05:53 +03:00
|
|
|
std::chrono::steady_clock::time_point lastPenLeftClickTime;
|
2025-07-06 20:43:53 +03:00
|
|
|
std::array<KeyData, 256> buttons;
|
|
|
|
|
} pen;
|
|
|
|
|
|
2026-03-05 12:36:34 +03:00
|
|
|
bool isTouchDevice = true;
|
|
|
|
|
|
2026-03-05 23:34:30 +03:00
|
|
|
enum AndroidInputType : int {
|
|
|
|
|
ANDROIDTEXT_TYPE_CLASS_DATETIME = 0x00000004,
|
|
|
|
|
ANDROIDTEXT_TYPE_CLASS_NUMBER = 0x00000002,
|
|
|
|
|
ANDROIDTEXT_TYPE_CLASS_PHONE = 0x00000003,
|
|
|
|
|
ANDROIDTEXT_TYPE_CLASS_TEXT = 0x00000001,
|
|
|
|
|
ANDROIDTEXT_TYPE_DATETIME_VARIATION_DATE = 0x00000010,
|
|
|
|
|
ANDROIDTEXT_TYPE_DATETIME_VARIATION_NORMAL = 0x00000000,
|
|
|
|
|
ANDROIDTEXT_TYPE_DATETIME_VARIATION_TIME = 0x00000020,
|
|
|
|
|
ANDROIDTEXT_TYPE_MASK_CLASS = 0x0000000f,
|
|
|
|
|
ANDROIDTEXT_TYPE_MASK_FLAGS = 0x00fff000,
|
|
|
|
|
ANDROIDTEXT_TYPE_MASK_VARIATION = 0x00000ff0,
|
|
|
|
|
ANDROIDTEXT_TYPE_NULL = 0x00000000,
|
|
|
|
|
ANDROIDTEXT_TYPE_NUMBER_FLAG_DECIMAL = 0x00002000,
|
|
|
|
|
ANDROIDTEXT_TYPE_NUMBER_FLAG_SIGNED = 0x00001000,
|
|
|
|
|
ANDROIDTEXT_TYPE_NUMBER_VARIATION_NORMAL = 0x00000000,
|
|
|
|
|
ANDROIDTEXT_TYPE_NUMBER_VARIATION_PASSWORD = 0x00000010,
|
|
|
|
|
ANDROIDTEXT_TYPE_TEXT_FLAG_AUTO_COMPLETE = 0x00010000,
|
|
|
|
|
ANDROIDTEXT_TYPE_TEXT_FLAG_AUTO_CORRECT = 0x00008000,
|
|
|
|
|
ANDROIDTEXT_TYPE_TEXT_FLAG_CAP_CHARACTERS = 0x00001000,
|
|
|
|
|
ANDROIDTEXT_TYPE_TEXT_FLAG_CAP_SENTENCES = 0x00004000,
|
|
|
|
|
ANDROIDTEXT_TYPE_TEXT_FLAG_CAP_WORDS = 0x00002000,
|
|
|
|
|
ANDROIDTEXT_TYPE_TEXT_FLAG_ENABLE_TEXT_CONVERSION_SUGGESTIONS = 0x00100000,
|
|
|
|
|
ANDROIDTEXT_TYPE_TEXT_FLAG_ENABLE_TEXT_SUGGESTION_SELECTED = 0x00200000,
|
|
|
|
|
ANDROIDTEXT_TYPE_TEXT_FLAG_IME_MULTI_LINE = 0x00040000,
|
|
|
|
|
ANDROIDTEXT_TYPE_TEXT_FLAG_MULTI_LINE = 0x00020000,
|
|
|
|
|
ANDROIDTEXT_TYPE_TEXT_FLAG_NO_SUGGESTIONS = 0x00080000,
|
|
|
|
|
ANDROIDTEXT_TYPE_TEXT_VARIATION_EMAIL_ADDRESS = 0x00000020,
|
|
|
|
|
ANDROIDTEXT_TYPE_TEXT_VARIATION_EMAIL_SUBJECT = 0x00000030,
|
|
|
|
|
ANDROIDTEXT_TYPE_TEXT_VARIATION_FILTER = 0x000000b0,
|
|
|
|
|
ANDROIDTEXT_TYPE_TEXT_VARIATION_LONG_MESSAGE = 0x00000050,
|
|
|
|
|
ANDROIDTEXT_TYPE_TEXT_VARIATION_NORMAL = 0x00000000,
|
|
|
|
|
ANDROIDTEXT_TYPE_TEXT_VARIATION_PASSWORD = 0x00000080,
|
|
|
|
|
ANDROIDTEXT_TYPE_TEXT_VARIATION_PERSON_NAME = 0x00000060,
|
|
|
|
|
ANDROIDTEXT_TYPE_TEXT_VARIATION_PHONETIC = 0x000000c0,
|
|
|
|
|
ANDROIDTEXT_TYPE_TEXT_VARIATION_POSTAL_ADDRESS = 0x00000070,
|
|
|
|
|
ANDROIDTEXT_TYPE_TEXT_VARIATION_SHORT_MESSAGE = 0x00000040,
|
|
|
|
|
ANDROIDTEXT_TYPE_TEXT_VARIATION_URI = 0x00000010,
|
|
|
|
|
ANDROIDTEXT_TYPE_TEXT_VARIATION_VISIBLE_PASSWORD = 0x00000090,
|
|
|
|
|
ANDROIDTEXT_TYPE_TEXT_VARIATION_WEB_EDIT_TEXT = 0x000000a0,
|
|
|
|
|
ANDROIDTEXT_TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS = 0x000000d0,
|
|
|
|
|
ANDROIDTEXT_TYPE_TEXT_VARIATION_WEB_PASSWORD = 0x000000e0
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct TextInputProperties {
|
|
|
|
|
SDL_TextInputType inputType;
|
|
|
|
|
SDL_Capitalization capitalization;
|
|
|
|
|
bool autocorrect;
|
|
|
|
|
bool multiline;
|
|
|
|
|
int androidInputType;
|
|
|
|
|
};
|
|
|
|
|
|
2026-03-07 13:12:11 +03:00
|
|
|
void set_rich_text_box_input_front(const std::shared_ptr<RichText::TextBox>& nTextBox, const std::shared_ptr<RichText::TextBox::Cursor>& nCursor, bool isRichTextBox, const std::shared_ptr<SCollision::AABB<float>>& textboxRect, const TextInputProperties& inputProps, const std::shared_ptr<RichText::TextStyleModifier::ModifierMap>& nModMap = nullptr);
|
|
|
|
|
void set_rich_text_box_input_back(const std::shared_ptr<RichText::TextBox>& nTextBox, const std::shared_ptr<RichText::TextBox::Cursor>& nCursor, bool isRichTextBox, const std::shared_ptr<SCollision::AABB<float>>& textboxRect, const TextInputProperties& inputProps, const std::shared_ptr<RichText::TextStyleModifier::ModifierMap>& nModMap = nullptr);
|
2026-03-01 12:09:27 +03:00
|
|
|
void remove_rich_text_box_input(const std::shared_ptr<RichText::TextBox>& nTextBox);
|
|
|
|
|
|
2025-07-06 20:43:53 +03:00
|
|
|
struct Text {
|
2026-03-01 12:09:27 +03:00
|
|
|
bool is_accepting_input();
|
2025-07-06 20:43:53 +03:00
|
|
|
|
2025-11-12 14:54:46 +03:00
|
|
|
void add_textbox_undo(const RichText::TextBox::Cursor& prevCursor, const RichText::TextData& prevRichText);
|
|
|
|
|
void do_textbox_operation_with_undo(const std::function<void()>& func);
|
2025-11-12 11:36:14 +03:00
|
|
|
|
2025-11-12 14:54:46 +03:00
|
|
|
private:
|
2026-03-01 12:09:27 +03:00
|
|
|
struct TextBoxInfo {
|
|
|
|
|
bool isRichTextBox;
|
|
|
|
|
std::shared_ptr<RichText::TextBox> textBox;
|
|
|
|
|
std::shared_ptr<RichText::TextBox::Cursor> cursor;
|
2026-03-05 23:34:30 +03:00
|
|
|
std::shared_ptr<SCollision::AABB<float>> rect;
|
2026-03-07 13:12:11 +03:00
|
|
|
std::shared_ptr<RichText::TextStyleModifier::ModifierMap> modMap;
|
2026-03-05 23:34:30 +03:00
|
|
|
TextInputProperties textInputProperties;
|
2026-03-01 12:09:27 +03:00
|
|
|
UndoManager textboxUndo;
|
|
|
|
|
};
|
2025-10-16 21:22:08 +03:00
|
|
|
|
2026-03-05 23:34:30 +03:00
|
|
|
void update_accepting_input(SDL_Window* window);
|
2025-11-12 11:36:14 +03:00
|
|
|
|
2026-03-01 12:09:27 +03:00
|
|
|
bool isNextPasteRich = false;
|
2026-03-05 23:34:30 +03:00
|
|
|
|
|
|
|
|
std::optional<SDL_PropertiesID> propID;
|
2026-03-01 12:09:27 +03:00
|
|
|
|
|
|
|
|
std::deque<TextBoxInfo> textBoxes;
|
2025-10-16 21:22:08 +03:00
|
|
|
|
2025-07-06 20:43:53 +03:00
|
|
|
friend struct InputManager;
|
|
|
|
|
} text;
|
|
|
|
|
|
|
|
|
|
#ifdef __APPLE__
|
|
|
|
|
SDL_Keymod CTRL_MOD = SDL_KMOD_GUI;
|
|
|
|
|
#else
|
|
|
|
|
SDL_Keymod CTRL_MOD = SDL_KMOD_CTRL;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
enum KeyCodeEnum : unsigned {
|
|
|
|
|
// Assignable
|
|
|
|
|
KEY_CAMERA_ROTATE_CLOCKWISE = 0,
|
|
|
|
|
KEY_CAMERA_ROTATE_COUNTERCLOCKWISE,
|
|
|
|
|
KEY_DRAW_DELETE,
|
|
|
|
|
KEY_UNDO,
|
|
|
|
|
KEY_REDO,
|
|
|
|
|
KEY_NOGUI,
|
|
|
|
|
KEY_FULLSCREEN,
|
|
|
|
|
KEY_SAVE,
|
|
|
|
|
KEY_SAVE_AS,
|
|
|
|
|
KEY_COPY,
|
|
|
|
|
KEY_CUT,
|
|
|
|
|
KEY_PASTE,
|
2026-01-06 19:06:44 +03:00
|
|
|
KEY_PASTE_IMAGE,
|
2025-07-06 20:43:53 +03:00
|
|
|
KEY_DRAW_TOOL_BRUSH,
|
|
|
|
|
KEY_DRAW_TOOL_ERASER,
|
2025-12-10 21:46:08 +05:30
|
|
|
KEY_DRAW_TOOL_ZOOM,
|
|
|
|
|
KEY_DRAW_TOOL_PAN,
|
|
|
|
|
KEY_DRAW_TOOL_LASSOSELECT,
|
2025-07-06 20:43:53 +03:00
|
|
|
KEY_DRAW_TOOL_TEXTBOX,
|
|
|
|
|
KEY_DRAW_TOOL_RECTANGLE,
|
|
|
|
|
KEY_DRAW_TOOL_ELLIPSE,
|
|
|
|
|
KEY_DRAW_TOOL_RECTSELECT,
|
2025-08-05 12:11:50 +03:00
|
|
|
KEY_DRAW_TOOL_EYEDROPPER,
|
2025-07-06 20:43:53 +03:00
|
|
|
KEY_DRAW_TOOL_SCREENSHOT,
|
2026-01-08 11:19:48 +03:00
|
|
|
KEY_DRAW_TOOL_LINE,
|
2025-07-06 20:43:53 +03:00
|
|
|
KEY_SHOW_METRICS,
|
|
|
|
|
KEY_OPEN_CHAT,
|
|
|
|
|
KEY_SHOW_PLAYER_LIST,
|
2025-09-28 18:25:46 +03:00
|
|
|
KEY_HOLD_TO_PAN,
|
2026-01-07 10:34:51 +03:00
|
|
|
KEY_HOLD_TO_ZOOM,
|
2026-02-28 22:47:35 +03:00
|
|
|
KEY_DESELECT_AND_EDIT_TOOL,
|
2025-07-06 20:43:53 +03:00
|
|
|
|
|
|
|
|
KEY_ASSIGNABLE_COUNT, // Not a real key
|
|
|
|
|
|
|
|
|
|
// Unassignable
|
|
|
|
|
KEY_TEXT_DOWN,
|
|
|
|
|
KEY_TEXT_UP,
|
|
|
|
|
KEY_TEXT_LEFT,
|
|
|
|
|
KEY_TEXT_RIGHT,
|
|
|
|
|
KEY_TEXT_BACKSPACE,
|
|
|
|
|
KEY_TEXT_DELETE,
|
|
|
|
|
KEY_TEXT_HOME,
|
2025-10-16 21:22:08 +03:00
|
|
|
KEY_TEXT_END,
|
2025-07-06 20:43:53 +03:00
|
|
|
KEY_TEXT_SHIFT,
|
|
|
|
|
KEY_TEXT_COPY,
|
|
|
|
|
KEY_TEXT_CUT,
|
|
|
|
|
KEY_TEXT_PASTE,
|
|
|
|
|
KEY_TEXT_ENTER,
|
2025-10-20 17:30:36 +03:00
|
|
|
KEY_TEXT_TAB,
|
2025-07-06 20:43:53 +03:00
|
|
|
KEY_TEXT_CTRL,
|
2025-10-16 21:22:08 +03:00
|
|
|
KEY_TEXT_META,
|
2025-07-06 20:43:53 +03:00
|
|
|
KEY_TEXT_SELECTALL,
|
2025-11-12 11:36:14 +03:00
|
|
|
KEY_TEXT_UNDO,
|
|
|
|
|
KEY_TEXT_REDO,
|
2026-03-04 12:15:24 +03:00
|
|
|
KEY_TEXT_ESCAPE,
|
|
|
|
|
KEY_GENERIC_UP,
|
|
|
|
|
KEY_GENERIC_DOWN,
|
|
|
|
|
KEY_GENERIC_LEFT,
|
|
|
|
|
KEY_GENERIC_RIGHT,
|
|
|
|
|
KEY_GENERIC_ENTER,
|
2025-09-29 15:15:16 +03:00
|
|
|
KEY_GENERIC_ESCAPE,
|
2025-08-05 19:04:47 +03:00
|
|
|
KEY_GENERIC_LSHIFT,
|
|
|
|
|
KEY_GENERIC_LALT,
|
|
|
|
|
KEY_GENERIC_LCTRL,
|
2025-10-16 21:22:08 +03:00
|
|
|
KEY_GENERIC_LMETA,
|
2025-07-06 20:43:53 +03:00
|
|
|
KEY_COUNT
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef unsigned KeyCode;
|
|
|
|
|
|
2025-10-16 21:22:08 +03:00
|
|
|
bool ctrl_or_meta_held();
|
2025-07-06 20:43:53 +03:00
|
|
|
uint32_t make_generic_key_mod(SDL_Keymod m);
|
|
|
|
|
void set_key_up(const SDL_KeyboardEvent& e, KeyCode kCode);
|
|
|
|
|
void set_key_down(const SDL_KeyboardEvent& e, KeyCode kCode);
|
2026-03-05 12:03:10 +03:00
|
|
|
std::vector<Vector2f> get_multiple_finger_positions();
|
|
|
|
|
std::vector<Vector2f> get_multiple_finger_motions();
|
2026-03-05 21:09:30 +03:00
|
|
|
void touch_finger_do_mouse_down();
|
|
|
|
|
void touch_finger_do_mouse_up(const SDL_TouchFingerEvent& f);
|
|
|
|
|
void touch_finger_do_mouse_motion(const SDL_TouchFingerEvent& f);
|
2026-03-03 14:59:18 +03:00
|
|
|
|
2026-04-02 10:15:22 +03:00
|
|
|
void add_text_to_textbox(const std::string& inputText);
|
|
|
|
|
|
2026-03-04 11:03:05 +03:00
|
|
|
void backend_drop_file_event(const SDL_DropEvent& e);
|
|
|
|
|
void backend_drop_text_event(const SDL_DropEvent& e);
|
2026-03-01 17:28:43 +03:00
|
|
|
void backend_mouse_button_up_update(const SDL_MouseButtonEvent& e);
|
|
|
|
|
void backend_mouse_button_down_update(const SDL_MouseButtonEvent& e);
|
|
|
|
|
void backend_mouse_motion_update(const SDL_MouseMotionEvent& e);
|
|
|
|
|
void backend_mouse_wheel_update(const SDL_MouseWheelEvent& e);
|
2025-07-06 20:43:53 +03:00
|
|
|
void backend_key_up_update(const SDL_KeyboardEvent& e);
|
|
|
|
|
void backend_key_down_update(const SDL_KeyboardEvent& e);
|
2026-03-03 14:59:18 +03:00
|
|
|
void backend_pen_button_down_update(const SDL_PenButtonEvent& e);
|
|
|
|
|
void backend_pen_button_up_update(const SDL_PenButtonEvent& e);
|
|
|
|
|
void backend_pen_touch_down_update(const SDL_PenTouchEvent& e);
|
|
|
|
|
void backend_pen_touch_up_update(const SDL_PenTouchEvent& e);
|
|
|
|
|
void backend_pen_motion_update(const SDL_PenMotionEvent& e);
|
2026-03-03 16:01:21 +03:00
|
|
|
void backend_pen_axis_update(const SDL_PenAxisEvent& e);
|
2026-03-05 12:03:10 +03:00
|
|
|
void backend_touch_finger_down_update(const SDL_TouchFingerEvent& e);
|
|
|
|
|
void backend_touch_finger_up_update(const SDL_TouchFingerEvent& e);
|
|
|
|
|
void backend_touch_finger_motion_update(const SDL_TouchFingerEvent& e);
|
2025-07-06 20:43:53 +03:00
|
|
|
|
|
|
|
|
void set_clipboard_str(std::string_view s);
|
2025-11-12 09:00:03 +03:00
|
|
|
void set_clipboard_plain_and_richtext_pair(const std::pair<std::string, RichText::TextData>& plainAndRichtextPair);
|
2025-12-02 09:53:03 +03:00
|
|
|
std::string get_clipboard_str_SDL();
|
2026-01-05 19:36:44 +03:00
|
|
|
void get_clipboard_image_data_SDL(const std::function<void(std::string_view data)>& callback);
|
2025-12-02 09:53:03 +03:00
|
|
|
void call_text_paste(bool isRichTextPaste);
|
|
|
|
|
void process_text_paste(const std::string& plainClipboardStr);
|
2025-07-06 20:43:53 +03:00
|
|
|
|
2025-11-12 11:07:40 +03:00
|
|
|
std::optional<RichText::TextData> lastCopiedRichText;
|
|
|
|
|
|
2026-03-31 13:17:58 +03:00
|
|
|
std::string key_assignment_to_str(const Vector2ui32& k) const;
|
|
|
|
|
Vector2ui32 key_assignment_from_str(const std::string& s) const;
|
2025-07-06 20:43:53 +03:00
|
|
|
|
|
|
|
|
const KeyData& key(KeyCode kCode);
|
|
|
|
|
|
2026-02-28 22:47:35 +03:00
|
|
|
struct KeyCallbackArgs {
|
2026-03-02 16:36:34 +03:00
|
|
|
KeyCode key;
|
2026-02-28 22:47:35 +03:00
|
|
|
bool down;
|
|
|
|
|
bool repeat;
|
|
|
|
|
};
|
|
|
|
|
|
2025-07-06 20:43:53 +03:00
|
|
|
std::unordered_map<Vector2ui32, KeyCode> keyAssignments;
|
|
|
|
|
std::unordered_map<Vector2ui32, KeyCode> defaultKeyAssignments;
|
|
|
|
|
std::array<KeyData, KEY_COUNT> keys;
|
2026-03-01 12:09:27 +03:00
|
|
|
|
2026-03-02 23:09:48 +03:00
|
|
|
enum class MouseButton : uint8_t {
|
|
|
|
|
LEFT = 1,
|
|
|
|
|
MIDDLE,
|
|
|
|
|
RIGHT
|
|
|
|
|
} button;
|
|
|
|
|
|
2026-03-05 21:09:30 +03:00
|
|
|
enum class MouseDeviceType {
|
|
|
|
|
MOUSE,
|
|
|
|
|
PEN,
|
|
|
|
|
TOUCH
|
|
|
|
|
};
|
|
|
|
|
|
2026-03-01 17:28:43 +03:00
|
|
|
struct MouseButtonCallbackArgs {
|
2026-03-05 21:09:30 +03:00
|
|
|
MouseDeviceType deviceType;
|
2026-03-02 23:09:48 +03:00
|
|
|
MouseButton button;
|
2026-03-01 17:28:43 +03:00
|
|
|
bool down;
|
|
|
|
|
uint8_t clicks;
|
|
|
|
|
Vector2f pos;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct MouseMotionCallbackArgs {
|
2026-03-05 21:09:30 +03:00
|
|
|
MouseDeviceType deviceType;
|
2026-03-01 17:28:43 +03:00
|
|
|
Vector2f pos;
|
|
|
|
|
Vector2f move;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct MouseWheelCallbackArgs {
|
2026-03-02 23:09:48 +03:00
|
|
|
Vector2f mousePos;
|
2026-03-01 17:28:43 +03:00
|
|
|
Vector2f amount;
|
2026-03-02 23:09:48 +03:00
|
|
|
Vector2i tickAmount;
|
2026-03-01 17:28:43 +03:00
|
|
|
};
|
|
|
|
|
|
2026-03-03 14:59:18 +03:00
|
|
|
struct PenButtonCallbackArgs {
|
|
|
|
|
uint8_t button;
|
|
|
|
|
bool down;
|
|
|
|
|
Vector2f pos;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct PenTouchCallbackArgs {
|
|
|
|
|
bool down;
|
|
|
|
|
bool eraser;
|
|
|
|
|
Vector2f pos;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct PenMotionCallbackArgs {
|
|
|
|
|
Vector2f pos;
|
|
|
|
|
Vector2f move;
|
|
|
|
|
};
|
|
|
|
|
|
2026-03-03 16:01:21 +03:00
|
|
|
struct PenAxisCallbackArgs {
|
|
|
|
|
Vector2f pos;
|
|
|
|
|
SDL_PenAxis axis;
|
|
|
|
|
float value;
|
|
|
|
|
};
|
|
|
|
|
|
2026-03-04 11:03:05 +03:00
|
|
|
struct DropCallbackArgs {
|
|
|
|
|
Vector2f pos;
|
|
|
|
|
const char* source;
|
|
|
|
|
const char* data;
|
|
|
|
|
};
|
|
|
|
|
|
2026-03-05 21:09:30 +03:00
|
|
|
struct MultiFingerTouchCallbackArgs {
|
2026-03-05 12:03:10 +03:00
|
|
|
bool down;
|
|
|
|
|
std::vector<Vector2f> pos;
|
|
|
|
|
};
|
|
|
|
|
|
2026-03-05 21:09:30 +03:00
|
|
|
struct MultiFingerMotionCallbackArgs {
|
2026-03-05 12:03:10 +03:00
|
|
|
std::vector<Vector2f> pos;
|
|
|
|
|
std::vector<Vector2f> move;
|
|
|
|
|
};
|
|
|
|
|
|
2026-03-05 21:09:30 +03:00
|
|
|
struct FingerTouchCallbackArgs {
|
|
|
|
|
SDL_FingerID fingerID;
|
|
|
|
|
bool down;
|
|
|
|
|
Vector2f pos;
|
|
|
|
|
size_t fingerDownCount;
|
|
|
|
|
int fingerTapCount;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct FingerMotionCallbackArgs {
|
|
|
|
|
SDL_FingerID fingerID;
|
|
|
|
|
Vector2f pos;
|
|
|
|
|
Vector2f move;
|
|
|
|
|
size_t fingerDownCount;
|
|
|
|
|
};
|
|
|
|
|
|
2026-03-01 17:28:43 +03:00
|
|
|
MainProgram& main;
|
2025-07-06 20:43:53 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
NLOHMANN_JSON_SERIALIZE_ENUM(InputManager::KeyCodeEnum, {
|
|
|
|
|
{InputManager::KEY_CAMERA_ROTATE_CLOCKWISE, "Rotate Canvas CW"},
|
|
|
|
|
{InputManager::KEY_CAMERA_ROTATE_COUNTERCLOCKWISE, "Rotate Canvas CCW"},
|
|
|
|
|
{InputManager::KEY_DRAW_DELETE, "Delete Selection"},
|
|
|
|
|
{InputManager::KEY_UNDO, "Undo"},
|
|
|
|
|
{InputManager::KEY_REDO, "Redo"},
|
|
|
|
|
{InputManager::KEY_NOGUI, "Toggle GUI"},
|
|
|
|
|
{InputManager::KEY_FULLSCREEN, "Toggle Fullscreen"},
|
|
|
|
|
{InputManager::KEY_SAVE, "Save"},
|
|
|
|
|
{InputManager::KEY_SAVE_AS, "Save As"},
|
|
|
|
|
{InputManager::KEY_COPY, "Copy"},
|
|
|
|
|
{InputManager::KEY_CUT, "Cut"},
|
|
|
|
|
{InputManager::KEY_PASTE, "Paste"},
|
2026-01-06 19:06:44 +03:00
|
|
|
{InputManager::KEY_PASTE_IMAGE, "Paste Image"},
|
2025-07-06 20:43:53 +03:00
|
|
|
{InputManager::KEY_DRAW_TOOL_BRUSH, "Brush Tool"},
|
|
|
|
|
{InputManager::KEY_DRAW_TOOL_ERASER, "Eraser Tool"},
|
2025-12-10 21:46:08 +05:30
|
|
|
{InputManager::KEY_DRAW_TOOL_ZOOM, "Zoom Tool"},
|
|
|
|
|
{InputManager::KEY_DRAW_TOOL_LASSOSELECT, "Lasso Select Tool"},
|
|
|
|
|
{InputManager::KEY_DRAW_TOOL_PAN, "Pan Tool"},
|
2025-07-06 20:43:53 +03:00
|
|
|
{InputManager::KEY_DRAW_TOOL_TEXTBOX, "Textbox Tool"},
|
|
|
|
|
{InputManager::KEY_DRAW_TOOL_RECTANGLE, "Rectangle Tool"},
|
|
|
|
|
{InputManager::KEY_DRAW_TOOL_ELLIPSE, "Ellipse Tool"},
|
|
|
|
|
{InputManager::KEY_DRAW_TOOL_RECTSELECT, "Rect Select Tool"},
|
2025-08-05 12:11:50 +03:00
|
|
|
{InputManager::KEY_DRAW_TOOL_EYEDROPPER, "Color Select Tool"},
|
2026-01-08 11:19:48 +03:00
|
|
|
{InputManager::KEY_DRAW_TOOL_SCREENSHOT, "Take Screenshot"},
|
|
|
|
|
{InputManager::KEY_DRAW_TOOL_LINE, "Line Tool"},
|
2025-07-06 20:43:53 +03:00
|
|
|
{InputManager::KEY_SHOW_METRICS, "Show Metrics"},
|
|
|
|
|
{InputManager::KEY_OPEN_CHAT, "Open Chat"},
|
2025-09-28 18:25:46 +03:00
|
|
|
{InputManager::KEY_SHOW_PLAYER_LIST, "Show Player List"},
|
2026-01-07 10:34:51 +03:00
|
|
|
{InputManager::KEY_HOLD_TO_PAN, "Hold to Pan"},
|
2026-02-28 22:47:35 +03:00
|
|
|
{InputManager::KEY_HOLD_TO_ZOOM, "Hold to Zoom"},
|
|
|
|
|
{InputManager::KEY_DESELECT_AND_EDIT_TOOL, "Deselect selection / Edit Tool"}
|
2025-07-06 20:43:53 +03:00
|
|
|
})
|