API Documentation
Loading...
Searching...
No Matches
ControllerInterface.h
Go to the documentation of this file.
1#pragma once
2#include "DLLInfo.h"
3#include <NDEVR/SoftwareService.h>
4#include <NDEVR/Battery.h>
5#include <NDEVR/Dictionary.h>
6#include <NDEVR/Buffer.h>
7#include <NDEVR/Vector.h>
8#include <NDEVR/RGBColor.h>
9namespace NDEVR
10{
11 class Thread;
12 class WindowInstance;
13 /**--------------------------------------------------------------------------------------------------
14 \brief Provides standard logic shared across all hardware controllers to be used with the software.
15 *-----------------------------------------------------------------------------------------------**/
16 class HARDWARE_API ControllerInterface : public QObject, public SoftwareService
17 {
18 Q_OBJECT
19 public:
21 {
23 : id(id)
24 {}
27 Bounds<2, fltp08> icon_bounds_location = Constant<Bounds<2, fltp08>>::Invalid;
29 };
31 {
32 ControlStick(const UUID& id)
33 : ControllerInput(id)
34 {}
35 ControlStick(const UUID& id, Vector<2, fltp08>& position)
36 : ControllerInput(id)
37 , position(position)
38 {}
40 bool pressed = false;
41 };
43 {
45 : ControllerInput(id)
46 {};
47 ControlButton(const UUID& id, bool pressed)
48 : ControllerInput(id)
49 , pressed(pressed)
50 {}
51 bool pressed = false;
52 };
54 {
56 : ControllerInput(id)
57 {};
58 ControlTrigger(const UUID& id, fltp08 percent)
59 : ControllerInput(id)
60 , percent(percent)
61 , pressed(percent > 0.5)
62 {}
63 fltp08 percent = 0.0;
64 bool pressed = false;
65 };
67 {
69 : ControllerInput(id)
70 {}
71 HapticFeedback(const UUID& id, fltp08 intensity)
72 : ControllerInput(id)
73 , intensity(intensity)
74 {}
75 //Referes to another item (for example joystick or trigger) which the feedback applies to. Invalid if just rumbler)
76 UUID feedbck_part_id = Constant<UUID>::Invalid;
77 fltp08 intensity = 0.0;
78 };
79 virtual Buffer<ControlStick> rightSticks() const = 0;
80 virtual Buffer<ControlStick> leftSticks() const = 0;
86 virtual Vector<2, fltp08> vibration() const = 0;
87 virtual RGBColor color() const = 0;
88 virtual Buffer<Battery*> batteries() const = 0;
89 virtual void setWindowInstance(WindowInstance*) {}
91 //0-1, 0 = off, 1 = full vibration
92 virtual bool requestVibrating(fltp08 left, fltp08 right) = 0;
93 virtual bool requestColor(const RGBColor& color) = 0;
94 virtual UUID id() const = 0;
95 virtual void updateState() = 0;
96 signals:
97 void onUpdated();
98 };
99 /**--------------------------------------------------------------------------------------------------
100 \brief Stores services that allow the software to access physical hardware controllers that can
101 be used with the system.
102 *-----------------------------------------------------------------------------------------------**/
104 {
105 Q_OBJECT
106 public:
108 protected:
110 public:
114 void setDefaultWindowInstance(WindowInstance* default_window_instance);
116 signals:
119 protected:
121 Thread* m_controller_thread = nullptr;
122 WindowInstance* m_default_window_instance = nullptr;
123 };
124}
#define HARDWARE_API
Definition DLLInfo.h:74
A specification of upper and lower bounds in N-dimensions.
Definition Bounds.hpp:52
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:59
Provides standard logic shared across all hardware controllers to be used with the software.
Definition ControllerInterface.h:17
virtual Vector< 2, fltp08 > vibration() const =0
virtual Buffer< HapticFeedback > hapticFeedback() const =0
virtual Buffer< Battery * > batteries() const =0
virtual bool requestColor(const RGBColor &color)=0
virtual RGBColor color() const =0
virtual Buffer< ControlTrigger > leftTriggers() const =0
virtual UUID id() const =0
virtual bool requestVibrating(fltp08 left, fltp08 right)=0
virtual Buffer< ControlStick > rightSticks() const =0
virtual Buffer< ControlStick > leftSticks() const =0
virtual void updateState()=0
virtual Buffer< ControlTrigger > rightTriggers() const =0
virtual void setWindowInstance(WindowInstance *)
Definition ControllerInterface.h:89
virtual Buffer< ControlButton > rightButtons() const =0
virtual Buffer< ControlButton > centerButtons() const =0
virtual Buffer< ControlButton > leftButtons() const =0
Stores services that allow the software to access physical hardware controllers that can.
Definition ControllerInterface.h:104
static ControllerInterfaceManager & Default()
void addController(ControllerInterface *joystick)
void setDefaultWindowInstance(WindowInstance *default_window_instance)
const Dictionary< UUID, ControllerInterface * > & controllers() const
Dictionary< UUID, ControllerInterface * > m_controllers
Definition ControllerInterface.h:120
A hash-based key-value store, useful for quick associative lookups.
Definition Dictionary.h:59
Represents a color in the RGB space with optional alpha transparency.
Definition RGBColor.h:53
Software Services provide an interface for adding to or changing the software behavior.
Definition SoftwareService.h:9
Software Service Managers take a Software service to modify the behavior of the software.
Definition SoftwareService.h:15
The core String class for the software.
Definition String.h:47
A thread is a single sequence stream within the software.
Definition Thread.h:66
Any text displayed to the user should be defined as a TranslatedString which allows the.
Definition TranslatedString.h:13
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:62
A fixed-size array with better performance compared to dynamic containers.
Definition Vector.hpp:60
Definition ACIColor.h:37
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:146
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved.
Definition BaseValues.hpp:230
Definition ControllerInterface.h:43
ControlButton(const UUID &id, bool pressed)
Definition ControllerInterface.h:47
ControlButton(const UUID &id)
Definition ControllerInterface.h:44
Definition ControllerInterface.h:31
Vector< 2, fltp08 > position
Definition ControllerInterface.h:39
ControlStick(const UUID &id)
Definition ControllerInterface.h:32
ControlStick(const UUID &id, Vector< 2, fltp08 > &position)
Definition ControllerInterface.h:35
Definition ControllerInterface.h:54
ControlTrigger(const UUID &id, fltp08 percent)
Definition ControllerInterface.h:58
ControlTrigger(const UUID &id)
Definition ControllerInterface.h:55
Definition ControllerInterface.h:21
ControllerInput(UUID id)
Definition ControllerInterface.h:22
String icon
Definition ControllerInterface.h:26
UUID id
Definition ControllerInterface.h:28
TranslatedString name
Definition ControllerInterface.h:25
Definition ControllerInterface.h:67
HapticFeedback(const UUID &id, fltp08 intensity)
Definition ControllerInterface.h:71
HapticFeedback(const UUID &id)
Definition ControllerInterface.h:68