Fixed Issue 1928

Fixed Issue 1917
(Since wxWidgets is not allowed in core, so I moved the popup window to CFrame)

*Maybe* this could also fix Issue 1919?

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4780 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
ayuanx 2010-01-03 23:05:52 +00:00
parent ede1c935f4
commit 72b1570e08
8 changed files with 87 additions and 42 deletions

View File

@ -506,15 +506,20 @@ u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update()
// or CPU will disconnect WiiMote automatically
// but don't send too many or it will jam the bus and cost extra CPU time
// TODO: Figure out the correct frequency to send this thing
if (m_HCIBuffer.m_address && !WII_IPCInterface::GetAddress() && m_WiiMotes[0].IsConnected())
if (m_HCIBuffer.m_address && !WII_IPCInterface::GetAddress())
{
m_FreqDividerSync++;
if (m_FreqDividerSync >= 500) // Feel free to tweak it
{
m_FreqDividerSync = 0;
SendEventNumberOfCompletedPackets();
memset(m_PacketCount, 0, sizeof(m_PacketCount));
return true;
for (unsigned int i = 0; i < m_WiiMotes.size(); i++)
{
if (m_WiiMotes[i].IsConnected() == 3)
{
SendEventNumberOfCompletedPackets();
return true;
}
}
}
}
@ -629,7 +634,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventInquiryResponse()
pInquiryResult->PayloadLength = (u8)(sizeof(SHCIEventInquiryResult) - 2 + (m_WiiMotes.size() * sizeof(hci_inquiry_response)));
pInquiryResult->num_responses = (u8)m_WiiMotes.size();
for (size_t i=0; i<m_WiiMotes.size(); i++)
for (size_t i=0; i < m_WiiMotes.size(); i++)
{
if (m_WiiMotes[i].IsConnected())
continue;
@ -968,7 +973,13 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventRoleChange(bdaddr_t _bd, bool
bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventNumberOfCompletedPackets()
{
int Num = m_WiiMotes.size();
int Num = 0;
for (unsigned int i = 0; i < m_WiiMotes.size(); i++)
{
if (m_WiiMotes[i].IsConnected() == 3)
Num++;
}
if (Num == NULL)
return false;
@ -980,10 +991,13 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventNumberOfCompletedPackets()
pNumberOfCompletedPackets->NumberOfHandles = Num;
u16 *pData = (u16 *)(Event.m_buffer + sizeof(SHCIEventNumberOfCompletedPackets));
for (int i = 0; i < Num; i++)
for (unsigned int i = 0; i < m_WiiMotes.size(); i++)
{
pData[i] = m_WiiMotes[i].GetConnectionHandle();
pData[Num + i] = m_PacketCount[i];
if (m_WiiMotes[i].IsConnected() != 3) continue;
pData[0] = m_WiiMotes[i].GetConnectionHandle();
pData[Num] = m_PacketCount[i];
m_PacketCount[i] = 0;
pData++;
}
// Log
@ -1325,6 +1339,9 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::ExecuteHCICommandMessage(const SHCICom
//
void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandInquiry(u8* _Input)
{
// Inquiry should not be called normally
PanicAlert("HCI_CMD_INQUIRY is called, please report!");
if (SendEventCommandStatus(HCI_CMD_INQUIRY))
return;
@ -1399,10 +1416,6 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandDisconnect(u8* _Input)
DEBUG_LOG(WII_IPC_WIIMOTE, " Reason: 0x%02x", pDiscon->reason);
SendEventDisconnect(pDiscon->con_handle, pDiscon->reason);
PanicAlert("Wiimote (%i) has been disconnected by system due to idle time out.\n"
"Don't panic, this is quite a normal behavior for power saving.\n\n"
"To reconnect, Click \"Menu -> Tools -> Connect Wiimote\"", (pDiscon->con_handle & 0xFF) + 1);
CWII_IPC_HLE_WiiMote* pWiimote = AccessWiiMote(pDiscon->con_handle);
if (pWiimote)

View File

@ -43,6 +43,7 @@
#include "ConfigManager.h" // Core
#include "Core.h"
#include "HW/DVDInterface.h"
#include "IPC_HLE/WII_IPC_HLE_Device_usb.h"
#include "State.h"
#include "VolumeHandler.h"
@ -135,7 +136,7 @@ CPanel::CPanel(
: wxPanel(parent, id)
{
}
int abc = 0;
#ifdef _WIN32
WXLRESULT CPanel::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
{
@ -157,6 +158,15 @@ int abc = 0;
else
main_frame->bRenderToMain = true;
return 0;
case WIIMOTE_DISCONNECT:
// The Wiimote has been disconnect, we offer reconnect here
if(AskYesNo("Wiimote %i has been disconnected by system.\n"
"Maybe this game doesn't support multi-wiimote,\n"
"or maybe it is due to idle time out or other reason.\n\n"
"Do you want to reconnect immediately?", lParam + 1, "Confirm", wxYES_NO))
GetUsbPointer()->AccessWiiMote(lParam | 0x100)->Activate(true);
return 0;
}
break;
}

View File

@ -34,6 +34,20 @@ const TCHAR m_szClassName[] = _T("DolphinEmuWnd");
int g_winstyle;
static volatile bool s_sizing;
// ---------------------------------------------------------------------
/* Invisible cursor option. In the lack of a predefined IDC_BLANK we make
an empty transparent cursor */
// ------------------
HCURSOR hCursor = NULL, hCursorBlank = NULL;
void CreateCursors(HINSTANCE hInstance)
{
BYTE ANDmaskCursor[] = { 0xff };
BYTE XORmaskCursor[] = { 0x00 };
hCursorBlank = CreateCursor(hInstance, 0,0, 1,1, ANDmaskCursor,XORmaskCursor);
hCursor = LoadCursor(NULL, IDC_ARROW);
}
bool IsSizing()
{
return s_sizing;
@ -117,14 +131,18 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
// Which then handles all the necessary steps to Shutdown the core + the plugins
if (m_hParent == NULL)
{
PostMessage( m_hMain, WM_USER, WM_USER_STOP, 0 );
PostMessage(m_hMain, WM_USER, WM_USER_STOP, 0);
return 0;
}
break;
case WM_USER:
if (wParam == TOGGLE_FULLSCREEN)
if (wParam == WM_USER_STOP)
SetCursor((lParam) ? hCursor : hCursorBlank);
else if (wParam == TOGGLE_FULLSCREEN)
ToggleFullscreen(hWnd);
else if (wParam == WIIMOTE_DISCONNECT)
PostMessage(m_hMain, WM_USER, wParam, lParam);
break;
case WM_SYSCOMMAND:
@ -159,6 +177,8 @@ HWND OpenWindow(HWND parent, HINSTANCE hInstance, int width, int height, const T
m_hInstance = hInstance;
RegisterClassEx( &wndClass );
CreateCursors(m_hInstance);
if (g_Config.RenderToMainframe)
{
m_hParent = m_hMain = parent;

View File

@ -332,18 +332,19 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
and coordinate it with the other settings if nessesary */
case WM_USER:
if (wParam == WM_USER_STOP)
SetCursor((lParam) ? hCursor : hCursorBlank);
else if (wParam == WM_USER_KEYDOWN)
{
if (lParam)
SetCursor(hCursor);
else
SetCursor(hCursorBlank);
}
if (wParam == WM_USER_KEYDOWN) {
OnKeyDown(lParam);
FreeLookInput(wParam, lParam);
}
if (wParam == TOGGLE_FULLSCREEN && !g_Config.RenderToMainframe)
ToggleFullscreen(m_hWnd);
else if (wParam == TOGGLE_FULLSCREEN)
{
if(!g_Config.RenderToMainframe)
ToggleFullscreen(m_hWnd);
}
else if (wParam == WIIMOTE_DISCONNECT)
PostMessage(m_hMain, WM_USER, wParam, lParam);
break;
// This is called when we close the window when we render to a separate window

View File

@ -191,15 +191,10 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
only let it pass through Dolphin > Frame.cpp to determine if it should be on or off
and coordinate it with the other settings if nessesary */
case WM_USER:
/* I set wParam to 10 just in case there are other WM_USER events. If we want more
WM_USER cases we would start making wParam or lParam cases */
if (wParam == 10)
{
if (lParam)
SetCursor(hCursor);
else
SetCursor(hCursorBlank);
}
if (wParam == WM_USER_STOP)
SetCursor((lParam) ? hCursor : hCursorBlank);
else if (wParam == WIIMOTE_DISCONNECT)
PostMessage(m_hMain, WM_USER, wParam, lParam);
break;
/* Post thes mouse events to the main window, it's nessesary becase in difference to the

View File

@ -311,6 +311,8 @@ void Shutdown()
// Finally close SDL
if (SDL_WasInit(0))
SDL_Quit();
g_SearchDeviceDone = false;
}
// Start emulation
@ -555,15 +557,7 @@ void InterruptChannel(int _number, u16 _channelID, const void* _pData, u32 _Size
}
void ControlChannel(int _number, u16 _channelID, const void* _pData, u32 _Size)
{
// Check for custom communication
if(_channelID == 99 && *(const u8*)_pData == WIIMOTE_DISCONNECT)
{
WARN_LOG(WIIMOTE, "Wiimote: #%i Disconnected", _number);
g_ReportingAuto[_number] = false;
return;
}
{
g_ID = _number;
hid_packet* hidp = (hid_packet*)_pData;

View File

@ -333,6 +333,17 @@ void Wiimote_ControlChannel(int _number, u16 _channelID, const void* _pData, u32
DEBUG_LOG(WIIMOTE, " Data: %s", Temp.c_str());
#endif
// Check for custom communication
if(_channelID == 99 && *(const u8*)_pData == WIIMOTE_DISCONNECT)
{
WiiMoteEmu::g_ReportingAuto[_number] = false;
WARN_LOG(WIIMOTE, "Wiimote: #%i Disconnected", _number);
#ifdef _WIN32
PostMessage(g_WiimoteInitialize.hWnd, WM_USER, WIIMOTE_DISCONNECT, _number);
#endif
return;
}
if (WiiMoteEmu::WiiMapping[_number].Source <= 1)
WiiMoteEmu::ControlChannel(_number, _channelID, _pData, _Size);
#if HAVE_WIIUSE

View File

@ -253,6 +253,7 @@ void Shutdown()
// Remove the pointer to the initialize data
g_PADInitialize = NULL;
g_SearchDeviceDone = false;
}