2015-01-27 01:24:47 +00:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include "Core/ConfigManager.h"
|
|
|
|
#include "Core/CoreParameter.h"
|
|
|
|
#include "Core/HotkeyManager.h"
|
|
|
|
|
|
|
|
const std::string hotkey_labels[] =
|
|
|
|
{
|
2015-03-06 00:54:29 +00:00
|
|
|
(""), // Open
|
|
|
|
(""), // Change Disc
|
|
|
|
(""), // Refresh List
|
2015-01-27 01:24:47 +00:00
|
|
|
|
2015-02-04 07:05:22 +00:00
|
|
|
_trans("Toggle Pause"),
|
2015-01-27 01:24:47 +00:00
|
|
|
_trans("Stop"),
|
|
|
|
_trans("Reset"),
|
|
|
|
_trans("Frame Advance"),
|
|
|
|
|
|
|
|
_trans("Start Recording"),
|
|
|
|
_trans("Play Recording"),
|
|
|
|
_trans("Export Recording"),
|
|
|
|
_trans("Read-only mode"),
|
|
|
|
|
|
|
|
_trans("Toggle Fullscreen"),
|
|
|
|
_trans("Take Screenshot"),
|
2015-03-06 00:54:29 +00:00
|
|
|
(""), // Exit
|
2015-01-27 01:24:47 +00:00
|
|
|
|
|
|
|
_trans("Connect Wiimote 1"),
|
|
|
|
_trans("Connect Wiimote 2"),
|
|
|
|
_trans("Connect Wiimote 3"),
|
|
|
|
_trans("Connect Wiimote 4"),
|
|
|
|
_trans("Connect Balance Board"),
|
|
|
|
|
|
|
|
_trans("Volume Down"),
|
2015-02-25 00:00:49 +00:00
|
|
|
_trans("Volume Up"),
|
2015-01-27 01:24:47 +00:00
|
|
|
_trans("Volume Toggle Mute"),
|
|
|
|
|
|
|
|
_trans("Toggle IR"),
|
|
|
|
_trans("Toggle Aspect Ratio"),
|
|
|
|
_trans("Toggle EFB Copies"),
|
|
|
|
_trans("Toggle Fog"),
|
|
|
|
_trans("Toggle Frame limit"),
|
|
|
|
_trans("Decrease Frame limit"),
|
2015-02-25 00:00:49 +00:00
|
|
|
_trans("Increase Frame limit"),
|
2015-01-27 01:24:47 +00:00
|
|
|
|
|
|
|
_trans("Freelook Decrease Speed"),
|
|
|
|
_trans("Freelook Increase Speed"),
|
|
|
|
_trans("Freelook Reset Speed"),
|
|
|
|
_trans("Freelook Move Up"),
|
|
|
|
_trans("Freelook Move Down"),
|
|
|
|
_trans("Freelook Move Left"),
|
|
|
|
_trans("Freelook Move Right"),
|
|
|
|
_trans("Freelook Zoom In"),
|
|
|
|
_trans("Freelook Zoom Out"),
|
|
|
|
_trans("Freelook Reset"),
|
|
|
|
|
|
|
|
_trans("Decrease Depth"),
|
2015-02-25 00:00:49 +00:00
|
|
|
_trans("Increase Depth"),
|
2015-01-27 01:24:47 +00:00
|
|
|
_trans("Decrease Convergence"),
|
2015-02-25 00:00:49 +00:00
|
|
|
_trans("Increase Convergence"),
|
2015-01-27 01:24:47 +00:00
|
|
|
|
|
|
|
_trans("Load State Slot 1"),
|
|
|
|
_trans("Load State Slot 2"),
|
|
|
|
_trans("Load State Slot 3"),
|
|
|
|
_trans("Load State Slot 4"),
|
|
|
|
_trans("Load State Slot 5"),
|
|
|
|
_trans("Load State Slot 6"),
|
|
|
|
_trans("Load State Slot 7"),
|
|
|
|
_trans("Load State Slot 8"),
|
|
|
|
_trans("Load State Slot 9"),
|
|
|
|
_trans("Load State Slot 10"),
|
|
|
|
|
|
|
|
_trans("Save State Slot 1"),
|
|
|
|
_trans("Save State Slot 2"),
|
|
|
|
_trans("Save State Slot 3"),
|
|
|
|
_trans("Save State Slot 4"),
|
|
|
|
_trans("Save State Slot 5"),
|
|
|
|
_trans("Save State Slot 6"),
|
|
|
|
_trans("Save State Slot 7"),
|
|
|
|
_trans("Save State Slot 8"),
|
|
|
|
_trans("Save State Slot 9"),
|
|
|
|
_trans("Save State Slot 10"),
|
|
|
|
|
|
|
|
_trans("Select State Slot 1"),
|
|
|
|
_trans("Select State Slot 2"),
|
|
|
|
_trans("Select State Slot 3"),
|
|
|
|
_trans("Select State Slot 4"),
|
|
|
|
_trans("Select State Slot 5"),
|
|
|
|
_trans("Select State Slot 6"),
|
|
|
|
_trans("Select State Slot 7"),
|
|
|
|
_trans("Select State Slot 8"),
|
|
|
|
_trans("Select State Slot 9"),
|
|
|
|
_trans("Select State Slot 10"),
|
|
|
|
|
|
|
|
_trans("Save to selected slot"),
|
|
|
|
_trans("Load from selected slot"),
|
|
|
|
|
|
|
|
_trans("Load State Last 1"),
|
|
|
|
_trans("Load State Last 2"),
|
|
|
|
_trans("Load State Last 3"),
|
|
|
|
_trans("Load State Last 4"),
|
|
|
|
_trans("Load State Last 5"),
|
|
|
|
_trans("Load State Last 6"),
|
|
|
|
_trans("Load State Last 7"),
|
|
|
|
_trans("Load State Last 8"),
|
|
|
|
|
|
|
|
_trans("Save Oldest State"),
|
|
|
|
_trans("Undo Load State"),
|
|
|
|
_trans("Undo Save State"),
|
|
|
|
_trans("Save State"),
|
|
|
|
_trans("Load State"),
|
|
|
|
};
|
|
|
|
|
|
|
|
const int num_hotkeys = (sizeof(hotkey_labels) / sizeof(hotkey_labels[0]));
|
|
|
|
|
|
|
|
namespace HotkeyManagerEmu
|
|
|
|
{
|
|
|
|
|
2015-02-28 20:43:34 +00:00
|
|
|
static u32 hotkeyDown[3];
|
|
|
|
static HotkeyStatus hotkey;
|
2015-02-04 19:19:16 +00:00
|
|
|
|
2015-01-27 01:24:47 +00:00
|
|
|
static InputConfig s_config("Hotkeys", _trans("Hotkeys"), "Hotkeys");
|
2015-03-05 08:49:10 +00:00
|
|
|
|
2015-01-27 01:24:47 +00:00
|
|
|
InputConfig* GetConfig()
|
|
|
|
{
|
|
|
|
return &s_config;
|
|
|
|
}
|
|
|
|
|
2015-02-28 20:43:34 +00:00
|
|
|
void GetStatus()
|
2015-01-27 01:24:47 +00:00
|
|
|
{
|
2015-02-28 20:43:34 +00:00
|
|
|
hotkey.err = PAD_ERR_NONE;
|
2015-01-27 01:24:47 +00:00
|
|
|
|
|
|
|
// get input
|
2015-02-28 20:43:34 +00:00
|
|
|
((HotkeyManager*)s_config.controllers[0])->GetInput(&hotkey);
|
|
|
|
}
|
|
|
|
|
2015-03-05 08:49:10 +00:00
|
|
|
bool IsEnabled()
|
2015-02-28 20:43:34 +00:00
|
|
|
{
|
2015-03-05 08:49:10 +00:00
|
|
|
return enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Enable(bool enable_toggle)
|
|
|
|
{
|
|
|
|
enabled = enable_toggle;
|
2015-01-27 01:24:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool IsPressed(int Id, bool held)
|
|
|
|
{
|
|
|
|
unsigned int set = Id / 32;
|
|
|
|
unsigned int setKey = Id % 32;
|
|
|
|
if (hotkey.button[set] & (1 << setKey))
|
|
|
|
{
|
|
|
|
hotkeyDown[set] |= (1 << setKey);
|
|
|
|
if (held)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
bool pressed = !!(hotkeyDown[set] & (1 << setKey));
|
|
|
|
hotkeyDown[set] &= ~(1 << setKey);
|
|
|
|
if (pressed)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Initialize(void* const hwnd)
|
|
|
|
{
|
2015-02-04 07:05:22 +00:00
|
|
|
if (s_config.controllers.empty())
|
|
|
|
s_config.controllers.push_back(new HotkeyManager());
|
2015-01-27 01:24:47 +00:00
|
|
|
|
|
|
|
g_controller_interface.Initialize(hwnd);
|
|
|
|
|
|
|
|
// load the saved controller config
|
|
|
|
s_config.LoadConfig(true);
|
|
|
|
|
2015-02-28 20:43:34 +00:00
|
|
|
for (unsigned int i = 0; i < 3; ++i)
|
2015-01-27 01:24:47 +00:00
|
|
|
hotkeyDown[i] = 0;
|
2015-03-05 08:49:10 +00:00
|
|
|
|
|
|
|
enabled = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void LoadConfig()
|
|
|
|
{
|
|
|
|
s_config.LoadConfig(true);
|
2015-01-27 01:24:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Shutdown()
|
|
|
|
{
|
|
|
|
std::vector<ControllerEmu*>::const_iterator
|
|
|
|
i = s_config.controllers.begin(),
|
|
|
|
e = s_config.controllers.end();
|
|
|
|
for (; i != e; ++i)
|
|
|
|
delete *i;
|
|
|
|
s_config.controllers.clear();
|
|
|
|
|
|
|
|
g_controller_interface.Shutdown();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
HotkeyManager::HotkeyManager()
|
|
|
|
{
|
2015-02-28 20:43:34 +00:00
|
|
|
for (int set = 0; set < 3; set++)
|
2015-01-27 01:24:47 +00:00
|
|
|
{
|
|
|
|
// buttons
|
|
|
|
if ((set * 32) < num_hotkeys)
|
|
|
|
groups.emplace_back(m_keys[set] = new Buttons(_trans("Keys")));
|
|
|
|
|
|
|
|
for (int key = 0; key < 32; key++)
|
|
|
|
{
|
2015-03-06 00:54:29 +00:00
|
|
|
if ((set * 32 + key) < num_hotkeys && hotkey_labels[set * 32 + key].length() != 0)
|
2015-01-27 01:24:47 +00:00
|
|
|
{
|
|
|
|
m_keys[set]->controls.emplace_back(new ControlGroup::Input(hotkey_labels[set * 32 + key]));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
groups.emplace_back(m_options = new ControlGroup(_trans("Options")));
|
|
|
|
m_options->settings.emplace_back(new ControlGroup::BackgroundInputSetting(_trans("Background Input")));
|
|
|
|
m_options->settings.emplace_back(new ControlGroup::IterateUI(_trans("Iterative Input")));
|
|
|
|
}
|
|
|
|
|
|
|
|
HotkeyManager::~HotkeyManager()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string HotkeyManager::GetName() const
|
|
|
|
{
|
|
|
|
return std::string("Hotkeys") + char('1' + 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void HotkeyManager::GetInput(HotkeyStatus* const kb)
|
|
|
|
{
|
2015-02-28 20:43:34 +00:00
|
|
|
for (int set = 0; set < 3; set++)
|
|
|
|
{
|
2015-03-06 00:54:29 +00:00
|
|
|
std::vector<u32> bitmasks;
|
|
|
|
for (int key = 0; key < 32; key++)
|
|
|
|
{
|
2015-03-07 03:41:08 +00:00
|
|
|
if ((set * 32 + key) < num_hotkeys && hotkey_labels[set * 32 + key].length() != 0)
|
2015-03-06 00:54:29 +00:00
|
|
|
bitmasks.push_back(1 << key);
|
|
|
|
}
|
|
|
|
|
2015-01-27 01:24:47 +00:00
|
|
|
if ((set * 32) < num_hotkeys)
|
2015-02-28 20:43:34 +00:00
|
|
|
{
|
|
|
|
kb->button[set] = 0;
|
2015-03-06 00:54:29 +00:00
|
|
|
m_keys[set]->GetState(&kb->button[set], bitmasks.data());
|
2015-02-28 20:43:34 +00:00
|
|
|
}
|
|
|
|
}
|
2015-01-27 01:24:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void HotkeyManager::LoadDefaults(const ControllerInterface& ciface)
|
|
|
|
{
|
2015-03-07 03:41:08 +00:00
|
|
|
for (int set = 0; set < 3; set++)
|
|
|
|
{
|
|
|
|
for (unsigned int key = 0; key < (m_keys[set])->controls.size(); key++)
|
|
|
|
{
|
|
|
|
(m_keys[set])->controls[key]->control_ref->expression = "";
|
|
|
|
}
|
|
|
|
}
|
2015-01-27 01:24:47 +00:00
|
|
|
}
|