🧠 A C++ command-line tool that tracks mouse events like movement, clicks, and more using SDL2.
The Mouse Event Detection project is a C++ command-line application that tracks mouse events using the SDL2 library.
It detects mouse movements and button presses (left and right), and saves the event data (coordinates and button statuses) into a text file (mouse_data.txt).
This project is perfect for C++ learners exploring:
- 🧩 Mouse event handling with SDL2
- 🧠 Event-driven programming
- 🖥️ Cross-platform C++ applications
- 📂 File I/O operations
✅ Tracks mouse motion inside a defined window area
✅ Detects left and right mouse button presses and releases
✅ Saves mouse event data (coordinates & button states) to a file
✅ Handles SDL2 initialization and error handling
✅ Cross-platform: Works on Linux, macOS, and Windows
✅ 100% pure C++ with no external dependencies other than SDL2
- The program initializes SDL2 and creates a window of 200x200 pixels.
- It listens for mouse events like movement and button clicks.
- On each event, it saves the mouse position and button state (left/right) to a file.
- The program runs in a loop until the window is closed.
sudo apt-get install libsdl2-devbrew install sdl2Download the SDL2 development libraries from the SDL2 website
Follow the instructions for setting up SDL2 in your C++ IDE (e.g., Visual Studio or MinGW).
g++ -o MouseEventDetector main.cpp -lSDL2./MouseEventDetectorRun MouseEventDetector.exe from your IDE or the command prompt.
This project can be expanded with more features, such as:
✅Customizable Mouse Area: Allowing users to define the mouse tracking area inside the window.
✅Gesture Recognition: Recognizing mouse gestures like dragging and zooming.
✅Data Analytics: Visualizing the tracked mouse data in real-time.
✅Game Integration: Using mouse events for games or simulations.
This project is open-source and licensed under the MIT License. See the LICENSE file for more details.
#SDL2 #C++ #MouseTracking #InputEvents #OpenSource