From db23e9a6c0dc3551cda583d3001e65fe2b8df3df Mon Sep 17 00:00:00 2001 From: masken Date: Fri, 12 Sep 2008 20:45:06 +0000 Subject: [PATCH] Wiimote: added hardcoded example data reporting functions. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@503 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp | 46 ++++++++++++++++ .../Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.h | 2 + Source/Core/Core/Src/IPC_HLE/wiimote_hid.h | 54 +++++++++++++++++++ 3 files changed, 102 insertions(+) diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp index a5dd0572d9..821995cf18 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp @@ -403,6 +403,51 @@ void CWII_IPC_HLE_WiiMote::WmDataReporting(wm_data_reporting* dr) { LOG(WIIMOTE, " Continuous: %x", dr->continuous); LOG(WIIMOTE, " Rumble: %x", dr->rumble); LOG(WIIMOTE, " Mode: 0x%02x", dr->mode); + + if(dr->mode == 0x33) + SendReportCoreAccelIr12(); + else if(dr->mode == 0x31) + SendReportCoreAccel(); +} + +void CWII_IPC_HLE_WiiMote::SendReportCoreAccelIr12() { + u8 DataFrame[1024]; + u32 Offset = WriteWmReport(DataFrame, WM_REPORT_CORE_ACCEL_IR12); + + wm_report_core_accel_ir12* pReport = (wm_report_core_accel_ir12*)(DataFrame + Offset); + Offset += sizeof(wm_report_core_accel_ir12); + memset(pReport, 0, sizeof(wm_report_core_accel_ir12)); + memset(pReport->ir, 0xFF, sizeof(pReport->ir)); + pReport->c.b = 1; + pReport->a.x = 0x81; + pReport->a.y = 0x78; + pReport->a.z = 0xD9; + pReport->ir[0].x = 320 & 0xFF; + pReport->ir[0].y = 240; + pReport->ir[0].size = 10; + pReport->ir[0].xHi = 320 >> 8; + pReport->ir[0].yHi = 0; + + LOG(WIIMOTE, " SendReportCoreAccelIr12()"); + + SendL2capData(HID_INPUT_SCID, DataFrame, Offset); +} + +void CWII_IPC_HLE_WiiMote::SendReportCoreAccel() { + u8 DataFrame[1024]; + u32 Offset = WriteWmReport(DataFrame, WM_REPORT_CORE_ACCEL); + + wm_report_core_accel* pReport = (wm_report_core_accel*)(DataFrame + Offset); + Offset += sizeof(wm_report_core_accel); + memset(pReport, 0, sizeof(wm_report_core_accel)); + pReport->c.a = 1; + pReport->a.x = 0x82; + pReport->a.y = 0x75; + pReport->a.z = 0xD6; + + LOG(WIIMOTE, " SendReportCoreAccel()"); + + SendL2capData(HID_INPUT_SCID, DataFrame, Offset); } void CWII_IPC_HLE_WiiMote::WmReadData(wm_read_data* rd) { @@ -505,6 +550,7 @@ void CWII_IPC_HLE_WiiMote::WmRequestStatus(wm_request_status* rs) { Offset += sizeof(wm_status_report); memset(pStatus, 0, sizeof(wm_status_report)); pStatus->leds = m_Leds; + pStatus->ir = 1; pStatus->battery = 100; //arbitrary number LOG(WIIMOTE, " SendStatusReport()"); diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.h b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.h index f3b0687149..5e151d25a5 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.h +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.h @@ -116,6 +116,8 @@ private: void SendConfigurationRequest(u16 scid); void SendReadDataReply(void* _Base, u16 _Address, u8 _Size); void SendWriteDataReply(); + void SendReportCoreAccel(); + void SendReportCoreAccelIr12(); int WriteWmReport(u8* dst, u8 channel); diff --git a/Source/Core/Core/Src/IPC_HLE/wiimote_hid.h b/Source/Core/Core/Src/IPC_HLE/wiimote_hid.h index e5557d1afc..0175a1c6b3 100644 --- a/Source/Core/Core/Src/IPC_HLE/wiimote_hid.h +++ b/Source/Core/Core/Src/IPC_HLE/wiimote_hid.h @@ -107,6 +107,60 @@ struct wm_read_data_reply { #define WM_RDERR_WOREG 7 #define WM_RDERR_NOMEM 8 +struct wm_core { + u8 left : 1; + u8 right : 1; + u8 down : 1; + u8 up : 1; + u8 plus : 1; + u8 : 3; + u8 two : 1; + u8 one : 1; + u8 b : 1; + u8 a : 1; + u8 minus : 1; + u8 : 2; + u8 home : 1; +}; + +struct wm_accel { + u8 x, y, z; +}; + +//filled with 0xFF if empty +struct wm_ir_extended { + u8 x; + u8 y; + u8 size : 4; + u8 xHi : 2; + u8 yHi : 2; +}; + +#define WM_REPORT_CORE 0x30 + +#define WM_REPORT_CORE_ACCEL 0x31 +struct wm_report_core_accel { + wm_core c; + wm_accel a; +}; + +#define WM_REPORT_CORE_EXT8 0x32 + +#define WM_REPORT_CORE_ACCEL_IR12 0x33 +struct wm_report_core_accel_ir12 { + wm_core c; + wm_accel a; + wm_ir_extended ir[4]; +}; + +#define WM_REPORT_CORE_EXT19 0x34 +#define WM_REPORT_CORE_ACCEL_EXT16 0x35 +#define WM_REPORT_CORE_IR10_EXT9 0x36 +#define WM_REPORT_CORE_ACCEL_IR10_EXT6 0x37 +#define WM_REPORT_EXT21 0x3d +#define WM_REPORT_INTERLEAVE1 0x3e +#define WM_REPORT_INTERLEAVE2 0x3f + #if defined(_MSC_VER) #pragma pack(pop) #endif