Leviathan  0.8.0.0
Leviathan game engine
Leviathan::InputController Class Reference

#include <InputController.h>

+ Inheritance diagram for Leviathan::InputController:

Public Member Functions

DLLEXPORT InputController ()
 
DLLEXPORT ~InputController ()
 
DLLEXPORT void LinkReceiver (std::shared_ptr< InputReceiver > object)
 
virtual DLLEXPORT void StartInputGather ()
 
virtual DLLEXPORT void OnInputGet (int32_t key, int specialmodifiers, bool down)
 
virtual DLLEXPORT void OnBlockedInput (int32_t key, int specialmodifiers, bool down)
 
virtual DLLEXPORT void SendMouseMovement (int xmoved, int ymoved)
 
- Public Member Functions inherited from Leviathan::ThreadSafeGeneric< MutexType >
DLLEXPORT ThreadSafeGeneric ()
 
DLLEXPORT ~ThreadSafeGeneric ()
 
FORCE_INLINE void VerifyLock (RecursiveLock &guard) const
 
FORCE_INLINE void VerifyLock (Lock &lockit) const
 

Protected Member Functions

virtual DLLEXPORT void _OnChildUnlink (Lock &guard, InputReceiver *child)
 

Protected Attributes

std::vector< std::shared_ptr< InputReceiver > > ConnectedReceivers
 
- Protected Attributes inherited from Leviathan::ThreadSafeGeneric< MutexType >
MutexType ObjectsLock
 

Detailed Description

Definition at line 49 of file InputController.h.

Constructor & Destructor Documentation

◆ InputController()

DLLEXPORT Leviathan::InputController::InputController ( )

Definition at line 7 of file InputController.cpp.

7  {
8 
9 }

◆ ~InputController()

DLLEXPORT Leviathan::InputController::~InputController ( )

Definition at line 11 of file InputController.cpp.

11  {
12  // unlink all children //
13  for(size_t i = 0; i < ConnectedReceivers.size(); i++){
14  // call disconnect function first //
15  ConnectedReceivers[i]->_OnDisconnect(this);
16  }
17 
18  ConnectedReceivers.clear();
19 }
std::vector< std::shared_ptr< InputReceiver > > ConnectedReceivers

Member Function Documentation

◆ _OnChildUnlink()

DLLEXPORT void Leviathan::InputController::_OnChildUnlink ( Lock guard,
InputReceiver child 
)
protectedvirtual

Definition at line 90 of file InputController.cpp.

90  {
91  for(size_t i = 0; i < ConnectedReceivers.size(); i++){
92  if(ConnectedReceivers[i].get() == child){
93  // call disconnect function first //
94  ConnectedReceivers[i]->_OnDisconnect(this);
95  ConnectedReceivers.erase(ConnectedReceivers.begin()+i);
96  return;
97  }
98  }
99 }
std::vector< std::shared_ptr< InputReceiver > > ConnectedReceivers

◆ LinkReceiver()

DLLEXPORT void Leviathan::InputController::LinkReceiver ( std::shared_ptr< InputReceiver object)

Definition at line 80 of file InputController.cpp.

80  {
81 
82  GUARD_LOCK();
83 
84  // Just add to list and call link function //
85  object->_OnConnected(this);
86 
87  ConnectedReceivers.push_back(object);
88 }
std::vector< std::shared_ptr< InputReceiver > > ConnectedReceivers
#define GUARD_LOCK()
Definition: ThreadSafe.h:91

◆ OnBlockedInput()

DLLEXPORT void Leviathan::InputController::OnBlockedInput ( int32_t  key,
int  specialmodifiers,
bool  down 
)
virtual

this is called when input is not received, basically everything should be reseted to not received //

Definition at line 54 of file InputController.cpp.

56 {
57 
58  GUARD_LOCK();
59 
60  // call on all //
61  for(size_t i = 0; i < ConnectedReceivers.size(); i++){
62 
63  ConnectedReceivers[i]->ReceiveBlockedInput(key, specialmodifiers, down);
64  }
65 }
std::vector< std::shared_ptr< InputReceiver > > ConnectedReceivers
#define GUARD_LOCK()
Definition: ThreadSafe.h:91

◆ OnInputGet()

DLLEXPORT void Leviathan::InputController::OnInputGet ( int32_t  key,
int  specialmodifiers,
bool  down 
)
virtual

Definition at line 33 of file InputController.cpp.

35 {
36  // call on first that gets it //
37  bool received = false;
38 
39  GUARD_LOCK();
40 
41  for(size_t i = 0; i < ConnectedReceivers.size(); i++){
42 
43  if(received){
44 
45  ConnectedReceivers[i]->ReceiveBlockedInput(key, specialmodifiers, down);
46  continue;
47  }
48 
49  if(ConnectedReceivers[i]->ReceiveInput(key, specialmodifiers, down))
50  received = true;
51  }
52 }
std::vector< std::shared_ptr< InputReceiver > > ConnectedReceivers
#define GUARD_LOCK()
Definition: ThreadSafe.h:91

◆ SendMouseMovement()

DLLEXPORT void Leviathan::InputController::SendMouseMovement ( int  xmoved,
int  ymoved 
)
virtual

Definition at line 68 of file InputController.cpp.

68  {
69 
70  GUARD_LOCK();
71 
72  // call on first that gets it //
73  for(size_t i = 0; i < ConnectedReceivers.size(); i++){
74 
75  if(ConnectedReceivers[i]->OnMouseMove(xmoved, ymoved))
76  return;
77  }
78 }
std::vector< std::shared_ptr< InputReceiver > > ConnectedReceivers
#define GUARD_LOCK()
Definition: ThreadSafe.h:91

◆ StartInputGather()

DLLEXPORT void Leviathan::InputController::StartInputGather ( )
virtual

Definition at line 21 of file InputController.cpp.

21  {
22 
23  GUARD_LOCK();
24  // reset internal state //
25 
26  // tell listeners that new frame begins //
27  for(size_t i = 0; i < ConnectedReceivers.size(); i++){
28 
29  ConnectedReceivers[i]->BeginNewReceiveQueue();
30  }
31 }
std::vector< std::shared_ptr< InputReceiver > > ConnectedReceivers
#define GUARD_LOCK()
Definition: ThreadSafe.h:91

Member Data Documentation

◆ ConnectedReceivers

std::vector<std::shared_ptr<InputReceiver> > Leviathan::InputController::ConnectedReceivers
protected

Definition at line 75 of file InputController.h.


The documentation for this class was generated from the following files: