Emulated Wiimote: Don't report IR positions outside the screen (leave them at 0xff), don't report A and B button mouse clicks when the cursor is outside the screen
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2042 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
31cd8ed9d2
commit
6c7e674e69
|
@ -106,11 +106,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plugin_Wiimote", "Plugins\P
|
|||
{C573CAF7-EE6A-458E-8049-16C0BF34C2E9} = {C573CAF7-EE6A-458E-8049-16C0BF34C2E9}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plugin_DSP_NULL", "Plugins\Plugin_DSP_NULL\Plugin_DSP_NULL.vcproj", "{C6CC7A52-0FDD-433A-B2CF-9C6F187DA807}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{C573CAF7-EE6A-458E-8049-16C0BF34C2E9} = {C573CAF7-EE6A-458E-8049-16C0BF34C2E9}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plugin_nJoy_SDL_Test", "Plugins\Plugin_nJoy_Testing\Plugin_nJoy_SDL_Test.vcproj", "{ADF64291-57ED-4B7A-AB76-37B4A991504B}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{48AD7E0A-25B1-4974-A1E3-03F8C438D34F} = {48AD7E0A-25B1-4974-A1E3-03F8C438D34F}
|
||||
|
@ -319,13 +314,6 @@ Global
|
|||
{8D612734-FAA5-4B8A-804F-4DEA2367D495}.Release|Win32.Build.0 = Release|Win32
|
||||
{8D612734-FAA5-4B8A-804F-4DEA2367D495}.Release|x64.ActiveCfg = Release|x64
|
||||
{8D612734-FAA5-4B8A-804F-4DEA2367D495}.Release|x64.Build.0 = Release|x64
|
||||
{C6CC7A52-0FDD-433A-B2CF-9C6F187DA807}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{C6CC7A52-0FDD-433A-B2CF-9C6F187DA807}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{C6CC7A52-0FDD-433A-B2CF-9C6F187DA807}.DebugFast|Win32.ActiveCfg = DebugFast|Win32
|
||||
{C6CC7A52-0FDD-433A-B2CF-9C6F187DA807}.DebugFast|x64.ActiveCfg = DebugFast|x64
|
||||
{C6CC7A52-0FDD-433A-B2CF-9C6F187DA807}.DebugFast|x64.Build.0 = DebugFast|x64
|
||||
{C6CC7A52-0FDD-433A-B2CF-9C6F187DA807}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{C6CC7A52-0FDD-433A-B2CF-9C6F187DA807}.Release|x64.ActiveCfg = Release|x64
|
||||
{ADF64291-57ED-4B7A-AB76-37B4A991504B}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{ADF64291-57ED-4B7A-AB76-37B4A991504B}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{ADF64291-57ED-4B7A-AB76-37B4A991504B}.DebugFast|Win32.ActiveCfg = DebugFast|Win32
|
||||
|
@ -429,7 +417,6 @@ Global
|
|||
{E5D1F0C0-AA07-4841-A4EB-4CF4DAA6B0FA} = {5C17B1EB-6C76-438A-A503-8F3C7831023B}
|
||||
{D6E56527-BBB9-4EAD-A6EC-49D4BF6AFCD8} = {5C17B1EB-6C76-438A-A503-8F3C7831023B}
|
||||
{8D612734-FAA5-4B8A-804F-4DEA2367D495} = {5C17B1EB-6C76-438A-A503-8F3C7831023B}
|
||||
{C6CC7A52-0FDD-433A-B2CF-9C6F187DA807} = {5C17B1EB-6C76-438A-A503-8F3C7831023B}
|
||||
{ADF64291-57ED-4B7A-AB76-37B4A991504B} = {5C17B1EB-6C76-438A-A503-8F3C7831023B}
|
||||
{521498BE-6089-4780-8223-E67C22F4E068} = {5C17B1EB-6C76-438A-A503-8F3C7831023B}
|
||||
{636FAD5F-02D1-4E9A-BE67-FB8EA99B9A18} = {5C17B1EB-6C76-438A-A503-8F3C7831023B}
|
||||
|
|
|
@ -180,7 +180,7 @@ void SendReportCoreAccelIr12(u16 _channelID) {
|
|||
FillReportInfo(pReport->c);
|
||||
FillReportAcc(pReport->a);
|
||||
|
||||
// We settle with emulating two objects, not all four
|
||||
// We settle with emulating two objects, not all four. We leave object 2 and 3 with zero.
|
||||
FillReportIR(pReport->ir[0], pReport->ir[1]);
|
||||
|
||||
LOGV(WII_IPC_WIIMOTE, 2, " SendReportCoreAccelIr12()");
|
||||
|
|
|
@ -57,30 +57,41 @@ u16 convert16bit(const u8* src) {
|
|||
|
||||
|
||||
// ===================================================
|
||||
/* Calibrate the mouse position to the emulation window. */
|
||||
/* Calibrate the mouse position to the emulation window. g_WiimoteInitialize.hWnd is the rendering window handle. */
|
||||
// ----------------
|
||||
void GetMousePos(float& x, float& y)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
POINT point;
|
||||
|
||||
// Get the cursor position for the entire screen
|
||||
GetCursorPos(&point);
|
||||
// Get the cursor position relative to the upper left corner of the rendering window
|
||||
ScreenToClient(g_WiimoteInitialize.hWnd, &point);
|
||||
|
||||
// Get the size of the rendering window. In my case top and left was zero.
|
||||
RECT Rect;
|
||||
GetClientRect(g_WiimoteInitialize.hWnd, &Rect);
|
||||
|
||||
// Width and height is the size of the rendering window
|
||||
int width = Rect.right - Rect.left;
|
||||
int height = Rect.bottom - Rect.top;
|
||||
|
||||
// Return the mouse position as a fraction of one
|
||||
x = point.x / (float)width;
|
||||
y = point.y / (float)height;
|
||||
|
||||
/*
|
||||
Console::ClearScreen();
|
||||
Console::Print("GetCursorPos: %i %i\n", point.x, point.y);
|
||||
Console::Print("GetClientRect: %i %i %i %i\n", Rect.left, Rect.right, Rect.top, Rect.bottom);
|
||||
Console::Print("x and y: %f %f\n", x, y);
|
||||
*/
|
||||
#else
|
||||
// TODO fix on linux
|
||||
// TODO fix on linux
|
||||
x = 0.5f;
|
||||
y = 0.5f;
|
||||
#endif
|
||||
}
|
||||
// ==============
|
||||
|
||||
|
||||
// ===================================================
|
||||
|
|
|
@ -197,11 +197,15 @@ void FillReportInfo(wm_core& _core)
|
|||
// These keys are reserved for the recording
|
||||
if ( GetAsyncKeyState(VK_SHIFT) || GetAsyncKeyState(VK_CONTROL) ) return;
|
||||
|
||||
// Check the mouse position. Don't allow mouse clicks from outside the window.
|
||||
float x, y; GetMousePos(x, y);
|
||||
bool InsideScreen = !(x < 0 || x > 1 || y < 0 || y > 1);
|
||||
|
||||
// Allow both mouse buttons and keyboard to press a and b
|
||||
if(GetAsyncKeyState(VK_LBUTTON) ? 1 : 0 || GetAsyncKeyState('A') ? 1 : 0)
|
||||
if((GetAsyncKeyState(VK_LBUTTON) && InsideScreen) || GetAsyncKeyState('A') ? 1 : 0)
|
||||
_core.a = 1;
|
||||
|
||||
if(GetAsyncKeyState(VK_RBUTTON) ? 1 : 0 || GetAsyncKeyState('B') ? 1 : 0)
|
||||
if((GetAsyncKeyState(VK_RBUTTON) && InsideScreen) || GetAsyncKeyState('B') ? 1 : 0)
|
||||
_core.b = 1;
|
||||
|
||||
_core.one = GetAsyncKeyState('1') ? 1 : 0;
|
||||
|
@ -447,6 +451,9 @@ void FillReportAcc(wm_accel& _acc)
|
|||
/////////////////////////
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
// The extended 12 byte (3 byte per object) reporting
|
||||
// ---------------
|
||||
void FillReportIR(wm_ir_extended& _ir0, wm_ir_extended& _ir1)
|
||||
{
|
||||
|
||||
|
@ -465,13 +472,17 @@ void FillReportIR(wm_ir_extended& _ir0, wm_ir_extended& _ir1)
|
|||
Bottom = BOTTOM; SensorBarRadius = SENSOR_BAR_RADIUS;
|
||||
}
|
||||
|
||||
// Fill with 0xff (0r 0x00?) if empty
|
||||
memset(&_ir0, 0x00, sizeof(wm_ir_extended));
|
||||
memset(&_ir1, 0x00, sizeof(wm_ir_extended));
|
||||
/* Fill with 0xff if empty. The real Wiimote seems to use 0xff when it sees to ojbects, at least from
|
||||
how WiiMoteReal::SendEvent() works. */
|
||||
memset(&_ir0, 0xff, sizeof(wm_ir_extended));
|
||||
memset(&_ir1, 0xff, sizeof(wm_ir_extended));
|
||||
|
||||
float MouseX, MouseY;
|
||||
GetMousePos(MouseX, MouseY);
|
||||
|
||||
// If we are outside the screen leave the values at 0xff
|
||||
if(MouseX > 1 || MouseX < 0 || MouseY > 1 || MouseY < 0) return;
|
||||
|
||||
int y0 = Top + (MouseY * (Bottom - Top));
|
||||
int y1 = Top + (MouseY * (Bottom - Top));
|
||||
|
||||
|
@ -548,13 +559,16 @@ void FillReportIRBasic(wm_ir_basic& _ir0, wm_ir_basic& _ir1)
|
|||
Bottom = BOTTOM; SensorBarRadius = SENSOR_BAR_RADIUS;
|
||||
}
|
||||
|
||||
// Fill with 0x00 if empty
|
||||
memset(&_ir0, 0x00, sizeof(wm_ir_basic));
|
||||
memset(&_ir1, 0x00, sizeof(wm_ir_basic));
|
||||
// Fill with 0xff if empty
|
||||
memset(&_ir0, 0xff, sizeof(wm_ir_basic));
|
||||
memset(&_ir1, 0xff, sizeof(wm_ir_basic));
|
||||
|
||||
float MouseX, MouseY;
|
||||
GetMousePos(MouseX, MouseY);
|
||||
|
||||
// If we are outside the screen leave the values at 0xff
|
||||
if(MouseX > 1 || MouseX < 0 || MouseY > 1 || MouseY < 0) return;
|
||||
|
||||
int y1 = Top + (MouseY * (Bottom - Top));
|
||||
int y2 = Top + (MouseY * (Bottom - Top));
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "main.h"
|
||||
#include "Config.h"
|
||||
#include "EmuMain.h"
|
||||
#include "EmuDefinitions.h"
|
||||
#define EXCLUDE_H // Avoid certain declarations in wiimote_real.h
|
||||
#include "wiimote_real.h"
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
|
@ -243,6 +244,15 @@ void SendEvent(SEvent& _rEvent)
|
|||
memcpy(&Buffer[Offset], _rEvent.m_PayLoad, MAX_PAYLOAD);
|
||||
Offset += MAX_PAYLOAD;
|
||||
|
||||
/* Debugging
|
||||
//if(GetAsyncKeyState('V'))
|
||||
{
|
||||
std::string Temp = ArrayToString(Buffer, Offset, 0, 30);
|
||||
Console::ClearScreen();
|
||||
Console::Print("Reporting Mode: 0x%02x\n", WiiMoteEmu::g_ReportingMode);
|
||||
Console::Print("DataFrame: %s\n", Temp.c_str());
|
||||
}*/
|
||||
|
||||
g_WiimoteInitialize.pWiimoteInput(m_channelID, Buffer, Offset);
|
||||
}
|
||||
/////////////////////
|
||||
|
|
Loading…
Reference in New Issue