fork download
  1. #include "BehaviourGamepad.h"
  2. #include "XInput.h"
  3. #pragma comment(lib, "XInput.lib")
  4.  
  5. BehaviourGamepad::BehaviourGamepad(void)
  6. {
  7. }
  8.  
  9. BehaviourGamepad::BehaviourGamepad(float weight)
  10. {
  11. m_weight = weight;
  12. }
  13.  
  14. BehaviourGamepad::~BehaviourGamepad(void)
  15. {
  16. }
  17.  
  18. void
  19. BehaviourGamepad::Update(Actor* actor)
  20. {
  21. DWORD dwResult; // Used to store if a controller is connected
  22. XINPUT_STATE state; // Data type that stores all the current states
  23. // of a controller.
  24. MOUSESTATE perbens;
  25. XINPUT_STATE perbens2;
  26.  
  27.  
  28. ZeroMemory( &state, sizeof(XINPUT_STATE) ); // Zeros out the states of
  29. // the controller.
  30.  
  31. // Get all the current states of controller 1
  32. dwResult = XInputGetState( 0, &state );
  33.  
  34. if( dwResult == ERROR_SUCCESS )
  35. {
  36. // Controller is connected.
  37. // -----------INSERT BUTTON CHECKS HERE----------
  38. float leftThumbY = state.Gamepad.sThumbLY;
  39. float leftThumbX = state.Gamepad.sThumbLX;
  40. if(leftThumbY)
  41. {
  42. actor->m_direction->y += -(leftThumbY / 500000.0f) * this->m_weight;
  43. actor->m_direction->x += (leftThumbX / 500000.0f) * this->m_weight;
  44. }
  45. }
  46. else
  47. {
  48. // Controller is disconnected.
  49. }
  50. }
  51.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
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
stdout
Standard output is empty