All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
EmscriptenInputProcessor.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "IEmscriptenInputHandler.h"
6 #include "PanGesture.h"
7 #include "RotateGesture.h"
8 #include "ZoomGesture.h"
9 #include "TiltGesture.h"
10 #include "TouchGesture.h"
11 #include "TapGesture.h"
12 #include "TouchPanGesture.h"
13 #include "TouchRotateGesture.h"
14 #include "TouchPinchGesture.h"
15 #include "InputEvents.h"
16 #include "UserIdleService.h"
17 
18 namespace Eegeo
19 {
20  namespace Emscripten
21  {
22  namespace Input
23  {
25  {
27  : PanStartThresholdPixels(0.f)
28  , ZoomSensitivity(0.f)
29  , MaxZoomDelta(0.f)
30  {}
31 
32  float PanStartThresholdPixels;
33  float ZoomSensitivity;
34  float MaxZoomDelta;
35  };
36 
38  {
39  private:
40  IEmscriptenInputHandler* m_pHandler;
41  Eegeo::Input::UserIdleService m_userIdleService;
42  float m_screenWidth;
43  float m_screenHeight;
44 
45  PanGesture m_pan;
46  ZoomGesture m_zoom;
47  RotateGesture m_rotate;
48  TiltGesture m_tilt;
49  TouchGesture m_touch;
50  TapGesture m_tap;
51 
52  TouchPanGesture m_touchPan;
53  TouchRotateGesture m_touchRotate;
54  TouchPinchGesture m_touchPinch;
55 
56  public:
57  static u32 MakeKeyboardModifiers(bool altDown, bool shiftDown, bool controlDown);
58 
60  IEmscriptenInputHandler* pHandler,
61  const float screenWidth,
62  const float screenHeight,
63  const EmscriptenInputProcessorConfig& config
64  );
65 
66  void HandleInput(const MouseInputEvent& event);
67  void HandleInput(const KeyboardInputEvent& keyEvent);
68  void HandleInput(const TouchInputEvent& touchEvent);
69  void Update(float deltaSeconds);
70 
71  bool IsMouseInsideWindow();
72  void SetAllInputEventsToPointerUp(int x, int y);
73 
74  inline static EmscriptenInputProcessorConfig DefaultConfig();
75 
76  static MouseInputEvent MakeMouseInputEvent(MouseInputAction mouseInputAction, u32 modifiers, float pointerX, float pointerY, float wheelDelta);
77 
78  void NotifyScreenPropertiesChanged(int screenWidth, int screenHeight);
79 
80  const Eegeo::Input::IUserIdleService& GetUserIdleService() const;
81  };
82 
83  inline EmscriptenInputProcessorConfig EmscriptenInputProcessor::DefaultConfig()
84  {
86  config.PanStartThresholdPixels = 4.f;
87  config.ZoomSensitivity = 0.0003f;
88  config.MaxZoomDelta = 5.0f;
89  return config;
90  }
91  }
92  }
93 }