mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 06:39:46 -06:00
Wiimote: Added optional status icons for the Wiimote speaker and leds. And a few other small changes.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1455 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -37,7 +37,9 @@ namespace WiiMoteEmu
|
||||
// Definitions and variable declarations
|
||||
//******************************************************************************
|
||||
|
||||
u8 g_Leds = 0x1;
|
||||
u8 g_Leds = 0x0; // 4 bits
|
||||
u8 g_Speaker = 0x1; // 1 = on
|
||||
u8 g_SpeakerVoice = 0x1; // 1 = on
|
||||
u8 g_IR = 0x1; // 1 = on
|
||||
|
||||
u8 g_Eeprom[WIIMOTE_EEPROM_SIZE];
|
||||
@ -54,4 +56,4 @@ wiimote_key g_ExtKey; // the extension encryption key
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif //_EMU_DECLARATIONS_
|
||||
#endif //_EMU_DECLARATIONS_
|
||||
|
@ -20,7 +20,10 @@
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "Common.h"
|
||||
|
||||
#include "Common.h" // Common
|
||||
#include "StringUtil.h" // for ArrayToString
|
||||
|
||||
#include "wiimote_hid.h"
|
||||
#include "EmuSubroutines.h"
|
||||
#include "EmuDefinitions.h"
|
||||
@ -53,7 +56,6 @@ namespace WiiMoteEmu
|
||||
// ----------------
|
||||
void HidOutputReport(u16 _channelID, wm_report* sr) {
|
||||
LOGV(WII_IPC_WIIMOTE, 0, "===========================================================");
|
||||
|
||||
LOGV(WII_IPC_WIIMOTE, 0, "HidOutputReport (0x%02x)", sr->channel);
|
||||
|
||||
switch(sr->channel)
|
||||
@ -73,22 +75,31 @@ void HidOutputReport(u16 _channelID, wm_report* sr) {
|
||||
case WM_READ_DATA: // 0x17
|
||||
WmReadData(_channelID, (wm_read_data*)sr->data);
|
||||
break;
|
||||
|
||||
/* This enables or disables the IR lights, we update the global variable g_IR
|
||||
so that WmRequestStatus() knows about it */
|
||||
case WM_IR_PIXEL_CLOCK: // 0x13
|
||||
case WM_IR_LOGIC: // 0x1a
|
||||
LOGV(WII_IPC_WIIMOTE, 0, " IR Enable 0x%02x: 0x%02x", sr->channel, sr->data[0]);
|
||||
//wprintf("IR Enable/Disable 0x%02x: 0x%02x\n", sr->channel, sr->data[0]);
|
||||
// Update the global value so that WmRequestStatus() knows it
|
||||
if(sr->data[0] == 0x02) g_IR = 0;
|
||||
else if(sr->data[0] == 0x06) g_IR = 1;
|
||||
break;
|
||||
|
||||
case WM_WRITE_DATA: // 0x16
|
||||
WmWriteData(_channelID, (wm_write_data*)sr->data);
|
||||
break;
|
||||
case WM_SPEAKER_ENABLE:
|
||||
case WM_SPEAKER_ENABLE: // 0x14
|
||||
LOGV(WII_IPC_WIIMOTE, 1, " WM Speaker Enable 0x%02x: 0x%02x", sr->channel, sr->data[0]);
|
||||
//wprintf("Speaker Enable/Disable 0x%02x: 0x%02x\n", sr->channel, sr->data[0]);
|
||||
if(sr->data[0] == 0x02) g_Speaker = 0;
|
||||
else if(sr->data[0] == 0x06) g_Speaker = 1;
|
||||
break;
|
||||
case WM_SPEAKER_MUTE:
|
||||
LOGV(WII_IPC_WIIMOTE, 1, " WM Mute Enable 0x%02x: 0x%02x", sr->channel, sr->data[0]);
|
||||
//wprintf("Speaker Mute/Unmute 0x%02x: 0x%02x\n", sr->channel, sr->data[0]);
|
||||
if(sr->data[0] == 0x02) g_SpeakerVoice = 0;
|
||||
else if(sr->data[0] == 0x06) g_SpeakerVoice = 1;
|
||||
break;
|
||||
default:
|
||||
PanicAlert("HidOutputReport: Unknown channel 0x%02x", sr->channel);
|
||||
@ -307,7 +318,7 @@ void WmWriteData(u16 _channelID, wm_write_data* wd)
|
||||
LOG(WII_IPC_WIIMOTE, " Address: 0x%06x", address);
|
||||
LOG(WII_IPC_WIIMOTE, " Size: 0x%02x", wd->size);
|
||||
LOG(WII_IPC_WIIMOTE, " Rumble: %x", wd->rumble);
|
||||
//std::string Temp = WiiMoteEmu::ArrayToString(wd->data, wd->size);
|
||||
//std::string Temp = ArrayToString(wd->data, wd->size);
|
||||
//LOGV(WII_IPC_WIIMOTE, 0, " Data: %s", Temp.c_str());
|
||||
|
||||
// Write to EEPROM
|
||||
@ -329,7 +340,10 @@ void WmWriteData(u16 _channelID, wm_write_data* wd)
|
||||
case 0xA2:
|
||||
block = g_RegSpeaker;
|
||||
blockSize = WIIMOTE_REG_SPEAKER_SIZE;
|
||||
LOGV(WII_IPC_WIIMOTE, 0, " Case 0xa2: g_RegSpeaker");
|
||||
LOGV(WII_IPC_WIIMOTE, 0, " Case 0xa2: RegSpeaker");
|
||||
//wprintf("\n\nWrite to RegSpeaker: Size: %i, Address: %08x, Offset: %08x\n",
|
||||
// wd->size, address, (address & 0xffff));
|
||||
//wprintf("Data: %s\n", Temp.c_str());
|
||||
break;
|
||||
case 0xA4:
|
||||
block = g_RegExt; // Extension Controller register
|
||||
@ -337,13 +351,13 @@ void WmWriteData(u16 _channelID, wm_write_data* wd)
|
||||
//LOGV(WII_IPC_WIIMOTE, 0, " *******************************************************");
|
||||
LOGV(WII_IPC_WIIMOTE, 0, " Case 0xa4: ExtReg");
|
||||
//LOGV(WII_IPC_WIIMOTE, 0, " *******************************************************");
|
||||
wprintf("\n\nWmWriteData Size: %i Address: %08x Offset: %08x \n",
|
||||
wd->size, address, (address & 0xffff));
|
||||
//wprintf("\n\nWmWriteData Size: %i Address: %08x Offset: %08x \n",
|
||||
// wd->size, address, (address & 0xffff));
|
||||
break;
|
||||
case 0xB0:
|
||||
block = g_RegIr;
|
||||
blockSize = WIIMOTE_REG_IR_SIZE;
|
||||
LOGV(WII_IPC_WIIMOTE, 0, " Case 0xb0: g_RegIr");
|
||||
LOGV(WII_IPC_WIIMOTE, 0, " Case 0xb0: RegIr");
|
||||
break;
|
||||
default:
|
||||
PanicAlert("WmWriteData: bad register block!");
|
||||
@ -479,9 +493,9 @@ void WmRequestStatus(u16 _channelID, wm_request_status* rs)
|
||||
|
||||
// Status values
|
||||
pStatus->battery_low = 0; // battery is okay
|
||||
pStatus->leds = g_Leds; // current setting
|
||||
pStatus->ir = g_IR; // current setting
|
||||
|
||||
pStatus->leds = g_Leds; // leds are 4 bit
|
||||
pStatus->ir = g_IR; // 1 bit
|
||||
pStatus->speaker = g_Speaker; // 1 bit
|
||||
/* Battery levels in voltage
|
||||
0x00 - 0x32: level 1
|
||||
0x33 - 0x43: level 2
|
||||
@ -500,11 +514,9 @@ void WmRequestStatus(u16 _channelID, wm_request_status* rs)
|
||||
LOGV(WII_IPC_WIIMOTE, 0, " Flags: 0x%02x", pStatus->padding1[2]);
|
||||
LOGV(WII_IPC_WIIMOTE, 0, " Battery: %d", pStatus->battery);
|
||||
|
||||
//std::string Temp = WiiMoteEmu::ArrayToString(DataFrame, Offset, 0);
|
||||
//wprintf("Status Report: %s\n", Temp.c_str());
|
||||
|
||||
g_WiimoteInitialize.pWiimoteInput(_channelID, DataFrame, Offset);
|
||||
LOGV(WII_IPC_WIIMOTE, 0, "=================================================");
|
||||
}
|
||||
|
||||
} // end of namespace
|
||||
|
||||
|
@ -31,8 +31,6 @@ void InterruptChannel(u16 _channelID, const void* _pData, u32 _Size);
|
||||
void ControlChannel(u16 _channelID, const void* _pData, u32 _Size) ;
|
||||
void Update();
|
||||
|
||||
std::string ArrayToString(const u8 *data, u32 size, u32 offset = 0, int line_len = 20);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -41,8 +41,12 @@
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "Common.h"
|
||||
|
||||
#include "Common.h" // Common
|
||||
#include "StringUtil.h"
|
||||
|
||||
#include "wiimote_hid.h"
|
||||
#include "EmuMain.h"
|
||||
#include "EmuSubroutines.h"
|
||||
#include "EmuDefinitions.h"
|
||||
#include "Console.h" // for startConsoleWin, wprintf, GetConsoleHwnd
|
||||
@ -172,17 +176,10 @@ void InterruptChannel(u16 _channelID, const void* _pData, u32 _Size)
|
||||
const u8* data = (const u8*)_pData;
|
||||
|
||||
// Debugging. Dump raw data.
|
||||
{
|
||||
LOGV(WII_IPC_WIIMOTE, 3, "Wiimote_Input");
|
||||
std::string Temp;
|
||||
for (u32 j=0; j<_Size; j++)
|
||||
{
|
||||
char Buffer[128];
|
||||
sprintf(Buffer, "%02x ", data[j]);
|
||||
Temp.append(Buffer);
|
||||
}
|
||||
LOGV(WII_IPC_WIIMOTE, 3, " Data: %s", Temp.c_str());
|
||||
}
|
||||
LOGV(WII_IPC_WIIMOTE, 3, "Wiimote_Input");
|
||||
//std::string Temp = ArrayToString(data, sizeof(data), 0, 30);
|
||||
//LOGV(WII_IPC_WIIMOTE, 3, " Data: %s", Temp.c_str());
|
||||
|
||||
hid_packet* hidp = (hid_packet*) data;
|
||||
|
||||
switch(hidp->type)
|
||||
@ -194,7 +191,6 @@ void InterruptChannel(u16 _channelID, const void* _pData, u32 _Size)
|
||||
case HID_PARAM_OUTPUT:
|
||||
{
|
||||
wm_report* sr = (wm_report*)hidp->data;
|
||||
|
||||
HidOutputReport(_channelID, sr);
|
||||
|
||||
/* This is the 0x22 answer to all Inputs. In most games it didn't matter
|
||||
|
@ -41,6 +41,8 @@ namespace WiiMoteEmu
|
||||
|
||||
|
||||
extern u8 g_Leds;
|
||||
extern u8 g_Speaker;
|
||||
extern u8 g_SpeakerVoice;
|
||||
extern u8 g_IR;
|
||||
|
||||
extern u8 g_Eeprom[WIIMOTE_EEPROM_SIZE];
|
||||
@ -156,4 +158,4 @@ void GetMousePos(float& x, float& y);
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif //_EMU_DECLARATIONS_
|
||||
#endif //_EMU_DECLARATIONS_
|
||||
|
@ -40,25 +40,6 @@ namespace WiiMoteEmu
|
||||
//******************************************************************************
|
||||
|
||||
|
||||
// ===================================================
|
||||
/* Debugging. Read out an u8 array. */
|
||||
// ----------------
|
||||
std::string ArrayToString(const u8 *data, u32 size, u32 offset, int line_len)
|
||||
{
|
||||
//const u8* _data = (const u8*)data;
|
||||
std::string Temp;
|
||||
for (u32 i = 0; i < size; i++)
|
||||
{
|
||||
char Buffer[128];
|
||||
sprintf(Buffer, "%02x ", data[i + offset]);
|
||||
if((i + 1) % line_len == 0) Temp.append("\n"); // break long lines
|
||||
Temp.append(Buffer);
|
||||
}
|
||||
return Temp;
|
||||
}
|
||||
// ================
|
||||
|
||||
|
||||
void FillReportInfo(wm_core& _core)
|
||||
{
|
||||
memset(&_core, 0x00, sizeof(wm_core));
|
||||
|
@ -177,7 +177,7 @@ extern "C" void Wiimote_InterruptChannel(u16 _channelID, const void* _pData, u32
|
||||
{
|
||||
LOGV(WII_IPC_WIIMOTE, 3, "Wiimote_Input");
|
||||
LOGV(WII_IPC_WIIMOTE, 3, " Channel ID: %04x", _channelID);
|
||||
std::string Temp = WiiMoteEmu::ArrayToString(data, _Size);
|
||||
std::string Temp = ArrayToString(data, _Size);
|
||||
LOGV(WII_IPC_WIIMOTE, 3, " Data: %s", Temp.c_str());
|
||||
}
|
||||
|
||||
@ -199,7 +199,7 @@ extern "C" void Wiimote_ControlChannel(u16 _channelID, const void* _pData, u32 _
|
||||
// Debugging
|
||||
{
|
||||
LOGV(WII_IPC_WIIMOTE, 3, "Wiimote_ControlChannel");
|
||||
std::string Temp = WiiMoteEmu::ArrayToString(data, _Size);
|
||||
std::string Temp = ArrayToString(data, _Size);
|
||||
LOGV(WII_IPC_WIIMOTE, 3, " Data: %s", Temp.c_str());
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user