close Warning: Can't use blame annotator:
svn blame failed on trunk/lib/FlairMeta/src/MetaDualShock3_impl.cpp: 200029 - Couldn't perform atomic initialization

source: flair-src/trunk/lib/FlairMeta/src/MetaDualShock3_impl.cpp@ 7

Last change on this file since 7 was 7, checked in by Sanahuja Guillaume, 8 years ago

filter and meta

File size: 2.9 KB
RevLine 
1// created: 2014/01/14
2// filename: MetaDualShock3_impl.cpp
3//
4// author: Guillaume Sanahuja
5// Copyright Heudiasyc UMR UTC/CNRS 7253
6//
7// version: $Id: $
8//
9// purpose: objet integrant la manette DualShock3 et les consignes joystick
10//
11//
12/*********************************************************************/
13
14#include "MetaDualShock3_impl.h"
15#include "MetaDualShock3.h"
16#include <JoyReference.h>
17#include <Tab.h>
18#include <cvmatrix.h>
19#include <FrameworkManager.h>
20
21using std::string;
22using namespace flair::core;
23using namespace flair::gui;
24using namespace flair::filter;
25using namespace flair::meta;
26
27MetaDualShock3_impl::MetaDualShock3_impl(MetaDualShock3* self,string name): IODevice((IODevice*)self,name) {
28 joy_ref=new JoyReference(self->GetTab()->NewRow(),"consignes joy");
29 this->self=self;
30 joy_init=false;
31 wasRollTrimUpButtonPressed=false;
32 wasRollTrimDownButtonPressed=false;
33 wasPitchTrimUpButtonPressed=false;
34 wasPitchTrimDownButtonPressed=false;
35}
36
37MetaDualShock3_impl::~MetaDualShock3_impl() {
38
39}
40
41//receives updates from the controler
42void MetaDualShock3_impl::UpdateFrom(const io_data *data) {
43 cvmatrix *input=(cvmatrix*)data;
44
45 //on prend une fois pour toute le mutex et on fait des accès directs
46 input->GetMutex();
47
48 //up
49 if(self->IsButtonPressed(12)) {
50 if(!wasPitchTrimDownButtonPressed) {
51 joy_ref->PitchTrimDown();
52 wasPitchTrimDownButtonPressed=true;
53 }
54 } else {
55 wasPitchTrimDownButtonPressed=false;
56 }
57
58 //down
59 if(self->IsButtonPressed(13)) {
60 if(!wasPitchTrimUpButtonPressed) {
61 joy_ref->PitchTrimUp();
62 wasPitchTrimUpButtonPressed=true;
63 }
64 } else {
65 wasPitchTrimUpButtonPressed=false;
66 }
67
68 //right
69 if(self->IsButtonPressed(15)) {
70 if(!wasRollTrimUpButtonPressed) {
71 joy_ref->RollTrimUp();
72 wasRollTrimUpButtonPressed=true;
73 }
74 } else {
75 wasRollTrimUpButtonPressed=false;
76 }
77
78 //left
79 if(self->IsButtonPressed(14)) {
80 if(!wasRollTrimDownButtonPressed) {
81 joy_ref->RollTrimDown();
82 wasRollTrimDownButtonPressed=true;
83 }
84 } else {
85 wasRollTrimDownButtonPressed=false;
86 }
87
88 if(!getFrameworkManager()->ConnectionLost()) {
89 input->GetMutex();
90 joy_ref->SetRollAxis(input->ValueNoMutex(0,0));
91 joy_ref->SetPitchAxis(input->ValueNoMutex(1,0));
92 joy_ref->SetYawAxis(input->ValueNoMutex(2,0));
93 joy_ref->SetAltitudeAxis(input->ValueNoMutex(3,0));
94 input->ReleaseMutex();
95 } else {
96 joy_ref->SetRollAxis(0);
97 joy_ref->SetPitchAxis(0);
98 joy_ref->SetYawAxis(0);
99 joy_ref->SetAltitudeAxis(0);
100 }
101 input->ReleaseMutex();
102
103 joy_ref->Update(data->DataTime());
104
105 if(!joy_init) {
106 self->TargetEthController::FlashLed(1,10,10);
107 joy_init=true;
108 }
109}
Note: See TracBrowser for help on using the repository browser.