File: PSMoveMgr.h

package info (click to toggle)
bespokesynth 1.3.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 44,592 kB
  • sloc: cpp: 117,136; ansic: 18,752; python: 593; xml: 74; makefile: 4
file content (46 lines) | stat: -rw-r--r-- 942 bytes parent folder | download | duplicates (2)
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
#pragma once

#include "OpenFrameworksPort.h"
#include "psmove/psmove.h"

struct _PSMove;

#define MAX_NUM_PS_MOVES 7

class PSMoveListener
{
public:
   virtual ~PSMoveListener() {}
   virtual void OnPSMoveButton(int id, std::string button, int val) = 0;
};

class PSMoveMgr
{
public:
   PSMoveMgr()
   {}

   void Setup();
   void Update();
   void Exit();

   void AddMoves();
   void SetVibration(int id, float amount);
   void SetColor(int id, float r, float g, float b);

   void GetGyros(int id, ofVec3f& gyros);
   void GetAccel(int id, ofVec3f& accel);
   bool IsButtonDown(int id, PSMove_Button button);
   float GetBattery(int id);

   void SetListener(PSMoveListener* listener) { mListener = listener; }

private:
   _PSMove* SetUpMove(int id);
   void SendButtonMessage(int id, std::string button, int val);

   _PSMove* mMove[MAX_NUM_PS_MOVES]{};
   int mButtons[MAX_NUM_PS_MOVES]{};

   PSMoveListener* mListener{ nullptr };
};