Blender V5.0
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
40#define NDOF_TIME_DELTA_STARTING 0.0125f
41
42using NDOF_Button_Array = std::array<GHOST_NDOF_ButtonT, 6>;
43
45
47 public:
49 virtual ~GHOST_NDOFManager() = default;
50
55 virtual bool available() = 0;
56
61 bool setDevice(unsigned short vendor_id, unsigned short product_id);
62
69 void setDeadZone(float);
70
83 void updateTranslation(const int t[3], uint64_t time);
84 void updateRotation(const int r[3], uint64_t time);
85
90 void updateButtonRAW(int button_number, bool press, uint64_t time);
94 void updateButton(GHOST_NDOF_ButtonT button, bool press, uint64_t time);
95 void updateButtonsBitmask(int button_bits, uint64_t time);
97 /* #NDOFButton events are sent immediately */
98
103 bool sendMotionEvent();
104
105 protected:
107
108 private:
109 void sendButtonEvent(GHOST_NDOF_ButtonT, bool press, uint64_t time, GHOST_IWindow *);
110 void sendKeyEvent(GHOST_TKey, bool press, uint64_t time, GHOST_IWindow *);
111
112 NDOF_DeviceT device_type_;
113 int hid_map_button_num_;
114 int hid_map_button_mask_;
115 const GHOST_NDOF_ButtonT *hid_map_;
116
117 int translation_[3];
118 int rotation_[3];
119
120 int button_depressed_; /* Bit field. */
121 NDOF_Button_Array pressed_buttons_cache_;
122 NDOF_Button_Array pressed_long_buttons_cache_;
123
124 uint64_t motion_time_; /* In milliseconds. */
125 uint64_t motion_time_prev_; /* Time of most recent motion event sent. */
126
127 GHOST_TProgress motion_state_;
128 bool motion_event_pending_;
129 float motion_dead_zone_; /* Discard motion with each component < this. */
130
131 inline static std::array<NDOF_DeviceT, 9> bitmask_devices_ = {
141 };
142};
@ 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
unsigned long long int uint64_t
void updateButtonsBitmask(int button_bits, uint64_t time)
void updateButton(GHOST_NDOF_ButtonT button, bool press, uint64_t time)
void updateButtonsArray(NDOF_Button_Array buttons, uint64_t time, NDOF_Button_Type type)
virtual ~GHOST_NDOFManager()=default
void updateTranslation(const int t[3], uint64_t time)
virtual bool available()=0
GHOST_NDOFManager(GHOST_System &)
void updateButtonRAW(int button_number, bool press, uint64_t time)
void updateRotation(const int r[3], uint64_t time)
bool setDevice(unsigned short vendor_id, unsigned short product_id)