language: C++ 4.7.2 (gcc-4.7.2)
date: 404 days 10 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "BehaviourGamepad.h"
#include "XInput.h"
#pragma comment(lib, "XInput.lib")
 
BehaviourGamepad::BehaviourGamepad(void)
{
}
 
BehaviourGamepad::BehaviourGamepad(float weight)
{
        m_weight = weight;
}
 
BehaviourGamepad::~BehaviourGamepad(void)
{
}
 
void
BehaviourGamepad::Update(Actor* actor)
{
        DWORD dwResult;         // Used to store if a controller is connected
        XINPUT_STATE state;     // Data type that stores all the current states
                        // of a controller.
        MOUSESTATE perbens;
        XINPUT_STATE perbens2;
        
 
        ZeroMemory( &state, sizeof(XINPUT_STATE) ); // Zeros out the states of
                                                                                          // the controller.
 
        // Get all the current states of controller 1
        dwResult = XInputGetState( 0, &state );
 
        if( dwResult == ERROR_SUCCESS )
        {
                // Controller is connected.
                // -----------INSERT BUTTON CHECKS HERE----------
      float leftThumbY = state.Gamepad.sThumbLY;
          float leftThumbX = state.Gamepad.sThumbLX;
      if(leftThumbY)
      {
                  actor->m_direction->y += -(leftThumbY / 500000.0f) * this->m_weight;
                  actor->m_direction->x += (leftThumbX / 500000.0f) * this->m_weight;
      }    
        }
        else
        {
        // Controller is disconnected.
        }
}
 
prog.cpp:1:30: error: BehaviourGamepad.h: No such file or directory
prog.cpp:2:20: error: XInput.h: No such file or directory
prog.cpp:3: warning: ignoring #pragma comment 
prog.cpp:5: error: ‘BehaviourGamepad’ has not been declared
prog.cpp:5: error: ISO C++ forbids declaration of ‘BehaviourGamepad’ with no type
prog.cpp:9: error: ‘BehaviourGamepad’ is not a class or namespace
prog.cpp:9: error: ISO C++ forbids declaration of ‘BehaviourGamepad’ with no type
prog.cpp: In function ‘int BehaviourGamepad(float)’:
prog.cpp:11: error: ‘m_weight’ was not declared in this scope
prog.cpp: At global scope:
prog.cpp:14: error: expected constructor, destructor, or type conversion before ‘::’ token
prog.cpp:19: error: ‘BehaviourGamepad’ is not a class or namespace
prog.cpp:19: error: variable or field ‘Update’ declared void
prog.cpp:19: error: ‘Actor’ was not declared in this scope
prog.cpp:19: error: ‘actor’ was not declared in this scope