-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSteamController.cpp
More file actions
58 lines (39 loc) · 1.41 KB
/
SteamController.cpp
File metadata and controls
58 lines (39 loc) · 1.41 KB
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
52
53
//
// Created by denis on 12/19/18.
//
#include "SteamController.h"
#include "base/CCEventDispatcher.h"
#include "base/CCDirector.h"
#include "EventSteamController.h"
NS_CC_BEGIN
const char *SteamController::DEVICE_UNSET = "";
const std::string &SteamController::getDeviceId() const {
return deviceId;
}
int SteamController::getTag() const {
return tag;
}
void SteamController::onConnected() {
connectEvent->setIsConnected(true);
eventDispatcher->dispatchEvent(connectEvent);
}
void SteamController::onDisconnected() {
connectEvent->setIsConnected(false);
eventDispatcher->dispatchEvent(connectEvent);
delete this;
}
void SteamController::setTag(int tag) {
SteamController::tag = tag;
}
void SteamController::init() {
eventDispatcher = Director::getInstance()->getEventDispatcher();
connectEvent = new(std::nothrow) EventSteamController(
EventSteamController::SteamControllerEventType::CONNECTION, this);
updateEvent = new(std::nothrow) EventSteamController(EventSteamController::SteamControllerEventType::UPDATE,
this);
}
void SteamController::onUpdated(cocos2d::SteamControllerValues &values) {
updateEvent->values = values;
eventDispatcher->dispatchEvent(updateEvent);
}
NS_CC_END