17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-17 21:29:19 +02:00
Files
maszyna/input/editormouseinput.cpp
maj00r b8f040e6fd propagate template headers transitively, import Console where used
AnimModel.cpp reaches cParser through the simulation core, not a direct
import, so the previous pass missed it; the propagation now follows the
whole import closure. Train.cpp, drivermode.cpp and Globals.cpp call
Console:: inside _WIN32 guards without importing eu07.console - invisible
on Linux, where those blocks are skipped.
2026-09-10 01:41:24 +02:00

84 lines
2.2 KiB
C++

module;
#include <chrono>
#include <cstddef>
#include <deque>
#include <limits>
#include <mutex>
#include <ostream>
#include <sstream>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <vector>
#include <array>
#include <GLFW/glfw3.h>
module eu07.input.editormouseinput;
import eu07.glm;
/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
bool
editormouse_input::init() {
return true;
}
void
editormouse_input::position( double Horizontal, double Vertical ) {
if( false == m_pickmodepanning ) {
// even if the view panning isn't active we capture the cursor position in case it does get activated
m_cursorposition.x = Horizontal;
m_cursorposition.y = Vertical;
return;
}
if( true == m_pickmodepanning_resync ) {
// panning just started (cursor may have been grabbed/hidden); reset the reference so the
// first frame doesn't produce a large, jarring camera jump
m_cursorposition.x = Horizontal;
m_cursorposition.y = Vertical;
m_pickmodepanning_resync = false;
return;
}
glm::dvec2 cursorposition { Horizontal, Vertical };
auto const viewoffset = cursorposition - m_cursorposition;
m_relay.post(
user_command::viewturn,
viewoffset.x,
viewoffset.y,
GLFW_PRESS,
// TODO: pass correct entity id once the missing systems are in place
0 );
m_cursorposition = cursorposition;
}
void
editormouse_input::button( int const Button, int const Action ) {
// store key state
if( Button >= 0 ) {
m_buttons[ Button ] = Action;
}
// right button controls panning
if( Button == GLFW_MOUSE_BUTTON_RIGHT ) {
bool const panning = Action == GLFW_PRESS;
// when panning starts, request a one-frame resync so toggling the cursor grab doesn't jerk the view
if( panning && false == m_pickmodepanning ) {
m_pickmodepanning_resync = true;
}
m_pickmodepanning = panning;
}
}
//---------------------------------------------------------------------------