Blender V4.3
GHOST_NDOFManager.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2002-2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
7#ifndef WITH_INPUT_NDOF
8# error NDOF code included in non-NDOF-enabled build
9#endif
10
11#include "GHOST_System.hh"
12
13#include <array>
14
35
36typedef std::array<GHOST_NDOF_ButtonT, 6> NDOF_Button_Array;
37
39
41 public:
43 virtual ~GHOST_NDOFManager() {}
44
49 virtual bool available() = 0;
50
55 bool setDevice(unsigned short vendor_id, unsigned short product_id);
56
63 void setDeadZone(float);
64
77 void updateTranslation(const int t[3], uint64_t time);
78 void updateRotation(const int r[3], uint64_t time);
79
84 void updateButton(int button_number, bool press, uint64_t time);
85 void updateButtonsBitmask(int button_bits, uint64_t time);
87 /* #NDOFButton events are sent immediately */
88
93 bool sendMotionEvent();
94
95 protected:
97
98 private:
99 void sendButtonEvent(GHOST_NDOF_ButtonT, bool press, uint64_t time, GHOST_IWindow *);
100 void sendKeyEvent(GHOST_TKey, bool press, uint64_t time, GHOST_IWindow *);
101
102 NDOF_DeviceT device_type_;
103 int hid_map_button_num_;
104 int hid_map_button_mask_;
105 const GHOST_NDOF_ButtonT *hid_map_;
106
107 int translation_[3];
108 int rotation_[3];
109
110 int button_depressed_; /* Bit field. */
111 NDOF_Button_Array pressed_buttons_cache_;
112 NDOF_Button_Array pressed_long_buttons_cache_;
113
114 uint64_t motion_time_; /* In milliseconds. */
115 uint64_t motion_time_prev_; /* Time of most recent motion event sent. */
116
117 GHOST_TProgress motion_state_;
118 bool motion_event_pending_;
119 float motion_dead_zone_; /* Discard motion with each component < this. */
120
121 inline static std::array<NDOF_DeviceT, 9> bitmask_devices_ = {
131 };
132};
@ NDOF_KeyboardPro
@ NDOF_SpaceMousePro
@ NDOF_SpaceMouseProWireless
@ NDOF_SpaceMouseWireless
@ NDOF_SpacePilotPro
@ NDOF_NumpadPro
@ NDOF_SpaceExplorer
@ NDOF_SpaceMouseEnterprise
@ NDOF_SpacePilot
@ NDOF_UnknownDevice
@ NDOF_SpaceNavigator
@ NDOF_Spaceball5000
@ NDOF_SpaceTraveler
std::array< GHOST_NDOF_ButtonT, 6 > NDOF_Button_Array
NDOF_Button_Type
@ ShortButton
@ LongButton
GHOST_NDOF_ButtonT
GHOST_TKey
GHOST_TProgress
void updateButtonsBitmask(int button_bits, uint64_t time)
void updateButtonsArray(NDOF_Button_Array buttons, uint64_t time, NDOF_Button_Type type)
void updateButton(int button_number, bool press, uint64_t time)
void updateTranslation(const int t[3], uint64_t time)
GHOST_System & system_
virtual bool available()=0
GHOST_NDOFManager(GHOST_System &)
void updateRotation(const int r[3], uint64_t time)
bool setDevice(unsigned short vendor_id, unsigned short product_id)
unsigned __int64 uint64_t
Definition stdint.h:90