OpenGothic
Open source reimplementation of Gothic I and II
Loading...
Searching...
No Matches
touchinput.cpp
Go to the documentation of this file.
1#include "touchinput.h"
2
3#include <Tempest/Painter>
4
6
7using namespace Tempest;
8
10 }
11
12void TouchInput::paintEvent(Tempest::PaintEvent& e) {
13 Painter p(e);
14
15 p.setBrush(Color(1,1,1, 0.2f));
16 p.drawRect(10, h()-10 - 100, 100, 100);
17 }
18
19void TouchInput::mouseDownEvent(Tempest::MouseEvent& e) {
20 auto r = Rect(10, h()-10-100, 100, 100);
21 if(!r.contains(e.pos())) {
22 e.ignore();
23 return;
24 }
25
26 mpos = e.pos();
27 ctrl.onKeyPressed(KeyCodec::Forward, KeyEvent::K_NoKey);
28 }
29
30void TouchInput::mouseDragEvent(Tempest::MouseEvent& e) {
31 auto dp = e.pos() - mpos;
32 mpos = e.pos();
33 if(std::abs(dp.x)>0) {
34 const float scale = 4.f;
35 ctrl.onRotateMouse(float(-dp.x) * scale);
36 }
37 }
38
39void TouchInput::mouseUpEvent(Tempest::MouseEvent& e) {
41 }
@ Forward
Definition keycodec.h:37
void onRotateMouse(float dAngle)
void onKeyReleased(KeyCodec::Action a, KeyCodec::Mapping mapping=KeyCodec::Mapping::Primary)
void onKeyPressed(KeyCodec::Action a, Tempest::Event::KeyType key, KeyCodec::Mapping mapping=KeyCodec::Mapping::Primary)
void mouseDragEvent(Tempest::MouseEvent &e)
TouchInput(PlayerControl &ctrl)
Definition touchinput.cpp:9
void paintEvent(Tempest::PaintEvent &e)
void mouseUpEvent(Tempest::MouseEvent &e)
void mouseDownEvent(Tempest::MouseEvent &e)