2015-05-24 06:55:12 +02:00
|
|
|
// Copyright 2010 Dolphin Emulator Project
|
2015-05-18 01:08:10 +02:00
|
|
|
// Licensed under GPLv2+
|
2013-04-17 22:43:11 -04:00
|
|
|
// Refer to the license.txt file included.
|
2010-06-13 09:14:40 +00:00
|
|
|
|
2017-02-08 22:15:43 -05:00
|
|
|
#include "Core/HW/GCPad.h"
|
|
|
|
|
2016-01-12 22:34:13 -05:00
|
|
|
#include <cstring>
|
|
|
|
|
2015-09-28 10:57:16 -05:00
|
|
|
#include "Common/Common.h"
|
2014-02-17 05:18:15 -05:00
|
|
|
#include "Core/HW/GCPadEmu.h"
|
2017-02-08 22:15:43 -05:00
|
|
|
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
|
|
|
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
2014-02-17 05:18:15 -05:00
|
|
|
#include "InputCommon/GCPadStatus.h"
|
|
|
|
#include "InputCommon/InputConfig.h"
|
2010-06-13 09:14:40 +00:00
|
|
|
|
2010-10-12 19:42:29 +00:00
|
|
|
namespace Pad
|
|
|
|
{
|
2014-08-31 00:04:15 -04:00
|
|
|
static InputConfig s_config("GCPadNew", _trans("Pad"), "GCPad");
|
|
|
|
InputConfig* GetConfig()
|
2010-10-12 19:42:29 +00:00
|
|
|
{
|
2014-08-31 00:04:15 -04:00
|
|
|
return &s_config;
|
2010-06-13 09:14:40 +00:00
|
|
|
}
|
|
|
|
|
2010-10-12 19:42:29 +00:00
|
|
|
void Shutdown()
|
2010-06-13 09:14:40 +00:00
|
|
|
{
|
2019-01-10 09:02:38 -06:00
|
|
|
s_config.UnregisterHotplugCallback();
|
|
|
|
|
2015-10-25 22:28:15 -04:00
|
|
|
s_config.ClearControllers();
|
2010-06-13 09:14:40 +00:00
|
|
|
}
|
|
|
|
|
2016-10-11 12:54:35 -07:00
|
|
|
void Initialize()
|
2010-06-13 09:14:40 +00:00
|
|
|
{
|
2015-10-25 22:28:15 -04:00
|
|
|
if (s_config.ControllersNeedToBeCreated())
|
|
|
|
{
|
2015-02-04 18:05:22 +11:00
|
|
|
for (unsigned int i = 0; i < 4; ++i)
|
2015-10-25 22:28:15 -04:00
|
|
|
s_config.CreateController<GCPad>(i);
|
|
|
|
}
|
2010-10-12 19:42:29 +00:00
|
|
|
|
2019-01-10 09:02:38 -06:00
|
|
|
s_config.RegisterHotplugCallback();
|
2010-10-12 19:42:29 +00:00
|
|
|
|
2015-10-25 22:28:15 -04:00
|
|
|
// Load the saved controller config
|
2014-08-31 00:04:15 -04:00
|
|
|
s_config.LoadConfig(true);
|
2010-06-13 09:14:40 +00:00
|
|
|
}
|
|
|
|
|
2015-03-05 19:49:10 +11:00
|
|
|
void LoadConfig()
|
|
|
|
{
|
|
|
|
s_config.LoadConfig(true);
|
|
|
|
}
|
|
|
|
|
2018-03-27 16:24:36 +02:00
|
|
|
bool IsInitialized()
|
|
|
|
{
|
|
|
|
return !s_config.ControllersNeedToBeCreated();
|
|
|
|
}
|
|
|
|
|
2016-10-07 07:49:32 -04:00
|
|
|
GCPadStatus GetStatus(int pad_num)
|
2010-06-13 09:14:40 +00:00
|
|
|
{
|
2016-08-01 20:30:03 -04:00
|
|
|
return static_cast<GCPad*>(s_config.GetController(pad_num))->GetInput();
|
2010-06-13 09:14:40 +00:00
|
|
|
}
|
|
|
|
|
2016-11-10 22:07:40 -05:00
|
|
|
ControllerEmu::ControlGroup* GetGroup(int pad_num, PadGroup group)
|
|
|
|
{
|
|
|
|
return static_cast<GCPad*>(s_config.GetController(pad_num))->GetGroup(group);
|
|
|
|
}
|
|
|
|
|
2016-10-07 07:49:32 -04:00
|
|
|
void Rumble(const int pad_num, const ControlState strength)
|
2010-06-13 09:14:40 +00:00
|
|
|
{
|
2015-10-25 22:28:15 -04:00
|
|
|
static_cast<GCPad*>(s_config.GetController(pad_num))->SetOutput(strength);
|
2010-06-13 09:14:40 +00:00
|
|
|
}
|
2010-10-12 19:42:29 +00:00
|
|
|
|
2018-03-25 22:23:46 -04:00
|
|
|
void ResetRumble(const int pad_num)
|
|
|
|
{
|
|
|
|
static_cast<GCPad*>(s_config.GetController(pad_num))->SetOutput(0.0);
|
|
|
|
}
|
|
|
|
|
2016-10-07 07:49:32 -04:00
|
|
|
bool GetMicButton(const int pad_num)
|
2011-10-09 04:27:43 -05:00
|
|
|
{
|
2015-10-25 22:28:15 -04:00
|
|
|
return static_cast<GCPad*>(s_config.GetController(pad_num))->GetMicButton();
|
2011-10-09 04:27:43 -05:00
|
|
|
}
|
2019-01-10 09:02:38 -06:00
|
|
|
} // namespace Pad
|