mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
Merge branch 'master' into windows-unicode
This commit is contained in:
@ -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
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user