Merge branch 'master' into windows-unicode
This commit is contained in:
commit
b1a2915304
|
@ -331,7 +331,7 @@ if(NOT ANDROID)
|
|||
message("bluez NOT found, disabling bluetooth support")
|
||||
endif(BLUEZ_FOUND)
|
||||
|
||||
check_lib(PULSEAUDIO libpulse QUIET)
|
||||
check_lib(PULSEAUDIO libpulse-simple QUIET)
|
||||
if(PULSEAUDIO_FOUND)
|
||||
add_definitions(-DHAVE_PULSEAUDIO=1)
|
||||
message("PulseAudio found, enabling PulseAudio sound backend")
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -69,7 +69,7 @@ bool OpenGL_ReportFBOError(const char *function, const char *file, int line);
|
|||
#define GL_REPORT_PROGRAM_ERROR() (void)0
|
||||
#endif
|
||||
|
||||
#if defined __APPLE__ || defined __linux__ || defined _WIN32
|
||||
#if (defined __APPLE__ || defined __linux__ || defined _WIN32) && !(defined _M_ARM)
|
||||
#include <Cg/cg.h>
|
||||
#include <Cg/cgGL.h>
|
||||
#define HAVE_CG 1
|
||||
|
|
|
@ -9,7 +9,7 @@ PerfQuery::PerfQuery()
|
|||
: m_query_read_pos()
|
||||
, m_query_count()
|
||||
{
|
||||
for (int i = 0; i != ARRAYSIZE(m_query_buffer); ++i)
|
||||
for (u32 i = 0; i != ARRAYSIZE(m_query_buffer); ++i)
|
||||
glGenQueries(1, &m_query_buffer[i].query_id);
|
||||
|
||||
ResetQuery();
|
||||
|
@ -17,7 +17,7 @@ PerfQuery::PerfQuery()
|
|||
|
||||
PerfQuery::~PerfQuery()
|
||||
{
|
||||
for (int i = 0; i != ARRAYSIZE(m_query_buffer); ++i)
|
||||
for (u32 i = 0; i != ARRAYSIZE(m_query_buffer); ++i)
|
||||
glDeleteQueries(1, &m_query_buffer[i].query_id);
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ private:
|
|||
};
|
||||
|
||||
// when testing in SMS: 64 was too small, 128 was ok
|
||||
static const int PERF_QUERY_BUFFER_SIZE = 512;
|
||||
static const u32 PERF_QUERY_BUFFER_SIZE = 512;
|
||||
|
||||
void WeakFlush();
|
||||
// Only use when non-empty
|
||||
|
@ -34,10 +34,10 @@ private:
|
|||
|
||||
// This contains gl query objects with unretrieved results.
|
||||
ActiveQuery m_query_buffer[PERF_QUERY_BUFFER_SIZE];
|
||||
int m_query_read_pos;
|
||||
u32 m_query_read_pos;
|
||||
|
||||
// TODO: sloppy
|
||||
volatile int m_query_count;
|
||||
volatile u32 m_query_count;
|
||||
volatile u32 m_results[PQG_NUM_MEMBERS];
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue