/
GCPad.cpp
67 lines (54 loc) · 1.45 KB
/
GCPad.cpp
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright 2010 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "Core/HW/GCPad.h"
#include <cstring>
#include "Common/Common.h"
#include "Core/HW/GCPadEmu.h"
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
#include "InputCommon/ControllerInterface/ControllerInterface.h"
#include "InputCommon/GCPadStatus.h"
#include "InputCommon/InputConfig.h"
namespace Pad
{
static InputConfig s_config("GCPadNew", _trans("Pad"), "GCPad");
InputConfig* GetConfig()
{
return &s_config;
}
void Shutdown()
{
s_config.ClearControllers();
}
void Initialize()
{
if (s_config.ControllersNeedToBeCreated())
{
for (unsigned int i = 0; i < 4; ++i)
s_config.CreateController<GCPad>(i);
}
g_controller_interface.RegisterDevicesChangedCallback(LoadConfig);
// Load the saved controller config
s_config.LoadConfig(true);
}
void LoadConfig()
{
s_config.LoadConfig(true);
}
GCPadStatus GetStatus(int pad_num)
{
return static_cast<GCPad*>(s_config.GetController(pad_num))->GetInput();
}
ControllerEmu::ControlGroup* GetGroup(int pad_num, PadGroup group)
{
return static_cast<GCPad*>(s_config.GetController(pad_num))->GetGroup(group);
}
void Rumble(const int pad_num, const ControlState strength)
{
static_cast<GCPad*>(s_config.GetController(pad_num))->SetOutput(strength);
}
bool GetMicButton(const int pad_num)
{
return static_cast<GCPad*>(s_config.GetController(pad_num))->GetMicButton();
}
}