Blender  V3.3
GHOST_TrackpadWin32.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
8 #pragma once
9 
10 #ifndef WIN32
11 # error WIN32 only!
12 #endif // WIN32
13 
14 #include "GHOST_Types.h"
15 
16 #include <directmanipulation.h>
17 #include <wrl.h>
18 
19 #define PINCH_SCALE_FACTOR 125.0f
20 
21 typedef struct {
25 
27 
29  : public Microsoft::WRL::RuntimeClass<
30  Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::RuntimeClassType::ClassicCom>,
31  Microsoft::WRL::Implements<
32  Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::RuntimeClassType::ClassicCom>,
33  Microsoft::WRL::FtmBase,
34  IDirectManipulationViewportEventHandler>> {
35  public:
37 
38  /*
39  * Resets viewport and tracked touchpad state.
40  */
41  void resetViewport(IDirectManipulationViewport *viewport);
42 
43  /* DirectManipulation callbacks. */
44  HRESULT STDMETHODCALLTYPE OnViewportStatusChanged(IDirectManipulationViewport *viewport,
45  DIRECTMANIPULATION_STATUS current,
46  DIRECTMANIPULATION_STATUS previous) override;
47 
48  HRESULT STDMETHODCALLTYPE OnViewportUpdated(IDirectManipulationViewport *viewport) override;
49 
50  HRESULT STDMETHODCALLTYPE OnContentUpdated(IDirectManipulationViewport *viewport,
51  IDirectManipulationContent *content) override;
52 
53  private:
54  enum { GESTURE_NONE, GESTURE_PAN, GESTURE_PINCH } gesture_state;
55 
56  int32_t last_x, last_y, last_scale;
57  GHOST_TTrackpadInfo accumulated_values;
58  uint16_t dpi;
59  DIRECTMANIPULATION_STATUS dm_status;
60 
62 };
63 
65  public:
66  /*
67  * Creates a GHOST_DirectManipulationHelper for the provided window.
68  * \param hWnd: The window receiving DirectManipulation events.
69  * \param dpi: The current DPI.
70  * \return Pointer to the new GHOST_DirectManipulationHelper if created, nullptr if there was an
71  * error.
72  */
73  static GHOST_DirectManipulationHelper *create(HWND hWnd, uint16_t dpi);
74 
76 
77  /*
78  * Drives the DirectManipulation context.
79  * DirectManipulation's intended use is to tie user input into DirectComposition's compositor
80  * scaling and translating. We are not using DirectComposition and therefore must drive
81  * DirectManipulation manually.
82  */
83  void update();
84 
85  /*
86  * Sets pointer in contact with the DirectManipulation context.
87  * \param pointerId: ID of the pointer in contact.
88  */
89  void onPointerHitTest(UINT32 pointerId);
90 
91  /*
92  * Updates DPI information for touchpad scaling.
93  * \param dpi: The new DPI.
94  */
95  void setDPI(uint16_t dpi);
96 
97  /*
98  * Retrieves trackpad input.
99  * \return The accumulated trackpad translation and scale since last call.
100  */
102 
103  private:
105  HWND hWnd,
106  Microsoft::WRL::ComPtr<IDirectManipulationManager> directManipulationManager,
107  Microsoft::WRL::ComPtr<IDirectManipulationUpdateManager> directManipulationUpdateManager,
108  Microsoft::WRL::ComPtr<IDirectManipulationViewport> directManipulationViewport,
109  Microsoft::WRL::ComPtr<GHOST_DirectManipulationViewportEventHandler>
110  directManipulationEventHandler,
111  DWORD directManipulationViewportHandlerCookie,
112  bool isScrollDirectionInverted);
113 
114  /*
115  * Retrieves the scroll direction from the registry.
116  * \return True if scroll direction is inverted.
117  */
118  static bool getScrollDirectionFromReg();
119 
120  /*
121  * Registers listener for registry scroll direction entry changes.
122  */
123  void registerScrollDirectionChangeListener();
124 
125  HWND m_hWnd;
126 
127  HKEY m_scrollDirectionRegKey;
128  HANDLE m_scrollDirectionChangeEvent;
129 
130  Microsoft::WRL::ComPtr<IDirectManipulationManager> m_directManipulationManager;
131  Microsoft::WRL::ComPtr<IDirectManipulationUpdateManager> m_directManipulationUpdateManager;
132  Microsoft::WRL::ComPtr<IDirectManipulationViewport> m_directManipulationViewport;
133  Microsoft::WRL::ComPtr<GHOST_DirectManipulationViewportEventHandler>
134  m_directManipulationEventHandler;
135  DWORD m_directManipulationViewportHandlerCookie;
136 
137  bool m_isScrollDirectionInverted;
138 };
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
void onPointerHitTest(UINT32 pointerId)
static GHOST_DirectManipulationHelper * create(HWND hWnd, uint16_t dpi)
void resetViewport(IDirectManipulationViewport *viewport)
HRESULT STDMETHODCALLTYPE OnContentUpdated(IDirectManipulationViewport *viewport, IDirectManipulationContent *content) override
HRESULT STDMETHODCALLTYPE OnViewportUpdated(IDirectManipulationViewport *viewport) override
HRESULT STDMETHODCALLTYPE OnViewportStatusChanged(IDirectManipulationViewport *viewport, DIRECTMANIPULATION_STATUS current, DIRECTMANIPULATION_STATUS previous) override
unsigned short uint16_t
Definition: stdint.h:79
signed int int32_t
Definition: stdint.h:77