diff options
| author | Jordan Woyak <jordan.woyak@gmail.com> | 2013-03-03 14:40:10 -0600 |
|---|---|---|
| committer | Jordan Woyak <jordan.woyak@gmail.com> | 2013-03-03 15:05:10 -0600 |
| commit | b1a29153044d7c6b7d81d88cb9d2c6befd043c4e (patch) | |
| tree | f9a96b0cc22aa20ca99eb237caac910deaae5703 /Source/Core | |
| parent | fad2b65d76dc9f0108c5ed3638c4d1ec6403c00e (diff) | |
| parent | cedfa452b4497590f828306b42b1e7c24915fd58 (diff) | |
Merge branch 'master' into windows-unicode
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/Core/Src/HW/WiimoteReal/IOWin.cpp | 35 | ||||
| -rw-r--r-- | Source/Core/VideoCommon/Src/GenericTextureDecoder.cpp | 34 |
2 files changed, 65 insertions, 4 deletions
diff --git a/Source/Core/Core/Src/HW/WiimoteReal/IOWin.cpp b/Source/Core/Core/Src/HW/WiimoteReal/IOWin.cpp index af52498def..08a5db8217 100644 --- a/Source/Core/Core/Src/HW/WiimoteReal/IOWin.cpp +++ b/Source/Core/Core/Src/HW/WiimoteReal/IOWin.cpp @@ -20,6 +20,7 @@ #include <algorithm> #include <unordered_map> #include <ctime> +#include <unordered_set> #include <windows.h> #include <dbt.h> @@ -35,6 +36,7 @@ #include <BluetoothAPIs.h> //#define AUTHENTICATE_WIIMOTES +#define SHARE_WRITE_WIIMOTES typedef struct _HIDD_ATTRIBUTES { @@ -83,6 +85,11 @@ static int initialized = 0; std::unordered_map<BTH_ADDR, std::time_t> g_connect_times; +#ifdef SHARE_WRITE_WIIMOTES +std::unordered_set<std::basic_string<TCHAR>> g_connected_wiimotes; +std::mutex g_connected_wiimotes_lock; +#endif + inline void init_lib() { if (!initialized) @@ -258,11 +265,22 @@ bool Wiimote::Connect() if (IsConnected()) return false; +#ifdef SHARE_WRITE_WIIMOTES + std::lock_guard<std::mutex> lk(g_connected_wiimotes_lock); + if (g_connected_wiimotes.count(devicepath) != 0) + return false; + + auto const open_flags = FILE_SHARE_READ | FILE_SHARE_WRITE; +#else + // Having no FILE_SHARE_WRITE disallows us from connecting to the same wiimote twice. + // (And disallows using wiimotes in use by other programs) + // This is what "WiiYourself" does. + // Apparently this doesn't work for everyone. It might be their fault. + auto const open_flags = FILE_SHARE_READ; +#endif + dev_handle = CreateFile(devicepath.c_str(), - GENERIC_READ | GENERIC_WRITE, - // Having no FILE_SHARE_WRITE disallows us from connecting to the same wiimote twice. - // This is what "WiiYourself" does. - FILE_SHARE_READ, + GENERIC_READ | GENERIC_WRITE, open_flags, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL); if (dev_handle == INVALID_HANDLE_VALUE) @@ -297,6 +315,10 @@ bool Wiimote::Connect() ERROR_LOG(WIIMOTE, "Failed to set wiimote thread priority"); } */ +#ifdef SHARE_WRITE_WIIMOTES + g_connected_wiimotes.insert(devicepath); +#endif + return true; } @@ -310,6 +332,11 @@ void Wiimote::Disconnect() CloseHandle(hid_overlap_read.hEvent); CloseHandle(hid_overlap_write.hEvent); + +#ifdef SHARE_WRITE_WIIMOTES + std::lock_guard<std::mutex> lk(g_connected_wiimotes_lock); + g_connected_wiimotes.erase(devicepath); +#endif } bool Wiimote::IsConnected() const diff --git a/Source/Core/VideoCommon/Src/GenericTextureDecoder.cpp b/Source/Core/VideoCommon/Src/GenericTextureDecoder.cpp index ad7cfeebf9..7546511515 100644 --- a/Source/Core/VideoCommon/Src/GenericTextureDecoder.cpp +++ b/Source/Core/VideoCommon/Src/GenericTextureDecoder.cpp @@ -1442,6 +1442,40 @@ void TexDecoder_DecodeTexel(u8 *dst, const u8 *src, int s, int t, int imageWidth } } +void TexDecoder_DecodeTexelRGBA8FromTmem(u8 *dst, const u8 *src_ar, const u8* src_gb, int s, int t, int imageWidth) +{ + u16 sBlk = s >> 2; + u16 tBlk = t >> 2; + u16 widthBlks = (imageWidth >> 2) + 1; // TODO: Looks wrong. Shouldn't this be ((imageWidth-1)>>2)+1 ? + u32 base_ar = (tBlk * widthBlks + sBlk) << 4; + u32 base_gb = (tBlk * widthBlks + sBlk) << 4; + u16 blkS = s & 3; + u16 blkT = t & 3; + u32 blk_off = (blkT << 2) + blkS; + + u32 offset_ar = (base_ar + blk_off) << 1; + u32 offset_gb = (base_gb + blk_off) << 1; + const u8* val_addr_ar = src_ar + offset_ar; + const u8* val_addr_gb = src_gb + offset_gb; + + dst[3] = val_addr_ar[0]; // A + dst[0] = val_addr_ar[1]; // R + dst[1] = val_addr_gb[0]; // G + dst[2] = val_addr_gb[1]; // B +} + +PC_TexFormat TexDecoder_DecodeRGBA8FromTmem(u8* dst, const u8 *src_ar, const u8 *src_gb, int width, int height) +{ + // TODO for someone who cares: Make this less slow! + for (int y = 0; y < height; ++y) + for (int x = 0; x < width; ++x) + { + TexDecoder_DecodeTexelRGBA8FromTmem(dst, src_ar, src_gb, x, y, width-1); + dst += 4; + } + + return PC_TEX_FMT_RGBA32; +} const char* texfmt[] = { // pixel |
