import Crafter.Graphics; import Crafter.Event; import std; using namespace Crafter; int main() { WindowWayland window(1280, 720, "Hello Input!"); // Listen for left mouse click events on the window // The callback receives the MousePoint struct containing the click coordinates in float pixels from the top left corner EventListener clickListener(&window.onMouseLeftClick, [&window](MousePoint point){ // Print the coordinates where the user clicked, we recieve the point in mapped space so we must convert it to pixels first std::cout << std::format("Clicked on X:{} Y:{}!", MappedToPixelBoundless(point.x, window.width), MappedToPixelBoundless(point.y, window.height)) << std::endl; }); // Listen specifically for the 'a' key being pressed down // The callback takes no parameters since the key is fixed EventListener keyAListener(&window.onKeyDown['a'], [](){ // Print confirmation of 'a' key press std::cout << std::format("Pressed specifically the a key!") << std::endl; }); // Listen for any key press on the window // The callback receives the character of the key pressed EventListener anyKeyListener(&window.onAnyKeyDown, [](char key){ // Print which key was pressed std::cout << std::format("Pressed the {} key!", key) << std::endl; }); //Start the window event loop, unless the window is started events will not trigger. window.StartSync(); }