Merge Latest Master Changes

This commit is contained in:
Rodolfo Bogado 2016-12-01 23:31:50 -03:00
parent a6494108b8
commit f37270dcb4
133 changed files with 16377 additions and 13710 deletions

View file

@ -0,0 +1,85 @@
# G2RE52 - Shrek SuperSlam
[Gecko]
$Disable Items [kirby]
040D3FE0 60000000
$Disable Triggers [kirby]
0411E6FC 60000000
$Disable Spitters (Slam Events) [kirby]
0411DCD0 60000000
$Unlock Everything [EIREXE]
0447B200 00000001
$Debug Camera [EIREXE]
0447B20C 00000001
$Fixes (DO NOT DISABLE) [EIREXE]
041C7F3C 38600005
# Stage Codes
$Replace Dragon's Gate with Danger Room [kirby]
C2051208 00000003
2C240006 40820008
38800000 7C9E2378
60000000 00000000
$Replace Dragon's Gate with MegaTemplate [kirby]
C2051208 00000003
2C240006 40820008
38800010 7C9E2378
60000000 00000000
$Replace Dragon's Gate with TFB One [kirby]
C2051208 00000003
2C240006 40820008
38800014 7C9E2378
60000000 00000000
$Replace Dragon's Gate with TFB Two [kirby]
C2051208 00000003
2C240006 40820008
38800015 7C9E2378
60000000 00000000
$Replace Dragon's Gate with Ships Ahoy [kirby]
C2051208 00000003
2C240006 40820008
38800016 7C9E2378
60000000 00000000
$Replace Dragon's Gate with FX Room [kirby]
C2051208 00000003
2C240006 40820008
38800017 7C9E2378
$Replace Dragon's Gate with HavokPlayground [kirby]
C2051208 00000003
2C240006 40820008
3880001B 7C9E2378
60000000 00000000
$Replace Dragon's Gate with Castle Ruins [kirby]
C2051208 00000003
2C240006 40820008
3880001D 7C9E2378
60000000 00000000
$Replace Dragon's Gate with King of the Hill [kirby]
C2051208 00000003
2C240006 40820008
3880001F 7C9E2378
60000000 00000000
$Replace Dragon's Gate with Donkey Charge Race [kirby]
C2051208 00000003
2C240006 40820008
38800020 7C9E2378
60000000 00000000
$Replace Dragon's Gate with Race Oval [kirby]
C2051208 00000003
2C240006 40820008
38800021 7C9E2378
60000000 00000000
$Replace Dragon's Gate with Race Platforms [kirby]
C2051208 00000003
2C240006 40820008
38800022 7C9E2378
60000000 00000000
$Replace Dragon's Gate with Anti Air [kirby]
C2051208 00000003
2C240006 40820008
38800024 7C9E2378
60000000 00000000
$Replace Dragon's Gate with Blocks [kirby]
C2051208 00000003
2C240006 40820008
38800025 7C9E2378
60000000 00000000

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -403,8 +403,6 @@ public final class SettingsFragmentPresenter
private void addWiimoteSubSettings(ArrayList<SettingsItem> sl, int wiimoteNumber)
{
mSettings.get(SettingsFile.SETTINGS_DOLPHIN).put(SettingsFile.SECTION_BINDINGS, new SettingSection(SettingsFile.SECTION_BINDINGS));
IntSetting extension = null;
Setting bindA = null;
Setting bindB = null;

View file

@ -3,22 +3,159 @@
// Refer to the license.txt file included.
#include <array>
#include <cstdlib>
#include <sstream>
#include <vector>
#include <string>
#include <windows.h>
#include "Common/GL/GLInterface/WGL.h"
#include "Common/Logging/Log.h"
#include "Common/MsgHandler.h"
static HDC hDC = nullptr; // Private GDI Device Context
static HGLRC hRC = nullptr; // Permanent Rendering Context
static HINSTANCE dllHandle = nullptr; // Handle to OpenGL32.dll
// from wglext.h
#ifndef WGL_ARB_pbuffer
#define WGL_ARB_pbuffer 1
DECLARE_HANDLE(HPBUFFERARB);
#define WGL_DRAW_TO_PBUFFER_ARB 0x202D
#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E
#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F
#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030
#define WGL_PBUFFER_LARGEST_ARB 0x2033
#define WGL_PBUFFER_WIDTH_ARB 0x2034
#define WGL_PBUFFER_HEIGHT_ARB 0x2035
#define WGL_PBUFFER_LOST_ARB 0x2036
typedef HPBUFFERARB(WINAPI* PFNWGLCREATEPBUFFERARBPROC)(HDC hDC, int iPixelFormat, int iWidth,
int iHeight, const int* piAttribList);
typedef HDC(WINAPI* PFNWGLGETPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer);
typedef int(WINAPI* PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer, HDC hDC);
typedef BOOL(WINAPI* PFNWGLDESTROYPBUFFERARBPROC)(HPBUFFERARB hPbuffer);
typedef BOOL(WINAPI* PFNWGLQUERYPBUFFERARBPROC)(HPBUFFERARB hPbuffer, int iAttribute, int* piValue);
#endif /* WGL_ARB_pbuffer */
// typedef from wglext.h
#ifndef WGL_ARB_pixel_format
#define WGL_ARB_pixel_format 1
#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000
#define WGL_DRAW_TO_WINDOW_ARB 0x2001
#define WGL_DRAW_TO_BITMAP_ARB 0x2002
#define WGL_ACCELERATION_ARB 0x2003
#define WGL_NEED_PALETTE_ARB 0x2004
#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005
#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006
#define WGL_SWAP_METHOD_ARB 0x2007
#define WGL_NUMBER_OVERLAYS_ARB 0x2008
#define WGL_NUMBER_UNDERLAYS_ARB 0x2009
#define WGL_TRANSPARENT_ARB 0x200A
#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037
#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038
#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039
#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A
#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B
#define WGL_SHARE_DEPTH_ARB 0x200C
#define WGL_SHARE_STENCIL_ARB 0x200D
#define WGL_SHARE_ACCUM_ARB 0x200E
#define WGL_SUPPORT_GDI_ARB 0x200F
#define WGL_SUPPORT_OPENGL_ARB 0x2010
#define WGL_DOUBLE_BUFFER_ARB 0x2011
#define WGL_STEREO_ARB 0x2012
#define WGL_PIXEL_TYPE_ARB 0x2013
#define WGL_COLOR_BITS_ARB 0x2014
#define WGL_RED_BITS_ARB 0x2015
#define WGL_RED_SHIFT_ARB 0x2016
#define WGL_GREEN_BITS_ARB 0x2017
#define WGL_GREEN_SHIFT_ARB 0x2018
#define WGL_BLUE_BITS_ARB 0x2019
#define WGL_BLUE_SHIFT_ARB 0x201A
#define WGL_ALPHA_BITS_ARB 0x201B
#define WGL_ALPHA_SHIFT_ARB 0x201C
#define WGL_ACCUM_BITS_ARB 0x201D
#define WGL_ACCUM_RED_BITS_ARB 0x201E
#define WGL_ACCUM_GREEN_BITS_ARB 0x201F
#define WGL_ACCUM_BLUE_BITS_ARB 0x2020
#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021
#define WGL_DEPTH_BITS_ARB 0x2022
#define WGL_STENCIL_BITS_ARB 0x2023
#define WGL_AUX_BUFFERS_ARB 0x2024
#define WGL_NO_ACCELERATION_ARB 0x2025
#define WGL_GENERIC_ACCELERATION_ARB 0x2026
#define WGL_FULL_ACCELERATION_ARB 0x2027
#define WGL_SWAP_EXCHANGE_ARB 0x2028
#define WGL_SWAP_COPY_ARB 0x2029
#define WGL_SWAP_UNDEFINED_ARB 0x202A
#define WGL_TYPE_RGBA_ARB 0x202B
#define WGL_TYPE_COLORINDEX_ARB 0x202C
typedef BOOL(WINAPI* PFNWGLGETPIXELFORMATATTRIBIVARBPROC)(HDC hdc, int iPixelFormat,
int iLayerPlane, UINT nAttributes,
const int* piAttributes, int* piValues);
typedef BOOL(WINAPI* PFNWGLGETPIXELFORMATATTRIBFVARBPROC)(HDC hdc, int iPixelFormat,
int iLayerPlane, UINT nAttributes,
const int* piAttributes, FLOAT* pfValues);
typedef BOOL(WINAPI* PFNWGLCHOOSEPIXELFORMATARBPROC)(HDC hdc, const int* piAttribIList,
const FLOAT* pfAttribFList, UINT nMaxFormats,
int* piFormats, UINT* nNumFormats);
#endif /* WGL_ARB_pixel_format */
#ifndef WGL_ARB_create_context
#define WGL_ARB_create_context 1
#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001
#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093
#define WGL_CONTEXT_FLAGS_ARB 0x2094
#define ERROR_INVALID_VERSION_ARB 0x2095
typedef HGLRC(WINAPI* PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC hDC, HGLRC hShareContext,
const int* attribList);
#endif /* WGL_ARB_create_context */
#ifndef WGL_ARB_create_context_profile
#define WGL_ARB_create_context_profile 1
#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126
#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
#define ERROR_INVALID_PROFILE_ARB 0x2096
#endif /* WGL_ARB_create_context_profile */
#ifndef WGL_EXT_swap_control
#define WGL_EXT_swap_control 1
typedef BOOL(WINAPI* PFNWGLSWAPINTERVALEXTPROC)(int interval);
typedef int(WINAPI* PFNWGLGETSWAPINTERVALEXTPROC)(void);
#endif /* WGL_EXT_swap_control */
// Persistent pointers
static PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT = nullptr;
static PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = nullptr;
static PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB = nullptr;
static PFNWGLCREATEPBUFFERARBPROC wglCreatePbufferARB = nullptr;
static PFNWGLGETPBUFFERDCARBPROC wglGetPbufferDCARB = nullptr;
static PFNWGLRELEASEPBUFFERDCARBPROC wglReleasePbufferDCARB = nullptr;
static PFNWGLDESTROYPBUFFERARBPROC wglDestroyPbufferARB = nullptr;
static void LoadWGLExtensions()
{
wglSwapIntervalEXT = reinterpret_cast<PFNWGLSWAPINTERVALEXTPROC>(
GLInterface->GetFuncAddress("wglSwapIntervalEXT"));
wglCreateContextAttribsARB = reinterpret_cast<PFNWGLCREATECONTEXTATTRIBSARBPROC>(
wglGetProcAddress("wglCreateContextAttribsARB"));
wglChoosePixelFormatARB = reinterpret_cast<PFNWGLCHOOSEPIXELFORMATARBPROC>(
wglGetProcAddress("wglChoosePixelFormatARB"));
wglCreatePbufferARB =
reinterpret_cast<PFNWGLCREATEPBUFFERARBPROC>(wglGetProcAddress("wglCreatePbufferARB"));
wglGetPbufferDCARB =
reinterpret_cast<PFNWGLGETPBUFFERDCARBPROC>(wglGetProcAddress("wglGetPbufferDCARB"));
wglReleasePbufferDCARB =
reinterpret_cast<PFNWGLRELEASEPBUFFERDCARBPROC>(wglGetProcAddress("wglReleasePbufferDCARB"));
wglDestroyPbufferARB =
reinterpret_cast<PFNWGLDESTROYPBUFFERARBPROC>(wglGetProcAddress("wglGetPbufferDCARB"));
}
static void ClearWGLExtensionPointers()
{
wglSwapIntervalEXT = nullptr;
wglCreateContextAttribsARB = nullptr;
wglChoosePixelFormatARB = nullptr;
wglCreatePbufferARB = nullptr;
wglGetPbufferDCARB = nullptr;
wglReleasePbufferDCARB = nullptr;
wglDestroyPbufferARB = nullptr;
}
void cInterfaceWGL::SwapInterval(int Interval)
{
@ -29,14 +166,20 @@ void cInterfaceWGL::SwapInterval(int Interval)
}
void cInterfaceWGL::Swap()
{
SwapBuffers(hDC);
SwapBuffers(m_dc);
}
void* cInterfaceWGL::GetFuncAddress(const std::string& name)
{
void* func = (void*)wglGetProcAddress((LPCSTR)name.c_str());
FARPROC func = wglGetProcAddress(name.c_str());
if (func == nullptr)
func = (void*)GetProcAddress(dllHandle, (LPCSTR)name.c_str());
{
// Using GetModuleHandle here is okay, since we import functions from opengl32.dll, it's
// guaranteed to be loaded.
HMODULE opengl_module = GetModuleHandle(TEXT("opengl32.dll"));
func = GetProcAddress(opengl_module, name.c_str());
}
return func;
}
@ -55,153 +198,272 @@ bool cInterfaceWGL::PeekMessages()
return TRUE;
}
#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093
#define WGL_CONTEXT_FLAGS_ARB 0x2094
#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126
#define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001
#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002
#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
static HGLRC wglCreateContextAttribsARB(HDC hDC, HGLRC hShareContext, const int *attribList)
{
typedef HGLRC(APIENTRY * PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC hDC, HGLRC hShareContext, const int *attribList);
static PFNWGLCREATECONTEXTATTRIBSARBPROC pfnCreateContextAttribsARB = 0;
HGLRC hContext = 0;
HGLRC hCurrentContext = 0;
if (!(hCurrentContext = wglCreateContext(hDC)))
return 0;
if (wglMakeCurrent(hDC, hCurrentContext))
{
if (!pfnCreateContextAttribsARB)
pfnCreateContextAttribsARB = reinterpret_cast<PFNWGLCREATECONTEXTATTRIBSARBPROC>(wglGetProcAddress("wglCreateContextAttribsARB"));
if (pfnCreateContextAttribsARB)
{
hContext = pfnCreateContextAttribsARB(hDC, hShareContext, attribList);
}
}
wglDeleteContext(hCurrentContext);
return hContext;
}
// Create rendering window.
// Call browser: Core.cpp:EmuThread() > main.cpp:Video_Initialize()
bool cInterfaceWGL::Create(void* window_handle, bool core)
{
if (window_handle == nullptr)
if (!window_handle)
return false;
HWND window_handle_reified = reinterpret_cast<HWND>(window_handle);
RECT window_rect = { 0 };
if (!GetClientRect(window_handle_reified, &window_rect))
RECT window_rect = {};
m_window_handle = reinterpret_cast<HWND>(window_handle);
if (!GetClientRect(m_window_handle, &window_rect))
return false;
// Clear extension function pointers before creating the first context.
ClearWGLExtensionPointers();
// Control window size and picture scaling
int twidth = (window_rect.right - window_rect.left);
int theight = (window_rect.bottom - window_rect.top);
int twidth = window_rect.right - window_rect.left;
int theight = window_rect.bottom - window_rect.top;
s_backbuffer_width = twidth;
s_backbuffer_height = theight;
m_window_handle = window_handle_reified;
dllHandle = LoadLibrary(TEXT("OpenGL32.dll"));
PIXELFORMATDESCRIPTOR pfd = // pfd Tells Windows How We Want Things To Be
{
sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
1, // Version Number
PFD_DRAW_TO_WINDOW | // Format Must Support Window
PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
PFD_DOUBLEBUFFER, // Must Support Double Buffering
PFD_TYPE_RGBA, // Request An RGBA Format
32, // Select Our Color Depth
0,
0, 0, 0, 0, 0, // Color Bits Ignored
0, // 8bit Alpha Buffer
0, // Shift Bit Ignored
0, // No Accumulation Buffer
0, 0, 0, 0, // Accumulation Bits Ignored
0, // 0Bit Z-Buffer (Depth Buffer)
0, // 0bit Stencil Buffer
0, // No Auxiliary Buffer
PFD_MAIN_PLANE, // Main Drawing Layer
0, // Reserved
0, 0, 0 // Layer Masks Ignored
static constexpr PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
1, // Version Number
PFD_DRAW_TO_WINDOW | // Format Must Support Window
PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
PFD_DOUBLEBUFFER, // Must Support Double Buffering
PFD_TYPE_RGBA, // Request An RGBA Format
32, // Select Our Color Depth
0,
0, 0, 0, 0, 0, // Color Bits Ignored
0, // 8bit Alpha Buffer
0, // Shift Bit Ignored
0, // No Accumulation Buffer
0, 0, 0, 0, // Accumulation Bits Ignored
0, // 0Bit Z-Buffer (Depth Buffer)
0, // 0bit Stencil Buffer
0, // No Auxiliary Buffer
PFD_MAIN_PLANE, // Main Drawing Layer
0, // Reserved
0, 0, 0 // Layer Masks Ignored
};
int PixelFormat; // Holds The Results After Searching For A Match
if (!(hDC = GetDC(window_handle_reified)))
m_dc = GetDC(m_window_handle);
if (!m_dc)
{
PanicAlert("(1) Can't create an OpenGL Device context. Fail.");
return false;
}
if (!(PixelFormat = ChoosePixelFormat(hDC, &pfd)))
int pixel_format;
if (!(pixel_format = ChoosePixelFormat(m_dc, &pfd)))
{
PanicAlert("(2) Can't find a suitable PixelFormat.");
return false;
}
if (!SetPixelFormat(hDC, PixelFormat, &pfd))
if (!SetPixelFormat(m_dc, pixel_format, &pfd))
{
PanicAlert("(3) Can't set the PixelFormat.");
return false;
}
std::array<std::pair<int, int>, 7> versions_to_try = { {
{ 4, 5 },{ 4, 4 },{ 4, 3 },{ 4, 2 },{ 4, 1 },{ 4, 0 },{ 3, 3 },
} };
for (const auto& version : versions_to_try)
if (!(m_rc = wglCreateContext(m_dc)))
{
int attriblist[] = {
WGL_CONTEXT_MAJOR_VERSION_ARB, version.first,
WGL_CONTEXT_MINOR_VERSION_ARB, version.second,
WGL_CONTEXT_FLAGS_ARB, 0,
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
0, 0 };
hRC = wglCreateContextAttribsARB(hDC, 0, attriblist);
if (hRC)
break;
PanicAlert("(4) Can't create an OpenGL rendering context.");
return false;
}
if (!hRC)
// WGL only supports desktop GL, for now.
if (s_opengl_mode == GLInterfaceMode::MODE_DETECT)
s_opengl_mode = GLInterfaceMode::MODE_OPENGL;
if (core)
{
if (!(hRC = wglCreateContext(hDC)))
// Make the fallback context current, temporarily.
// This is because we need an active context to use wglCreateContextAttribsARB.
if (!wglMakeCurrent(m_dc, m_rc))
{
PanicAlert("(4) Can't create an OpenGL rendering context.");
PanicAlert("(5) Can't make dummy WGL context current.");
return false;
}
// Load WGL extension function pointers.
LoadWGLExtensions();
// Attempt creating a core context.
HGLRC core_context = CreateCoreContext(m_dc, nullptr);
// Switch out the temporary context before continuing, regardless of whether we got a core
// context. If we didn't get a core context, the caller expects that the context is not current.
if (!wglMakeCurrent(m_dc, nullptr))
{
PanicAlert("(6) Failed to switch out temporary context");
return false;
}
// If we got a core context, destroy and replace the temporary context.
if (core_context)
{
wglDeleteContext(m_rc);
m_rc = core_context;
m_core = true;
}
else
{
WARN_LOG(VIDEO, "Failed to create a core OpenGL context. Using fallback context.");
}
}
return true;
}
bool cInterfaceWGL::Create(cInterfaceBase* main_context)
{
cInterfaceWGL* wgl_main_context = static_cast<cInterfaceWGL*>(main_context);
// WGL does not support surfaceless contexts, so we use a 1x1 pbuffer instead.
if (!CreatePBuffer(wgl_main_context->m_dc, 1, 1, &m_pbuffer_handle, &m_dc))
return false;
m_rc = CreateCoreContext(m_dc, wgl_main_context->m_rc);
if (!m_rc)
return false;
m_core = true;
return true;
}
std::unique_ptr<cInterfaceBase> cInterfaceWGL::CreateSharedContext()
{
std::unique_ptr<cInterfaceWGL> context = std::make_unique<cInterfaceWGL>();
if (!context->Create(this))
{
context->Shutdown();
return nullptr;
}
return std::move(context);
}
HGLRC cInterfaceWGL::CreateCoreContext(HDC dc, HGLRC share_context)
{
if (!wglCreateContextAttribsARB)
{
WARN_LOG(VIDEO, "Missing WGL_ARB_create_context extension");
return nullptr;
}
// List of versions to attempt context creation for. (4.5-3.2, geometry shaders is a minimum
// requirement since we're using core profile)
static constexpr std::array<std::pair<int, int>, 8> try_versions = {
{ { 4, 5 },{ 4, 4 },{ 4, 3 },{ 4, 2 },{ 4, 1 },{ 4, 0 },{ 3, 3 },{ 3, 2 } } };
for (const auto& version : try_versions)
{
// Construct list of attributes. Prefer a forward-compatible, core context.
std::array<int, 5 * 2> attribs = {
WGL_CONTEXT_PROFILE_MASK_ARB,
WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
#ifdef _DEBUG
WGL_CONTEXT_FLAGS_ARB,
WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB | WGL_CONTEXT_DEBUG_BIT_ARB,
#else
WGL_CONTEXT_FLAGS_ARB,
WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
#endif
WGL_CONTEXT_MAJOR_VERSION_ARB,
version.first,
WGL_CONTEXT_MINOR_VERSION_ARB,
version.second,
0,
0 };
// Attempt creating this context.
HGLRC core_context = wglCreateContextAttribsARB(dc, nullptr, attribs.data());
if (core_context)
{
// If we're creating a shared context, share the resources before the context is used.
if (share_context)
{
if (!wglShareLists(share_context, core_context))
{
ERROR_LOG(VIDEO, "wglShareLists failed");
wglDeleteContext(core_context);
return nullptr;
}
}
INFO_LOG(VIDEO, "WGL: Created a GL %d.%d core context", version.first, version.second);
return core_context;
}
}
WARN_LOG(VIDEO, "Unable to create a core OpenGL context of an acceptable version");
return nullptr;
}
bool cInterfaceWGL::CreatePBuffer(HDC onscreen_dc, int width, int height, HANDLE* pbuffer_handle,
HDC* pbuffer_dc)
{
if (!wglChoosePixelFormatARB || !wglCreatePbufferARB || !wglGetPbufferDCARB ||
!wglReleasePbufferDCARB || !wglDestroyPbufferARB)
{
ERROR_LOG(VIDEO, "Missing WGL_ARB_pbuffer extension");
return false;
}
static constexpr std::array<int, 7 * 2> pf_iattribs = {
WGL_DRAW_TO_PBUFFER_ARB,
1, // Pixel format compatible with pbuffer rendering
WGL_RED_BITS_ARB,
0,
WGL_GREEN_BITS_ARB,
0,
WGL_BLUE_BITS_ARB,
0,
WGL_DEPTH_BITS_ARB,
0,
WGL_STENCIL_BITS_ARB,
0,
0,
0 };
static constexpr std::array<float, 1 * 2> pf_fattribs = {};
int pixel_format;
UINT num_pixel_formats;
if (!wglChoosePixelFormatARB(onscreen_dc, pf_iattribs.data(), pf_fattribs.data(), 1,
&pixel_format, &num_pixel_formats))
{
ERROR_LOG(VIDEO, "Failed to obtain a compatible pbuffer pixel format");
return false;
}
static constexpr std::array<int, 1 * 2> pb_attribs = {};
HPBUFFERARB pbuffer =
wglCreatePbufferARB(onscreen_dc, pixel_format, width, height, pb_attribs.data());
if (!pbuffer)
{
ERROR_LOG(VIDEO, "Failed to create pbuffer");
return false;
}
HDC dc = wglGetPbufferDCARB(pbuffer);
if (!dc)
{
ERROR_LOG(VIDEO, "Failed to get drawing context from pbuffer");
wglDestroyPbufferARB(pbuffer);
return false;
}
*pbuffer_handle = pbuffer;
*pbuffer_dc = dc;
return true;
}
bool cInterfaceWGL::MakeCurrent()
{
bool success = wglMakeCurrent(hDC, hRC) ? true : false;
if (success)
{
// Grab the swap interval function pointer
wglSwapIntervalEXT =
(PFNWGLSWAPINTERVALEXTPROC)GLInterface->GetFuncAddress("wglSwapIntervalEXT");
}
return success;
return wglMakeCurrent(m_dc, m_rc) == TRUE;
}
bool cInterfaceWGL::ClearCurrent()
{
return wglMakeCurrent(hDC, nullptr) ? true : false;
return wglMakeCurrent(m_dc, nullptr) == TRUE;
}
// Update window width, size and etc. Called from Render.cpp
@ -211,9 +473,8 @@ void cInterfaceWGL::Update()
GetClientRect(m_window_handle, &rcWindow);
// Get the new window width and height
s_backbuffer_width = (rcWindow.right - rcWindow.left);
s_backbuffer_height = (rcWindow.bottom - rcWindow.top);
s_backbuffer_width = rcWindow.right - rcWindow.left;
s_backbuffer_height = rcWindow.bottom - rcWindow.top;
// Get the top-left corner of the client area in screen coordinates
POINT originPoint = { 0, 0 };
ClientToScreen(m_window_handle, &originPoint);
@ -224,21 +485,33 @@ void cInterfaceWGL::Update()
// Close backend
void cInterfaceWGL::Shutdown()
{
if (hRC)
if (m_rc)
{
if (!wglMakeCurrent(nullptr, nullptr))
if (!wglMakeCurrent(m_dc, nullptr))
NOTICE_LOG(VIDEO, "Could not release drawing context.");
if (!wglDeleteContext(hRC))
if (!wglDeleteContext(m_rc))
ERROR_LOG(VIDEO, "Attempt to release rendering context failed.");
hRC = nullptr;
m_rc = nullptr;
}
if (hDC && !ReleaseDC(m_window_handle, hDC))
if (m_dc)
{
ERROR_LOG(VIDEO, "Attempt to release device context failed.");
hDC = nullptr;
if (m_pbuffer_handle)
{
wglReleasePbufferDCARB(static_cast<HPBUFFERARB>(m_pbuffer_handle), m_dc);
m_dc = nullptr;
wglDestroyPbufferARB(static_cast<HPBUFFERARB>(m_pbuffer_handle));
m_pbuffer_handle = nullptr;
}
else
{
if (!ReleaseDC(m_window_handle, m_dc))
ERROR_LOG(VIDEO, "Attempt to release device context failed.");
m_dc = nullptr;
}
}
FreeLibrary(dllHandle);
}

View file

@ -14,6 +14,7 @@ public:
void Swap() override;
void* GetFuncAddress(const std::string& name) override;
bool Create(void* window_handle, bool core) override;
bool Create(cInterfaceBase* main_context) override;
bool MakeCurrent() override;
bool ClearCurrent() override;
void Shutdown() override;
@ -21,6 +22,15 @@ public:
void Update() override;
bool PeekMessages() override;
std::unique_ptr<cInterfaceBase> CreateSharedContext() override;
private:
static HGLRC CreateCoreContext(HDC dc, HGLRC share_context);
static bool CreatePBuffer(HDC onscreen_dc, int width, int height, HANDLE* pbuffer_handle,
HDC* pbuffer_dc);
HWND m_window_handle = nullptr;
HANDLE m_pbuffer_handle = nullptr;
HDC m_dc = nullptr;
HGLRC m_rc = nullptr;
};

View file

@ -384,6 +384,8 @@ bool CBoot::BootUp()
PowerPC::ppcState.spr[SPR_DBAT4L] = 0x10000002;
PowerPC::ppcState.spr[SPR_DBAT5U] = 0xd0001fff;
PowerPC::ppcState.spr[SPR_DBAT5L] = 0x1000002a;
if (dolLoader.IsWii())
HID4.SBE = 1;
PowerPC::DBATUpdated();
PowerPC::IBATUpdated();

View file

@ -14,7 +14,7 @@
bool CBoot::IsElfWii(const std::string& filename)
{
/* We already check if filename existed before we called this function, so
there is no need for another check, just read the file right away */
there is no need for another check, just read the file right away */
size_t filesize = File::GetSize(filename);
auto elf = std::make_unique<u8[]>(filesize);
@ -35,12 +35,12 @@ bool CBoot::IsElfWii(const std::string& filename)
u32 HID4_mask = Common::swap32(0xfc1fffff);
ElfReader reader(elf.get());
for (int i = 0; i < reader.GetNumSections(); ++i)
for (int i = 0; i < reader.GetNumSegments(); ++i)
{
if (reader.IsCodeSection(i))
if (reader.IsCodeSegment(i))
{
u32* code = (u32*)reader.GetSectionDataPtr(i);
for (u32 j = 0; j < reader.GetSectionSize(i) / sizeof(u32); ++j)
u32* code = (u32*)reader.GetSegmentPtr(i);
for (u32 j = 0; j < reader.GetSegmentSize(i) / sizeof(u32); ++j)
{
if ((code[j] & HID4_mask) == HID4_pattern)
return true;
@ -85,6 +85,8 @@ bool CBoot::Boot_ELF(const std::string& filename)
PowerPC::ppcState.spr[SPR_DBAT4L] = 0x10000002;
PowerPC::ppcState.spr[SPR_DBAT5U] = 0xd0001fff;
PowerPC::ppcState.spr[SPR_DBAT5L] = 0x1000002a;
if (IsElfWii(filename))
HID4.SBE = 1;
PowerPC::DBATUpdated();
PowerPC::IBATUpdated();

View file

@ -109,7 +109,11 @@ bool CBoot::Boot_WiiWAD(const std::string& _pFilename)
return false;
pDolLoader->Load();
PC = pDolLoader->GetEntryPoint();
// NAND titles start with address translation off at 0x3400 (via the PPC bootstub)
// The state of other CPU registers (like the BAT registers) doesn't matter much
// because the realmode code at 0x3400 initializes everything itself anyway.
MSR = 0;
PC = 0x3400;
// Pass the "#002 check"
// Apploader should write the IOS version and revision to 0x3140, and compare it

View file

@ -55,8 +55,9 @@ public:
else
return nullptr;
}
bool IsCodeSection(int section) const { return sections[section].sh_type == SHT_PROGBITS; }
bool IsCodeSegment(int segment) const { return segments[segment].p_flags & PF_X; }
const u8* GetSegmentPtr(int segment) { return GetPtr(segments[segment].p_offset); }
int GetSegmentSize(int segment) const { return segments[segment].p_filesz; }
u32 GetSectionAddr(SectionID section) const { return sectionAddrs[section]; }
int GetSectionSize(SectionID section) const { return sections[section].sh_size; }
SectionID GetSectionByName(const char* name, int firstSection = 0) const; //-1 for not found

View file

@ -44,6 +44,11 @@ void LoadConfig()
s_config.LoadConfig(true);
}
ControllerEmu::ControlGroup* GetGroup(int port, KeyboardGroup group)
{
return static_cast<GCKeyboard*>(s_config.GetController(port))->GetGroup(group);
}
KeyboardStatus GetStatus(int port)
{
return static_cast<GCKeyboard*>(s_config.GetController(port))->GetInput();

View file

@ -5,8 +5,10 @@
#pragma once
#include "Common/CommonTypes.h"
#include "InputCommon/ControllerEmu.h"
class InputConfig;
enum class KeyboardGroup;
struct KeyboardStatus;
namespace Keyboard
@ -16,6 +18,7 @@ void Initialize();
void LoadConfig();
InputConfig* GetConfig();
ControllerEmu::ControlGroup* GetGroup(int port, KeyboardGroup group);
KeyboardStatus GetStatus(int port);
}

View file

@ -4,44 +4,45 @@
#include "Core/HW/GCKeyboardEmu.h"
#include "Common/Common.h"
#include "InputCommon/ControllerEmu.h"
#include "InputCommon/KeyboardStatus.h"
static const u16 keys0_bitmasks[] = { KEYMASK_HOME, KEYMASK_END, KEYMASK_PGUP, KEYMASK_PGDN,
KEYMASK_SCROLLLOCK, KEYMASK_A, KEYMASK_B, KEYMASK_C,
KEYMASK_D, KEYMASK_E, KEYMASK_F, KEYMASK_G,
KEYMASK_H, KEYMASK_I, KEYMASK_J, KEYMASK_K };
KEYMASK_SCROLLLOCK, KEYMASK_A, KEYMASK_B, KEYMASK_C,
KEYMASK_D, KEYMASK_E, KEYMASK_F, KEYMASK_G,
KEYMASK_H, KEYMASK_I, KEYMASK_J, KEYMASK_K };
static const u16 keys1_bitmasks[] = {
KEYMASK_L, KEYMASK_M, KEYMASK_N, KEYMASK_O, KEYMASK_P, KEYMASK_Q, KEYMASK_R, KEYMASK_S,
KEYMASK_T, KEYMASK_U, KEYMASK_V, KEYMASK_W, KEYMASK_X, KEYMASK_Y, KEYMASK_Z, KEYMASK_1 };
KEYMASK_L, KEYMASK_M, KEYMASK_N, KEYMASK_O, KEYMASK_P, KEYMASK_Q, KEYMASK_R, KEYMASK_S,
KEYMASK_T, KEYMASK_U, KEYMASK_V, KEYMASK_W, KEYMASK_X, KEYMASK_Y, KEYMASK_Z, KEYMASK_1 };
static const u16 keys2_bitmasks[] = {
KEYMASK_2, KEYMASK_3, KEYMASK_4, KEYMASK_5,
KEYMASK_6, KEYMASK_7, KEYMASK_8, KEYMASK_9,
KEYMASK_0, KEYMASK_MINUS, KEYMASK_PLUS, KEYMASK_PRINTSCR,
KEYMASK_BRACE_OPEN, KEYMASK_BRACE_CLOSE, KEYMASK_COLON, KEYMASK_QUOTE };
KEYMASK_2, KEYMASK_3, KEYMASK_4, KEYMASK_5,
KEYMASK_6, KEYMASK_7, KEYMASK_8, KEYMASK_9,
KEYMASK_0, KEYMASK_MINUS, KEYMASK_PLUS, KEYMASK_PRINTSCR,
KEYMASK_BRACE_OPEN, KEYMASK_BRACE_CLOSE, KEYMASK_COLON, KEYMASK_QUOTE };
static const u16 keys3_bitmasks[] = {
KEYMASK_HASH, KEYMASK_COMMA, KEYMASK_PERIOD, KEYMASK_QUESTIONMARK, KEYMASK_INTERNATIONAL1,
KEYMASK_F1, KEYMASK_F2, KEYMASK_F3, KEYMASK_F4, KEYMASK_F5,
KEYMASK_F6, KEYMASK_F7, KEYMASK_F8, KEYMASK_F9, KEYMASK_F10,
KEYMASK_F11 };
KEYMASK_HASH, KEYMASK_COMMA, KEYMASK_PERIOD, KEYMASK_QUESTIONMARK, KEYMASK_INTERNATIONAL1,
KEYMASK_F1, KEYMASK_F2, KEYMASK_F3, KEYMASK_F4, KEYMASK_F5,
KEYMASK_F6, KEYMASK_F7, KEYMASK_F8, KEYMASK_F9, KEYMASK_F10,
KEYMASK_F11 };
static const u16 keys4_bitmasks[] = {
KEYMASK_F12, KEYMASK_ESC, KEYMASK_INSERT, KEYMASK_DELETE,
KEYMASK_TILDE, KEYMASK_BACKSPACE, KEYMASK_TAB, KEYMASK_CAPSLOCK,
KEYMASK_LEFTSHIFT, KEYMASK_RIGHTSHIFT, KEYMASK_LEFTCONTROL, KEYMASK_RIGHTALT,
KEYMASK_LEFTWINDOWS, KEYMASK_SPACE, KEYMASK_RIGHTWINDOWS, KEYMASK_MENU };
KEYMASK_F12, KEYMASK_ESC, KEYMASK_INSERT, KEYMASK_DELETE,
KEYMASK_TILDE, KEYMASK_BACKSPACE, KEYMASK_TAB, KEYMASK_CAPSLOCK,
KEYMASK_LEFTSHIFT, KEYMASK_RIGHTSHIFT, KEYMASK_LEFTCONTROL, KEYMASK_RIGHTALT,
KEYMASK_LEFTWINDOWS, KEYMASK_SPACE, KEYMASK_RIGHTWINDOWS, KEYMASK_MENU };
static const u16 keys5_bitmasks[] = { KEYMASK_LEFTARROW, KEYMASK_DOWNARROW, KEYMASK_UPARROW,
KEYMASK_RIGHTARROW, KEYMASK_ENTER };
KEYMASK_RIGHTARROW, KEYMASK_ENTER };
static const char* const named_keys0[] = { "HOME", "END", "PGUP", "PGDN", "SCR LK", "A", "B", "C",
"D", "E", "F", "G", "H", "I", "J", "K" };
"D", "E", "F", "G", "H", "I", "J", "K" };
static const char* const named_keys1[] = { "L", "M", "N", "O", "P", "Q", "R", "S",
"T", "U", "V", "W", "X", "Y", "Z", "1" };
"T", "U", "V", "W", "X", "Y", "Z", "1" };
static const char* const named_keys2[] = { "2", "3", "4", "5", "6", "7", "8", "9",
"0", "-", "`", "PRT SC", "'", "[", "EQUALS", "*" };
"0", "-", "`", "PRT SC", "'", "[", "EQUALS", "*" };
static const char* const named_keys3[] = { "]", ",", ".", "/", "\\", "F1", "F2", "F3",
"F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11" };
"F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11" };
static const char* const named_keys4[] = {
"F12", "ESC", "INSERT", "DELETE", ";", "BACKSPACE", "TAB", "CAPS LOCK",
"L SHIFT", "R SHIFT", "L CTRL", "R ALT", "L WIN", "SPACE", "R WIN", "MENU" };
"F12", "ESC", "INSERT", "DELETE", ";", "BACKSPACE", "TAB", "CAPS LOCK",
"L SHIFT", "R SHIFT", "L CTRL", "R ALT", "L WIN", "SPACE", "R WIN", "MENU" };
static const char* const named_keys5[] = { "LEFT", "DOWN", "UP", "RIGHT", "ENTER" };
GCKeyboard::GCKeyboard(const unsigned int index) : m_index(index)
@ -84,6 +85,29 @@ std::string GCKeyboard::GetName() const
return std::string("GCKeyboard") + char('1' + m_index);
}
ControllerEmu::ControlGroup* GCKeyboard::GetGroup(KeyboardGroup group)
{
switch (group)
{
case KeyboardGroup::Kb0x:
return m_keys0x;
case KeyboardGroup::Kb1x:
return m_keys1x;
case KeyboardGroup::Kb2x:
return m_keys2x;
case KeyboardGroup::Kb3x:
return m_keys3x;
case KeyboardGroup::Kb4x:
return m_keys4x;
case KeyboardGroup::Kb5x:
return m_keys5x;
case KeyboardGroup::Options:
return m_options;
default:
return nullptr;
}
}
KeyboardStatus GCKeyboard::GetInput() const
{
auto lock = ControllerEmu::GetStateLock();

View file

@ -10,12 +10,25 @@
struct KeyboardStatus;
enum class KeyboardGroup
{
Kb0x,
Kb1x,
Kb2x,
Kb3x,
Kb4x,
Kb5x,
Options
};
class GCKeyboard : public ControllerEmu
{
public:
GCKeyboard(const unsigned int index);
KeyboardStatus GetInput() const;
std::string GetName() const override;
ControlGroup* GetGroup(KeyboardGroup group);
void LoadDefaults(const ControllerInterface& ciface) override;
private:

View file

@ -100,7 +100,7 @@ struct Header // Offset Size Description
u32 SramBias; // 0x0014 4 SRAM bias at time of format
u32 SramLang; // 0x0018 4 SRAM language
u8 Unk2[4]; // 0x001c 4 ? almost always 0
// end Serial in libogc
// end Serial in libogc
u8 deviceID[2]; // 0x0020 2 0 if formated in slot A 1 if formated in slot B
u8 SizeMb[2]; // 0x0022 2 Size of memcard in Mbits
u16 Encoding; // 0x0024 2 Encoding (ASCII or Japanese)
@ -164,40 +164,40 @@ struct DEntry
u8 Makercode[2]; // 0x04 0x02 Makercode
u8 Unused1; // 0x06 0x01 reserved/unused (always 0xff, has no effect)
u8 BIFlags; // 0x07 0x01 banner gfx format and icon animation (Image Key)
// Bit(s) Description
// 2 Icon Animation 0: forward 1: ping-pong
// 1 [--0: No Banner 1: Banner present--] WRONG! YAGCD LIES!
// 0 [--Banner Color 0: RGB5A3 1: CI8--] WRONG! YAGCD LIES!
// bits 0 and 1: image format
// 00 no banner
// 01 CI8 banner
// 10 RGB5A3 banner
// 11 ? maybe ==00? Time Splitters 2 and 3 have it and don't have banner
//
// Bit(s) Description
// 2 Icon Animation 0: forward 1: ping-pong
// 1 [--0: No Banner 1: Banner present--] WRONG! YAGCD LIES!
// 0 [--Banner Color 0: RGB5A3 1: CI8--] WRONG! YAGCD LIES!
// bits 0 and 1: image format
// 00 no banner
// 01 CI8 banner
// 10 RGB5A3 banner
// 11 ? maybe ==00? Time Splitters 2 and 3 have it and don't have banner
//
u8 Filename[DENTRY_STRLEN]; // 0x08 0x20 Filename
u8 ModTime[4]; // 0x28 0x04 Time of file's last modification in seconds since 12am,
// January 1st, 2000
u8 ImageOffset[4]; // 0x2c 0x04 image data offset
u8 IconFmt[2]; // 0x30 0x02 icon gfx format (2bits per icon)
// Bits Description
// 00 No icon
// 01 CI8 with a shared color palette after the last frame
// 10 RGB5A3
// 11 CI8 with a unique color palette after itself
//
// Bits Description
// 00 No icon
// 01 CI8 with a shared color palette after the last frame
// 10 RGB5A3
// 11 CI8 with a unique color palette after itself
//
u8 AnimSpeed[2]; // 0x32 0x02 Animation speed (2bits per icon) (*1)
// Bits Description
// 00 No icon
// 01 Icon lasts for 4 frames
// 10 Icon lasts for 8 frames
// 11 Icon lasts for 12 frames
//
// Bits Description
// 00 No icon
// 01 Icon lasts for 4 frames
// 10 Icon lasts for 8 frames
// 11 Icon lasts for 12 frames
//
u8 Permissions; // 0x34 0x01 File-permissions
// Bit Permission Description
// 4 no move File cannot be moved by the IPL
// 3 no copy File cannot be copied by the IPL
// 2 public Can be read by any game
//
// Bit Permission Description
// 4 no move File cannot be moved by the IPL
// 3 no copy File cannot be copied by the IPL
// 2 public Can be read by any game
//
u8 CopyCounter; // 0x35 0x01 Copy counter (*2)
u8 FirstBlock[2]; // 0x36 0x02 Block no of first block of file (0 == offset 0)
u8 BlockCount[2]; // 0x38 0x02 File-length (number of blocks in file)

View file

@ -5,7 +5,6 @@
#include <cstring>
#include "Common/Common.h"
#include "Common/CommonTypes.h"
#include "Core/HW/GCPad.h"
#include "Core/HW/GCPadEmu.h"
#include "InputCommon/GCPadStatus.h"
@ -48,6 +47,11 @@ 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);

View file

@ -5,9 +5,11 @@
#pragma once
#include "Common/CommonTypes.h"
#include "InputCommon/ControllerEmu.h"
#include "InputCommon/ControllerInterface/Device.h"
class InputConfig;
enum class PadGroup;
struct GCPadStatus;
namespace Pad
@ -19,6 +21,7 @@ void LoadConfig();
InputConfig* GetConfig();
GCPadStatus GetStatus(int pad_num);
ControllerEmu::ControlGroup* GetGroup(int pad_num, PadGroup group);
void Rumble(int pad_num, ControlState strength);
bool GetMicButton(int pad_num);

View file

@ -8,24 +8,24 @@
#include "Core/Host.h"
static const u16 button_bitmasks[] = {
PAD_BUTTON_A,
PAD_BUTTON_B,
PAD_BUTTON_X,
PAD_BUTTON_Y,
PAD_TRIGGER_Z,
PAD_BUTTON_START,
0 // MIC HAX
PAD_BUTTON_A,
PAD_BUTTON_B,
PAD_BUTTON_X,
PAD_BUTTON_Y,
PAD_TRIGGER_Z,
PAD_BUTTON_START,
0 // MIC HAX
};
static const u16 trigger_bitmasks[] = {
PAD_TRIGGER_L, PAD_TRIGGER_R,
PAD_TRIGGER_L, PAD_TRIGGER_R,
};
static const u16 dpad_bitmasks[] = { PAD_BUTTON_UP, PAD_BUTTON_DOWN, PAD_BUTTON_LEFT,
PAD_BUTTON_RIGHT };
PAD_BUTTON_RIGHT };
static const char* const named_buttons[] = { "A", "B", "X", "Y", "Z", _trans("Start"),
_trans("Mic") };
_trans("Mic") };
static const char* const named_triggers[] = {
// i18n: The left trigger button (labeled L on real controllers)
@ -79,6 +79,29 @@ std::string GCPad::GetName() const
return std::string("GCPad") + char('1' + m_index);
}
ControllerEmu::ControlGroup* GCPad::GetGroup(PadGroup group)
{
switch (group)
{
case PadGroup::Buttons:
return m_buttons;
case PadGroup::MainStick:
return m_main_stick;
case PadGroup::CStick:
return m_c_stick;
case PadGroup::DPad:
return m_dpad;
case PadGroup::Triggers:
return m_triggers;
case PadGroup::Rumble:
return m_rumble;
case PadGroup::Options:
return m_options;
default:
return nullptr;
}
}
GCPadStatus GCPad::GetInput() const
{
auto lock = ControllerEmu::GetStateLock();
@ -138,11 +161,11 @@ void GCPad::LoadDefaults(const ControllerInterface& ciface)
#ifdef _WIN32
m_buttons->SetControlExpression(5, "!LMENU & RETURN"); // Start
#else
// OS X/Linux
// OS X/Linux
m_buttons->SetControlExpression(5, "!`Alt_L` & Return"); // Start
#endif
// stick modifiers to 50 %
// stick modifiers to 50 %
m_main_stick->controls[4]->control_ref->range = 0.5f;
m_c_stick->controls[4]->control_ref->range = 0.5f;
@ -152,7 +175,7 @@ void GCPad::LoadDefaults(const ControllerInterface& ciface)
m_dpad->SetControlExpression(2, "F"); // Left
m_dpad->SetControlExpression(3, "H"); // Right
// C Stick
// C Stick
m_c_stick->SetControlExpression(0, "I"); // Up
m_c_stick->SetControlExpression(1, "K"); // Down
m_c_stick->SetControlExpression(2, "J"); // Left
@ -160,7 +183,7 @@ void GCPad::LoadDefaults(const ControllerInterface& ciface)
#ifdef _WIN32
m_c_stick->SetControlExpression(4, "LCONTROL"); // Modifier
// Control Stick
// Control Stick
m_main_stick->SetControlExpression(0, "UP"); // Up
m_main_stick->SetControlExpression(1, "DOWN"); // Down
m_main_stick->SetControlExpression(2, "LEFT"); // Left
@ -170,18 +193,18 @@ void GCPad::LoadDefaults(const ControllerInterface& ciface)
#elif __APPLE__
m_c_stick->SetControlExpression(4, "Left Control"); // Modifier
// Control Stick
// Control Stick
m_main_stick->SetControlExpression(0, "Up Arrow"); // Up
m_main_stick->SetControlExpression(1, "Down Arrow"); // Down
m_main_stick->SetControlExpression(2, "Left Arrow"); // Left
m_main_stick->SetControlExpression(3, "Right Arrow"); // Right
m_main_stick->SetControlExpression(4, "Left Shift"); // Modifier
#else
// not sure if these are right
// not sure if these are right
m_c_stick->SetControlExpression(4, "Control_L"); // Modifier
// Control Stick
// Control Stick
m_main_stick->SetControlExpression(0, "Up"); // Up
m_main_stick->SetControlExpression(1, "Down"); // Down
m_main_stick->SetControlExpression(2, "Left"); // Left
@ -189,7 +212,7 @@ void GCPad::LoadDefaults(const ControllerInterface& ciface)
m_main_stick->SetControlExpression(4, "Shift_L"); // Modifier
#endif
// Triggers
// Triggers
m_triggers->SetControlExpression(0, "Q"); // L
m_triggers->SetControlExpression(1, "W"); // R
}

View file

@ -8,6 +8,19 @@
#include "InputCommon/ControllerEmu.h"
class ControlGroup;
enum class PadGroup
{
Buttons,
MainStick,
CStick,
DPad,
Triggers,
Rumble,
Options
};
class GCPad : public ControllerEmu
{
public:
@ -19,6 +32,8 @@ public:
std::string GetName() const override;
ControlGroup* GetGroup(PadGroup group);
void LoadDefaults(const ControllerInterface& ciface) override;
private:

View file

@ -19,6 +19,37 @@ InputConfig* GetConfig()
return &s_config;
}
ControllerEmu::ControlGroup* GetWiimoteGroup(int number, WiimoteEmu::WiimoteGroup group)
{
return static_cast<WiimoteEmu::Wiimote*>(s_config.GetController(number))->GetWiimoteGroup(group);
}
ControllerEmu::ControlGroup* GetNunchukGroup(int number, WiimoteEmu::NunchukGroup group)
{
return static_cast<WiimoteEmu::Wiimote*>(s_config.GetController(number))->GetNunchukGroup(group);
}
ControllerEmu::ControlGroup* GetClassicGroup(int number, WiimoteEmu::ClassicGroup group)
{
return static_cast<WiimoteEmu::Wiimote*>(s_config.GetController(number))->GetClassicGroup(group);
}
ControllerEmu::ControlGroup* GetGuitarGroup(int number, WiimoteEmu::GuitarGroup group)
{
return static_cast<WiimoteEmu::Wiimote*>(s_config.GetController(number))->GetGuitarGroup(group);
}
ControllerEmu::ControlGroup* GetDrumsGroup(int number, WiimoteEmu::DrumsGroup group)
{
return static_cast<WiimoteEmu::Wiimote*>(s_config.GetController(number))->GetDrumsGroup(group);
}
ControllerEmu::ControlGroup* GetTurntableGroup(int number, WiimoteEmu::TurntableGroup group)
{
return static_cast<WiimoteEmu::Wiimote*>(s_config.GetController(number))
->GetTurntableGroup(group);
}
void Shutdown()
{
s_config.ClearControllers();

View file

@ -6,9 +6,19 @@
#include "Common/Common.h"
#include "Common/CommonTypes.h"
#include "InputCommon/ControllerEmu.h"
class InputConfig;
class PointerWrap;
namespace WiimoteEmu
{
enum class WiimoteGroup;
enum class NunchukGroup;
enum class ClassicGroup;
enum class GuitarGroup;
enum class DrumsGroup;
enum class TurntableGroup;
}
enum
{
@ -52,6 +62,12 @@ unsigned int GetAttached();
void DoState(PointerWrap& p);
void EmuStateChange(EMUSTATE_CHANGE newState);
InputConfig* GetConfig();
ControllerEmu::ControlGroup* GetWiimoteGroup(int number, WiimoteEmu::WiimoteGroup group);
ControllerEmu::ControlGroup* GetNunchukGroup(int number, WiimoteEmu::NunchukGroup group);
ControllerEmu::ControlGroup* GetClassicGroup(int number, WiimoteEmu::ClassicGroup group);
ControllerEmu::ControlGroup* GetGuitarGroup(int number, WiimoteEmu::GuitarGroup group);
ControllerEmu::ControlGroup* GetDrumsGroup(int number, WiimoteEmu::DrumsGroup group);
ControllerEmu::ControlGroup* GetTurntableGroup(int number, WiimoteEmu::TurntableGroup group);
void ControlChannel(int _number, u16 _channelID, const void* _pData, u32 _Size);
void InterruptChannel(int _number, u16 _channelID, const void* _pData, u32 _Size);

View file

@ -2,6 +2,7 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <cassert>
#include <cstring>
#include "Common/Common.h"
@ -14,30 +15,30 @@ namespace WiimoteEmu
static const u8 classic_id[] = { 0x00, 0x00, 0xa4, 0x20, 0x01, 0x01 };
/* Classic Controller calibration */
static const u8 classic_calibration[] = { 0xff, 0x00, 0x80, 0xff, 0x00, 0x80, 0xff, 0x00,
0x80, 0xff, 0x00, 0x80, 0x00, 0x00, 0x51, 0xa6 };
0x80, 0xff, 0x00, 0x80, 0x00, 0x00, 0x51, 0xa6 };
static const u16 classic_button_bitmasks[] = {
Classic::BUTTON_A, Classic::BUTTON_B, Classic::BUTTON_X, Classic::BUTTON_Y,
Classic::BUTTON_A, Classic::BUTTON_B, Classic::BUTTON_X, Classic::BUTTON_Y,
Classic::BUTTON_ZL, Classic::BUTTON_ZR,
Classic::BUTTON_ZL, Classic::BUTTON_ZR,
Classic::BUTTON_MINUS, Classic::BUTTON_PLUS,
Classic::BUTTON_MINUS, Classic::BUTTON_PLUS,
Classic::BUTTON_HOME,
Classic::BUTTON_HOME,
};
static const char* const classic_button_names[] = {
"A", "B", "X", "Y", "ZL", "ZR", "-", "+", "Home",
"A", "B", "X", "Y", "ZL", "ZR", "-", "+", "Home",
};
static const u16 classic_trigger_bitmasks[] = {
Classic::TRIGGER_L, Classic::TRIGGER_R,
Classic::TRIGGER_L, Classic::TRIGGER_R,
};
static const char* const classic_trigger_names[] = { "L", "R", "L-Analog", "R-Analog" };
static const u16 classic_dpad_bitmasks[] = { Classic::PAD_UP, Classic::PAD_DOWN, Classic::PAD_LEFT,
Classic::PAD_RIGHT };
Classic::PAD_RIGHT };
Classic::Classic(WiimoteEmu::ExtensionReg& _reg) : Attachment(_trans("Classic"), _reg)
{
@ -134,4 +135,24 @@ bool Classic::IsButtonPressed() const
m_triggers->GetState(&buttons, classic_trigger_bitmasks, trigs);
return buttons != 0;
}
ControllerEmu::ControlGroup* Classic::GetGroup(ClassicGroup group)
{
switch (group)
{
case ClassicGroup::Buttons:
return m_buttons;
case ClassicGroup::Triggers:
return m_triggers;
case ClassicGroup::DPad:
return m_dpad;
case ClassicGroup::LeftStick:
return m_left_stick;
case ClassicGroup::RightStick:
return m_right_stick;
default:
assert(false);
return nullptr;
}
}
}

View file

@ -8,6 +8,7 @@
namespace WiimoteEmu
{
enum class ClassicGroup;
struct ExtensionReg;
class Classic : public Attachment
@ -17,6 +18,8 @@ public:
void GetState(u8* const data) override;
bool IsButtonPressed() const override;
ControlGroup* GetGroup(ClassicGroup group);
enum
{
PAD_RIGHT = 0x80,

View file

@ -2,6 +2,7 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <cassert>
#include <cstring>
#include "Common/Common.h"
@ -14,15 +15,15 @@ namespace WiimoteEmu
static const u8 drums_id[] = { 0x01, 0x00, 0xa4, 0x20, 0x01, 0x03 };
static const u16 drum_pad_bitmasks[] = {
Drums::PAD_RED, Drums::PAD_YELLOW, Drums::PAD_BLUE,
Drums::PAD_GREEN, Drums::PAD_ORANGE, Drums::PAD_BASS,
Drums::PAD_RED, Drums::PAD_YELLOW, Drums::PAD_BLUE,
Drums::PAD_GREEN, Drums::PAD_ORANGE, Drums::PAD_BASS,
};
static const char* const drum_pad_names[] = { _trans("Red"), _trans("Yellow"), _trans("Blue"),
_trans("Green"), _trans("Orange"), _trans("Bass") };
_trans("Green"), _trans("Orange"), _trans("Bass") };
static const u16 drum_button_bitmasks[] = {
Drums::BUTTON_MINUS, Drums::BUTTON_PLUS,
Drums::BUTTON_MINUS, Drums::BUTTON_PLUS,
};
Drums::Drums(WiimoteEmu::ExtensionReg& _reg) : Attachment(_trans("Drums"), _reg)
@ -81,4 +82,20 @@ bool Drums::IsButtonPressed() const
m_pads->GetState(&buttons, drum_pad_bitmasks);
return buttons != 0;
}
ControllerEmu::ControlGroup* Drums::GetGroup(DrumsGroup group)
{
switch (group)
{
case DrumsGroup::Buttons:
return m_buttons;
case DrumsGroup::Pads:
return m_pads;
case DrumsGroup::Stick:
return m_stick;
default:
assert(false);
return nullptr;
}
}
}

View file

@ -8,6 +8,7 @@
namespace WiimoteEmu
{
enum class DrumsGroup;
struct ExtensionReg;
class Drums : public Attachment
@ -17,6 +18,8 @@ public:
void GetState(u8* const data) override;
bool IsButtonPressed() const override;
ControlGroup* GetGroup(DrumsGroup group);
enum
{
BUTTON_PLUS = 0x04,

View file

@ -2,6 +2,7 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <cassert>
#include <cstring>
#include "Common/Common.h"
@ -14,20 +15,20 @@ namespace WiimoteEmu
static const u8 guitar_id[] = { 0x00, 0x00, 0xa4, 0x20, 0x01, 0x03 };
static const u16 guitar_fret_bitmasks[] = {
Guitar::FRET_GREEN, Guitar::FRET_RED, Guitar::FRET_YELLOW,
Guitar::FRET_BLUE, Guitar::FRET_ORANGE,
Guitar::FRET_GREEN, Guitar::FRET_RED, Guitar::FRET_YELLOW,
Guitar::FRET_BLUE, Guitar::FRET_ORANGE,
};
static const char* const guitar_fret_names[] = {
"Green", "Red", "Yellow", "Blue", "Orange",
"Green", "Red", "Yellow", "Blue", "Orange",
};
static const u16 guitar_button_bitmasks[] = {
Guitar::BUTTON_MINUS, Guitar::BUTTON_PLUS,
Guitar::BUTTON_MINUS, Guitar::BUTTON_PLUS,
};
static const u16 guitar_strum_bitmasks[] = {
Guitar::BAR_UP, Guitar::BAR_DOWN,
Guitar::BAR_UP, Guitar::BAR_DOWN,
};
Guitar::Guitar(WiimoteEmu::ExtensionReg& _reg) : Attachment(_trans("Guitar"), _reg)
@ -78,7 +79,7 @@ void Guitar::GetState(u8* const data)
// TODO: touch bar, probably not
gdata->tb = 0x0F; // not touched
// whammy bar
// whammy bar
ControlState whammy;
m_whammy->GetState(&whammy);
gdata->whammy = static_cast<u8>(whammy * 0x1F);
@ -102,4 +103,24 @@ bool Guitar::IsButtonPressed() const
m_strum->GetState(&buttons, guitar_strum_bitmasks);
return buttons != 0;
}
ControllerEmu::ControlGroup* Guitar::GetGroup(GuitarGroup group)
{
switch (group)
{
case GuitarGroup::Buttons:
return m_buttons;
case GuitarGroup::Frets:
return m_frets;
case GuitarGroup::Strum:
return m_strum;
case GuitarGroup::Whammy:
return m_whammy;
case GuitarGroup::Stick:
return m_stick;
default:
assert(false);
return nullptr;
}
}
}

View file

@ -8,6 +8,7 @@
namespace WiimoteEmu
{
enum class GuitarGroup;
struct ExtensionReg;
class Guitar : public Attachment
@ -17,6 +18,8 @@ public:
void GetState(u8* const data) override;
bool IsButtonPressed() const override;
ControlGroup* GetGroup(GuitarGroup group);
enum
{
BUTTON_PLUS = 0x04,

View file

@ -2,6 +2,7 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <cassert>
#include <cstring>
#include "Common/Common.h"
@ -15,7 +16,7 @@ namespace WiimoteEmu
static const u8 nunchuk_id[] = { 0x00, 0x00, 0xa4, 0x20, 0x00, 0x00 };
static const u8 nunchuk_button_bitmasks[] = {
Nunchuk::BUTTON_C, Nunchuk::BUTTON_Z,
Nunchuk::BUTTON_C, Nunchuk::BUTTON_Z,
};
Nunchuk::Nunchuk(WiimoteEmu::ExtensionReg& _reg) : Attachment(_trans("Nunchuk"), _reg)
@ -114,6 +115,26 @@ bool Nunchuk::IsButtonPressed() const
return buttons != 0;
}
ControllerEmu::ControlGroup* Nunchuk::GetGroup(NunchukGroup group)
{
switch (group)
{
case NunchukGroup::Buttons:
return m_buttons;
case NunchukGroup::Stick:
return m_stick;
case NunchukGroup::Tilt:
return m_tilt;
case NunchukGroup::Swing:
return m_swing;
case NunchukGroup::Shake:
return m_shake;
default:
assert(false);
return nullptr;
}
}
void Nunchuk::LoadDefaults(const ControllerInterface& ciface)
{
// Stick
@ -122,7 +143,7 @@ void Nunchuk::LoadDefaults(const ControllerInterface& ciface)
m_stick->SetControlExpression(2, "A"); // left
m_stick->SetControlExpression(3, "D"); // right
// Buttons
// Buttons
#ifdef _WIN32
m_buttons->SetControlExpression(0, "LCONTROL"); // C
m_buttons->SetControlExpression(1, "LSHIFT"); // Z

View file

@ -8,6 +8,7 @@
namespace WiimoteEmu
{
enum class NunchukGroup;
struct ExtensionReg;
class Nunchuk : public Attachment
@ -18,6 +19,8 @@ public:
void GetState(u8* const data) override;
bool IsButtonPressed() const override;
ControlGroup* GetGroup(NunchukGroup group);
enum
{
BUTTON_C = 0x02,

View file

@ -2,6 +2,7 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <cassert>
#include <cstring>
#include "Common/Common.h"
@ -14,21 +15,21 @@ namespace WiimoteEmu
static const u8 turntable_id[] = { 0x03, 0x00, 0xa4, 0x20, 0x01, 0x03 };
static const u16 turntable_button_bitmasks[] = {
Turntable::BUTTON_L_GREEN, Turntable::BUTTON_L_RED, Turntable::BUTTON_L_BLUE,
Turntable::BUTTON_R_GREEN, Turntable::BUTTON_R_RED, Turntable::BUTTON_R_BLUE,
Turntable::BUTTON_MINUS, Turntable::BUTTON_PLUS, Turntable::BUTTON_EUPHORIA,
Turntable::BUTTON_L_GREEN, Turntable::BUTTON_L_RED, Turntable::BUTTON_L_BLUE,
Turntable::BUTTON_R_GREEN, Turntable::BUTTON_R_RED, Turntable::BUTTON_R_BLUE,
Turntable::BUTTON_MINUS, Turntable::BUTTON_PLUS, Turntable::BUTTON_EUPHORIA,
};
static const char* const turntable_button_names[] = {
_trans("Green Left"),
_trans("Red Left"),
_trans("Blue Left"),
_trans("Green Right"),
_trans("Red Right"),
_trans("Blue Right"),
"-",
"+",
_trans("Euphoria"),
_trans("Green Left"),
_trans("Red Left"),
_trans("Blue Left"),
_trans("Green Right"),
_trans("Red Right"),
_trans("Blue Right"),
"-",
"+",
_trans("Euphoria"),
};
Turntable::Turntable(WiimoteEmu::ExtensionReg& _reg) : Attachment(_trans("Turntable"), _reg)
@ -131,4 +132,26 @@ bool Turntable::IsButtonPressed() const
m_buttons->GetState(&buttons, turntable_button_bitmasks);
return buttons != 0;
}
ControllerEmu::ControlGroup* Turntable::GetGroup(TurntableGroup group)
{
switch (group)
{
case TurntableGroup::Buttons:
return m_buttons;
case TurntableGroup::Stick:
return m_stick;
case TurntableGroup::EffectDial:
return m_effect_dial;
case TurntableGroup::LeftTable:
return m_left_table;
case TurntableGroup::RightTable:
return m_right_table;
case TurntableGroup::Crossfade:
return m_crossfade;
default:
assert(false);
return nullptr;
}
}
}

View file

@ -8,6 +8,7 @@
namespace WiimoteEmu
{
enum class TurntableGroup;
struct ExtensionReg;
class Turntable : public Attachment
@ -17,6 +18,8 @@ public:
void GetState(u8* const data) override;
bool IsButtonPressed() const override;
ControlGroup* GetGroup(TurntableGroup group);
enum
{
BUTTON_EUPHORIA = 0x1000,

View file

@ -2,6 +2,7 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <cassert>
#include <cmath>
#include <cstring>
@ -315,6 +316,61 @@ std::string Wiimote::GetName() const
return std::string("Wiimote") + char('1' + m_index);
}
ControllerEmu::ControlGroup* Wiimote::GetWiimoteGroup(WiimoteGroup group)
{
switch (group)
{
case WiimoteGroup::Buttons:
return m_buttons;
case WiimoteGroup::DPad:
return m_dpad;
case WiimoteGroup::Shake:
return m_shake;
case WiimoteGroup::IR:
return m_ir;
case WiimoteGroup::Tilt:
return m_tilt;
case WiimoteGroup::Swing:
return m_swing;
case WiimoteGroup::Rumble:
return m_rumble;
case WiimoteGroup::Extension:
return m_extension;
case WiimoteGroup::Options:
return m_options;
case WiimoteGroup::Hotkeys:
return m_hotkeys;
default:
assert(false);
return nullptr;
}
}
ControllerEmu::ControlGroup* Wiimote::GetNunchukGroup(NunchukGroup group)
{
return static_cast<Nunchuk*>(m_extension->attachments[EXT_NUNCHUK].get())->GetGroup(group);
}
ControllerEmu::ControlGroup* Wiimote::GetClassicGroup(ClassicGroup group)
{
return static_cast<Classic*>(m_extension->attachments[EXT_CLASSIC].get())->GetGroup(group);
}
ControllerEmu::ControlGroup* Wiimote::GetGuitarGroup(GuitarGroup group)
{
return static_cast<Guitar*>(m_extension->attachments[EXT_GUITAR].get())->GetGroup(group);
}
ControllerEmu::ControlGroup* Wiimote::GetDrumsGroup(DrumsGroup group)
{
return static_cast<Drums*>(m_extension->attachments[EXT_DRUMS].get())->GetGroup(group);
}
ControllerEmu::ControlGroup* Wiimote::GetTurntableGroup(TurntableGroup group)
{
return static_cast<Turntable*>(m_extension->attachments[EXT_TURNTABLE].get())->GetGroup(group);
}
bool Wiimote::Step()
{
// TODO: change this a bit
@ -795,7 +851,7 @@ void Wiimote::ControlChannel(const u16 _channelID, const void* _pData, u32 _Size
// Check for custom communication
if (99 == _channelID)
{
// Wiimote disconnected
// Wii Remote disconnected
// reset eeprom/register/reporting mode
Reset();
if (WIIMOTE_SRC_REAL & g_wiimote_sources[m_index])
@ -911,7 +967,7 @@ void Wiimote::ConnectOnInput()
{
Host_ConnectWiimote(m_index, true);
// arbitrary value so it doesn't try to send multiple requests before Dolphin can react
// if Wiimotes are polled at 200Hz then this results in one request being sent per 500ms
// if Wii Remotes are polled at 200Hz then this results in one request being sent per 500ms
m_last_connect_request_counter = 100;
}
}

View file

@ -26,7 +26,77 @@ class Wiimote;
}
namespace WiimoteEmu
{
enum class WiimoteGroup
{
Buttons,
DPad,
Shake,
IR,
Tilt,
Swing,
Rumble,
Extension,
Options,
Hotkeys
};
enum
{
EXT_NONE,
EXT_NUNCHUK,
EXT_CLASSIC,
EXT_GUITAR,
EXT_DRUMS,
EXT_TURNTABLE
};
enum class NunchukGroup
{
Buttons,
Stick,
Tilt,
Swing,
Shake
};
enum class ClassicGroup
{
Buttons,
Triggers,
DPad,
LeftStick,
RightStick
};
enum class GuitarGroup
{
Buttons,
Frets,
Strum,
Whammy,
Stick
};
enum class DrumsGroup
{
Buttons,
Pads,
Stick
};
enum class TurntableGroup
{
Buttons,
Stick,
EffectDial,
LeftTable,
RightTable,
Crossfade
};
#pragma pack(push, 1)
struct ReportFeatures
{
u8 core, accel, ir, ext, size;
@ -105,6 +175,12 @@ public:
Wiimote(const unsigned int index);
std::string GetName() const override;
ControlGroup* GetWiimoteGroup(WiimoteGroup group);
ControlGroup* GetNunchukGroup(NunchukGroup group);
ControllerEmu::ControlGroup* GetClassicGroup(ClassicGroup group);
ControllerEmu::ControlGroup* GetGuitarGroup(GuitarGroup group);
ControllerEmu::ControlGroup* GetDrumsGroup(DrumsGroup group);
ControllerEmu::ControlGroup* GetTurntableGroup(TurntableGroup group);
void Update();
void InterruptChannel(const u16 _channelID, const void* _pData, u32 _Size);

View file

@ -10,122 +10,121 @@
#include "InputCommon/GCPadStatus.h"
const std::string hotkey_labels[] = {
_trans("Open"),
_trans("Change Disc"),
_trans("Refresh List"),
_trans("Open"),
_trans("Change Disc"),
_trans("Refresh List"),
_trans("Toggle Pause"),
_trans("Stop"),
_trans("Reset"),
_trans("Toggle Fullscreen"),
_trans("Take Screenshot"),
_trans("Exit"),
_trans("Toggle Pause"),
_trans("Stop"),
_trans("Reset"),
_trans("Frame Advance"),
_trans("Frame Advance Decrease Speed"),
_trans("Frame Advance Increase Speed"),
_trans("Frame Advance Reset Speed"),
_trans("Volume Down"),
_trans("Volume Up"),
_trans("Volume Toggle Mute"),
_trans("Start Recording"),
_trans("Play Recording"),
_trans("Export Recording"),
_trans("Read-only mode"),
_trans("Decrease Emulation Speed"),
_trans("Increase Emulation Speed"),
_trans("Disable Emulation Speed Limit"),
_trans("Toggle Fullscreen"),
_trans("Take Screenshot"),
_trans("Exit"),
_trans("Frame Advance"),
_trans("Frame Advance Decrease Speed"),
_trans("Frame Advance Increase Speed"),
_trans("Frame Advance Reset Speed"),
_trans("Press Sync Button"),
_trans("Connect Wii Remote 1"),
_trans("Connect Wii Remote 2"),
_trans("Connect Wii Remote 3"),
_trans("Connect Wii Remote 4"),
_trans("Connect Balance Board"),
_trans("Start Recording"),
_trans("Play Recording"),
_trans("Export Recording"),
_trans("Read-only mode"),
_trans("Volume Down"),
_trans("Volume Up"),
_trans("Volume Toggle Mute"),
_trans("Press Sync Button"),
_trans("Connect Wii Remote 1"),
_trans("Connect Wii Remote 2"),
_trans("Connect Wii Remote 3"),
_trans("Connect Wii Remote 4"),
_trans("Connect Balance Board"),
_trans("Increase IR"),
_trans("Decrease IR"),
_trans("Toggle Crop"),
_trans("Toggle Aspect Ratio"),
_trans("Toggle EFB Copies"),
_trans("Toggle Fog"),
_trans("Toggle Custom Textures"),
_trans("Toggle Crop"),
_trans("Toggle Aspect Ratio"),
_trans("Toggle EFB Copies"),
_trans("Toggle Fog"),
_trans("Disable Emulation Speed Limit"),
_trans("Decrease Emulation Speed"),
_trans("Increase Emulation Speed"),
_trans("Increase IR"),
_trans("Decrease IR"),
_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("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("Toggle 3D Side-by-side"),
_trans("Toggle 3D Top-bottom"),
_trans("Toggle 3D Anaglyph"),
_trans("Toggle 3D Vision"),
_trans("Toggle 3D Side-by-side"),
_trans("Toggle 3D Top-bottom"),
_trans("Toggle 3D Anaglyph"),
_trans("Toggle 3D Vision"),
_trans("Decrease Depth"),
_trans("Increase Depth"),
_trans("Decrease Convergence"),
_trans("Increase Convergence"),
_trans("Decrease Depth"),
_trans("Increase Depth"),
_trans("Decrease Convergence"),
_trans("Increase Convergence"),
_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("Load from selected slot"),
_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("Save to selected slot"),
_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("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("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("Load State Last 9"),
_trans("Load State Last 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("Load State Last 9"),
_trans("Load State Last 10"),
_trans("Save Oldest State"),
_trans("Undo Load State"),
_trans("Undo Save State"),
_trans("Save State"),
_trans("Load State"),
_trans("Save Oldest State"),
_trans("Undo Load State"),
_trans("Undo Save State"),
_trans("Save State"),
_trans("Load State"),
_trans("Reload Post-Processing Shaders"),
_trans("Switch Hires Textures"),
_trans("Switch Material Textures"),
@ -135,7 +134,7 @@ static_assert(NUM_HOTKEYS == sizeof(hotkey_labels) / sizeof(hotkey_labels[0]),
namespace HotkeyManagerEmu
{
static u32 s_hotkeyDown[(NUM_HOTKEYS + 31) / 32];
static u32 s_hotkeyDown[NUM_HOTKEY_GROUPS];
static HotkeyStatus s_hotkey;
static bool s_enabled;
@ -164,20 +163,21 @@ void Enable(bool enable_toggle)
s_enabled = enable_toggle;
}
bool IsPressed(int Id, bool held)
bool IsPressed(int id, bool held)
{
unsigned int set = Id / 32;
unsigned int setKey = Id % 32;
if (s_hotkey.button[set] & (1 << setKey))
unsigned int group = static_cast<HotkeyManager*>(s_config.GetController(0))->FindGroupByID(id);
unsigned int group_key =
static_cast<HotkeyManager*>(s_config.GetController(0))->GetIndexForGroup(group, id);
if (s_hotkey.button[group] & (1 << group_key))
{
bool pressed = !!(s_hotkeyDown[set] & (1 << setKey));
s_hotkeyDown[set] |= (1 << setKey);
bool pressed = !!(s_hotkeyDown[group] & (1 << group_key));
s_hotkeyDown[group] |= (1 << group_key);
if (!pressed || held)
return true;
}
else
{
s_hotkeyDown[set] &= ~(1 << setKey);
s_hotkeyDown[group] &= ~(1 << group_key);
}
return false;
@ -204,22 +204,50 @@ void LoadConfig()
s_config.LoadConfig(true);
}
ControllerEmu::ControlGroup* GetHotkeyGroup(HotkeyGroup group)
{
return static_cast<HotkeyManager*>(s_config.GetController(0))->GetHotkeyGroup(group);
}
ControllerEmu::ControlGroup* GetOptionsGroup()
{
return static_cast<HotkeyManager*>(s_config.GetController(0))->GetOptionsGroup();
}
void Shutdown()
{
s_config.ClearControllers();
}
}
const std::array<HotkeyGroupInfo, NUM_HOTKEY_GROUPS> groups_info = {
{ { "General", HK_OPEN, HK_EXIT },
{ "Volume", HK_VOLUME_DOWN, HK_VOLUME_TOGGLE_MUTE },
{ "Emulation speed", HK_DECREASE_EMULATION_SPEED, HK_TOGGLE_THROTTLE },
{ "Frame advance", HK_FRAME_ADVANCE, HK_FRAME_ADVANCE_RESET_SPEED },
{ "Movie", HK_START_RECORDING, HK_READ_ONLY_MODE },
{ "Wii", HK_TRIGGER_SYNC_BUTTON, HK_BALANCEBOARD_CONNECT },
{ "Graphics toggles", HK_TOGGLE_CROP, HK_TOGGLE_TEXTURES },
{ "Internal Resolution", HK_INCREASE_IR, HK_DECREASE_IR },
{ "Freelook", HK_FREELOOK_DECREASE_SPEED, HK_FREELOOK_RESET },
{ "3D", HK_TOGGLE_STEREO_SBS, HK_TOGGLE_STEREO_3DVISION },
{ "3D depth", HK_DECREASE_DEPTH, HK_INCREASE_CONVERGENCE },
{ "Load state", HK_LOAD_STATE_SLOT_1, HK_LOAD_STATE_SLOT_SELECTED },
{ "Save state", HK_SAVE_STATE_SLOT_1, HK_SAVE_STATE_SLOT_SELECTED },
{ "Select state", HK_SELECT_STATE_SLOT_1, HK_SELECT_STATE_SLOT_10 },
{ "Load last state", HK_LOAD_LAST_STATE_1, HK_LOAD_LAST_STATE_10 },
{ "Other state hotkeys", HK_SAVE_FIRST_STATE, HK_LOAD_STATE_FILE } } };
HotkeyManager::HotkeyManager()
{
for (int key = 0; key < NUM_HOTKEYS; key++)
for (int group = 0; group < NUM_HOTKEY_GROUPS; group++)
{
int set = key / 32;
if (key % 32 == 0)
groups.emplace_back(m_keys[set] = new Buttons(_trans("Keys")));
m_keys[set]->controls.emplace_back(new ControlGroup::Input(hotkey_labels[key]));
m_hotkey_groups[group] = (m_keys[group] = new Buttons("Keys", _trans(groups_info[group].name)));
groups.emplace_back(m_hotkey_groups[group]);
for (int key = groups_info[group].first; key <= groups_info[group].last; key++)
{
m_keys[group]->controls.emplace_back(new ControlGroup::Input(hotkey_labels[key]));
}
}
groups.emplace_back(m_options = new ControlGroup(_trans("Options")));
@ -241,17 +269,41 @@ std::string HotkeyManager::GetName() const
void HotkeyManager::GetInput(HotkeyStatus* const kb)
{
auto lock = ControllerEmu::GetStateLock();
for (int set = 0; set < (NUM_HOTKEYS + 31) / 32; set++)
for (int group = 0; group < NUM_HOTKEY_GROUPS; group++)
{
std::vector<u32> bitmasks;
for (int key = 0; key < std::min(32, NUM_HOTKEYS - set * 32); key++)
bitmasks.push_back(1 << key);
const int group_count = (groups_info[group].last - groups_info[group].first) + 1;
std::vector<u32> bitmasks(group_count);
for (size_t key = 0; key < bitmasks.size(); key++)
bitmasks[key] = static_cast<u32>(1 << key);
kb->button[set] = 0;
m_keys[set]->GetState(&kb->button[set], bitmasks.data());
kb->button[group] = 0;
m_keys[group]->GetState(&kb->button[group], bitmasks.data());
}
}
ControllerEmu::ControlGroup* HotkeyManager::GetHotkeyGroup(HotkeyGroup group) const
{
return m_hotkey_groups[group];
}
ControllerEmu::ControlGroup* HotkeyManager::GetOptionsGroup() const
{
return m_options;
}
int HotkeyManager::FindGroupByID(int id) const
{
const auto i = std::find_if(groups_info.begin(), groups_info.end(),
[id](const auto& entry) { return entry.last >= id; });
return static_cast<int>(std::distance(groups_info.begin(), i));
}
int HotkeyManager::GetIndexForGroup(int group, int id) const
{
return id - groups_info[group].first;
}
void HotkeyManager::LoadDefaults(const ControllerInterface& ciface)
{
ControllerEmu::LoadDefaults(ciface);
@ -269,7 +321,9 @@ void HotkeyManager::LoadDefaults(const ControllerInterface& ciface)
#endif
auto set_key_expression = [this](int index, const std::string& expression) {
m_keys[index / 32]->controls[index % 32]->control_ref->expression = expression;
m_keys[FindGroupByID(index)]
->controls[GetIndexForGroup(FindGroupByID(index), index)]
->control_ref->expression = expression;
};
// General hotkeys

View file

@ -4,7 +4,9 @@
#pragma once
#include <array>
#include <string>
#include "InputCommon/ControllerEmu.h"
#include "InputCommon/InputConfig.h"
@ -13,10 +15,21 @@ enum Hotkey
HK_OPEN,
HK_CHANGE_DISC,
HK_REFRESH_LIST,
HK_PLAY_PAUSE,
HK_STOP,
HK_RESET,
HK_FULLSCREEN,
HK_SCREENSHOT,
HK_EXIT,
HK_VOLUME_DOWN,
HK_VOLUME_UP,
HK_VOLUME_TOGGLE_MUTE,
HK_DECREASE_EMULATION_SPEED,
HK_INCREASE_EMULATION_SPEED,
HK_TOGGLE_THROTTLE,
HK_FRAME_ADVANCE,
HK_FRAME_ADVANCE_DECREASE_SPEED,
HK_FRAME_ADVANCE_INCREASE_SPEED,
@ -27,10 +40,6 @@ enum Hotkey
HK_EXPORT_RECORDING,
HK_READ_ONLY_MODE,
HK_FULLSCREEN,
HK_SCREENSHOT,
HK_EXIT,
HK_TRIGGER_SYNC_BUTTON,
HK_WIIMOTE1_CONNECT,
HK_WIIMOTE2_CONNECT,
@ -38,21 +47,14 @@ enum Hotkey
HK_WIIMOTE4_CONNECT,
HK_BALANCEBOARD_CONNECT,
HK_VOLUME_DOWN,
HK_VOLUME_UP,
HK_VOLUME_TOGGLE_MUTE,
HK_INCREASE_IR,
HK_DECREASE_IR,
HK_TOGGLE_CROP,
HK_TOGGLE_AR,
HK_TOGGLE_EFBCOPIES,
HK_TOGGLE_FOG,
HK_TOGGLE_THROTTLE,
HK_TOGGLE_TEXTURES,
HK_DECREASE_EMULATION_SPEED,
HK_INCREASE_EMULATION_SPEED,
HK_INCREASE_IR,
HK_DECREASE_IR,
HK_FREELOOK_DECREASE_SPEED,
HK_FREELOOK_INCREASE_SPEED,
@ -85,6 +87,7 @@ enum Hotkey
HK_LOAD_STATE_SLOT_8,
HK_LOAD_STATE_SLOT_9,
HK_LOAD_STATE_SLOT_10,
HK_LOAD_STATE_SLOT_SELECTED,
HK_SAVE_STATE_SLOT_1,
HK_SAVE_STATE_SLOT_2,
@ -96,6 +99,7 @@ enum Hotkey
HK_SAVE_STATE_SLOT_8,
HK_SAVE_STATE_SLOT_9,
HK_SAVE_STATE_SLOT_10,
HK_SAVE_STATE_SLOT_SELECTED,
HK_SELECT_STATE_SLOT_1,
HK_SELECT_STATE_SLOT_2,
@ -108,9 +112,6 @@ enum Hotkey
HK_SELECT_STATE_SLOT_9,
HK_SELECT_STATE_SLOT_10,
HK_SAVE_STATE_SLOT_SELECTED,
HK_LOAD_STATE_SLOT_SELECTED,
HK_LOAD_LAST_STATE_1,
HK_LOAD_LAST_STATE_2,
HK_LOAD_LAST_STATE_3,
@ -134,9 +135,38 @@ enum Hotkey
NUM_HOTKEYS,
};
enum HotkeyGroup : int
{
HKGP_GENERAL,
HKGP_VOLUME,
HKGP_SPEED,
HKGP_FRANE_ADVANCE,
HKGP_MOVIE,
HKGP_WII,
HKGP_GRAPHICS_TOGGLES,
HKGP_IR,
HKGP_FREELOOK,
HKGP_3D_TOGGLE,
HKGP_3D_DEPTH,
HKGP_LOAD_STATE,
HKGP_SAVE_STATE,
HKGP_SELECT_STATE,
HKGP_LOAD_LAST_STATE,
HKGP_STATE_MISC,
NUM_HOTKEY_GROUPS,
};
struct HotkeyGroupInfo
{
std::string name;
Hotkey first;
Hotkey last;
};
struct HotkeyStatus
{
u32 button[(NUM_HOTKEYS + 31) / 32];
u32 button[NUM_HOTKEY_GROUPS];
s8 err;
};
@ -148,10 +178,15 @@ public:
void GetInput(HotkeyStatus* const hk);
std::string GetName() const override;
ControlGroup* GetHotkeyGroup(HotkeyGroup group) const;
ControlGroup* GetOptionsGroup() const;
int FindGroupByID(int id) const;
int GetIndexForGroup(int group, int id) const;
void LoadDefaults(const ControllerInterface& ciface) override;
private:
Buttons* m_keys[(NUM_HOTKEYS + 31) / 32];
Buttons* m_keys[NUM_HOTKEY_GROUPS];
std::array<ControlGroup*, NUM_HOTKEY_GROUPS> m_hotkey_groups;
ControlGroup* m_options;
};
@ -162,6 +197,8 @@ void Shutdown();
void LoadConfig();
InputConfig* GetConfig();
ControllerEmu::ControlGroup* GetHotkeyGroup(HotkeyGroup group);
ControllerEmu::ControlGroup* GetOptionsGroup();
void GetStatus();
bool IsEnabled();
void Enable(bool enable_toggle);

View file

@ -533,6 +533,11 @@ void ExecuteCommand(u32 address)
{
result = device->IOCtl(address);
}
else
{
Memory::Write_U32(FS_EINVAL, address + 4);
result = IWII_IPC_HLE_Device::GetDefaultReply();
}
break;
}
case IPC_CMD_IOCTLV:
@ -541,6 +546,11 @@ void ExecuteCommand(u32 address)
{
result = device->IOCtlV(address);
}
else
{
Memory::Write_U32(FS_EINVAL, address + 4);
result = IWII_IPC_HLE_Device::GetDefaultReply();
}
break;
}
default:

View file

@ -6,27 +6,27 @@
// File description
// -------------
/* Here we handle /dev/es requests. We have cases for these functions, the exact
DevKitPro/libogc name is in parenthesis:
DevKitPro/libogc name is in parenthesis:
0x20 GetTitleID (ES_GetTitleID) (Input: none, Output: 8 bytes)
0x1d GetDataDir (ES_GetDataDir) (Input: 8 bytes, Output: 30 bytes)
0x20 GetTitleID (ES_GetTitleID) (Input: none, Output: 8 bytes)
0x1d GetDataDir (ES_GetDataDir) (Input: 8 bytes, Output: 30 bytes)
0x1b DiGetTicketView (Input: none, Output: 216 bytes)
0x16 GetConsumption (Input: 8 bytes, Output: 0 bytes, 4 bytes) // there are two output buffers
0x1b DiGetTicketView (Input: none, Output: 216 bytes)
0x16 GetConsumption (Input: 8 bytes, Output: 0 bytes, 4 bytes) // there are two output buffers
0x12 GetNumTicketViews (ES_GetNumTicketViews) (Input: 8 bytes, Output: 4 bytes)
0x14 GetTMDViewSize (ES_GetTMDViewSize) (Input: ?, Output: ?) // I don't get this anymore,
it used to come after 0x12
0x12 GetNumTicketViews (ES_GetNumTicketViews) (Input: 8 bytes, Output: 4 bytes)
0x14 GetTMDViewSize (ES_GetTMDViewSize) (Input: ?, Output: ?) // I don't get this anymore,
it used to come after 0x12
but only the first two are correctly supported. For the other four we ignore any potential
input and only write zero to the out buffer. However, most games only use first two,
but some Nintendo developed games use the other ones to:
but only the first two are correctly supported. For the other four we ignore any potential
input and only write zero to the out buffer. However, most games only use first two,
but some Nintendo developed games use the other ones to:
0x1b: Mario Galaxy, Mario Kart, SSBB
0x16: Mario Galaxy, Mario Kart, SSBB
0x12: Mario Kart
0x14: Mario Kart: But only if we don't return a zeroed out buffer for the 0x12 question,
and instead answer for example 1 will this question appear.
0x1b: Mario Galaxy, Mario Kart, SSBB
0x16: Mario Galaxy, Mario Kart, SSBB
0x12: Mario Kart
0x14: Mario Kart: But only if we don't return a zeroed out buffer for the 0x12 question,
and instead answer for example 1 will this question appear.
*/
// =============
@ -73,26 +73,26 @@ CWII_IPC_HLE_Device_es::CWII_IPC_HLE_Device_es(u32 device_id, const std::string&
}
static u8 key_sd[0x10] = { 0xab, 0x01, 0xb9, 0xd8, 0xe1, 0x62, 0x2b, 0x08,
0xaf, 0xba, 0xd8, 0x4d, 0xbf, 0xc2, 0xa5, 0x5d };
0xaf, 0xba, 0xd8, 0x4d, 0xbf, 0xc2, 0xa5, 0x5d };
static u8 key_ecc[0x1e] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
static u8 key_empty[0x10] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
// default key table
u8* CWII_IPC_HLE_Device_es::keyTable[11] = {
key_ecc, // ECC Private Key
key_empty, // Console ID
key_empty, // NAND AES Key
key_empty, // NAND HMAC
key_empty, // Common Key
key_empty, // PRNG seed
key_sd, // SD Key
key_empty, // Unknown
key_empty, // Unknown
key_empty, // Unknown
key_empty, // Unknown
key_ecc, // ECC Private Key
key_empty, // Console ID
key_empty, // NAND AES Key
key_empty, // NAND HMAC
key_empty, // Common Key
key_empty, // PRNG seed
key_sd, // SD Key
key_empty, // Unknown
key_empty, // Unknown
key_empty, // Unknown
key_empty, // Unknown
};
CWII_IPC_HLE_Device_es::~CWII_IPC_HLE_Device_es()
@ -937,6 +937,7 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress)
{
_dbg_assert_(WII_IPC_ES, Buffer.NumberInBuffer == 2);
bool bSuccess = false;
bool bReset = false;
u16 IOSv = 0xffff;
u64 TitleID = Memory::Read_U64(Buffer.InBuffer[0].m_Address);
@ -968,13 +969,14 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress)
if (pDolLoader->IsValid())
{
pDolLoader->Load(); // TODO: Check why sysmenu does not load the DOL correctly
// WADs start with address translation off at the given entry point.
//
// The state of other CPU registers (like the BAT registers) doesn't matter much
// because the WAD initializes everything itself anyway.
// NAND titles start with address translation off at 0x3400 (via the PPC bootstub)
//
// The state of other CPU registers (like the BAT registers) doesn't matter much
// because the realmode code at 0x3400 initializes everything itself anyway.
MSR = 0;
PC = pDolLoader->GetEntryPoint();
PC = 0x3400;
bSuccess = true;
bReset = true;
}
else
{
@ -1045,7 +1047,12 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress)
Memory::Write_U32(Memory::Read_U32(0x00003140), 0x00003188);
// TODO: provide correct return code when bSuccess= false
Memory::Write_U32(0, _CommandAddress + 0x4);
// Note: If we just reset the PPC, don't write anything to the command buffer. This
// could clobber the DOL we just loaded.
if (!bReset)
{
Memory::Write_U32(0, _CommandAddress + 0x4);
}
ERROR_LOG(WII_IPC_ES,
"IOCTL_ES_LAUNCH %016" PRIx64 " %08x %016" PRIx64 " %08x %016" PRIx64 " %04x",
@ -1055,10 +1062,13 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress)
// This is necessary because Reset(true) above deleted this object. Ew.
// The original hardware overwrites the command type with the async reply type.
Memory::Write_U32(IPC_REP_ASYNC, _CommandAddress);
// IOS also seems to write back the command that was responded to in the FD field.
Memory::Write_U32(IPC_CMD_IOCTLV, _CommandAddress + 8);
if (!bReset)
{
// The original hardware overwrites the command type with the async reply type.
Memory::Write_U32(IPC_REP_ASYNC, _CommandAddress);
// IOS also seems to write back the command that was responded to in the FD field.
Memory::Write_U32(IPC_CMD_IOCTLV, _CommandAddress + 8);
}
// Generate a "reply" to the IPC command. ES_LAUNCH is unique because it
// involves restarting IOS; IOS generates two acknowledgements in a row.
@ -1069,9 +1079,9 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress)
case IOCTL_ES_CHECKKOREAREGION: // note by DacoTaco : name is unknown, i just tried to name it
// SOMETHING
// IOS70 has this to let system menu 4.2 check if the console is region changed. it returns
// -1017
// if the IOS didn't find the Korean keys and 0 if it does. 0 leads to a error 003
// IOS70 has this to let system menu 4.2 check if the console is region changed. it returns
// -1017
// if the IOS didn't find the Korean keys and 0 if it does. 0 leads to a error 003
INFO_LOG(WII_IPC_ES, "IOCTL_ES_CHECKKOREAREGION: Title checked for Korean keys.");
Memory::Write_U32(ES_PARAMTER_SIZE_OR_ALIGNMENT, _CommandAddress + 0x4);
return GetDefaultReply();

View file

@ -22,7 +22,7 @@
#include "Core/IPC_HLE/WII_IPC_HLE_Device_FileIO.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device_fs.h"
bool IsValidWiiPath(const std::string& path)
static bool IsValidWiiPath(const std::string& path)
{
return path.compare(0, 1, "/") == 0;
}

View file

@ -50,7 +50,7 @@ IPCCommandResult CWII_IPC_HLE_Device_usb_ven::IOCtlV(u32 command_address)
IPCCommandResult CWII_IPC_HLE_Device_usb_ven::IOCtl(u32 command_address)
{
IPCCommandResult reply = GetNoReply();
IPCCommandResult reply = GetDefaultReply();
u32 command = Memory::Read_U32(command_address + 0x0c);
u32 buffer_in = Memory::Read_U32(command_address + 0x10);
u32 buffer_in_size = Memory::Read_U32(command_address + 0x14);

View file

@ -40,6 +40,17 @@ set(GUI_SRCS
NetPlay/NetPlaySetupFrame.cpp
NetPlay/NetWindow.cpp
NetPlay/PadMapDialog.cpp
Input/InputConfigDiag.cpp
Input/InputConfigDiagBitmaps.cpp
Input/HotkeyInputConfigDiag.cpp
Input/GCPadInputConfigDiag.cpp
Input/GCKeyboardInputConfigDiag.cpp
Input/WiimoteInputConfigDiag.cpp
Input/NunchukInputConfigDiag.cpp
Input/ClassicInputConfigDiag.cpp
Input/GuitarInputConfigDiag.cpp
Input/DrumsInputConfigDiag.cpp
Input/TurntableInputConfigDiag.cpp
DolphinSlider.cpp
FifoPlayerDlg.cpp
Frame.cpp
@ -48,8 +59,6 @@ set(GUI_SRCS
GameListCtrl.cpp
ISOFile.cpp
ISOProperties.cpp
InputConfigDiag.cpp
InputConfigDiagBitmaps.cpp
LogConfigWindow.cpp
LogWindow.cpp
Main.cpp

View file

@ -24,7 +24,7 @@
#include "Core/HotkeyManager.h"
#include "DolphinWX/Config/InterfaceConfigPane.h"
#include "DolphinWX/Frame.h"
#include "DolphinWX/InputConfigDiag.h"
#include "DolphinWX/Input/InputConfigDiag.h"
#include "DolphinWX/WxUtils.h"
#if defined(HAVE_XRANDR) && HAVE_XRANDR
@ -39,7 +39,7 @@ static const std::array<std::string, 29> language_ids{ {
"pl", "pt", "pt_BR", "ro", "sr", "sv", "tr",
"el", "ru", "ar", "fa", "ko", "ja", "zh_CN", "zh_TW",
} };
} };
InterfaceConfigPane::InterfaceConfigPane(wxWindow* parent, wxWindowID id) : wxPanel(parent, id)
{

View file

@ -33,7 +33,10 @@
#include "DolphinWX/Config/GCAdapterConfigDiag.h"
#include "DolphinWX/ControllerConfigDiag.h"
#include "DolphinWX/DolphinSlider.h"
#include "DolphinWX/InputConfigDiag.h"
#include "DolphinWX/Input/GCKeyboardInputConfigDiag.h"
#include "DolphinWX/Input/GCPadInputConfigDiag.h"
#include "DolphinWX/Input/InputConfigDiag.h"
#include "DolphinWX/Input/WiimoteInputConfigDiag.h"
#include "DolphinWX/WxUtils.h"
#include "InputCommon/GCAdapter.h"
@ -44,9 +47,9 @@
ControllerConfigDiag::ControllerConfigDiag(wxWindow* const parent)
: wxDialog(parent, wxID_ANY, _("Dolphin Controller Configuration"))
{
m_gc_pad_type_strs = { {_("None"), _("Standard Controller"), _("GameCube Adapter for Wii U"),
_("Steering Wheel"), _("Dance Mat"), _("DK Bongos"), _("GBA"),
_("Keyboard")} };
m_gc_pad_type_strs = { { _("None"), _("Standard Controller"), _("GameCube Adapter for Wii U"),
_("Steering Wheel"), _("Dance Mat"), _("DK Bongos"), _("GBA"),
_("Keyboard") } };
const int space5 = FromDIP(5);
@ -285,7 +288,7 @@ wxSizer* ControllerConfigDiag::CreatePassthroughBTConfigSizer()
wxSizer* ControllerConfigDiag::CreateEmulatedBTConfigSizer()
{
const std::array<wxString, 4> src_choices{
{_("None"), _("Emulated Wii Remote"), _("Real Wii Remote"), _("Hybrid Wii Remote")} };
{ _("None"), _("Emulated Wii Remote"), _("Real Wii Remote"), _("Hybrid Wii Remote") } };
const int space5 = FromDIP(5);
@ -447,20 +450,24 @@ void ControllerConfigDiag::OnGameCubeConfigButton(wxCommandEvent& event)
if (SConfig::GetInstance().m_SIDevice[port_num] == SIDEVICE_GC_KEYBOARD)
{
InputConfigDialog config_diag(this, *key_plugin, _("GameCube Keyboard Configuration"),
port_num);
GCKeyboardInputConfigDialog config_diag(
this, *key_plugin,
wxString::Format("GameCube Keyboard Configuration Port %i", port_num + 1), port_num);
config_diag.ShowModal();
}
else if (SConfig::GetInstance().m_SIDevice[port_num] == SIDEVICE_WIIU_ADAPTER)
{
GCAdapterConfigDiag config_diag(this, _("Wii U GameCube Controller Adapter Configuration"),
GCAdapterConfigDiag config_diag(
this,
wxString::Format("Wii U GameCube Controller Adapter Configuration Port %i", port_num + 1),
port_num);
config_diag.ShowModal();
}
else
{
InputConfigDialog config_diag(this, *pad_plugin, _("GameCube Controller Configuration"),
port_num);
GCPadInputConfigDialog config_diag(
this, *pad_plugin,
wxString::Format("GameCube Controller Configuration Port %i", port_num + 1), port_num);
config_diag.ShowModal();
}
@ -494,9 +501,12 @@ void ControllerConfigDiag::OnWiimoteConfigButton(wxCommandEvent& ev)
HotkeyManagerEmu::Enable(false);
InputConfigDialog m_ConfigFrame(this, *wiimote_plugin,
_("Dolphin Emulated Wii Remote Configuration"),
m_wiimote_index_from_config_id[ev.GetId()]);
const int port_num = m_wiimote_index_from_config_id[ev.GetId()];
WiimoteInputConfigDialog m_ConfigFrame(
this, *wiimote_plugin,
wxString::Format("Dolphin Emulated Wii Remote Configuration Port %i", port_num + 1),
port_num);
m_ConfigFrame.ShowModal();
HotkeyManagerEmu::Enable(true);

View file

@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include <array>
#include <chrono>
#include <cstdio>
#include <string>
#include <vector>
@ -302,6 +303,7 @@ void CCodeWindow::SingleStep()
CPU::StepOpcode(&sync_event);
sync_event.WaitFor(std::chrono::milliseconds(20));
PowerPC::SetMode(old_mode);
Core::DisplayMessage(_("Step successful!").ToStdString(), 2000);
// Will get a IDM_UPDATE_DISASM_DIALOG. Don't update the GUI here.
}
}
@ -316,6 +318,7 @@ void CCodeWindow::StepOver()
PowerPC::breakpoints.ClearAllTemporary();
PowerPC::breakpoints.Add(PC + 4, true);
CPU::EnableStepping(false);
Core::DisplayMessage(_("Step over in progress...").ToStdString(), 2000);
}
else
{
@ -324,9 +327,12 @@ void CCodeWindow::StepOver()
}
}
// Returns true on a blr or on a bclr that evaluates to true.
// Returns true on a rfi, blr or on a bclr that evaluates to true.
static bool WillInstructionReturn(UGeckoInstruction inst)
{
// Is a rfi instruction
if (inst.hex == 0x4C000064u)
return true;
bool counter = (inst.BO_2 >> 2 & 1) != 0 || (CTR != 0) != ((inst.BO_2 >> 1 & 1) != 0);
bool condition = inst.BO_2 >> 4 != 0 || GetCRBit(inst.BI_2) == (inst.BO_2 >> 3 & 1);
bool isBclr = inst.OPCD_7 == 0b010011 && (inst.hex >> 1 & 0b10000) != 0;
@ -340,44 +346,55 @@ void CCodeWindow::StepOut()
CPU::PauseAndLock(true, false);
PowerPC::breakpoints.ClearAllTemporary();
// Keep stepping until the next return instruction or timeout after one second
u64 timeout = SystemTimers::GetTicksPerSecond();
u64 steps = 0;
// Keep stepping until the next return instruction or timeout after five seconds
using clock = std::chrono::steady_clock;
clock::time_point timeout = clock::now() + std::chrono::seconds(5);
PowerPC::CoreMode old_mode = PowerPC::GetMode();
PowerPC::SetMode(PowerPC::MODE_INTERPRETER);
UGeckoInstruction inst = PowerPC::HostRead_Instruction(PC);
// Loop until either the current instruction is a return instruction with no Link flag
// or a breakpoint is detected so it can step at the breakpoint.
while (!(WillInstructionReturn(inst)) && steps < timeout &&
!PowerPC::breakpoints.IsAddressBreakPoint(PC))
// or a breakpoint is detected so it can step at the breakpoint. If the PC is currently
// on a breakpoint, skip it.
UGeckoInstruction inst = PowerPC::HostRead_Instruction(PC);
do
{
if (WillInstructionReturn(inst))
{
PowerPC::SingleStep();
break;
}
if (inst.LK)
{
// Step over branches
u32 next_pc = PC + 4;
while (PC != next_pc && steps < timeout)
do
{
PowerPC::SingleStep();
++steps;
}
} while (PC != next_pc && clock::now() < timeout &&
!PowerPC::breakpoints.IsAddressBreakPoint(PC));
}
else
{
PowerPC::SingleStep();
++steps;
}
inst = PowerPC::HostRead_Instruction(PC);
}
// If the loop stopped because of a breakpoint, we do not want to step to
// an instruction after it.
if (!PowerPC::breakpoints.IsAddressBreakPoint(PC))
PowerPC::SingleStep();
} while (clock::now() < timeout && !PowerPC::breakpoints.IsAddressBreakPoint(PC));
PowerPC::SetMode(old_mode);
CPU::PauseAndLock(false, false);
wxCommandEvent ev(wxEVT_HOST_COMMAND, IDM_UPDATE_DISASM_DIALOG);
GetEventHandler()->ProcessEvent(ev);
if (PowerPC::breakpoints.IsAddressBreakPoint(PC))
Core::DisplayMessage(_("Breakpoint encountered! Step out aborted.").ToStdString(), 2000);
else if (clock::now() >= timeout)
Core::DisplayMessage(_("Step out timed out!").ToStdString(), 2000);
else
Core::DisplayMessage(_("Step out successful!").ToStdString(), 2000);
// Update all toolbars in the aui manager
Parent->UpdateGUI();
}

View file

@ -97,6 +97,17 @@
<ClCompile Include="Debugger\WatchView.cpp" />
<ClCompile Include="Debugger\WatchWindow.cpp" />
<ClCompile Include="DolphinSlider.cpp" />
<ClCompile Include="Input\ClassicInputConfigDiag.cpp" />
<ClCompile Include="Input\DrumsInputConfigDiag.cpp" />
<ClCompile Include="Input\GCKeyboardInputConfigDiag.cpp" />
<ClCompile Include="Input\GCPadInputConfigDiag.cpp" />
<ClCompile Include="Input\GuitarInputConfigDiag.cpp" />
<ClCompile Include="Input\HotkeyInputConfigDiag.cpp" />
<ClCompile Include="Input\InputConfigDiag.cpp" />
<ClCompile Include="Input\InputConfigDiagBitmaps.cpp" />
<ClCompile Include="Input\NunchukInputConfigDiag.cpp" />
<ClCompile Include="Input\TurntableInputConfigDiag.cpp" />
<ClCompile Include="Input\WiimoteInputConfigDiag.cpp" />
<ClCompile Include="NetPlay\ChangeGameDialog.cpp" />
<ClCompile Include="NetPlay\MD5Dialog.cpp" />
<ClCompile Include="NetPlay\NetPlayLauncher.cpp" />
@ -107,8 +118,6 @@
<ClCompile Include="FrameAui.cpp" />
<ClCompile Include="FrameTools.cpp" />
<ClCompile Include="GameListCtrl.cpp" />
<ClCompile Include="InputConfigDiag.cpp" />
<ClCompile Include="InputConfigDiagBitmaps.cpp" />
<ClCompile Include="ISOFile.cpp" />
<ClCompile Include="ISOProperties.cpp" />
<ClCompile Include="LogConfigWindow.cpp" />
@ -143,6 +152,16 @@
<ClInclude Include="Config\PathConfigPane.h" />
<ClInclude Include="Config\WiiConfigPane.h" />
<ClInclude Include="DolphinSlider.h" />
<ClInclude Include="Input\ClassicInputConfigDiag.h" />
<ClInclude Include="Input\DrumsInputConfigDiag.h" />
<ClInclude Include="Input\GCKeyboardInputConfigDiag.h" />
<ClInclude Include="Input\GCPadInputConfigDiag.h" />
<ClInclude Include="Input\GuitarInputConfigDiag.h" />
<ClInclude Include="Input\HotkeyInputConfigDiag.h" />
<ClInclude Include="Input\InputConfigDiag.h" />
<ClInclude Include="Input\NunchukInputConfigDiag.h" />
<ClInclude Include="Input\TurntableInputConfigDiag.h" />
<ClInclude Include="Input\WiimoteInputConfigDiag.h" />
<ClInclude Include="NetPlay\ChangeGameDialog.h" />
<ClInclude Include="NetPlay\MD5Dialog.h" />
<ClInclude Include="NetPlay\NetPlayLauncher.h" />
@ -177,7 +196,6 @@
<ClInclude Include="Frame.h" />
<ClInclude Include="GameListCtrl.h" />
<ClInclude Include="Globals.h" />
<ClInclude Include="InputConfigDiag.h" />
<ClInclude Include="ISOFile.h" />
<ClInclude Include="ISOProperties.h" />
<ClInclude Include="LogConfigWindow.h" />

View file

@ -104,12 +104,6 @@
<ClCompile Include="NetPlay\NetWindow.cpp">
<Filter>GUI\NetPlay</Filter>
</ClCompile>
<ClCompile Include="InputConfigDiag.cpp">
<Filter>GUI\InputConfig</Filter>
</ClCompile>
<ClCompile Include="InputConfigDiagBitmaps.cpp">
<Filter>GUI\InputConfig</Filter>
</ClCompile>
<ClCompile Include="Debugger\DebuggerPanel.cpp">
<Filter>GUI\Video</Filter>
</ClCompile>
@ -221,6 +215,39 @@
<ClCompile Include="DolphinSlider.cpp">
<Filter>GUI\Widgets</Filter>
</ClCompile>
<ClCompile Include="Input\ClassicInputConfigDiag.cpp">
<Filter>GUI\InputConfig</Filter>
</ClCompile>
<ClCompile Include="Input\DrumsInputConfigDiag.cpp">
<Filter>GUI\InputConfig</Filter>
</ClCompile>
<ClCompile Include="Input\GCKeyboardInputConfigDiag.cpp">
<Filter>GUI\InputConfig</Filter>
</ClCompile>
<ClCompile Include="Input\GCPadInputConfigDiag.cpp">
<Filter>GUI\InputConfig</Filter>
</ClCompile>
<ClCompile Include="Input\GuitarInputConfigDiag.cpp">
<Filter>GUI\InputConfig</Filter>
</ClCompile>
<ClCompile Include="Input\HotkeyInputConfigDiag.cpp">
<Filter>GUI\InputConfig</Filter>
</ClCompile>
<ClCompile Include="Input\InputConfigDiag.cpp">
<Filter>GUI\InputConfig</Filter>
</ClCompile>
<ClCompile Include="Input\InputConfigDiagBitmaps.cpp">
<Filter>GUI\InputConfig</Filter>
</ClCompile>
<ClCompile Include="Input\NunchukInputConfigDiag.cpp">
<Filter>GUI\InputConfig</Filter>
</ClCompile>
<ClCompile Include="Input\TurntableInputConfigDiag.cpp">
<Filter>GUI\InputConfig</Filter>
</ClCompile>
<ClCompile Include="Input\WiimoteInputConfigDiag.cpp">
<Filter>GUI\InputConfig</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Main.h" />
@ -290,9 +317,6 @@
<ClInclude Include="NetPlay\NetWindow.h">
<Filter>GUI\NetPlay</Filter>
</ClInclude>
<ClInclude Include="InputConfigDiag.h">
<Filter>GUI\InputConfig</Filter>
</ClInclude>
<ClInclude Include="Debugger\DebuggerPanel.h">
<Filter>GUI\Video</Filter>
</ClInclude>
@ -403,7 +427,37 @@
</ClInclude>
<ClInclude Include="DolphinSlider.h">
<Filter>GUI\Widgets</Filter>
</ClInclude>
</ClInclude>
<ClInclude Include="Input\ClassicInputConfigDiag.h">
<Filter>GUI\InputConfig</Filter>
</ClInclude>
<ClInclude Include="Input\DrumsInputConfigDiag.h">
<Filter>GUI\InputConfig</Filter>
</ClInclude>
<ClInclude Include="Input\GCKeyboardInputConfigDiag.h">
<Filter>GUI\InputConfig</Filter>
</ClInclude>
<ClInclude Include="Input\GCPadInputConfigDiag.h">
<Filter>GUI\InputConfig</Filter>
</ClInclude>
<ClInclude Include="Input\GuitarInputConfigDiag.h">
<Filter>GUI\InputConfig</Filter>
</ClInclude>
<ClInclude Include="Input\HotkeyInputConfigDiag.h">
<Filter>GUI\InputConfig</Filter>
</ClInclude>
<ClInclude Include="Input\InputConfigDiag.h">
<Filter>GUI\InputConfig</Filter>
</ClInclude>
<ClInclude Include="Input\NunchukInputConfigDiag.h">
<Filter>GUI\InputConfig</Filter>
</ClInclude>
<ClInclude Include="Input\TurntableInputConfigDiag.h">
<Filter>GUI\InputConfig</Filter>
</ClInclude>
<ClInclude Include="Input\WiimoteInputConfigDiag.h">
<Filter>GUI\InputConfig</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Text Include="CMakeLists.txt" />

View file

@ -5,6 +5,6 @@
<LocalDebuggerCommand>$(BinaryOutputDir)$(TargetFileName)</LocalDebuggerCommand>
<LocalDebuggerWorkingDirectory>$(BinaryOutputDir)</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<ShowAllFiles>false</ShowAllFiles>
<ShowAllFiles>true</ShowAllFiles>
</PropertyGroup>
</Project>

View file

@ -65,7 +65,8 @@
#include "DolphinWX/GameListCtrl.h"
#include "DolphinWX/Globals.h"
#include "DolphinWX/ISOFile.h"
#include "DolphinWX/InputConfigDiag.h"
#include "DolphinWX/Input/HotkeyInputConfigDiag.h"
#include "DolphinWX/Input/InputConfigDiag.h"
#include "DolphinWX/LogWindow.h"
#include "DolphinWX/MainMenuBar.h"
#include "DolphinWX/MainToolBar.h"
@ -997,7 +998,7 @@ void CFrame::OnConfigHotkey(wxCommandEvent& WXUNUSED(event))
HotkeyManagerEmu::Enable(false);
InputConfigDialog m_ConfigFrame(this, *hotkey_plugin, _("Dolphin Hotkeys"));
HotkeyInputConfigDialog m_ConfigFrame(this, *hotkey_plugin, _("Dolphin Hotkeys"));
m_ConfigFrame.ShowModal();
// Update references in case controllers were refreshed

View file

@ -0,0 +1,50 @@
// Copyright 2016 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DolphinWX/Input/ClassicInputConfigDiag.h"
#include "Core/HW/Wiimote.h"
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
ClassicInputConfigDialog::ClassicInputConfigDialog(wxWindow* const parent, InputConfig& config,
const wxString& name, const int port_num)
: InputConfigDialog(parent, config, name, port_num)
{
const int space5 = FromDIP(5);
auto* const group_box_buttons = new ControlGroupBox(
Wiimote::GetClassicGroup(port_num, WiimoteEmu::ClassicGroup::Buttons), this, this);
auto* const group_box_dpad = new ControlGroupBox(
Wiimote::GetClassicGroup(port_num, WiimoteEmu::ClassicGroup::DPad), this, this);
auto* const group_box_left_stick = new ControlGroupBox(
Wiimote::GetClassicGroup(port_num, WiimoteEmu::ClassicGroup::LeftStick), this, this);
auto* const group_box_right_stick = new ControlGroupBox(
Wiimote::GetClassicGroup(port_num, WiimoteEmu::ClassicGroup::RightStick), this, this);
auto* const group_box_triggers = new ControlGroupBox(
Wiimote::GetClassicGroup(port_num, WiimoteEmu::ClassicGroup::Triggers), this, this);
auto* const controls_sizer = new wxBoxSizer(wxHORIZONTAL);
controls_sizer->AddSpacer(space5);
controls_sizer->Add(group_box_buttons, 0, wxEXPAND);
controls_sizer->AddSpacer(space5);
controls_sizer->Add(group_box_dpad, 0, wxEXPAND);
controls_sizer->AddSpacer(space5);
controls_sizer->Add(group_box_left_stick, 0, wxEXPAND);
controls_sizer->AddSpacer(space5);
controls_sizer->Add(group_box_right_stick, 0, wxEXPAND);
controls_sizer->AddSpacer(space5);
controls_sizer->Add(group_box_triggers, 0, wxEXPAND);
controls_sizer->AddSpacer(space5);
auto* const szr_main = new wxBoxSizer(wxVERTICAL);
szr_main->AddSpacer(space5);
szr_main->Add(controls_sizer, 1, wxEXPAND | wxLEFT | wxRIGHT, space5);
szr_main->AddSpacer(space5);
szr_main->Add(CreateButtonSizer(wxCLOSE | wxNO_DEFAULT), 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
szr_main->AddSpacer(space5);
SetSizerAndFit(szr_main);
Center();
UpdateGUI();
}

View file

@ -0,0 +1,14 @@
// Copyright 2016 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include "DolphinWX/Input/InputConfigDiag.h"
class ClassicInputConfigDialog final : public InputConfigDialog
{
public:
ClassicInputConfigDialog(wxWindow* parent, InputConfig& config, const wxString& name,
int port_num = 0);
};

View file

@ -0,0 +1,46 @@
// Copyright 2016 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DolphinWX/Input/DrumsInputConfigDiag.h"
#include "Core/HW/Wiimote.h"
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
DrumsInputConfigDialog::DrumsInputConfigDialog(wxWindow* const parent, InputConfig& config,
const wxString& name, const int port_num)
: InputConfigDialog(parent, config, name, port_num)
{
const int space5 = FromDIP(5);
auto* const group_box_buttons = new ControlGroupBox(
Wiimote::GetDrumsGroup(port_num, WiimoteEmu::DrumsGroup::Buttons), this, this);
auto* const group_box_pads = new ControlGroupBox(
Wiimote::GetDrumsGroup(port_num, WiimoteEmu::DrumsGroup::Pads), this, this);
auto* const buttons_pads_sizer = new wxBoxSizer(wxVERTICAL);
buttons_pads_sizer->Add(group_box_buttons);
buttons_pads_sizer->AddSpacer(space5);
buttons_pads_sizer->Add(group_box_pads);
auto* const group_box_stick = new ControlGroupBox(
Wiimote::GetDrumsGroup(port_num, WiimoteEmu::DrumsGroup::Stick), this, this);
auto* const controls_sizer = new wxBoxSizer(wxHORIZONTAL);
controls_sizer->AddSpacer(space5);
controls_sizer->Add(buttons_pads_sizer, 0, wxEXPAND);
controls_sizer->AddSpacer(space5);
controls_sizer->Add(group_box_stick, 0, wxEXPAND);
controls_sizer->AddSpacer(space5);
auto* const szr_main = new wxBoxSizer(wxVERTICAL);
szr_main->AddSpacer(space5);
szr_main->Add(controls_sizer, 1, wxEXPAND | wxLEFT | wxRIGHT, space5);
szr_main->AddSpacer(space5);
szr_main->Add(CreateButtonSizer(wxCLOSE | wxNO_DEFAULT), 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
szr_main->AddSpacer(space5);
SetSizerAndFit(szr_main);
Center();
UpdateGUI();
}

View file

@ -0,0 +1,14 @@
// Copyright 2016 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include "DolphinWX/Input/InputConfigDiag.h"
class DrumsInputConfigDialog final : public InputConfigDialog
{
public:
DrumsInputConfigDialog(wxWindow* parent, InputConfig& config, const wxString& name,
int port_num = 0);
};

View file

@ -0,0 +1,83 @@
// Copyright 2016 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DolphinWX/Input/GCKeyboardInputConfigDiag.h"
#include "Core/HW/GCKeyboard.h"
#include "Core/HW/GCKeyboardEmu.h"
enum class KeyboardGroup;
GCKeyboardInputConfigDialog::GCKeyboardInputConfigDialog(wxWindow* const parent,
InputConfig& config, const wxString& name,
const int port_num)
: InputConfigDialog(parent, config, name, port_num)
{
const int space5 = FromDIP(5);
auto* const device_chooser = CreateDeviceChooserGroupBox();
auto* const reset_sizer = CreaterResetGroupBox(wxHORIZONTAL);
auto* const profile_chooser = CreateProfileChooserGroupBox();
auto* const group_box_keys0x =
new ControlGroupBox(Keyboard::GetGroup(port_num, KeyboardGroup::Kb0x), this, this);
auto* const group_box_keys1x =
new ControlGroupBox(Keyboard::GetGroup(port_num, KeyboardGroup::Kb1x), this, this);
auto* const group_box_keys2x =
new ControlGroupBox(Keyboard::GetGroup(port_num, KeyboardGroup::Kb2x), this, this);
auto* const group_box_keys3x =
new ControlGroupBox(Keyboard::GetGroup(port_num, KeyboardGroup::Kb3x), this, this);
auto* const group_box_keys4x =
new ControlGroupBox(Keyboard::GetGroup(port_num, KeyboardGroup::Kb4x), this, this);
auto* const group_box_keys5x =
new ControlGroupBox(Keyboard::GetGroup(port_num, KeyboardGroup::Kb5x), this, this);
auto* const group_box_options =
new ControlGroupBox(Keyboard::GetGroup(port_num, KeyboardGroup::Options), this, this);
auto* const key5x_options_sizer = new wxBoxSizer(wxVERTICAL);
key5x_options_sizer->Add(group_box_keys5x);
key5x_options_sizer->AddSpacer(space5);
key5x_options_sizer->Add(group_box_options);
auto* const controls_sizer = new wxBoxSizer(wxHORIZONTAL);
controls_sizer->AddSpacer(space5);
controls_sizer->Add(group_box_keys0x, 0, wxEXPAND | wxTOP, space5);
controls_sizer->AddSpacer(space5);
controls_sizer->Add(group_box_keys1x, 0, wxEXPAND | wxTOP, space5);
controls_sizer->AddSpacer(space5);
controls_sizer->Add(group_box_keys2x, 0, wxEXPAND | wxTOP, space5);
controls_sizer->AddSpacer(space5);
controls_sizer->Add(group_box_keys3x, 0, wxEXPAND | wxTOP, space5);
controls_sizer->AddSpacer(space5);
controls_sizer->Add(group_box_keys4x, 0, wxEXPAND | wxTOP, space5);
controls_sizer->AddSpacer(space5);
controls_sizer->Add(key5x_options_sizer, 0, wxEXPAND | wxTOP, space5);
controls_sizer->AddSpacer(space5);
auto* const dio = new wxBoxSizer(wxHORIZONTAL);
dio->AddSpacer(space5);
dio->Add(device_chooser, 3, wxEXPAND);
dio->AddSpacer(space5);
dio->Add(reset_sizer, 1, wxEXPAND);
dio->AddSpacer(space5);
dio->Add(profile_chooser, 3, wxEXPAND);
dio->AddSpacer(space5);
auto* const szr_main = new wxBoxSizer(wxVERTICAL);
szr_main->AddSpacer(space5);
szr_main->Add(dio);
szr_main->AddSpacer(space5);
szr_main->Add(controls_sizer, 1, wxEXPAND | wxLEFT | wxRIGHT, space5);
szr_main->AddSpacer(space5);
szr_main->Add(CreateButtonSizer(wxCLOSE | wxNO_DEFAULT), 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
szr_main->AddSpacer(space5);
SetSizerAndFit(szr_main);
Center();
UpdateDeviceComboBox();
UpdateProfileComboBox();
UpdateGUI();
}

View file

@ -0,0 +1,14 @@
// Copyright 2016 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include "DolphinWX/Input/InputConfigDiag.h"
class GCKeyboardInputConfigDialog final : public InputConfigDialog
{
public:
GCKeyboardInputConfigDialog(wxWindow* parent, InputConfig& config, const wxString& name,
int port_num = 0);
};

View file

@ -0,0 +1,83 @@
// Copyright 2016 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DolphinWX/Input/GCPadInputConfigDiag.h"
#include "Core/HW/GCPad.h"
#include "Core/HW/GCPadEmu.h"
GCPadInputConfigDialog::GCPadInputConfigDialog(wxWindow* const parent, InputConfig& config,
const wxString& name, const int port_num)
: InputConfigDialog(parent, config, name, port_num)
{
const int space5 = FromDIP(5);
auto* const device_chooser = CreateDeviceChooserGroupBox();
auto* const reset_sizer = CreaterResetGroupBox(wxHORIZONTAL);
auto* const profile_chooser = CreateProfileChooserGroupBox();
auto* const group_box_buttons =
new ControlGroupBox(Pad::GetGroup(port_num, PadGroup::Buttons), this, this);
auto* const group_box_main_stick =
new ControlGroupBox(Pad::GetGroup(port_num, PadGroup::MainStick), this, this);
auto* const group_box_c_stick =
new ControlGroupBox(Pad::GetGroup(port_num, PadGroup::CStick), this, this);
auto* const group_box_dpad =
new ControlGroupBox(Pad::GetGroup(port_num, PadGroup::DPad), this, this);
auto* const group_box_triggers =
new ControlGroupBox(Pad::GetGroup(port_num, PadGroup::Triggers), this, this);
auto* const group_box_rumble =
new ControlGroupBox(Pad::GetGroup(port_num, PadGroup::Rumble), this, this);
auto* const group_box_options =
new ControlGroupBox(Pad::GetGroup(port_num, PadGroup::Options), this, this);
auto* const triggers_rumble_sizer = new wxBoxSizer(wxVERTICAL);
triggers_rumble_sizer->Add(group_box_triggers, 0, wxEXPAND);
triggers_rumble_sizer->AddSpacer(space5);
triggers_rumble_sizer->Add(group_box_rumble, 0, wxEXPAND);
auto* const dpad_options_sizer = new wxBoxSizer(wxVERTICAL);
dpad_options_sizer->Add(group_box_dpad, 0, wxEXPAND);
dpad_options_sizer->AddSpacer(space5);
dpad_options_sizer->Add(group_box_options, 0, wxEXPAND);
auto* const controls_sizer = new wxBoxSizer(wxHORIZONTAL);
controls_sizer->AddSpacer(space5);
controls_sizer->Add(group_box_buttons, 0, wxEXPAND | wxTOP, space5);
controls_sizer->AddSpacer(space5);
controls_sizer->Add(group_box_main_stick, 0, wxEXPAND | wxTOP, space5);
controls_sizer->AddSpacer(space5);
controls_sizer->Add(group_box_c_stick, 0, wxEXPAND | wxTOP, space5);
controls_sizer->AddSpacer(space5);
controls_sizer->Add(triggers_rumble_sizer, 0, wxEXPAND | wxTOP, space5);
controls_sizer->AddSpacer(space5);
controls_sizer->Add(dpad_options_sizer, 0, wxEXPAND | wxTOP, space5);
controls_sizer->AddSpacer(space5);
auto* const dio = new wxBoxSizer(wxHORIZONTAL);
dio->AddSpacer(space5);
dio->Add(device_chooser, 2, wxEXPAND);
dio->AddSpacer(space5);
dio->Add(reset_sizer, 1, wxEXPAND);
dio->AddSpacer(space5);
dio->Add(profile_chooser, 2, wxEXPAND);
dio->AddSpacer(space5);
auto* const szr_main = new wxBoxSizer(wxVERTICAL);
szr_main->AddSpacer(space5);
szr_main->Add(dio);
szr_main->AddSpacer(space5);
szr_main->Add(controls_sizer, 1, wxEXPAND | wxLEFT | wxRIGHT, space5);
szr_main->AddSpacer(space5);
szr_main->Add(CreateButtonSizer(wxCLOSE | wxNO_DEFAULT), 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
szr_main->AddSpacer(space5);
SetSizerAndFit(szr_main);
Center();
UpdateDeviceComboBox();
UpdateProfileComboBox();
UpdateGUI();
}

View file

@ -0,0 +1,14 @@
// Copyright 2016 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include "DolphinWX/Input/InputConfigDiag.h"
class GCPadInputConfigDialog final : public InputConfigDialog
{
public:
GCPadInputConfigDialog(wxWindow* parent, InputConfig& config, const wxString& name,
int port_num = 0);
};

View file

@ -0,0 +1,58 @@
// Copyright 2016 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DolphinWX/Input/GuitarInputConfigDiag.h"
#include "Core/HW/Wiimote.h"
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
GuitarInputConfigDialog::GuitarInputConfigDialog(wxWindow* const parent, InputConfig& config,
const wxString& name, const int port_num)
: InputConfigDialog(parent, config, name, port_num)
{
const int space5 = FromDIP(5);
auto* const group_box_buttons = new ControlGroupBox(
Wiimote::GetGuitarGroup(port_num, WiimoteEmu::GuitarGroup::Buttons), this, this);
auto* const group_left_strum = new ControlGroupBox(
Wiimote::GetGuitarGroup(port_num, WiimoteEmu::GuitarGroup::Strum), this, this);
auto* const buttons_strum_sizer = new wxBoxSizer(wxVERTICAL);
buttons_strum_sizer->Add(group_box_buttons, 0, wxEXPAND);
buttons_strum_sizer->AddSpacer(space5);
buttons_strum_sizer->Add(group_left_strum, 0, wxEXPAND);
auto* const group_box_frets = new ControlGroupBox(
Wiimote::GetGuitarGroup(port_num, WiimoteEmu::GuitarGroup::Frets), this, this);
ControlGroupBox* group_box_whammy = new ControlGroupBox(
Wiimote::GetGuitarGroup(port_num, WiimoteEmu::GuitarGroup::Whammy), this, this);
auto* const frets_whammy_sizer = new wxBoxSizer(wxVERTICAL);
frets_whammy_sizer->Add(group_box_frets, 0, wxEXPAND);
frets_whammy_sizer->AddSpacer(space5);
frets_whammy_sizer->Add(group_box_whammy, 0, wxEXPAND);
auto* const group_box_stick = new ControlGroupBox(
Wiimote::GetGuitarGroup(port_num, WiimoteEmu::GuitarGroup::Stick), this, this);
auto* const controls_sizer = new wxBoxSizer(wxHORIZONTAL);
controls_sizer->AddSpacer(space5);
controls_sizer->Add(buttons_strum_sizer, 0, wxEXPAND);
controls_sizer->AddSpacer(space5);
controls_sizer->Add(frets_whammy_sizer, 0, wxEXPAND);
controls_sizer->AddSpacer(space5);
controls_sizer->Add(group_box_stick, 0, wxEXPAND);
controls_sizer->AddSpacer(space5);
auto* const szr_main = new wxBoxSizer(wxVERTICAL);
szr_main->AddSpacer(space5);
szr_main->Add(controls_sizer, 1, wxEXPAND | wxLEFT | wxRIGHT, space5);
szr_main->AddSpacer(space5);
szr_main->Add(CreateButtonSizer(wxCLOSE | wxNO_DEFAULT), 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
szr_main->AddSpacer(space5);
SetSizerAndFit(szr_main);
Center();
UpdateGUI();
}

View file

@ -0,0 +1,14 @@
// Copyright 2016 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include "DolphinWX/Input/InputConfigDiag.h"
class GuitarInputConfigDialog final : public InputConfigDialog
{
public:
GuitarInputConfigDialog(wxWindow* parent, InputConfig& config, const wxString& name,
int port_num = 0);
};

View file

@ -0,0 +1,204 @@
// Copyright 2016 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <wx/notebook.h>
#include <wx/panel.h>
#include <wx/sizer.h>
#include "Core/HotkeyManager.h"
#include "DolphinWX/Input/HotkeyInputConfigDiag.h"
enum HotkeyGroup : int;
HotkeyInputConfigDialog::HotkeyInputConfigDialog(wxWindow* const parent, InputConfig& config,
const wxString& name, const int port_num)
: InputConfigDialog(parent, config, name, port_num)
{
const int space5 = FromDIP(5);
auto* const device_chooser = CreateDeviceChooserGroupBox();
auto* const reset_sizer = CreaterResetGroupBox(wxVERTICAL);
auto* const profile_chooser = CreateProfileChooserGroupBox();
auto* const notebook = new wxNotebook(this, wxID_ANY);
// General
auto* const tab_general = new wxPanel(notebook);
auto* const group_box_general =
new ControlGroupBox(HotkeyManagerEmu::GetHotkeyGroup(HKGP_GENERAL), tab_general, this);
auto* const group_box_volume =
new ControlGroupBox(HotkeyManagerEmu::GetHotkeyGroup(HKGP_VOLUME), tab_general, this);
auto* const group_box_speed =
new ControlGroupBox(HotkeyManagerEmu::GetHotkeyGroup(HKGP_SPEED), tab_general, this);
auto* const szr_volume_speed = new wxBoxSizer(wxVERTICAL);
szr_volume_speed->AddSpacer(space5);
szr_volume_speed->Add(group_box_volume, 0, wxEXPAND);
szr_volume_speed->AddSpacer(space5);
szr_volume_speed->Add(group_box_speed, 0, wxEXPAND);
auto* const szr_general = new wxBoxSizer(wxHORIZONTAL);
szr_general->Add(group_box_general, 0, wxEXPAND | wxTOP, space5);
szr_general->AddSpacer(space5);
szr_general->Add(szr_volume_speed, 0, wxEXPAND);
tab_general->SetSizerAndFit(szr_general);
notebook->AddPage(tab_general, "General");
// TAS Tools
auto* const tab_tas = new wxPanel(notebook);
auto* const group_box_frame_advance =
new ControlGroupBox(HotkeyManagerEmu::GetHotkeyGroup(HKGP_FRANE_ADVANCE), tab_tas, this);
auto* const group_box_movie =
new ControlGroupBox(HotkeyManagerEmu::GetHotkeyGroup(HKGP_MOVIE), tab_tas, this);
auto* const szr_tas = new wxBoxSizer(wxHORIZONTAL);
szr_tas->AddSpacer(space5);
szr_tas->Add(group_box_frame_advance, 0, wxEXPAND | wxTOP, space5);
szr_tas->AddSpacer(space5);
szr_tas->Add(group_box_movie, 0, wxEXPAND | wxTOP, space5);
tab_tas->SetSizerAndFit(szr_tas);
notebook->AddPage(tab_tas, "TAS Tools");
// WII and Wii Remote
auto* const tab_wii = new wxPanel(notebook);
auto* const group_box_wii =
new ControlGroupBox(HotkeyManagerEmu::GetHotkeyGroup(HKGP_WII), tab_wii, this);
auto* const szr_wii = new wxBoxSizer(wxHORIZONTAL);
szr_wii->AddSpacer(space5);
szr_wii->Add(group_box_wii, 0, wxEXPAND | wxTOP, space5);
szr_wii->AddSpacer(space5);
tab_wii->SetSizerAndFit(szr_wii);
notebook->AddPage(tab_wii, "Wii and Wii Remote");
// Graphics
auto* const tab_graphics = new wxPanel(notebook);
auto* const group_box_graphics_toggles = new ControlGroupBox(
HotkeyManagerEmu::GetHotkeyGroup(HKGP_GRAPHICS_TOGGLES), tab_graphics, this);
auto* const group_box_ir =
new ControlGroupBox(HotkeyManagerEmu::GetHotkeyGroup(HKGP_IR), tab_graphics, this);
auto* const szr_toggle_ir = new wxBoxSizer(wxVERTICAL);
szr_toggle_ir->Add(group_box_graphics_toggles, 0, wxEXPAND);
szr_toggle_ir->AddSpacer(space5);
szr_toggle_ir->Add(group_box_ir, 0, wxEXPAND);
auto* const group_box_freelook =
new ControlGroupBox(HotkeyManagerEmu::GetHotkeyGroup(HKGP_FREELOOK), tab_graphics, this);
auto* const szr_graphics_toggles = new wxBoxSizer(wxHORIZONTAL);
szr_graphics_toggles->AddSpacer(space5);
szr_graphics_toggles->Add(szr_toggle_ir, 0, wxEXPAND | wxTOP, space5);
szr_graphics_toggles->AddSpacer(space5);
szr_graphics_toggles->Add(group_box_freelook, 0, wxEXPAND | wxTOP, space5);
szr_graphics_toggles->AddSpacer(space5);
tab_graphics->SetSizerAndFit(szr_graphics_toggles);
notebook->AddPage(tab_graphics, "Graphics");
// 3D
auto* const tab_3D = new wxPanel(notebook);
auto* const group_box_3D_toggles =
new ControlGroupBox(HotkeyManagerEmu::GetHotkeyGroup(HKGP_3D_TOGGLE), tab_3D, this);
auto* const group_box_3D_depth =
new ControlGroupBox(HotkeyManagerEmu::GetHotkeyGroup(HKGP_3D_DEPTH), tab_3D, this);
auto* const szr_3D = new wxBoxSizer(wxHORIZONTAL);
szr_3D->AddSpacer(space5);
szr_3D->Add(group_box_3D_toggles, 0, wxEXPAND | wxTOP, space5);
szr_3D->AddSpacer(space5);
szr_3D->Add(group_box_3D_depth, 0, wxEXPAND | wxTOP, space5);
szr_3D->AddSpacer(space5);
tab_3D->SetSizerAndFit(szr_3D);
notebook->AddPage(tab_3D, "3D");
// Save and Load State
auto* const tab_save_load_state = new wxPanel(notebook);
auto* const group_box_load_state = new ControlGroupBox(
HotkeyManagerEmu::GetHotkeyGroup(HKGP_LOAD_STATE), tab_save_load_state, this);
auto* const group_box_save_state = new ControlGroupBox(
HotkeyManagerEmu::GetHotkeyGroup(HKGP_SAVE_STATE), tab_save_load_state, this);
auto* const szr_save_load_state = new wxBoxSizer(wxHORIZONTAL);
szr_save_load_state->AddSpacer(space5);
szr_save_load_state->Add(group_box_load_state, 0, wxEXPAND | wxTOP, space5);
szr_save_load_state->AddSpacer(space5);
szr_save_load_state->Add(group_box_save_state, 0, wxEXPAND | wxTOP, space5);
szr_save_load_state->AddSpacer(space5);
tab_save_load_state->SetSizerAndFit(szr_save_load_state);
notebook->AddPage(tab_save_load_state, "Save and Load State");
// Other State Managament
auto* const tab_other_state = new wxPanel(notebook);
auto* const group_box_select_state = new ControlGroupBox(
HotkeyManagerEmu::GetHotkeyGroup(HKGP_SELECT_STATE), tab_other_state, this);
auto* const group_box_load_last_state = new ControlGroupBox(
HotkeyManagerEmu::GetHotkeyGroup(HKGP_LOAD_LAST_STATE), tab_other_state, this);
auto* const group_box_state_misc =
new ControlGroupBox(HotkeyManagerEmu::GetHotkeyGroup(HKGP_STATE_MISC), tab_other_state, this);
auto* const szr_other_state = new wxBoxSizer(wxHORIZONTAL);
szr_other_state->AddSpacer(space5);
szr_other_state->Add(group_box_select_state, 0, wxEXPAND | wxTOP, space5);
szr_other_state->AddSpacer(space5);
szr_other_state->Add(group_box_load_last_state, 0, wxEXPAND | wxTOP, space5);
szr_other_state->AddSpacer(space5);
szr_other_state->Add(group_box_state_misc, 0, wxEXPAND | wxTOP, space5);
szr_other_state->AddSpacer(space5);
tab_other_state->SetSizerAndFit(szr_other_state);
notebook->AddPage(tab_other_state, "Other State Management");
notebook->SetSelection(0);
auto* const device_profile_sizer = new wxBoxSizer(wxVERTICAL);
device_profile_sizer->Add(device_chooser, 1, wxEXPAND);
device_profile_sizer->Add(profile_chooser, 1, wxEXPAND);
auto* const group_box_options =
new ControlGroupBox(HotkeyManagerEmu::GetOptionsGroup(), this, this);
auto* const dio = new wxBoxSizer(wxHORIZONTAL);
dio->AddSpacer(space5);
dio->Add(device_profile_sizer, 3, wxEXPAND);
dio->Add(reset_sizer, 0, wxEXPAND);
dio->Add(group_box_options, 1, wxEXPAND);
dio->AddSpacer(space5);
auto* const szr_main = new wxBoxSizer(wxVERTICAL);
szr_main->AddSpacer(space5);
szr_main->Add(dio);
szr_main->AddSpacer(space5);
szr_main->Add(notebook, 1, wxEXPAND | wxLEFT | wxRIGHT, space5);
szr_main->AddSpacer(space5);
szr_main->Add(CreateButtonSizer(wxCLOSE | wxNO_DEFAULT), 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
szr_main->AddSpacer(space5);
SetSizerAndFit(szr_main);
Center();
UpdateDeviceComboBox();
UpdateProfileComboBox();
UpdateGUI();
}

View file

@ -0,0 +1,14 @@
// Copyright 2016 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include "DolphinWX/Input/InputConfigDiag.h"
class HotkeyInputConfigDialog final : public InputConfigDialog
{
public:
HotkeyInputConfigDialog(wxWindow* parent, InputConfig& config, const wxString& name,
int port_num = 0);
};

View file

@ -42,9 +42,15 @@
#include "Core/HW/GCKeyboard.h"
#include "Core/HW/GCPad.h"
#include "Core/HW/Wiimote.h"
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
#include "Core/HotkeyManager.h"
#include "DolphinWX/DolphinSlider.h"
#include "DolphinWX/InputConfigDiag.h"
#include "DolphinWX/Input/ClassicInputConfigDiag.h"
#include "DolphinWX/Input/DrumsInputConfigDiag.h"
#include "DolphinWX/Input/GuitarInputConfigDiag.h"
#include "DolphinWX/Input/InputConfigDiag.h"
#include "DolphinWX/Input/NunchukInputConfigDiag.h"
#include "DolphinWX/Input/TurntableInputConfigDiag.h"
#include "DolphinWX/WxUtils.h"
#include "InputCommon/ControllerEmu.h"
#include "InputCommon/ControllerInterface/ControllerInterface.h"
@ -54,32 +60,47 @@
using namespace ciface::ExpressionParser;
void GamepadPage::ConfigExtension(wxCommandEvent& event)
void InputConfigDialog::ConfigExtension(wxCommandEvent& event)
{
ControllerEmu::Extension* const ex = ((ExtensionButton*)event.GetEventObject())->extension;
int extension_type = ex->switch_extension;
// show config diag, if "none" isn't selected
if (ex->switch_extension)
switch (extension_type)
{
wxDialog dlg(this, wxID_ANY,
wxGetTranslation(StrToWxStr(ex->attachments[ex->switch_extension]->GetName())));
wxBoxSizer* const main_szr = new wxBoxSizer(wxVERTICAL);
const std::size_t orig_size = control_groups.size();
ControlGroupsSizer* const szr = new ControlGroupsSizer(
ex->attachments[ex->switch_extension].get(), &dlg, this, &control_groups);
const int space5 = FromDIP(5);
main_szr->Add(szr, 0, wxLEFT, space5);
main_szr->Add(dlg.CreateButtonSizer(wxOK), 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
main_szr->AddSpacer(space5);
dlg.SetSizerAndFit(main_szr);
dlg.Center();
case WiimoteEmu::EXT_NUNCHUK:
{
NunchukInputConfigDialog dlg(this, m_config, _("Nunchuk Configuration"), m_port_num);
dlg.ShowModal();
// remove the new groups that were just added, now that the window closed
control_groups.resize(orig_size);
}
break;
case WiimoteEmu::EXT_CLASSIC:
{
ClassicInputConfigDialog dlg(this, m_config, _("Classic Controller Configuration"), m_port_num);
dlg.ShowModal();
}
break;
case WiimoteEmu::EXT_GUITAR:
{
GuitarInputConfigDialog dlg(this, m_config, _("Guitar Configuration"), m_port_num);
dlg.ShowModal();
}
break;
case WiimoteEmu::EXT_DRUMS:
{
DrumsInputConfigDialog dlg(this, m_config, _("Drums Configuration"), m_port_num);
dlg.ShowModal();
}
break;
case WiimoteEmu::EXT_TURNTABLE:
{
TurntableInputConfigDialog dlg(this, m_config, _("Turntable Configuration"), m_port_num);
dlg.ShowModal();
}
break;
default:
break;
}
}
@ -150,13 +171,13 @@ void PadSettingSpin::UpdateValue()
setting->SetValue(ControlState(((wxSpinCtrl*)wxcontrol)->GetValue()) / 100);
}
ControlDialog::ControlDialog(GamepadPage* const parent, InputConfig& config,
ControlDialog::ControlDialog(InputConfigDialog* const parent, InputConfig& config,
ControllerInterface::ControlReference* const ref)
: wxDialog(parent, wxID_ANY, _("Configure Control"), wxDefaultPosition, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER),
control_reference(ref), m_config(config), m_parent(parent)
{
m_devq = m_parent->controller->default_device;
m_devq = m_parent->GetController()->default_device;
const int space5 = FromDIP(5);
// GetStrings() sounds slow :/
@ -229,19 +250,13 @@ void InputConfigDialog::UpdateProfileComboBox()
strs.push_back(StrToWxStr(base));
}
for (GamepadPage* page : m_padpages)
{
page->profile_cbox->Clear();
page->profile_cbox->Append(strs);
}
profile_cbox->Clear();
profile_cbox->Append(strs);
}
void InputConfigDialog::UpdateControlReferences()
{
for (GamepadPage* page : m_padpages)
{
page->controller->UpdateReferences(g_controller_interface);
}
controller->UpdateReferences(g_controller_interface);
}
void InputConfigDialog::OnClose(wxCloseEvent& event)
@ -315,9 +330,10 @@ void ControlDialog::UpdateGUI()
}
};
void GamepadPage::UpdateGUI()
void InputConfigDialog::UpdateGUI()
{
device_cbox->SetValue(StrToWxStr(controller->default_device.ToString()));
if (device_cbox != nullptr)
device_cbox->SetValue(StrToWxStr(controller->default_device.ToString()));
for (ControlGroupBox* cgBox : control_groups)
{
@ -333,7 +349,7 @@ void GamepadPage::UpdateGUI()
}
}
void GamepadPage::ClearAll(wxCommandEvent&)
void InputConfigDialog::ClearAll(wxCommandEvent&)
{
// just load an empty ini section to clear everything :P
IniFile::Section section;
@ -347,7 +363,7 @@ void GamepadPage::ClearAll(wxCommandEvent&)
UpdateGUI();
}
void GamepadPage::LoadDefaults(wxCommandEvent&)
void InputConfigDialog::LoadDefaults(wxCommandEvent&)
{
controller->LoadDefaults(g_controller_interface);
@ -361,7 +377,8 @@ bool ControlDialog::Validate()
control_reference->expression = WxStrToStr(textctrl->GetValue());
auto lock = ControllerEmu::GetStateLock();
g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
g_controller_interface.UpdateReference(control_reference,
m_parent->GetController()->default_device);
UpdateGUI();
@ -369,7 +386,7 @@ bool ControlDialog::Validate()
control_reference->parse_error == EXPRESSION_PARSE_NO_DEVICE);
}
void GamepadPage::SetDevice(wxCommandEvent&)
void InputConfigDialog::SetDevice(wxCommandEvent&)
{
controller->default_device.FromString(WxStrToStr(device_cbox->GetValue()));
@ -399,7 +416,8 @@ void ControlDialog::ClearControl(wxCommandEvent&)
control_reference->expression.clear();
auto lock = ControllerEmu::GetStateLock();
g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
g_controller_interface.UpdateReference(control_reference,
m_parent->GetController()->default_device);
UpdateGUI();
}
@ -441,7 +459,7 @@ bool ControlDialog::GetExpressionForSelectedControl(wxString& expr)
return false;
wxString control_name = control_lbox->GetString(num);
GetExpressionForControl(expr, control_name, &m_devq, &m_parent->controller->default_device);
GetExpressionForControl(expr, control_name, &m_devq, &m_parent->GetController()->default_device);
return true;
}
@ -457,7 +475,8 @@ void ControlDialog::SetSelectedControl(wxCommandEvent&)
control_reference->expression = textctrl->GetValue();
auto lock = ControllerEmu::GetStateLock();
g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
g_controller_interface.UpdateReference(control_reference,
m_parent->GetController()->default_device);
UpdateGUI();
}
@ -492,12 +511,13 @@ void ControlDialog::AppendControl(wxCommandEvent& event)
control_reference->expression = textctrl->GetValue();
auto lock = ControllerEmu::GetStateLock();
g_controller_interface.UpdateReference(control_reference, m_parent->controller->default_device);
g_controller_interface.UpdateReference(control_reference,
m_parent->GetController()->default_device);
UpdateGUI();
}
void GamepadPage::EnablePadSetting(const std::string& group_name, const std::string& name,
void InputConfigDialog::EnablePadSetting(const std::string& group_name, const std::string& name,
const bool enabled)
{
const auto box_iterator =
@ -517,7 +537,7 @@ void GamepadPage::EnablePadSetting(const std::string& group_name, const std::str
(*it)->wxcontrol->Enable(enabled);
}
void GamepadPage::EnableControlButton(const std::string& group_name, const std::string& name,
void InputConfigDialog::EnableControlButton(const std::string& group_name, const std::string& name,
const bool enabled)
{
const auto box_iterator =
@ -553,14 +573,14 @@ void ControlDialog::OnRangeThumbtrack(wxScrollEvent& event)
m_range_spinner->SetValue(event.GetPosition());
}
void GamepadPage::AdjustSetting(wxCommandEvent& event)
void InputConfigDialog::AdjustSetting(wxCommandEvent& event)
{
const auto* const control = static_cast<wxControl*>(event.GetEventObject());
auto* const pad_setting = static_cast<PadSetting*>(control->GetClientData());
pad_setting->UpdateValue();
}
void GamepadPage::AdjustBooleanSetting(wxCommandEvent& event)
void InputConfigDialog::AdjustBooleanSetting(wxCommandEvent& event)
{
const auto* const control = static_cast<wxControl*>(event.GetEventObject());
auto* const pad_setting = static_cast<PadSettingCheckBox*>(control->GetClientData());
@ -578,7 +598,7 @@ void GamepadPage::AdjustBooleanSetting(wxCommandEvent& event)
}
}
void GamepadPage::ConfigControl(wxEvent& event)
void InputConfigDialog::ConfigControl(wxEvent& event)
{
m_control_dialog = new ControlDialog(this, m_config,
((ControlButton*)event.GetEventObject())->control_reference);
@ -589,7 +609,7 @@ void GamepadPage::ConfigControl(wxEvent& event)
UpdateGUI();
}
void GamepadPage::ClearControl(wxEvent& event)
void InputConfigDialog::ClearControl(wxEvent& event)
{
ControlButton* const btn = (ControlButton*)event.GetEventObject();
btn->control_reference->expression.clear();
@ -630,7 +650,7 @@ void ControlDialog::DetectControl(wxCommandEvent& event)
}
}
void GamepadPage::DetectControl(wxCommandEvent& event)
void InputConfigDialog::DetectControl(wxCommandEvent& event)
{
auto* btn = static_cast<ControlButton*>(event.GetEventObject());
if (DetectButton(btn) && m_iterate)
@ -649,7 +669,7 @@ void GamepadPage::DetectControl(wxCommandEvent& event)
}
}
bool GamepadPage::DetectButton(ControlButton* button)
bool InputConfigDialog::DetectButton(ControlButton* button)
{
bool success = false;
// find device :/
@ -687,7 +707,7 @@ bool GamepadPage::DetectButton(ControlButton* button)
return success;
}
wxStaticBoxSizer* ControlDialog::CreateControlChooser(GamepadPage* const parent)
wxStaticBoxSizer* ControlDialog::CreateControlChooser(InputConfigDialog* const parent)
{
wxStaticBoxSizer* const main_szr = new wxStaticBoxSizer(
wxVERTICAL, this, control_reference->is_input ? _("Input") : _("Output"));
@ -785,7 +805,7 @@ wxStaticBoxSizer* ControlDialog::CreateControlChooser(GamepadPage* const parent)
return main_szr;
}
void GamepadPage::GetProfilePath(std::string& path)
void InputConfigDialog::GetProfilePath(std::string& path)
{
const wxString& name = profile_cbox->GetValue();
if (!name.empty())
@ -801,10 +821,15 @@ void GamepadPage::GetProfilePath(std::string& path)
}
}
void GamepadPage::LoadProfile(wxCommandEvent&)
ControllerEmu* InputConfigDialog::GetController() const
{
return controller;
}
void InputConfigDialog::LoadProfile(wxCommandEvent&)
{
std::string fname;
GamepadPage::GetProfilePath(fname);
InputConfigDialog::GetProfilePath(fname);
if (!File::Exists(fname))
return;
@ -818,10 +843,10 @@ void GamepadPage::LoadProfile(wxCommandEvent&)
UpdateGUI();
}
void GamepadPage::SaveProfile(wxCommandEvent&)
void InputConfigDialog::SaveProfile(wxCommandEvent&)
{
std::string fname;
GamepadPage::GetProfilePath(fname);
InputConfigDialog::GetProfilePath(fname);
File::CreateFullPath(fname);
if (!fname.empty())
@ -830,7 +855,7 @@ void GamepadPage::SaveProfile(wxCommandEvent&)
controller->SaveConfig(inifile.GetOrCreateSection("Profile"));
inifile.Save(fname);
m_config_dialog->UpdateProfileComboBox();
UpdateProfileComboBox();
}
else
{
@ -838,10 +863,10 @@ void GamepadPage::SaveProfile(wxCommandEvent&)
}
}
void GamepadPage::DeleteProfile(wxCommandEvent&)
void InputConfigDialog::DeleteProfile(wxCommandEvent&)
{
std::string fname;
GamepadPage::GetProfilePath(fname);
InputConfigDialog::GetProfilePath(fname);
const char* const fnamecstr = fname.c_str();
@ -850,35 +875,32 @@ void GamepadPage::DeleteProfile(wxCommandEvent&)
{
File::Delete(fnamecstr);
m_config_dialog->UpdateProfileComboBox();
UpdateProfileComboBox();
}
}
void InputConfigDialog::UpdateDeviceComboBox()
{
for (GamepadPage* page : m_padpages)
{
page->device_cbox->Clear();
device_cbox->Clear();
for (const std::string& device_string : g_controller_interface.GetAllDeviceStrings())
page->device_cbox->Append(StrToWxStr(device_string));
for (const std::string& device_string : g_controller_interface.GetAllDeviceStrings())
device_cbox->Append(StrToWxStr(device_string));
page->device_cbox->SetValue(StrToWxStr(page->controller->default_device.ToString()));
}
device_cbox->SetValue(StrToWxStr(controller->default_device.ToString()));
}
void GamepadPage::RefreshDevices(wxCommandEvent&)
void InputConfigDialog::RefreshDevices(wxCommandEvent&)
{
bool was_unpaused = Core::PauseAndLock(true);
// refresh devices
g_controller_interface.Reinitialize();
g_controller_interface.RefreshDevices();
// update all control references
m_config_dialog->UpdateControlReferences();
UpdateControlReferences();
// update device cbox
m_config_dialog->UpdateDeviceComboBox();
UpdateDeviceComboBox();
Wiimote::LoadConfig();
Keyboard::LoadConfig();
@ -897,8 +919,9 @@ ControlGroupBox::~ControlGroupBox()
}
ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWindow* const parent,
GamepadPage* const eventsink)
: wxBoxSizer(wxVERTICAL), control_group(group), static_bitmap(nullptr), m_scale(1)
InputConfigDialog* eventsink)
: wxStaticBoxSizer(wxVERTICAL, parent, wxGetTranslation(StrToWxStr(group->ui_name))),
control_group(group), static_bitmap(nullptr), m_scale(1)
{
static constexpr std::array<const char* const, 2> exclude_buttons{ {"Mic", "Modifier"} };
static constexpr std::array<const char* const, 7> exclude_groups{
@ -929,16 +952,16 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
{
control_button->SetToolTip(
_("Left-click to detect input.\nMiddle-click to clear.\nRight-click for more options."));
control_button->Bind(wxEVT_BUTTON, &GamepadPage::DetectControl, eventsink);
control_button->Bind(wxEVT_BUTTON, &InputConfigDialog::DetectControl, eventsink);
}
else
{
control_button->SetToolTip(_("Left/Right-click for more options.\nMiddle-click to clear."));
control_button->Bind(wxEVT_BUTTON, &GamepadPage::ConfigControl, eventsink);
control_button->Bind(wxEVT_BUTTON, &InputConfigDialog::ConfigControl, eventsink);
}
control_button->Bind(wxEVT_MIDDLE_DOWN, &GamepadPage::ClearControl, eventsink);
control_button->Bind(wxEVT_RIGHT_UP, &GamepadPage::ConfigControl, eventsink);
control_button->Bind(wxEVT_MIDDLE_DOWN, &InputConfigDialog::ClearControl, eventsink);
control_button->Bind(wxEVT_RIGHT_UP, &InputConfigDialog::ConfigControl, eventsink);
control_grid->Add(label, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT);
control_grid->Add(control_button, 0, wxALIGN_CENTER_VERTICAL);
@ -968,7 +991,7 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
for (auto& groupSetting : group->numeric_settings)
{
PadSettingSpin* setting = new PadSettingSpin(parent, groupSetting.get());
setting->wxcontrol->Bind(wxEVT_SPINCTRL, &GamepadPage::AdjustSetting, eventsink);
setting->wxcontrol->Bind(wxEVT_SPINCTRL, &InputConfigDialog::AdjustSetting, eventsink);
options.push_back(setting);
szr->Add(
new wxStaticText(parent, wxID_ANY, wxGetTranslation(StrToWxStr(groupSetting->m_name))));
@ -977,7 +1000,8 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
for (auto& groupSetting : group->boolean_settings)
{
auto* checkbox = new PadSettingCheckBox(parent, groupSetting.get());
checkbox->wxcontrol->Bind(wxEVT_CHECKBOX, &GamepadPage::AdjustBooleanSetting, eventsink);
checkbox->wxcontrol->Bind(wxEVT_CHECKBOX, &InputConfigDialog::AdjustBooleanSetting,
eventsink);
options.push_back(checkbox);
Add(checkbox->wxcontrol, 0, wxALL | wxLEFT, space3);
}
@ -1010,7 +1034,7 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
wxBITMAP_TYPE_BMP);
auto* const threshold_cbox = new PadSettingSpin(parent, group->numeric_settings[0].get());
threshold_cbox->wxcontrol->Bind(wxEVT_SPINCTRL, &GamepadPage::AdjustSetting, eventsink);
threshold_cbox->wxcontrol->Bind(wxEVT_SPINCTRL, &InputConfigDialog::AdjustSetting, eventsink);
threshold_cbox->wxcontrol->SetToolTip(
_("Adjust the analog control pressure required to activate buttons."));
@ -1057,7 +1081,7 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
for (auto& groupSetting : group->numeric_settings)
{
PadSettingSpin* setting = new PadSettingSpin(parent, groupSetting.get());
setting->wxcontrol->Bind(wxEVT_SPINCTRL, &GamepadPage::AdjustSetting, eventsink);
setting->wxcontrol->Bind(wxEVT_SPINCTRL, &InputConfigDialog::AdjustSetting, eventsink);
options.push_back(setting);
wxBoxSizer* const szr = new wxBoxSizer(wxHORIZONTAL);
szr->Add(
@ -1081,8 +1105,8 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
options.push_back(attachments);
attachments->wxcontrol->Bind(wxEVT_CHOICE, &GamepadPage::AdjustSetting, eventsink);
configure_btn->Bind(wxEVT_BUTTON, &GamepadPage::ConfigExtension, eventsink);
attachments->wxcontrol->Bind(wxEVT_CHOICE, &InputConfigDialog::AdjustSetting, eventsink);
configure_btn->Bind(wxEVT_BUTTON, &InputConfigDialog::ConfigExtension, eventsink);
AddSpacer(space3);
Add(attachments->wxcontrol, 0, wxEXPAND | wxLEFT | wxRIGHT, space3);
@ -1096,7 +1120,8 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
for (auto& groupSetting : group->boolean_settings)
{
PadSettingCheckBox* setting_cbox = new PadSettingCheckBox(parent, groupSetting.get());
setting_cbox->wxcontrol->Bind(wxEVT_CHECKBOX, &GamepadPage::AdjustBooleanSetting, eventsink);
setting_cbox->wxcontrol->Bind(wxEVT_CHECKBOX, &InputConfigDialog::AdjustBooleanSetting,
eventsink);
if (groupSetting->m_name == "Iterative Input")
groupSetting->SetValue(false);
options.push_back(setting_cbox);
@ -1106,7 +1131,7 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
for (auto& groupSetting : group->numeric_settings)
{
PadSettingSpin* setting = new PadSettingSpin(parent, groupSetting.get());
setting->wxcontrol->Bind(wxEVT_SPINCTRL, &GamepadPage::AdjustSetting, eventsink);
setting->wxcontrol->Bind(wxEVT_SPINCTRL, &InputConfigDialog::AdjustSetting, eventsink);
options.push_back(setting);
wxBoxSizer* const szr = new wxBoxSizer(wxHORIZONTAL);
szr->Add(
@ -1114,70 +1139,18 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
wxALIGN_CENTER_VERTICAL, space3);
szr->Add(setting->wxcontrol, 0, wxLEFT, space3);
AddSpacer(space3);
Add(szr, 0, wxLEFT | wxRIGHT, space3);
Add(szr, 0, wxLEFT | wxRIGHT | wxALIGN_RIGHT, space3);
}
break;
}
}
AddSpacer(space3);
eventsink->control_groups.push_back(this);
}
ControlGroupsSizer::ControlGroupsSizer(ControllerEmu* const controller, wxWindow* const parent,
GamepadPage* const eventsink,
std::vector<ControlGroupBox*>* groups)
: wxBoxSizer(wxHORIZONTAL)
wxBoxSizer* InputConfigDialog::CreateDeviceChooserGroupBox()
{
const int space5 = parent->FromDIP(5);
size_t col_size = 0;
wxBoxSizer* stacked_groups = nullptr;
for (auto& group : controller->groups)
{
wxStaticBoxSizer* control_group =
new wxStaticBoxSizer(wxVERTICAL, parent, wxGetTranslation(StrToWxStr(group->ui_name)));
ControlGroupBox* control_group_box =
new ControlGroupBox(group.get(), control_group->GetStaticBox(), eventsink);
control_group->Add(control_group_box, 0, wxEXPAND);
const size_t grp_size =
group->controls.size() + group->numeric_settings.size() + group->boolean_settings.size();
col_size += grp_size;
if (col_size > 8 || nullptr == stacked_groups)
{
if (stacked_groups)
{
Add(stacked_groups, 0, wxBOTTOM, space5);
AddSpacer(space5);
}
stacked_groups = new wxBoxSizer(wxVERTICAL);
stacked_groups->Add(control_group, 0, wxEXPAND);
col_size = grp_size;
}
else
{
stacked_groups->Add(control_group, 0, wxEXPAND);
}
if (groups)
groups->push_back(control_group_box);
}
if (stacked_groups)
Add(stacked_groups, 0, wxBOTTOM, space5);
}
GamepadPage::GamepadPage(wxWindow* parent, InputConfig& config, const int pad_num,
InputConfigDialog* const config_dialog)
: wxPanel(parent, wxID_ANY), controller(config.GetController(pad_num)),
m_config_dialog(config_dialog), m_config(config)
{
wxBoxSizer* control_group_sizer = new ControlGroupsSizer(controller, this, this, &control_groups);
const int space3 = FromDIP(3);
const int space5 = FromDIP(5);
// device chooser
wxStaticBoxSizer* const device_sbox = new wxStaticBoxSizer(wxVERTICAL, this, _("Device"));
device_cbox = new wxComboBox(device_sbox->GetStaticBox(), wxID_ANY, "");
@ -1186,9 +1159,9 @@ GamepadPage::GamepadPage(wxWindow* parent, InputConfig& config, const int pad_nu
wxButton* refresh_button = new wxButton(device_sbox->GetStaticBox(), wxID_ANY, _("Refresh"),
wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
device_cbox->Bind(wxEVT_COMBOBOX, &GamepadPage::SetDevice, this);
device_cbox->Bind(wxEVT_TEXT_ENTER, &GamepadPage::SetDevice, this);
refresh_button->Bind(wxEVT_BUTTON, &GamepadPage::RefreshDevices, this);
device_cbox->Bind(wxEVT_COMBOBOX, &InputConfigDialog::SetDevice, this);
device_cbox->Bind(wxEVT_TEXT_ENTER, &InputConfigDialog::SetDevice, this);
refresh_button->Bind(wxEVT_BUTTON, &InputConfigDialog::RefreshDevices, this);
wxBoxSizer* const device_sbox_in = new wxBoxSizer(wxHORIZONTAL);
device_sbox_in->Add(WxUtils::GiveMinSizeDIP(device_cbox, wxSize(64, -1)), 1,
@ -1196,25 +1169,32 @@ GamepadPage::GamepadPage(wxWindow* parent, InputConfig& config, const int pad_nu
device_sbox_in->Add(refresh_button, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, space3);
device_sbox->Add(device_sbox_in, 1, wxEXPAND | wxLEFT | wxRIGHT, space3);
device_sbox->AddSpacer(space3);
return device_sbox;
}
// Clear / Reset buttons
wxStaticBoxSizer* const clear_sbox = new wxStaticBoxSizer(wxVERTICAL, this, _("Reset"));
wxBoxSizer* InputConfigDialog::CreaterResetGroupBox(wxOrientation orientation)
{
const int space3 = FromDIP(3);
wxStaticBoxSizer* const clear_sbox = new wxStaticBoxSizer(orientation, this, _("Reset"));
wxButton* const default_button = new wxButton(clear_sbox->GetStaticBox(), wxID_ANY, _("Default"),
wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
wxButton* const clearall_button = new wxButton(clear_sbox->GetStaticBox(), wxID_ANY, _("Clear"),
wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
wxBoxSizer* clear_sbox_in = new wxBoxSizer(wxHORIZONTAL);
clear_sbox_in->Add(default_button, 1, wxALIGN_CENTER_VERTICAL);
clear_sbox_in->Add(clearall_button, 1, wxALIGN_CENTER_VERTICAL);
clear_sbox->Add(clear_sbox_in, 1, wxEXPAND | wxLEFT | wxRIGHT, space3);
clear_sbox->AddSpacer(space3);
wxBoxSizer* clear_sbox_in = new wxBoxSizer(orientation);
clear_sbox_in->Add(default_button, 1, wxEXPAND);
clear_sbox_in->Add(clearall_button, 1, wxEXPAND);
clear_sbox->Add(clear_sbox_in, 1, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, space3);
clearall_button->Bind(wxEVT_BUTTON, &GamepadPage::ClearAll, this);
default_button->Bind(wxEVT_BUTTON, &GamepadPage::LoadDefaults, this);
clearall_button->Bind(wxEVT_BUTTON, &InputConfigDialog::ClearAll, this);
default_button->Bind(wxEVT_BUTTON, &InputConfigDialog::LoadDefaults, this);
return clear_sbox;
}
// Profile selector
wxBoxSizer* InputConfigDialog::CreateProfileChooserGroupBox()
{
const int space3 = FromDIP(3);
wxStaticBoxSizer* profile_sbox = new wxStaticBoxSizer(wxVERTICAL, this, _("Profile"));
profile_cbox = new wxComboBox(profile_sbox->GetStaticBox(), wxID_ANY, "");
@ -1225,9 +1205,9 @@ GamepadPage::GamepadPage(wxWindow* parent, InputConfig& config, const int pad_nu
wxButton* const pdelete_btn = new wxButton(profile_sbox->GetStaticBox(), wxID_ANY, _("Delete"),
wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
pload_btn->Bind(wxEVT_BUTTON, &GamepadPage::LoadProfile, this);
psave_btn->Bind(wxEVT_BUTTON, &GamepadPage::SaveProfile, this);
pdelete_btn->Bind(wxEVT_BUTTON, &GamepadPage::DeleteProfile, this);
pload_btn->Bind(wxEVT_BUTTON, &InputConfigDialog::LoadProfile, this);
psave_btn->Bind(wxEVT_BUTTON, &InputConfigDialog::SaveProfile, this);
pdelete_btn->Bind(wxEVT_BUTTON, &InputConfigDialog::DeleteProfile, this);
wxBoxSizer* profile_sbox_in = new wxBoxSizer(wxHORIZONTAL);
profile_sbox_in->Add(WxUtils::GiveMinSizeDIP(profile_cbox, wxSize(64, -1)), 1,
@ -1238,55 +1218,19 @@ GamepadPage::GamepadPage(wxWindow* parent, InputConfig& config, const int pad_nu
profile_sbox_in->Add(pdelete_btn, 0, wxALIGN_CENTER_VERTICAL);
profile_sbox->Add(profile_sbox_in, 1, wxEXPAND | wxLEFT | wxRIGHT, space3);
profile_sbox->AddSpacer(space3);
wxBoxSizer* const dio = new wxBoxSizer(wxHORIZONTAL);
dio->Add(device_sbox, 1, wxEXPAND);
dio->Add(clear_sbox, 0, wxEXPAND | wxLEFT, space5);
dio->Add(profile_sbox, 1, wxEXPAND | wxLEFT, space5);
wxBoxSizer* const mapping = new wxBoxSizer(wxVERTICAL);
mapping->AddSpacer(space5);
mapping->Add(dio, 1, wxEXPAND | wxLEFT | wxRIGHT, space5);
mapping->AddSpacer(space5);
mapping->Add(control_group_sizer, 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
UpdateGUI();
SetSizerAndFit(mapping); // needed
Layout();
};
return profile_sbox;
}
InputConfigDialog::InputConfigDialog(wxWindow* const parent, InputConfig& config,
const wxString& name, const int tab_num)
: wxDialog(parent, wxID_ANY, name), m_config(config)
const wxString& name, const int port_num)
: wxDialog(parent, wxID_ANY, name), controller(config.GetController(port_num)),
m_config(config), m_port_num(port_num)
{
m_pad_notebook = new wxNotebook(this, wxID_ANY);
GamepadPage* gp = new GamepadPage(m_pad_notebook, m_config, tab_num, this);
m_padpages.push_back(gp);
m_pad_notebook->AddPage(gp, wxString::Format("%s [%u]",
wxGetTranslation(StrToWxStr(m_config.GetGUIName())),
1 + tab_num));
m_pad_notebook->SetSelection(0);
UpdateDeviceComboBox();
UpdateProfileComboBox();
Bind(wxEVT_CLOSE_WINDOW, &InputConfigDialog::OnClose, this);
Bind(wxEVT_BUTTON, &InputConfigDialog::OnCloseButton, this, wxID_CLOSE);
wxBoxSizer* const szr = new wxBoxSizer(wxVERTICAL);
const int space5 = FromDIP(5);
szr->AddSpacer(space5);
szr->Add(m_pad_notebook, 1, wxEXPAND | wxLEFT | wxRIGHT, space5);
szr->AddSpacer(space5);
szr->Add(CreateButtonSizer(wxCLOSE | wxNO_DEFAULT), 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
szr->AddSpacer(space5);
SetLayoutAdaptationMode(wxDIALOG_ADAPTATION_MODE_ENABLED);
SetLayoutAdaptationLevel(wxDIALOG_ADAPTATION_STANDARD_SIZER);
SetSizerAndFit(szr);
Center();
// live preview update timer
m_update_timer.SetOwner(this);

View file

@ -31,7 +31,6 @@ class DolphinSlider;
class InputConfig;
class wxComboBox;
class wxListBox;
class wxNotebook;
class wxStaticBitmap;
class wxStaticText;
class wxTextCtrl;
@ -100,12 +99,12 @@ private:
bool m_block = false;
};
class GamepadPage;
class InputConfigDialog;
class ControlDialog : public wxDialog
{
public:
ControlDialog(GamepadPage* const parent, InputConfig& config,
ControlDialog(InputConfigDialog* const parent, InputConfig& config,
ControllerInterface::ControlReference* const ref);
bool Validate() override;
@ -116,7 +115,7 @@ public:
InputConfig& m_config;
private:
wxStaticBoxSizer* CreateControlChooser(GamepadPage* const parent);
wxStaticBoxSizer* CreateControlChooser(InputConfigDialog* parent);
void UpdateGUI();
void UpdateListContents();
@ -134,7 +133,7 @@ private:
bool GetExpressionForSelectedControl(wxString& expr);
GamepadPage* const m_parent;
InputConfigDialog* m_parent;
wxComboBox* device_cbox;
wxTextCtrl* textctrl;
wxListBox* control_lbox;
@ -172,11 +171,11 @@ protected:
int m_configured_width = wxDefaultCoord;
};
class ControlGroupBox : public wxBoxSizer
class ControlGroupBox : public wxStaticBoxSizer
{
public:
ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWindow* const parent,
GamepadPage* const eventsink);
InputConfigDialog* eventsink);
~ControlGroupBox();
bool HasBitmapHeading() const
@ -193,24 +192,21 @@ public:
double m_scale;
};
class ControlGroupsSizer : public wxBoxSizer
class InputConfigDialog : public wxDialog
{
public:
ControlGroupsSizer(ControllerEmu* const controller, wxWindow* const parent,
GamepadPage* const eventsink,
std::vector<ControlGroupBox*>* const groups = nullptr);
};
InputConfigDialog(wxWindow* const parent, InputConfig& config, const wxString& name,
const int port_num = 0);
virtual ~InputConfigDialog() = default;
class InputConfigDialog;
void OnClose(wxCloseEvent& event);
void OnCloseButton(wxCommandEvent& event);
class GamepadPage : public wxPanel
{
friend class InputConfigDialog;
friend class ControlDialog;
void UpdateDeviceComboBox();
void UpdateProfileComboBox();
public:
GamepadPage(wxWindow* parent, InputConfig& config, const int pad_num,
InputConfigDialog* const config_dialog);
void UpdateControlReferences();
void UpdateBitmaps(wxTimerEvent&);
void UpdateGUI();
@ -238,44 +234,29 @@ public:
void AdjustBooleanSetting(wxCommandEvent& event);
void GetProfilePath(std::string& path);
ControllerEmu* GetController() const;
wxComboBox* profile_cbox;
wxComboBox* device_cbox;
wxComboBox* profile_cbox = nullptr;
wxComboBox* device_cbox = nullptr;
std::vector<ControlGroupBox*> control_groups;
std::vector<ControlButton*> control_buttons;
protected:
wxBoxSizer* CreateDeviceChooserGroupBox();
wxBoxSizer* CreaterResetGroupBox(wxOrientation orientation);
wxBoxSizer* CreateProfileChooserGroupBox();
ControllerEmu* const controller;
wxTimer m_update_timer;
private:
ControlDialog* m_control_dialog;
InputConfigDialog* const m_config_dialog;
InputConfig& m_config;
int m_port_num;
ControlDialog* m_control_dialog;
InputEventFilter m_event_filter;
bool DetectButton(ControlButton* button);
bool m_iterate = false;
};
class InputConfigDialog : public wxDialog
{
public:
InputConfigDialog(wxWindow* const parent, InputConfig& config, const wxString& name,
const int tab_num = 0);
void OnClose(wxCloseEvent& event);
void OnCloseButton(wxCommandEvent& event);
void UpdateDeviceComboBox();
void UpdateProfileComboBox();
void UpdateControlReferences();
void UpdateBitmaps(wxTimerEvent&);
private:
wxNotebook* m_pad_notebook;
std::vector<GamepadPage*> m_padpages;
InputConfig& m_config;
wxTimer m_update_timer;
};

View file

@ -19,7 +19,7 @@
#include <wx/settings.h>
#include <wx/statbmp.h>
#include "DolphinWX/InputConfigDiag.h"
#include "DolphinWX/Input/InputConfigDiag.h"
#include "DolphinWX/WxUtils.h"
#include "InputCommon/ControllerEmu.h"
@ -466,7 +466,7 @@ static void DrawBorder(wxGraphicsContext* gc, double scale)
{
double pen_width = std::round(scale); // Pen width = 1px * scale
// Use the window caption bar color as a safe accent color.
// Use the window caption bar color as a safe accent color.
wxPen border_pen(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION),
static_cast<int>(pen_width));
border_pen.SetCap(wxCAP_PROJECTING);
@ -487,12 +487,9 @@ void InputConfigDialog::UpdateBitmaps(wxTimerEvent& WXUNUSED(event))
g_controller_interface.UpdateInput();
GamepadPage* const current_page =
static_cast<GamepadPage*>(m_pad_notebook->GetPage(m_pad_notebook->GetSelection()));
wxMemoryDC dc;
auto lock = ControllerEmu::GetStateLock();
for (ControlGroupBox* g : current_page->control_groups)
for (ControlGroupBox* g : control_groups)
{
// Only if this control group has a bitmap
if (!g->static_bitmap)

View file

@ -0,0 +1,54 @@
// Copyright 2016 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DolphinWX/Input/NunchukInputConfigDiag.h"
#include "Core/HW/Wiimote.h"
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
NunchukInputConfigDialog::NunchukInputConfigDialog(wxWindow* const parent, InputConfig& config,
const wxString& name, const int port_num)
: InputConfigDialog(parent, config, name, port_num)
{
const int space5 = FromDIP(5);
auto* const group_box_buttons = new ControlGroupBox(
Wiimote::GetNunchukGroup(port_num, WiimoteEmu::NunchukGroup::Buttons), this, this);
auto* const group_box_shake = new ControlGroupBox(
Wiimote::GetNunchukGroup(port_num, WiimoteEmu::NunchukGroup::Shake), this, this);
auto* const buttons_shake = new wxBoxSizer(wxVERTICAL);
buttons_shake->Add(group_box_buttons, 0, wxEXPAND);
buttons_shake->AddSpacer(space5);
buttons_shake->Add(group_box_shake, 0, wxEXPAND);
auto* const group_box_stick = new ControlGroupBox(
Wiimote::GetNunchukGroup(port_num, WiimoteEmu::NunchukGroup::Stick), this, this);
auto* const group_box_tilt = new ControlGroupBox(
Wiimote::GetNunchukGroup(port_num, WiimoteEmu::NunchukGroup::Tilt), this, this);
auto* const group_box_swing = new ControlGroupBox(
Wiimote::GetNunchukGroup(port_num, WiimoteEmu::NunchukGroup::Swing), this, this);
auto* const controls_sizer = new wxBoxSizer(wxHORIZONTAL);
controls_sizer->AddSpacer(space5);
controls_sizer->Add(buttons_shake, 0, wxEXPAND);
controls_sizer->AddSpacer(space5);
controls_sizer->Add(group_box_stick, 0, wxEXPAND);
controls_sizer->AddSpacer(space5);
controls_sizer->Add(group_box_tilt, 0, wxEXPAND);
controls_sizer->AddSpacer(space5);
controls_sizer->Add(group_box_swing, 0, wxEXPAND);
controls_sizer->AddSpacer(space5);
auto* const szr_main = new wxBoxSizer(wxVERTICAL);
szr_main->AddSpacer(space5);
szr_main->Add(controls_sizer, 1, wxEXPAND | wxLEFT | wxRIGHT, space5);
szr_main->AddSpacer(space5);
szr_main->Add(CreateButtonSizer(wxCLOSE | wxNO_DEFAULT), 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
szr_main->AddSpacer(space5);
SetSizerAndFit(szr_main);
Center();
UpdateGUI();
}

View file

@ -0,0 +1,14 @@
// Copyright 2016 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include "DolphinWX/Input/InputConfigDiag.h"
class NunchukInputConfigDialog final : public InputConfigDialog
{
public:
NunchukInputConfigDialog(wxWindow* parent, InputConfig& config, const wxString& name,
int port_num = 0);
};

View file

@ -0,0 +1,62 @@
// Copyright 2016 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DolphinWX/Input/TurntableInputConfigDiag.h"
#include "Core/HW/Wiimote.h"
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
TurntableInputConfigDialog::TurntableInputConfigDialog(wxWindow* const parent, InputConfig& config,
const wxString& name, const int port_num)
: InputConfigDialog(parent, config, name, port_num)
{
const int space5 = FromDIP(5);
auto* const group_box_stick = new ControlGroupBox(
Wiimote::GetTurntableGroup(port_num, WiimoteEmu::TurntableGroup::Stick), this, this);
auto* const group_box_effect_dial = new ControlGroupBox(
Wiimote::GetTurntableGroup(port_num, WiimoteEmu::TurntableGroup::EffectDial), this, this);
auto* const stick_effect_sizer = new wxBoxSizer(wxVERTICAL);
stick_effect_sizer->Add(group_box_stick, 0, wxEXPAND);
stick_effect_sizer->AddSpacer(space5);
stick_effect_sizer->Add(group_box_effect_dial, 0, wxEXPAND);
auto* const group_box_left_table = new ControlGroupBox(
Wiimote::GetTurntableGroup(port_num, WiimoteEmu::TurntableGroup::LeftTable), this, this);
auto* const group_box_right_table = new ControlGroupBox(
Wiimote::GetTurntableGroup(port_num, WiimoteEmu::TurntableGroup::RightTable), this, this);
auto* const group_box_crossfade = new ControlGroupBox(
Wiimote::GetTurntableGroup(port_num, WiimoteEmu::TurntableGroup::Crossfade), this, this);
auto* const tables_crossfade_sizer = new wxBoxSizer(wxVERTICAL);
tables_crossfade_sizer->Add(group_box_right_table, 0, wxEXPAND);
tables_crossfade_sizer->AddSpacer(space5);
tables_crossfade_sizer->Add(group_box_left_table, 0, wxEXPAND);
tables_crossfade_sizer->AddSpacer(space5);
tables_crossfade_sizer->Add(group_box_crossfade, 0, wxEXPAND);
auto* const group_box_buttons = new ControlGroupBox(
Wiimote::GetTurntableGroup(port_num, WiimoteEmu::TurntableGroup::Buttons), this, this);
auto* const controls_sizer = new wxBoxSizer(wxHORIZONTAL);
controls_sizer->AddSpacer(space5);
controls_sizer->Add(group_box_buttons, 0, wxEXPAND);
controls_sizer->AddSpacer(space5);
controls_sizer->Add(stick_effect_sizer, 0, wxEXPAND);
controls_sizer->AddSpacer(space5);
controls_sizer->Add(tables_crossfade_sizer, 0, wxEXPAND);
controls_sizer->AddSpacer(space5);
auto* const szr_main = new wxBoxSizer(wxVERTICAL);
szr_main->AddSpacer(space5);
szr_main->Add(controls_sizer, 1, wxEXPAND | wxLEFT | wxRIGHT, space5);
szr_main->AddSpacer(space5);
szr_main->Add(CreateButtonSizer(wxCLOSE | wxNO_DEFAULT), 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
szr_main->AddSpacer(space5);
SetSizerAndFit(szr_main);
Center();
UpdateGUI();
}

View file

@ -0,0 +1,14 @@
// Copyright 2016 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include "DolphinWX/Input/InputConfigDiag.h"
class TurntableInputConfigDialog final : public InputConfigDialog
{
public:
TurntableInputConfigDialog(wxWindow* parent, InputConfig& config, const wxString& name,
int port_num = 0);
};

View file

@ -0,0 +1,129 @@
// Copyright 2016 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <wx/notebook.h>
#include <wx/panel.h>
#include "DolphinWX/Input/WiimoteInputConfigDiag.h"
#include "Core/HW/Wiimote.h"
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"
WiimoteInputConfigDialog::WiimoteInputConfigDialog(wxWindow* const parent, InputConfig& config,
const wxString& name, const int port_num)
: InputConfigDialog(parent, config, name, port_num)
{
const int space5 = FromDIP(5);
auto* const device_chooser = CreateDeviceChooserGroupBox();
auto* const reset_sizer = CreaterResetGroupBox(wxVERTICAL);
auto* const profile_chooser = CreateProfileChooserGroupBox();
auto* const notebook = new wxNotebook(this, wxID_ANY);
// General and Options
auto* const tab_general = new wxPanel(notebook);
auto* const group_box_buttons = new ControlGroupBox(
Wiimote::GetWiimoteGroup(port_num, WiimoteEmu::WiimoteGroup::Buttons), tab_general, this);
auto* const group_box_dpad = new ControlGroupBox(
Wiimote::GetWiimoteGroup(port_num, WiimoteEmu::WiimoteGroup::DPad), tab_general, this);
auto* const group_box_rumble = new ControlGroupBox(
Wiimote::GetWiimoteGroup(port_num, WiimoteEmu::WiimoteGroup::Rumble), tab_general, this);
auto* const group_box_extension = new ControlGroupBox(
Wiimote::GetWiimoteGroup(port_num, WiimoteEmu::WiimoteGroup::Extension), tab_general, this);
auto* const group_box_options = new ControlGroupBox(
Wiimote::GetWiimoteGroup(port_num, WiimoteEmu::WiimoteGroup::Options), tab_general, this);
auto* const group_box_hotkeys = new ControlGroupBox(
Wiimote::GetWiimoteGroup(port_num, WiimoteEmu::WiimoteGroup::Hotkeys), tab_general, this);
auto* const dpad_extension_rumble_sizer = new wxBoxSizer(wxVERTICAL);
dpad_extension_rumble_sizer->Add(group_box_dpad, 0, wxEXPAND);
dpad_extension_rumble_sizer->AddSpacer(space5);
dpad_extension_rumble_sizer->Add(group_box_extension, 0, wxEXPAND);
dpad_extension_rumble_sizer->AddSpacer(space5);
dpad_extension_rumble_sizer->Add(group_box_rumble, 0, wxEXPAND);
auto* const options_hotkeys_sizer = new wxBoxSizer(wxVERTICAL);
options_hotkeys_sizer->Add(group_box_options, 0, wxEXPAND);
options_hotkeys_sizer->AddSpacer(space5);
options_hotkeys_sizer->Add(group_box_hotkeys, 0, wxEXPAND);
auto* const general_options_sizer = new wxBoxSizer(wxHORIZONTAL);
general_options_sizer->AddSpacer(space5);
general_options_sizer->Add(group_box_buttons, 0, wxEXPAND | wxTOP, space5);
general_options_sizer->AddSpacer(space5);
general_options_sizer->Add(dpad_extension_rumble_sizer, 0, wxEXPAND | wxTOP, space5);
general_options_sizer->AddSpacer(space5);
general_options_sizer->Add(options_hotkeys_sizer, 0, wxEXPAND | wxTOP, space5);
general_options_sizer->AddSpacer(space5);
tab_general->SetSizerAndFit(general_options_sizer);
notebook->AddPage(tab_general, "General and Options");
// Motion Controls and IR
auto* const tab_motion_controls_ir = new wxPanel(notebook);
auto* const group_box_shake =
new ControlGroupBox(Wiimote::GetWiimoteGroup(port_num, WiimoteEmu::WiimoteGroup::Shake),
tab_motion_controls_ir, this);
auto* const group_box_ir =
new ControlGroupBox(Wiimote::GetWiimoteGroup(port_num, WiimoteEmu::WiimoteGroup::IR),
tab_motion_controls_ir, this);
auto* const group_box_tilt =
new ControlGroupBox(Wiimote::GetWiimoteGroup(port_num, WiimoteEmu::WiimoteGroup::Tilt),
tab_motion_controls_ir, this);
auto* const group_box_swing =
new ControlGroupBox(Wiimote::GetWiimoteGroup(port_num, WiimoteEmu::WiimoteGroup::Swing),
tab_motion_controls_ir, this);
auto* const swing_shake_sizer = new wxBoxSizer(wxVERTICAL);
swing_shake_sizer->Add(group_box_swing, 0, wxEXPAND);
swing_shake_sizer->AddSpacer(space5);
swing_shake_sizer->Add(group_box_shake, 0, wxEXPAND);
auto* const motion_controls_ir_sizer = new wxBoxSizer(wxHORIZONTAL);
motion_controls_ir_sizer->AddSpacer(space5);
motion_controls_ir_sizer->Add(group_box_ir, 0, wxEXPAND | wxTOP, space5);
motion_controls_ir_sizer->AddSpacer(space5);
motion_controls_ir_sizer->Add(group_box_tilt, 0, wxEXPAND | wxTOP, space5);
motion_controls_ir_sizer->AddSpacer(space5);
motion_controls_ir_sizer->Add(swing_shake_sizer, 0, wxEXPAND | wxTOP, space5);
motion_controls_ir_sizer->AddSpacer(space5);
tab_motion_controls_ir->SetSizerAndFit(motion_controls_ir_sizer);
notebook->AddPage(tab_motion_controls_ir, "Motion Controls and IR");
notebook->SetSelection(0);
auto* const device_profile_sizer = new wxBoxSizer(wxVERTICAL);
device_profile_sizer->Add(device_chooser, 1, wxEXPAND);
device_profile_sizer->Add(profile_chooser, 1, wxEXPAND);
auto* const dio = new wxBoxSizer(wxHORIZONTAL);
dio->AddSpacer(space5);
dio->Add(device_profile_sizer, 5, wxEXPAND);
dio->AddSpacer(space5);
dio->Add(reset_sizer, 1, wxEXPAND);
dio->AddSpacer(space5);
auto* const szr_main = new wxBoxSizer(wxVERTICAL);
szr_main->AddSpacer(space5);
szr_main->Add(dio);
szr_main->AddSpacer(space5);
szr_main->Add(notebook, 1, wxEXPAND | wxLEFT | wxRIGHT, space5);
szr_main->AddSpacer(space5);
szr_main->Add(CreateButtonSizer(wxCLOSE | wxNO_DEFAULT), 0, wxEXPAND | wxLEFT | wxRIGHT, space5);
szr_main->AddSpacer(space5);
SetSizerAndFit(szr_main);
Center();
UpdateDeviceComboBox();
UpdateProfileComboBox();
UpdateGUI();
}

View file

@ -0,0 +1,14 @@
// Copyright 2016 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include "DolphinWX/Input/InputConfigDiag.h"
class WiimoteInputConfigDialog final : public InputConfigDialog
{
public:
WiimoteInputConfigDialog(wxWindow* parent, InputConfig& config, const wxString& name,
int port_num = 0);
};

View file

@ -187,7 +187,14 @@ ControllerEmu::AnalogStick::AnalogStick(const char* const _name, const char* con
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Dead Zone"), 0, 0, 50));
}
ControllerEmu::Buttons::Buttons(const std::string& _name) : ControlGroup(_name, GROUP_TYPE_BUTTONS)
ControllerEmu::Buttons::Buttons(const std::string& _name)
: ControlGroup(_name, _name, GROUP_TYPE_BUTTONS)
{
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Threshold"), 0.5));
}
ControllerEmu::Buttons::Buttons(const std::string& ini_name, const std::string& group_name)
: ControlGroup(ini_name, group_name, GROUP_TYPE_BUTTONS)
{
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Threshold"), 0.5));
}

View file

@ -204,6 +204,7 @@ public:
{
public:
Buttons(const std::string& _name);
Buttons(const std::string& ini_name, const std::string& group_name);
template <typename C>
void GetState(C* const buttons, const C* bitmasks)

View file

@ -10,7 +10,7 @@ namespace ciface
{
namespace Android
{
void Init()
void PopulateDevices()
{
for (int i = 0; i < 8; ++i)
g_controller_interface.AddDevice(std::make_shared<Touchscreen>(i));

View file

@ -11,7 +11,7 @@ namespace ciface
{
namespace Android
{
void Init();
void PopulateDevices();
class Touchscreen : public Core::Device
{
private:

View file

@ -55,41 +55,70 @@ void ControllerInterface::Initialize(void* const hwnd)
m_hwnd = hwnd;
#ifdef CIFACE_USE_DINPUT
ciface::DInput::Init((HWND)hwnd);
// nothing needed
#endif
#ifdef CIFACE_USE_XINPUT
ciface::XInput::Init();
#endif
#ifdef CIFACE_USE_XLIB
ciface::XInput2::Init(hwnd);
// nothing needed
#endif
#ifdef CIFACE_USE_OSX
ciface::OSX::Init(hwnd);
ciface::Quartz::Init(hwnd);
// nothing needed for Quartz
#endif
#ifdef CIFACE_USE_SDL
ciface::SDL::Init();
#endif
#ifdef CIFACE_USE_ANDROID
ciface::Android::Init();
// nothing needed
#endif
#ifdef CIFACE_USE_EVDEV
ciface::evdev::Init();
#endif
#ifdef CIFACE_USE_PIPES
ciface::Pipes::Init();
// nothing needed
#endif
m_is_init = true;
RefreshDevices();
}
void ControllerInterface::Reinitialize()
void ControllerInterface::RefreshDevices()
{
if (!m_is_init)
return;
Shutdown();
Initialize(m_hwnd);
{
std::lock_guard<std::mutex> lk(m_devices_mutex);
m_devices.clear();
}
#ifdef CIFACE_USE_DINPUT
ciface::DInput::PopulateDevices(reinterpret_cast<HWND>(m_hwnd));
#endif
#ifdef CIFACE_USE_XINPUT
ciface::XInput::PopulateDevices();
#endif
#ifdef CIFACE_USE_XLIB
ciface::XInput2::PopulateDevices(m_hwnd);
#endif
#ifdef CIFACE_USE_OSX
ciface::OSX::PopulateDevices(m_hwnd);
ciface::Quartz::PopulateDevices(m_hwnd);
#endif
#ifdef CIFACE_USE_SDL
ciface::SDL::PopulateDevices();
#endif
#ifdef CIFACE_USE_ANDROID
ciface::Android::PopulateDevices();
#endif
#ifdef CIFACE_USE_EVDEV
ciface::evdev::PopulateDevices();
#endif
#ifdef CIFACE_USE_PIPES
ciface::Pipes::PopulateDevices();
#endif
}
//
@ -102,6 +131,19 @@ void ControllerInterface::Shutdown()
if (!m_is_init)
return;
{
std::lock_guard<std::mutex> lk(m_devices_mutex);
for (const auto& d : m_devices)
{
// Set outputs to ZERO before destroying device
for (ciface::Core::Device::Output* o : d->Outputs())
o->SetState(0);
}
m_devices.clear();
}
#ifdef CIFACE_USE_XINPUT
ciface::XInput::DeInit();
#endif
@ -126,17 +168,6 @@ void ControllerInterface::Shutdown()
ciface::evdev::Shutdown();
#endif
std::lock_guard<std::mutex> lk(m_devices_mutex);
for (const auto& d : m_devices)
{
// Set outputs to ZERO before destroying device
for (ciface::Core::Device::Output* o : d->Outputs())
o->SetState(0);
}
m_devices.clear();
m_is_init = false;
}

Some files were not shown because too many files have changed in this diff Show more