From 4b3a6a6d474a8cea3a00a10a92d684983b4e78d5 Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Fri, 31 Dec 2010 15:47:42 +0000 Subject: [PATCH] This should fix wiimote extensions on linux. Now to figure out the windows issue, and then OSX ... Sigh! git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6702 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Core/Src/HW/WiimoteReal/IONix.cpp | 2 +- .../Core/Src/HW/WiimoteReal/WiimoteReal.cpp | 6 +- .../Core/Src/HW/WiimoteReal/WiimoteReal.h | 110 +++++++++--------- 3 files changed, 59 insertions(+), 59 deletions(-) diff --git a/Source/Core/Core/Src/HW/WiimoteReal/IONix.cpp b/Source/Core/Core/Src/HW/WiimoteReal/IONix.cpp index a9233c21bb..cc8a51a8d1 100644 --- a/Source/Core/Core/Src/HW/WiimoteReal/IONix.cpp +++ b/Source/Core/Core/Src/HW/WiimoteReal/IONix.cpp @@ -223,7 +223,7 @@ unsigned char *Wiimote::IORead() // Read the pending message into the buffer unsigned char *buffer = new unsigned char[MAX_PAYLOAD]; - r = read(in_sock, buffer, sizeof(buffer)); + r = read(in_sock, buffer, sizeof(unsigned char) * MAX_PAYLOAD); if (r == -1) { // Error reading data diff --git a/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp b/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp index 442cd88bb7..dad72a6bdf 100644 --- a/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp +++ b/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp @@ -51,11 +51,11 @@ Wiimote *g_wiimotes[MAX_WIIMOTES]; Wiimote::Wiimote(const unsigned int _index) : index(_index) #if defined(__linux__) && HAVE_BLUEZ - , out_sock(-1), in_sock(-1) + , out_sock(-1), in_sock(-1) #elif defined(_WIN32) - , dev_handle(0), stack(MSBT_STACK_UNKNOWN) + , dev_handle(0), stack(MSBT_STACK_UNKNOWN) #endif - , leds(0) , m_last_data_report(NULL) , m_channel(0) , m_connected(false) + , leds(0), m_last_data_report(NULL), m_channel(0), m_connected(false) { #if defined(__linux__) && HAVE_BLUEZ bdaddr = (bdaddr_t){{0, 0, 0, 0, 0, 0}}; diff --git a/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.h b/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.h index 7f152a4205..06d0be40f0 100644 --- a/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.h +++ b/Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.h @@ -42,74 +42,74 @@ namespace WiimoteReal class Wiimote { - friend class WiimoteEmu::Wiimote; - public: - Wiimote(const unsigned int _index); - ~Wiimote(); +friend class WiimoteEmu::Wiimote; +public: + Wiimote(const unsigned int _index); + ~Wiimote(); - void ControlChannel(const u16 channel, const void* const data, const u32 size); - void InterruptChannel(const u16 channel, const void* const data, const u32 size); - void Update(); + void ControlChannel(const u16 channel, const void* const data, const u32 size); + void InterruptChannel(const u16 channel, const void* const data, const u32 size); + void Update(); - u8* ProcessReadQueue(); + u8* ProcessReadQueue(); - bool Read(); - bool Write(); - bool Connect(); - bool IsConnected(); - void Disconnect(); - void DisableDataReporting(); - void Rumble(); - void SendPacket(const u8 rpt_id, const void* const data, const unsigned int size); + bool Read(); + bool Write(); + bool Connect(); + bool IsConnected(); + void Disconnect(); + void DisableDataReporting(); + void Rumble(); + void SendPacket(const u8 rpt_id, const void* const data, const unsigned int size); - // Pointer to data, and size of data - typedef std::pair Report; + // Pointer to data, and size of data + typedef std::pair Report; - const unsigned int index; + const unsigned int index; #if defined(__APPLE__) - IOBluetoothDevice *btd; - IOBluetoothL2CAPChannel *ichan; - IOBluetoothL2CAPChannel *cchan; - #define QUEUE_SIZE 64 - struct qbuffer - { - char data[MAX_PAYLOAD]; - int len; - } queue[QUEUE_SIZE]; - int reader; - int writer; - int outstanding; - int watermark; + IOBluetoothDevice *btd; + IOBluetoothL2CAPChannel *ichan; + IOBluetoothL2CAPChannel *cchan; +#define QUEUE_SIZE 64 + struct qbuffer + { + char data[MAX_PAYLOAD]; + int len; + } queue[QUEUE_SIZE]; + int reader; + int writer; + int outstanding; + int watermark; #elif defined(__linux__) && HAVE_BLUEZ - bdaddr_t bdaddr; // Bluetooth address - int out_sock; // Output socket - int in_sock; // Input socket + bdaddr_t bdaddr; // Bluetooth address + int out_sock; // Output socket + int in_sock; // Input socket #elif defined(_WIN32) - char devicepath[255]; // Unique wiimote reference - //ULONGLONG btaddr; // Bluetooth address - HANDLE dev_handle; // HID handle - OVERLAPPED hid_overlap; // Overlap handle - enum win_bt_stack_t stack; // Type of bluetooth stack to use + char devicepath[255]; // Unique wiimote reference + //ULONGLONG btaddr; // Bluetooth address + HANDLE dev_handle; // HID handle + OVERLAPPED hid_overlap; // Overlap handle + enum win_bt_stack_t stack; // Type of bluetooth stack to use #endif - unsigned char leds; // Currently lit leds + unsigned char leds; // Currently lit leds - protected: - u8 *m_last_data_report; - u16 m_channel; +protected: + u8 *m_last_data_report; + u16 m_channel; - private: - void ClearReadQueue(); - void RealDisconnect(); - bool SendRequest(unsigned char report_type, unsigned char* data, int length); - bool Handshake(); - void SetLEDs(int leds); - unsigned char *IORead(); - int IOWrite(unsigned char* buf, int len); +private: + void ClearReadQueue(); + void RealDisconnect(); + bool SendRequest(unsigned char report_type, unsigned char* data, int length); + bool Handshake(); + void SetLEDs(int leds); + unsigned char *IORead(); + int IOWrite(unsigned char* buf, int len); - bool m_connected; - Common::FifoQueue m_read_reports; - Common::FifoQueue m_write_reports; + bool m_connected; + Common::FifoQueue m_read_reports; + Common::FifoQueue m_write_reports; }; extern Common::CriticalSection g_refresh_critsec;