Blender  V3.3
GHOST_SystemWin32.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2001-2002 NaN Holding BV. All rights reserved. */
3 
9 #pragma once
10 
11 #ifndef WIN32
12 # error WIN32 only!
13 #endif // WIN32
14 
15 #define WIN32_LEAN_AND_MEAN
16 #include <ole2.h> // for drag-n-drop
17 #include <windows.h>
18 
19 #include "GHOST_System.h"
20 
21 class GHOST_EventButton;
22 class GHOST_EventCursor;
23 class GHOST_EventKey;
24 class GHOST_EventWheel;
25 class GHOST_EventWindow;
27 
28 class GHOST_ContextD3D;
29 class GHOST_WindowWin32;
30 
36  public:
41 
46 
47  /***************************************************************************************
48  ** Time(r) functionality
49  ***************************************************************************************/
50 
56  uint64_t performanceCounterToMillis(__int64 perf_ticks) const;
57 
63  uint64_t tickCountToMillis(__int64 ticks) const;
64 
71  uint64_t getMilliSeconds() const;
72 
73  /***************************************************************************************
74  ** Display/window management functionality
75  ***************************************************************************************/
76 
81  uint8_t getNumDisplays() const;
82 
88 
94 
112  GHOST_IWindow *createWindow(const char *title,
113  int32_t left,
114  int32_t top,
115  uint32_t width,
119  GHOST_GLSettings glSettings,
120  const bool exclusive = false,
121  const bool is_dialog = false,
122  const GHOST_IWindow *parentWindow = 0);
123 
130 
137 
146 
154 
155  /***************************************************************************************
156  ** Event management functionality
157  ***************************************************************************************/
158 
164  bool processEvents(bool waitForEvent);
165 
166  /***************************************************************************************
167  ** Cursor management functionality
168  ***************************************************************************************/
169 
177 
185 
186  /***************************************************************************************
187  ** Access to mouse button and keyboard states.
188  ***************************************************************************************/
189 
196 
202  GHOST_TSuccess getButtons(GHOST_Buttons &buttons) const;
203 
209  char *getClipboard(bool selection) const;
210 
216  void putClipboard(const char *buffer, bool selection) const;
217 
227  GHOST_TSuccess showMessageBox(const char *title,
228  const char *message,
229  const char *help_label,
230  const char *continue_label,
231  const char *link,
232  GHOST_DialogOptions dialog_options) const;
233 
246  GHOST_TDragnDropTypes draggedObjectType,
247  GHOST_WindowWin32 *window,
248  int mouseX,
249  int mouseY,
250  void *data);
251 
252  /***************************************************************************************
253  ** Modify tablet API
254  ***************************************************************************************/
255 
260  void setTabletAPI(GHOST_TTabletAPI api) override;
261 
262  /***************************************************************************************
263  ** Debug Info
264  ***************************************************************************************/
265 
270  void initDebug(GHOST_Debug debug) override;
271 
272  protected:
279 
285 
293  GHOST_TKey convertKey(short vKey, short ScanCode, short extend) const;
294 
302  GHOST_TKey hardKey(RAWINPUT const &raw, bool *r_keyDown, bool *r_is_repeated_modifier);
303 
312  GHOST_WindowWin32 *window,
314 
319  static void processWintabEvent(GHOST_WindowWin32 *window);
320 
329  static void processPointerEvent(
330  UINT type, GHOST_WindowWin32 *window, WPARAM wParam, LPARAM lParam, bool &eventhandled);
331 
338 
345  static void processWheelEvent(GHOST_WindowWin32 *window, WPARAM wParam, LPARAM lParam);
346 
354  static GHOST_EventKey *processKeyEvent(GHOST_WindowWin32 *window, RAWINPUT const &raw);
355 
362  GHOST_TKey processSpecialKey(short vKey, short scanCode) const;
363 
370 
378 
379 #ifdef WITH_INPUT_IME
387  static GHOST_Event *processImeEvent(GHOST_TEventType type,
388  GHOST_WindowWin32 *window,
390 #endif // WITH_INPUT_IME
391 
396  static void processMinMaxInfo(MINMAXINFO *minmax);
397 
398 #ifdef WITH_INPUT_NDOF
406  bool processNDOF(RAWINPUT const &raw);
407 #endif
408 
412  void driveTrackpad();
413 
417  void processTrackpad();
418 
423  inline void retrieveModifierKeys(GHOST_ModifierKeys &keys) const;
424 
430  inline void storeModifierKeys(const GHOST_ModifierKeys &keys);
431 
435  inline void handleKeyboardChange(void);
436 
440  static LRESULT WINAPI s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
441 
448 
456  __int64 m_freq;
458  __int64 m_start;
460  __int64 m_lfstart;
464  WORD m_langId;
467 
470 
473 };
474 
476 {
477  keys = m_modifierKeys;
478 }
479 
481 {
482  m_modifierKeys = keys;
483 }
484 
486 {
487  m_keylayout = GetKeyboardLayout(0); // get keylayout for current thread
488  int i;
489  SHORT s;
490 
491  // save the language identifier.
492  m_langId = LOWORD(m_keylayout);
493 
494  for (m_hasAltGr = false, i = 32; i < 256; ++i) {
495  s = VkKeyScanEx((char)i, m_keylayout);
496  // s == -1 means no key that translates passed char code
497  // high byte contains shift state. bit 2 ctrl pressed, bit 4 alt pressed
498  // if both are pressed, we have AltGr keycombo on keylayout
499  if (s != -1 && (s & 0x600) == 0x600) {
500  m_hasAltGr = true;
501  break;
502  }
503  }
504 }
GHOST_TWindowState
Definition: GHOST_Types.h:129
GHOST_TEventType
Definition: GHOST_Types.h:169
GHOST_TKey
Definition: GHOST_Types.h:259
GHOST_TDrawingContextType
Definition: GHOST_Types.h:148
GHOST_TSuccess
Definition: GHOST_Types.h:74
GHOST_TDragnDropTypes
Definition: GHOST_Types.h:474
GHOST_TButton
Definition: GHOST_Types.h:156
GHOST_TConsoleWindowState
Definition: GHOST_Types.h:139
GHOST_TTabletAPI
Definition: GHOST_Types.h:89
GHOST_DialogOptions
Definition: GHOST_Types.h:67
typedef UINT(API *GHOST_WIN32_GetDpiForWindow)(HWND)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_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
_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 type
_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 GLsizei width
_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 GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble top
GHOST_TSuccess setCursorPosition(int32_t x, int32_t y)
uint64_t getMilliSeconds() const
void getMainDisplayDimensions(uint32_t &width, uint32_t &height) const
void setTabletAPI(GHOST_TTabletAPI api) override
GHOST_TKey hardKey(RAWINPUT const &raw, bool *r_keyDown, bool *r_is_repeated_modifier)
static void processWheelEvent(GHOST_WindowWin32 *window, WPARAM wParam, LPARAM lParam)
GHOST_IContext * createOffscreenContext(GHOST_GLSettings glSettings)
static GHOST_EventButton * processButtonEvent(GHOST_TEventType type, GHOST_WindowWin32 *window, GHOST_TButton mask)
unsigned short m_keycode_last_repeat_key
GHOST_TSuccess getCursorPosition(int32_t &x, int32_t &y) const
GHOST_IWindow * createWindow(const char *title, int32_t left, int32_t top, uint32_t width, uint32_t height, GHOST_TWindowState state, GHOST_TDrawingContextType type, GHOST_GLSettings glSettings, const bool exclusive=false, const bool is_dialog=false, const GHOST_IWindow *parentWindow=0)
GHOST_TKey processSpecialKey(short vKey, short scanCode) const
static GHOST_Event * processWindowSizeEvent(GHOST_WindowWin32 *window)
GHOST_TKey convertKey(short vKey, short ScanCode, short extend) const
GHOST_TSuccess init()
void putClipboard(const char *buffer, bool selection) const
GHOST_ModifierKeys m_modifierKeys
static GHOST_ContextD3D * createOffscreenContextD3D()
bool processEvents(bool waitForEvent)
char * getClipboard(bool selection) const
uint64_t tickCountToMillis(__int64 ticks) const
static GHOST_TSuccess disposeContextD3D(GHOST_ContextD3D *context)
static void processWintabEvent(GHOST_WindowWin32 *window)
uint64_t performanceCounterToMillis(__int64 perf_ticks) const
GHOST_TSuccess getButtons(GHOST_Buttons &buttons) const
void retrieveModifierKeys(GHOST_ModifierKeys &keys) const
static GHOST_EventKey * processKeyEvent(GHOST_WindowWin32 *window, RAWINPUT const &raw)
void initDebug(GHOST_Debug debug) override
void getAllDisplayDimensions(uint32_t &width, uint32_t &height) const
GHOST_TSuccess getModifierKeys(GHOST_ModifierKeys &keys) const
static void processMinMaxInfo(MINMAXINFO *minmax)
int setConsoleWindowState(GHOST_TConsoleWindowState action)
void storeModifierKeys(const GHOST_ModifierKeys &keys)
static GHOST_Event * processWindowEvent(GHOST_TEventType type, GHOST_WindowWin32 *window)
uint8_t getNumDisplays() const
static GHOST_EventCursor * processCursorEvent(GHOST_WindowWin32 *window)
void handleKeyboardChange(void)
static void processPointerEvent(UINT type, GHOST_WindowWin32 *window, WPARAM wParam, LPARAM lParam, bool &eventhandled)
GHOST_TSuccess disposeContext(GHOST_IContext *context)
GHOST_TSuccess showMessageBox(const char *title, const char *message, const char *help_label, const char *continue_label, const char *link, GHOST_DialogOptions dialog_options) const
static LRESULT WINAPI s_wndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
static GHOST_TSuccess pushDragDropEvent(GHOST_TEventType eventType, GHOST_TDragnDropTypes draggedObjectType, GHOST_WindowWin32 *window, int mouseX, int mouseY, void *data)
GHOST_TSuccess exit()
ccl_global float * buffer
const int state
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
Definition: math_float4.h:513
static int left
static const pxr::TfToken raw("raw", pxr::TfToken::Immortal)
unsigned int uint32_t
Definition: stdint.h:80
signed int int32_t
Definition: stdint.h:77
unsigned char uint8_t
Definition: stdint.h:78
unsigned __int64 uint64_t
Definition: stdint.h:90