VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
joystickFunctionEnableHandler.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2015 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
10 
11 #pragma once
12 
13 //vrf includes
18 
19 //vrv includes
21 #include <vrvUtil/DtUnicode.h>
23 //third party includes
24 #include <boost/signals2.hpp>
25 
26 //std lib includes
27 #include <map>
28 #include <string>
29 #include <unordered_map>
30 
31 namespace makVrv
32 {
33  class DtDe;
34  class DtJoystickManager;
35 
39  {
40  public:
43  {
45  ControlStatus(const ControlStatus& orig) : controlProcessor(orig.controlProcessor),
46  functionGroup(orig.functionGroup), function(orig.function), configuration(orig.configuration)
47  {
48  }
49  virtual ~ControlStatus() {};
50 
51  std::string functionGroup;
52  std::string function;
53  std::string configuration;
54  std::shared_ptr<DtGameControlProcessor> controlProcessor;
55  };
56 
57  public:
60 
62  virtual ~DtJoystickFunctionEnableHandler() override;
63 
65  virtual bool gameControllerEvent(DtGenericControllerEvent*) override;
66 
69  virtual void tick(bool sentEvents) override;
70 
72  virtual void gameControllerDeviceRemoved(int) override;
73 
75  virtual void gameControllerDeviceAdded(int) override;
76 
80  virtual bool enableJoystickFunctions(const std::string& configuration, const std::set<std::string>& functionalGroups,
81  std::set<std::string>& enabled);
82 
84  virtual bool inControlOfConfiguration(const std::string& configuration) const;
85 
88  virtual bool disableJoystickFunctions(const std::set<std::string>& functionalGroups,
89  std::set<std::string>& disabled);
90 
92  virtual std::set<std::string> controlledFunctionGroups() const;
93 
95  virtual bool canFunctionGroupBeAssigned(const std::string& functionGroup) const;
96 
98  virtual bool eventActive(DtGenericControllerEvent* sdlEvent) const;
99 
101  virtual bool canProcessEvent(DtGenericControllerEvent* sdlEvent) const override;
102 
104  virtual bool anyFunctionGroupsActive() const;
105 
107  virtual void releaseAllControllerInformation();
108 
109  protected:
111  virtual bool filterGameControllerEvent(DtGenericControllerEvent*) override;
112 
114  virtual bool isFunctionGroupActive(const std::string& configuration, const std::string&) const;
115 
117  virtual void activateFunctionGroup(const std::string& configuration, const std::string&);
118 
120  virtual void deactivateFunctionGroup(const std::string& configuration, const std::string&);
121 
122  virtual void switchControlOfFunction(const std::string& configuration, const std::string& functionGroup);
123 
125  virtual void noQueuedEvents() override;
126 
129  virtual void gameControlInformationAdded(const std::string& configuration, const std::string& functionGroup,
130  const std::string& function, const DtGameControlInformation& i) override;
131 
135  virtual bool joystickFunctionFired(const std::string& functionGroup, const std::string& function,
136  double value, bool repeat, bool valueChanged) = 0;
137 
138  protected:
140  typedef std::vector<ControlStatus> ControlStatusVector;
141 
143  typedef std::map<std::string, ControlStatusVector> ControlStatusMap;
144  typedef std::map<int, ControlStatusMap> ControlledDevices;
146 
148  {
149  std::set<std::string> functionGroups;
150  std::map<std::string, std::set<std::string> > switchGroups;
151  std::map<std::string, int> switchGroupsIndex;
152  };
153 
155  typedef std::unordered_map<std::string, ControlStruct> InControlOf;
157 
160 
161  typedef std::map<int, std::map<int, int> > LastJoystickAxisValue;
163 
165  typedef std::unordered_map<DtGameControlProcessor*, std::pair<ControlStatus, DtGenericControllerEvent*> > RepeatQueue;
167 
169  };
170 }
std::vector< ControlStatus > ControlStatusVector
Devices that are controlled and their current status.
Definition: joystickFunctionEnableHandler.h:140
Control processors that are keeping track of current values by function group and function...
Definition: joystickFunctionEnableHandler.h:42
LastJoystickAxisValue myLastJoystickAxisValue
Definition: joystickFunctionEnableHandler.h:162
std::map< std::string, ControlStatusVector > ControlStatusMap
By function group.
Definition: joystickFunctionEnableHandler.h:143
InControlOf myInControlOf
Definition: joystickFunctionEnableHandler.h:156
Handler that you insert into the manager to be made aware of game controller events. A subclass of this handler can be added to the joystick manager to be made aware of any joystick/keyboard event.
Definition: joystickManager.h:47
This class will be used to query about current joysticks and the capabilities they might have...
Definition: joystickManager.h:101
ControlStatus()
Definition: joystickFunctionEnableHandler.h:44
std::set< std::string > functionGroups
Definition: joystickFunctionEnableHandler.h:149
std::unordered_map< DtGameControlProcessor *, std::pair< ControlStatus, DtGenericControllerEvent * > > RepeatQueue
Queue of funcutons that wish to get a repeat of an event if that event is not triggered (such as a bu...
Definition: joystickFunctionEnableHandler.h:165
std::unordered_map< std::string, ControlStruct > InControlOf
Configurations that are controlled and their current switch status.
Definition: joystickFunctionEnableHandler.h:155
Definition: joystickFunctionEnableHandler.h:147
Definition: gameControllerEvents.h:33
DtSignalConnectionManager myConnections
Definition: joystickFunctionEnableHandler.h:159
#define DT_DLL_JOYSTICKCORE
Contains DLL export macros.
Definition: joystickCore.h:25
Handler that will manage the objects that are taken control of for joystick controls and process the ...
Definition: joystickFunctionEnableHandler.h:38
Contains makVrv::DtVirtualBaseClass class.
DtDe & myDe
Definition: joystickFunctionEnableHandler.h:168
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:20
std::map< std::string, std::set< std::string > > switchGroups
Definition: joystickFunctionEnableHandler.h:150
std::string configuration
Definition: joystickFunctionEnableHandler.h:53
The DtGameControlInformation class contains information about how a function within a function group ...
Definition: gameControlInformation.h:32
Base class to provide boost signal/slot management.
RepeatQueue myRepeatQueue
Definition: joystickFunctionEnableHandler.h:166
std::map< int, std::map< int, int > > LastJoystickAxisValue
Definition: joystickFunctionEnableHandler.h:161
virtual ~ControlStatus()
Definition: joystickFunctionEnableHandler.h:49
std::map< std::string, int > switchGroupsIndex
Definition: joystickFunctionEnableHandler.h:151
The DtDe is the core component of any VR-Vantage application. It owns a DtRenderer, DtDeCommunicator, as well as a DtDisplay and other things.
Definition: DtDe.h:76
std::map< int, ControlStatusMap > ControlledDevices
Definition: joystickFunctionEnableHandler.h:144
std::shared_ptr< DtGameControlProcessor > controlProcessor
Definition: joystickFunctionEnableHandler.h:54
DtJoystickManager & myJoystickManager
Definition: joystickFunctionEnableHandler.h:158
ControlStatus(const ControlStatus &orig)
Definition: joystickFunctionEnableHandler.h:45
ControlledDevices myControlledDevices
Definition: joystickFunctionEnableHandler.h:145

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)