Some Wiimote to Gamepad translations for Wario Land Shake It
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1095 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
3303639a6e
commit
83b8527085
|
@ -433,7 +433,11 @@ void CFrame::OnPlay(wxCommandEvent& WXUNUSED (event))
|
|||
|
||||
void CFrame::OnStop(wxCommandEvent& WXUNUSED (event))
|
||||
{
|
||||
if (Core::GetState() != Core::CORE_UNINITIALIZED)
|
||||
// Ask for confirmation in case the user accidently clicked Stop
|
||||
int answer = wxMessageBox("Are you sure you want to stop the current emulation?",
|
||||
"Confirm", wxYES_NO);
|
||||
|
||||
if (answer == wxYES && Core::GetState() != Core::CORE_UNINITIALIZED)
|
||||
{
|
||||
Core::Stop();
|
||||
UpdateGUI();
|
||||
|
|
|
@ -43,9 +43,9 @@ BEGIN_EVENT_TABLE(CDebugger,wxDialog)
|
|||
|
||||
EVT_BUTTON(ID_UPD,CDebugger::OnUpdate) // buttons
|
||||
|
||||
EVT_CHECKBOX(IDC_CHECK0,CDebugger::SaveFile) // options
|
||||
EVT_CHECKBOX(IDC_CHECK2,CDebugger::ShowHideConsole)
|
||||
EVT_CHECKBOX(IDC_CHECK1,CDebugger::SaveFile) // options
|
||||
EVT_CHECKBOX(IDC_CHECK3,CDebugger::OnlyLooping)
|
||||
EVT_CHECKBOX(IDC_CHECK4,CDebugger::ShowHideConsole)
|
||||
|
||||
EVT_RADIOBOX(IDC_RADIO1,CDebugger::ChangeFrequency) // update frequency
|
||||
|
||||
|
@ -405,7 +405,6 @@ void CDebugger::ShowHideConsole(wxCommandEvent& event)
|
|||
|
||||
void CDebugger::DoShowHideConsole()
|
||||
{
|
||||
|
||||
if(m_Check[2]->IsChecked())
|
||||
{
|
||||
OpenConsole();
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
// On and off
|
||||
bool g_consoleEnable = true;
|
||||
int gSaveFile = 0;
|
||||
#define DEBUGG
|
||||
#define DEBUG_HLE
|
||||
|
||||
|
||||
// --------------------
|
||||
|
@ -40,11 +40,11 @@ int nFiles = 4;
|
|||
// --------------------
|
||||
// Create handles
|
||||
|
||||
#ifdef DEBUGG
|
||||
FILE* __fStdOut[4]; // you have to update this manually, we can't place a nFiles in there
|
||||
#ifdef DEBUG_HLE
|
||||
FILE* __fStdOut[4]; // you have to update this manually, we can't place a nFiles in there
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
HANDLE __hStdOut = NULL;
|
||||
HANDLE __hStdOut = NULL;
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -55,8 +55,7 @@ is closed */
|
|||
// -------------
|
||||
void startConsoleWin(int width, int height, char* fname)
|
||||
{
|
||||
|
||||
#if defined(DEBUGG) && defined(_WIN32)
|
||||
#if defined(DEBUG_HLE) defined(_WIN32)
|
||||
|
||||
AllocConsole();
|
||||
|
||||
|
@ -84,6 +83,7 @@ void startConsoleWin(int width, int height, char* fname)
|
|||
}
|
||||
}
|
||||
// ---------------
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ void startConsoleWin(int width, int height, char* fname)
|
|||
// File printf function
|
||||
int aprintf(int a, char *fmt, ...)
|
||||
{
|
||||
#if defined(DEBUGG) && defined(_WIN32)
|
||||
#if defined(DEBUG_HLE) && defined(_WIN32)
|
||||
if(gSaveFile)
|
||||
{
|
||||
char s[5000]; // WARNING: mind this value
|
||||
|
@ -126,7 +126,7 @@ int aprintf(int a, char *fmt, ...)
|
|||
// Printf to screen function
|
||||
int wprintf(char *fmt, ...)
|
||||
{
|
||||
#if defined(DEBUGG) && defined(_WIN32)
|
||||
#if defined(DEBUG_HLE) && defined(_WIN32)
|
||||
char s[5000]; // WARNING: mind this value
|
||||
va_list argptr;
|
||||
int cnt;
|
||||
|
@ -151,9 +151,11 @@ int wprintf(char *fmt, ...)
|
|||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
// Clear console screen
|
||||
void ClearScreen()
|
||||
{
|
||||
#if defined(DEBUGG) && defined(_WIN32)
|
||||
#if defined(DEBUG_HLE) && defined(_WIN32)
|
||||
if(g_consoleEnable)
|
||||
{
|
||||
COORD coordScreen = { 0, 0 };
|
||||
|
@ -175,7 +177,10 @@ void ClearScreen()
|
|||
#endif
|
||||
}
|
||||
|
||||
#if defined(DEBUGG) && defined(_WIN32)
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
// Get window handle of console window to be able to resize it
|
||||
#if defined(DEBUG_HLE) && defined(_WIN32)
|
||||
HWND GetConsoleHwnd(void)
|
||||
{
|
||||
|
||||
|
|
|
@ -521,6 +521,18 @@
|
|||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Debugging"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\Src\Console.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\Console.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath=".\Src\main.cpp"
|
||||
>
|
||||
|
|
|
@ -0,0 +1,223 @@
|
|||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
|
||||
// --------------------
|
||||
// Includes
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
|
||||
// --------------------
|
||||
// On and off
|
||||
bool g_consoleEnable = true;
|
||||
int gSaveFile = 0;
|
||||
#define DEBUG_WIIMOTE
|
||||
|
||||
|
||||
// --------------------
|
||||
// Settings
|
||||
int nFiles = 1;
|
||||
|
||||
|
||||
// --------------------
|
||||
// Create handles
|
||||
|
||||
#ifdef DEBUG_WIIMOTE
|
||||
FILE* __fStdOut[1]; // you have to update this manually, we can't place a nFiles in there
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
HANDLE __hStdOut = NULL;
|
||||
#endif
|
||||
|
||||
|
||||
// =======================================================================================
|
||||
/* Start console window - width and height is the size of console window, if you specify
|
||||
fname, the output will also be written to this file. TODO: Close the file pointer when the app
|
||||
is closed */
|
||||
// -------------
|
||||
void startConsoleWin(int width, int height, char* fname)
|
||||
{
|
||||
#if defined(DEBUG_WIIMOTE) && defined(_WIN32)
|
||||
|
||||
AllocConsole();
|
||||
|
||||
SetConsoleTitle(fname);
|
||||
__hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
|
||||
COORD co = {width,height};
|
||||
SetConsoleScreenBufferSize(__hStdOut, co);
|
||||
|
||||
SMALL_RECT coo = {0,0,(width - 1),70}; // top, left, right, bottom
|
||||
SetConsoleWindowInfo(__hStdOut, TRUE, &coo);
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
// Write to a file
|
||||
if(fname)
|
||||
{
|
||||
for(int i = 0; i < nFiles; i++)
|
||||
{
|
||||
// Edit the log file name
|
||||
std::string FileEnding = ".log";
|
||||
std::string FileName = fname;
|
||||
char buffer[33]; itoa(i, buffer, 10); // convert number to string
|
||||
std::string FullFilename = (FileName + buffer + FileEnding);
|
||||
__fStdOut[i] = fopen(FullFilename.c_str(), "w");
|
||||
}
|
||||
}
|
||||
// ---------------
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
// File printf function
|
||||
int aprintf(int a, char *fmt, ...)
|
||||
{
|
||||
#if defined(DEBUG_WIIMOTE) && defined(_WIN32)
|
||||
if(gSaveFile)
|
||||
{
|
||||
char s[500]; // WARNING: mind this value
|
||||
va_list argptr;
|
||||
int cnt;
|
||||
|
||||
va_start(argptr, fmt);
|
||||
cnt = vsnprintf(s, 500, fmt, argptr); // remember to update this value to
|
||||
va_end(argptr);
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
if(__fStdOut[a]) // TODO: make this work, we have to set all default values to NULL
|
||||
//to make it work
|
||||
fprintf(__fStdOut[a], s);
|
||||
// -------------
|
||||
|
||||
return(cnt);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
// Printf to screen function
|
||||
int wprintf(char *fmt, ...)
|
||||
{
|
||||
#if defined(DEBUG_WIIMOTE) && defined(_WIN32)
|
||||
char s[500]; // WARNING: mind this value
|
||||
va_list argptr;
|
||||
int cnt;
|
||||
|
||||
va_start(argptr, fmt);
|
||||
cnt = vsnprintf(s, 500, fmt, argptr);
|
||||
va_end(argptr);
|
||||
|
||||
DWORD cCharsWritten;
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
if(__hStdOut)
|
||||
{
|
||||
WriteConsole(__hStdOut, s, strlen(s), &cCharsWritten, NULL);
|
||||
}
|
||||
// -------------
|
||||
|
||||
return(cnt);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
// Clear console screen
|
||||
void ClearScreen()
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
if(g_consoleEnable)
|
||||
{
|
||||
COORD coordScreen = { 0, 0 };
|
||||
DWORD cCharsWritten;
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||
DWORD dwConSize;
|
||||
|
||||
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
|
||||
GetConsoleScreenBufferInfo(hConsole, &csbi);
|
||||
dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
|
||||
FillConsoleOutputCharacter(hConsole, TEXT(' '), dwConSize,
|
||||
coordScreen, &cCharsWritten);
|
||||
GetConsoleScreenBufferInfo(hConsole, &csbi);
|
||||
FillConsoleOutputAttribute(hConsole, csbi.wAttributes, dwConSize,
|
||||
coordScreen, &cCharsWritten);
|
||||
SetConsoleCursorPosition(hConsole, coordScreen);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
// Get window handle of console window to be able to resize it
|
||||
#if defined(_WIN32)
|
||||
HWND GetConsoleHwnd(void)
|
||||
{
|
||||
|
||||
#define MY_BUFSIZE 1024 // Buffer size for console window titles.
|
||||
HWND hwndFound; // This is what is returned to the caller.
|
||||
char pszNewWindowTitle[MY_BUFSIZE]; // Contains fabricated
|
||||
// WindowTitle.
|
||||
char pszOldWindowTitle[MY_BUFSIZE]; // Contains original
|
||||
// WindowTitle.
|
||||
|
||||
// Fetch current window title.
|
||||
|
||||
GetConsoleTitle(pszOldWindowTitle, MY_BUFSIZE);
|
||||
|
||||
// Format a "unique" NewWindowTitle.
|
||||
|
||||
wsprintf(pszNewWindowTitle,"%d/%d",
|
||||
GetTickCount(),
|
||||
GetCurrentProcessId());
|
||||
|
||||
// Change current window title.
|
||||
|
||||
SetConsoleTitle(pszNewWindowTitle);
|
||||
|
||||
// Ensure window title has been updated.
|
||||
|
||||
Sleep(40);
|
||||
|
||||
// Look for NewWindowTitle.
|
||||
|
||||
hwndFound = FindWindow(NULL, pszNewWindowTitle);
|
||||
|
||||
// Restore original window title.
|
||||
|
||||
SetConsoleTitle(pszOldWindowTitle);
|
||||
|
||||
return(hwndFound);
|
||||
|
||||
}
|
||||
#endif // win32
|
|
@ -0,0 +1,26 @@
|
|||
// Copyright (C) 2003-2008 Dolphin Project.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, version 2.0.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License 2.0 for more details.
|
||||
|
||||
// A copy of the GPL 2.0 should have been included with the program.
|
||||
// If not, see http://www.gnu.org/licenses/
|
||||
|
||||
// Official SVN repository and contact information can be found at
|
||||
// http://code.google.com/p/dolphin-emu/
|
||||
|
||||
|
||||
void startConsoleWin(int width, int height, char* fname);
|
||||
int wprintf(char *fmt, ...);
|
||||
int aprintf(int a, char *fmt, ...);
|
||||
void ClearScreen();
|
||||
|
||||
#ifdef _WIN32
|
||||
HWND GetConsoleHwnd(void);
|
||||
#endif
|
|
@ -28,6 +28,8 @@
|
|||
#include "wiimote_emu.h"
|
||||
#include "wiimote_real.h"
|
||||
|
||||
#include "Console.h" // for startConsoleWin, wprintf, GetConsoleHwnd
|
||||
|
||||
SWiimoteInitialize g_WiimoteInitialize;
|
||||
#define VERSION_STRING "0.1"
|
||||
|
||||
|
@ -35,8 +37,6 @@ bool g_UseRealWiiMote = false;
|
|||
|
||||
HINSTANCE g_hInstance;
|
||||
|
||||
|
||||
|
||||
class wxDLLApp : public wxApp
|
||||
{
|
||||
bool OnInit()
|
||||
|
@ -119,6 +119,11 @@ extern "C" void Wiimote_Initialize(SWiimoteInitialize _WiimoteInitialize)
|
|||
|
||||
|
||||
WiiMoteEmu::Initialize();
|
||||
|
||||
// Debugging window
|
||||
/*startConsoleWin(100, 30, "Wiimote"); // give room for 20 rows
|
||||
wprintf("Wiimote console opened\n");
|
||||
MoveWindow(GetConsoleHwnd(), 0,400, 100*8,30*14, true); // move window, TODO: make this*/
|
||||
}
|
||||
|
||||
extern "C" void Wiimote_DoState(void* ptr, int mode)
|
||||
|
|
|
@ -18,9 +18,11 @@
|
|||
|
||||
#include "pluginspecs_wiimote.h"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "common.h"
|
||||
#include "wiimote_hid.h"
|
||||
#include "Console.h" // for startConsoleWin, wprintf, GetConsoleHwnd
|
||||
|
||||
extern SWiimoteInitialize g_WiimoteInitialize;
|
||||
extern void __Log(int log, const char *format, ...);
|
||||
|
@ -416,11 +418,142 @@ void FillReportInfo(wm_core& _core)
|
|||
#endif
|
||||
}
|
||||
|
||||
// -----------------------------
|
||||
// Global declarations for FillReportAcc. The accelerometer x, y and z values range from
|
||||
// 0x00 to 0xff with 0x80 being neutral and 0x00 being - and 0xff being +
|
||||
// ----------
|
||||
//int A = 64, B = 64, C = 64; // for debugging
|
||||
int X = 0x80, Y = 0x80, Z = 0x80; // global so they can be changed during debugging
|
||||
u8 x = 0x80, y = 0x80, z = 0x80;
|
||||
int shake = -1; // for the shake function
|
||||
std::vector<u8> yhist(15); // for the tilt function
|
||||
|
||||
void FillReportAcc(wm_accel& _acc)
|
||||
{
|
||||
_acc.x = 0x00;
|
||||
_acc.y = 0x00;
|
||||
_acc.z = 0x00;
|
||||
// -----------------------------
|
||||
// Wiimote to Gamepad translations
|
||||
// ----------
|
||||
// Tilting Wiimote (Wario Land aiming, Mario Kart steering)
|
||||
if(GetAsyncKeyState('3'))
|
||||
y+=2; // aim left
|
||||
else if(GetAsyncKeyState('4'))
|
||||
y-=2; // aim right
|
||||
|
||||
// Single shake of Wiimote while holding it sideways (Wario Land pound ground)
|
||||
if(GetAsyncKeyState('S'))
|
||||
{
|
||||
z = 0;
|
||||
y = 0;
|
||||
shake = 2;
|
||||
}
|
||||
else if(shake == 2)
|
||||
{
|
||||
z = 128;
|
||||
y = 0;
|
||||
shake = 1;
|
||||
}
|
||||
else if(shake == 1)
|
||||
{
|
||||
z = Z;
|
||||
y = Y;
|
||||
shake = -1;
|
||||
}
|
||||
// ----------
|
||||
|
||||
|
||||
// -----------------------------
|
||||
// Add new value and move all back
|
||||
// ----------
|
||||
bool ypressed = false;
|
||||
|
||||
yhist[yhist.size() - 1] = (
|
||||
GetAsyncKeyState('3') ? true : false
|
||||
|| GetAsyncKeyState('4') ? true : false
|
||||
|| shake > 0
|
||||
);
|
||||
for (int i = 1; i < yhist.size(); i++)
|
||||
{
|
||||
yhist[i-1] = yhist[i];
|
||||
if(yhist[i]) ypressed = true;
|
||||
}
|
||||
|
||||
if(!ypressed) // y was not pressed a single time
|
||||
{
|
||||
y = Y;
|
||||
}
|
||||
// ----------
|
||||
|
||||
|
||||
// Write values
|
||||
_acc.x = X;
|
||||
_acc.y = y;
|
||||
_acc.z = z;
|
||||
|
||||
|
||||
// ----------------------------
|
||||
// Debugging for translating Wiimote to Gamepad
|
||||
// ----------
|
||||
/*
|
||||
if(GetAsyncKeyState('5'))
|
||||
A-=8;
|
||||
else if(GetAsyncKeyState('6'))
|
||||
A+=8;
|
||||
if(GetAsyncKeyState('7'))
|
||||
B-=8;
|
||||
else if(GetAsyncKeyState('8'))
|
||||
B+=8;
|
||||
if(GetAsyncKeyState('9'))
|
||||
C-=8;
|
||||
else if(GetAsyncKeyState('0'))
|
||||
C+=8;
|
||||
|
||||
|
||||
if(GetAsyncKeyState(VK_NUMPAD1))
|
||||
X+=8;
|
||||
else if(GetAsyncKeyState(VK_NUMPAD2))
|
||||
X-=8;
|
||||
if(GetAsyncKeyState(VK_NUMPAD4))
|
||||
Y+=8;
|
||||
else if(GetAsyncKeyState(VK_NUMPAD5))
|
||||
Y-=8;
|
||||
if(GetAsyncKeyState(VK_NUMPAD7))
|
||||
Z+=8;
|
||||
else if(GetAsyncKeyState(VK_NUMPAD8))
|
||||
Z-=8;
|
||||
|
||||
if(GetAsyncKeyState('S'))
|
||||
{
|
||||
z = Z + C;
|
||||
}
|
||||
else
|
||||
{
|
||||
z = Z;
|
||||
}
|
||||
|
||||
if(GetAsyncKeyState('D'))
|
||||
{
|
||||
y = Y + B;
|
||||
}
|
||||
else
|
||||
{
|
||||
y = Y;
|
||||
}
|
||||
|
||||
if(GetAsyncKeyState('F'))
|
||||
{
|
||||
z = Z + C;
|
||||
y = Y + B;
|
||||
}
|
||||
else if(!GetAsyncKeyState('S') && !GetAsyncKeyState('D'))
|
||||
{
|
||||
z = Z;
|
||||
y = Y;
|
||||
}
|
||||
|
||||
wprintf("x: %03i | y: %03i | z: %03i | A:%i B:%i C:%i X:%i Y:%i Z:%i\n", _acc.x, _acc.y, _acc.z,
|
||||
A, B, C,
|
||||
X, Y, Z);
|
||||
*/
|
||||
}
|
||||
|
||||
void FillReportIR(wm_ir_extended& _ir0, wm_ir_extended& _ir1)
|
||||
|
|
Loading…
Reference in New Issue