summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorJordan Woyak <jordan.woyak@gmail.com>2013-02-11 05:30:51 -0600
committerJordan Woyak <jordan.woyak@gmail.com>2013-02-11 05:30:51 -0600
commitc267be2682cd6d6fbcf163893a1361aa49511c8f (patch)
tree7cf3de472e5c3f2be5d4134299cf04f713bcda6b /Source/Core
parent7a053d0f0715a5308300a9ee05928433a8250953 (diff)
Hopefully fix windows!
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/Src/HW/WiimoteReal/IOWin.cpp13
-rw-r--r--Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp10
2 files changed, 18 insertions, 5 deletions
diff --git a/Source/Core/Core/Src/HW/WiimoteReal/IOWin.cpp b/Source/Core/Core/Src/HW/WiimoteReal/IOWin.cpp
index 1920577de4..7c6f6f20d0 100644
--- a/Source/Core/Core/Src/HW/WiimoteReal/IOWin.cpp
+++ b/Source/Core/Core/Src/HW/WiimoteReal/IOWin.cpp
@@ -18,6 +18,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <regex>
+#include <algorithm>
#include <unordered_set>
#include <windows.h>
@@ -379,6 +380,14 @@ int Wiimote::IORead(unsigned char* buf)
int Wiimote::IOWrite(const u8* buf, int len)
{
+ u8 big_buf[MAX_PAYLOAD];
+ if (len < MAX_PAYLOAD)
+ {
+ std::copy(buf, buf + len, big_buf);
+ std::fill(big_buf + len, big_buf + MAX_PAYLOAD, 0);
+ buf = big_buf;
+ }
+
DWORD bytes = 0;
switch (stack)
{
@@ -386,7 +395,7 @@ int Wiimote::IOWrite(const u8* buf, int len)
{
// Try to auto-detect the stack type
- auto i = WriteFile(dev_handle, buf + 1, 22, &bytes, &hid_overlap);
+ auto i = WriteFile(dev_handle, buf + 1, MAX_PAYLOAD - 1, &bytes, &hid_overlap);
if (i)
{
// Bluesoleil will always return 1 here, even if it's not connected
@@ -433,7 +442,7 @@ int Wiimote::IOWrite(const u8* buf, int len)
break;
}
case MSBT_STACK_BLUESOLEIL:
- return WriteFile(dev_handle, buf + 1, 22, &bytes, &hid_overlap);
+ return WriteFile(dev_handle, buf + 1, MAX_PAYLOAD - 1, &bytes, &hid_overlap);
break;
}
diff --git a/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp b/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp
index 821eccea0c..e006ec1f69 100644
--- a/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp
+++ b/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp
@@ -249,15 +249,19 @@ bool Wiimote::Prepare(int _index)
{
index = _index;
+ // core buttons, no continuous reporting
+ u8 const mode_report[] = {WM_SET_REPORT | WM_BT_OUTPUT, WM_CMD_REPORT_TYPE, 0, 0x30};
+
// Set the active LEDs.
- u8 const led_report[] = {HID_TYPE_SET_REPORT, WM_CMD_LED, u8(WIIMOTE_LED_1 << index)};
+ u8 const led_report[] = {WM_SET_REPORT | WM_BT_OUTPUT, WM_CMD_LED, u8(WIIMOTE_LED_1 << index)};
// Rumble briefly
- u8 rumble_report[] = {HID_TYPE_SET_REPORT, WM_CMD_RUMBLE, 1};
+ u8 rumble_report[] = {WM_SET_REPORT | WM_BT_OUTPUT, WM_CMD_RUMBLE, 1};
// TODO: request status and check for sane response?
- return (IOWrite(led_report, sizeof(led_report))
+ return (IOWrite(mode_report, sizeof(mode_report))
+ && IOWrite(led_report, sizeof(led_report))
&& IOWrite(rumble_report, sizeof(rumble_report))
&& (rumble_report[2] = 0, SLEEP(200), IOWrite(rumble_report, sizeof(rumble_report))));
}