mirror of https://github.com/PCSX2/pcsx2.git
USB: clean up logging
This commit is contained in:
parent
47d65c3f89
commit
1aa585e56b
|
@ -331,7 +331,6 @@ set(pcsx2USBSources
|
|||
USB/USB.cpp
|
||||
USB/deviceproxy.cpp
|
||||
USB/configuration.cpp
|
||||
USB/osdebugout.cpp
|
||||
USB/device_init.cpp
|
||||
USB/qemu-usb/glib.cpp
|
||||
USB/qemu-usb/vl.cpp
|
||||
|
@ -384,7 +383,6 @@ set(pcsx2USBHeaders
|
|||
USB/proxybase.h
|
||||
USB/deviceproxy.h
|
||||
USB/configuration.h
|
||||
USB/osdebugout.h
|
||||
USB/platcompat.h
|
||||
USB/helpers.h
|
||||
USB/readerwriterqueue/readerwriterqueue.h
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#include "PrecompiledHeader.h"
|
||||
#include "Utilities/pxStreams.h"
|
||||
#include "USB.h"
|
||||
#include "osdebugout.h"
|
||||
#include "qemu-usb/USBinternal.h"
|
||||
#include "qemu-usb/desc.h"
|
||||
#include "shared/shared_usb.h"
|
||||
|
@ -36,7 +35,9 @@ USBDevice* usb_device[2] = {NULL};
|
|||
bool configChanged = false;
|
||||
|
||||
Config conf;
|
||||
char USBfreezeID[] = "USBqemuW01";
|
||||
// we'll probably switch our save state system at some point to standardize in
|
||||
// the core anyways
|
||||
char USBfreezeID[] = "govqemUSB1";
|
||||
typedef struct
|
||||
{
|
||||
char freezeID[11];
|
||||
|
@ -121,7 +122,6 @@ USBDevice* CreateDevice(DeviceType index, int port)
|
|||
|
||||
if (!device)
|
||||
{
|
||||
USB_LOG("USBqemu: failed to create device type %d on port %d\n", index, port);
|
||||
}
|
||||
return device;
|
||||
}
|
||||
|
@ -164,7 +164,6 @@ USBDevice* CreateDevice(const std::string& name, int port)
|
|||
|
||||
if (!device)
|
||||
{
|
||||
USB_LOG("USBqemu: failed to create device '%s' on port %d\n", name.c_str(), port);
|
||||
}
|
||||
return device;
|
||||
}
|
||||
|
@ -212,7 +211,6 @@ s32 USBinit()
|
|||
void USBshutdown()
|
||||
{
|
||||
|
||||
OSDebugOut(TEXT("USBshutdown\n"));
|
||||
DestroyDevices();
|
||||
RegisterDevice::instance().Unregister();
|
||||
|
||||
|
@ -259,7 +257,6 @@ s32 USBopen(void* pDsp)
|
|||
|
||||
g_GSdsp = (Display*)((uptr*)pDsp)[0];
|
||||
g_GSwin = (Window)((uptr*)pDsp)[1];
|
||||
OSDebugOut("X11 display %p Xwindow %lu\n", g_GSdsp, g_GSwin);
|
||||
#endif
|
||||
|
||||
try
|
||||
|
@ -289,7 +286,6 @@ s32 USBopen(void* pDsp)
|
|||
|
||||
void USBclose()
|
||||
{
|
||||
OSDebugOut(TEXT("USBclose\n"));
|
||||
|
||||
if (usb_device[0] && usb_device[0]->klass.close)
|
||||
usb_device[0]->klass.close(usb_device[0]);
|
||||
|
@ -302,13 +298,11 @@ void USBclose()
|
|||
|
||||
u8 USBread8(u32 addr)
|
||||
{
|
||||
USB_LOG("* Invalid 8bit read at address %08x\n", addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
u16 USBread16(u32 addr)
|
||||
{
|
||||
USB_LOG("* Invalid 16bit read at address %08x\n", addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -318,24 +312,20 @@ u32 USBread32(u32 addr)
|
|||
|
||||
hard = ohci_mem_read(qemu_ohci, addr);
|
||||
|
||||
USB_LOG("* Known 32bit read at address %08x: %08x\n", addr, hard);
|
||||
|
||||
return hard;
|
||||
}
|
||||
|
||||
void USBwrite8(u32 addr, u8 value)
|
||||
{
|
||||
USB_LOG("* Invalid 8bit write at address %08x value %x\n", addr, value);
|
||||
}
|
||||
|
||||
void USBwrite16(u32 addr, u16 value)
|
||||
{
|
||||
USB_LOG("* Invalid 16bit write at address %08x value %x\n", addr, value);
|
||||
}
|
||||
|
||||
void USBwrite32(u32 addr, u32 value)
|
||||
{
|
||||
USB_LOG("* Known 32bit write at address %08x value %08x\n", addr, value);
|
||||
ohci_mem_write(qemu_ohci, addr, value);
|
||||
}
|
||||
|
||||
|
@ -437,21 +427,6 @@ s32 USBfreeze(int mode, freezeData* data)
|
|||
usb_device[i]->setup_len = tmp.setup_len;
|
||||
usb_device[i]->setup_index = tmp.setup_index;
|
||||
|
||||
#ifndef NDEBUG
|
||||
std::cerr << "Loading save state:\nport: " << i
|
||||
<< "\naddr: " << (int)usb_device[i]->addr
|
||||
<< "\nattached: " << usb_device[i]->attached
|
||||
<< "\nauto_attach: " << usb_device[i]->auto_attach
|
||||
<< "\nconfig: " << usb_device[i]->configuration
|
||||
<< "\nninterf: " << usb_device[i]->ninterfaces
|
||||
<< "\nflags: " << usb_device[i]->flags
|
||||
<< "\nstate: " << usb_device[i]->state
|
||||
<< "\nremote_wakeup: " << usb_device[i]->remote_wakeup
|
||||
<< "\nsetup_state: " << usb_device[i]->setup_state
|
||||
<< "\nsetup_len: " << usb_device[i]->setup_len
|
||||
<< "\nsetup_index: " << usb_device[i]->setup_index
|
||||
<< std::endl;
|
||||
#endif
|
||||
memcpy(usb_device[i]->data_buf, tmp.data_buf, sizeof(tmp.data_buf));
|
||||
memcpy(usb_device[i]->setup_buf, tmp.setup_buf, sizeof(tmp.setup_buf));
|
||||
|
||||
|
@ -600,7 +575,7 @@ s32 USBfreeze(int mode, freezeData* data)
|
|||
data->size += 8192; // qemu_ohci->usb_packet.actual_length;
|
||||
if (qemu_ohci->usb_packet.actual_length > 8192)
|
||||
{
|
||||
fprintf(stderr, "Saving failed! USB packet is larger than 8K, try again later.\n");
|
||||
Console.Warning("Saving failed! USB packet is larger than 8K, try again later.\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -645,11 +620,9 @@ void USBasync(u32 cycles)
|
|||
|
||||
int cpu_physical_memory_rw(u32 addr, u8* buf, size_t len, int is_write)
|
||||
{
|
||||
//OSDebugOut(TEXT("%s addr %08X, len %d\n"), is_write ? TEXT("write") : TEXT("read "), addr, len);
|
||||
// invalid address, reset and try again
|
||||
if (addr + len >= 0x200000)
|
||||
{
|
||||
OSDebugOut(TEXT("invalid address, soft resetting ohci.\n"));
|
||||
if (qemu_ohci)
|
||||
ohci_soft_reset(qemu_ohci);
|
||||
return 1;
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#include <limits.h>
|
||||
|
||||
#include "SaveState.h"
|
||||
#include "osdebugout.h"
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
#define USBdefs
|
||||
|
|
|
@ -66,7 +66,6 @@ void SelChangedAPI(HWND hW, int port)
|
|||
|
||||
void PopulateAPIs(HWND hW, int port)
|
||||
{
|
||||
OSDebugOut(TEXT("Populate api %d\n"), port);
|
||||
SendDlgItemMessage(hW, port ? IDC_COMBO_API1 : IDC_COMBO_API2, CB_RESETCONTENT, 0, 0);
|
||||
int devtype = SendDlgItemMessage(hW, port ? IDC_COMBO1 : IDC_COMBO2, CB_GETCURSEL, 0, 0);
|
||||
if (devtype == 0)
|
||||
|
@ -81,7 +80,6 @@ void PopulateAPIs(HWND hW, int port)
|
|||
|
||||
std::string var;
|
||||
if (LoadSetting(nullptr, port, rd.Name(devtype), N_DEVICE_API, str_to_wstr(var)))
|
||||
OSDebugOut(L"Current API: %S\n", var.c_str());
|
||||
else
|
||||
{
|
||||
if (apis.begin() != apis.end())
|
||||
|
|
|
@ -71,7 +71,7 @@ CAPTION "USBabout"
|
|||
FONT 8, "MS Sans Serif", 0, 0, 0x0
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,65,85,50,14
|
||||
LTEXT "USBqemu Driver",IDC_NAME,70,10,54,8
|
||||
LTEXT "USB Driver",IDC_NAME,70,10,54,8
|
||||
GROUPBOX "",IDC_STATIC,5,35,170,43
|
||||
LTEXT "Author: gigaherz <gigaherz@pcsx2.net>",IDC_STATIC,20,20,141,10
|
||||
LTEXT "Parts of this code were originally from the QEMU project.",IDC_STATIC,14,44,149,16
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
*/
|
||||
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "osdebugout.h"
|
||||
#include "deviceproxy.h"
|
||||
#include "configuration.h"
|
||||
#include "shared/inifile_usb.h"
|
||||
|
@ -168,10 +167,8 @@ void SaveConfig()
|
|||
|
||||
#ifdef _WIN32
|
||||
bool ret = ciniFile.Save(IniPath);
|
||||
OSDebugOut(TEXT("ciniFile.Save: %d [%s]\n"), ret, IniPath.c_str());
|
||||
#else
|
||||
bool ret = ciniFile.Save(str_to_wstr(IniPath));
|
||||
DevCon.WriteLn("ciniFile.Save: %d [%s]\n", ret, IniPath.c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -213,7 +210,6 @@ void LoadConfig()
|
|||
|
||||
if (dev)
|
||||
{
|
||||
DevCon.WriteLn("Checking device '%s' api: '%s'...\n", conf.Port[i].c_str(), api.c_str());
|
||||
if (!dev->IsValidAPI(api))
|
||||
{
|
||||
api = "<invalid>";
|
||||
|
@ -221,10 +217,7 @@ void LoadConfig()
|
|||
if (!apis.empty())
|
||||
api = *apis.begin();
|
||||
|
||||
DevCon.WriteLn("Invalid! Defaulting to '%s'\n", api.c_str());
|
||||
}
|
||||
else
|
||||
DevCon.WriteLn("API OK\n");
|
||||
}
|
||||
|
||||
if (api.size())
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include <string>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include "osdebugout.h"
|
||||
#include "platcompat.h"
|
||||
|
||||
#define RESULT_CANCELED 0
|
||||
|
@ -95,7 +94,6 @@ bool LoadSetting(const char* dev_type, int port, const std::string& key, const T
|
|||
bool ret = false;
|
||||
if (key.empty())
|
||||
{
|
||||
DevCon.WriteLn("Key is empty for '%s' on port %d\n", name, port);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -108,12 +106,7 @@ bool LoadSetting(const char* dev_type, int port, const std::string& key, const T
|
|||
section << tkey << TEXT(" ") << port;
|
||||
TSTDSTRING str = section.str();
|
||||
|
||||
DevCon.WriteLn("[%s] '%s'=", str.c_str(), name);
|
||||
ret = LoadSettingValue(IniPath, str, name, var);
|
||||
if (ret)
|
||||
OSDebugOutStream_noprfx(var);
|
||||
else
|
||||
OSDebugOut_noprfx("<failed>\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -121,12 +114,7 @@ template <typename Type>
|
|||
bool LoadSetting(const TCHAR* section, const TCHAR* key, Type& var)
|
||||
{
|
||||
bool ret = false;
|
||||
DevCon.WriteLn("[%s] '%s'=", section, key);
|
||||
ret = LoadSettingValue(IniPath, section, key, var);
|
||||
if (ret)
|
||||
OSDebugOutStream_noprfx(var);
|
||||
else
|
||||
OSDebugOut_noprfx("<failed>\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -150,7 +138,6 @@ bool SaveSetting(const char* dev_type, int port, const std::string& key, const T
|
|||
bool ret = false;
|
||||
if (key.empty())
|
||||
{
|
||||
DevCon.WriteLn("Key is empty for '%s' on port %d\n", name, port);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -163,10 +150,8 @@ bool SaveSetting(const char* dev_type, int port, const std::string& key, const T
|
|||
section << tkey << TEXT(" ") << port;
|
||||
TSTDSTRING str = section.str();
|
||||
|
||||
DevCon.WriteLn("[%s] '%s'=", str.c_str(), name);
|
||||
|
||||
ret = SaveSettingValue(IniPath, str, name, var);
|
||||
OSDebugOutStream_noprfx(var);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -174,9 +159,7 @@ template <typename Type>
|
|||
bool SaveSetting(const TCHAR* section, const TCHAR* key, const Type var)
|
||||
{
|
||||
bool ret = false;
|
||||
DevCon.WriteLn("[%s] '%s'=", section, key);
|
||||
|
||||
ret = SaveSettingValue(IniPath, section, key, var);
|
||||
OSDebugOutStream_noprfx(var);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -97,7 +97,6 @@ public:
|
|||
DeviceProxy() {}
|
||||
virtual ~DeviceProxy()
|
||||
{
|
||||
OSDebugOut(TEXT("%p\n"), this);
|
||||
}
|
||||
virtual USBDevice* CreateDevice(int port)
|
||||
{
|
||||
|
@ -146,7 +145,6 @@ public:
|
|||
virtual ~RegisterProxy()
|
||||
{
|
||||
Clear();
|
||||
OSDebugOut("%p\n", this);
|
||||
}
|
||||
|
||||
void Clear()
|
||||
|
@ -207,7 +205,7 @@ public:
|
|||
return *registerDevice;
|
||||
}
|
||||
|
||||
~RegisterDevice() { OSDebugOut("%p\n", this); }
|
||||
~RegisterDevice() { }
|
||||
|
||||
static void Register();
|
||||
void Unregister();
|
||||
|
|
|
@ -28,17 +28,9 @@ int IsActualFile(const char *filename) {
|
|||
int retval;
|
||||
struct stat64 filestat;
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_ACTUALFILE
|
||||
PrintLog("USBqemu file: IsActualFile(%s)", filename);
|
||||
#endif /* VERBOSE_FUNCTION_ACTUALFILE */
|
||||
|
||||
errno = 0;
|
||||
retval = stat64(filename, &filestat);
|
||||
if((retval < 0) || (errno != 0)) {
|
||||
#ifdef VERBOSE_WARNING_ACTUALFILE
|
||||
PrintLog("USBqemu file: Error retrieving stats on %s", filename);
|
||||
PrintLog("USBqemu file: %i:%s\n", errno, strerror(errno));
|
||||
#endif /* VERBOSE_WARNING_ACTUALFILE */
|
||||
return(-1); // Name doesn't exist.
|
||||
} // ENDIF- Trouble getting stat on a file?
|
||||
|
||||
|
@ -48,18 +40,12 @@ int IsActualFile(const char *filename) {
|
|||
|
||||
|
||||
void ActualFileDelete(const char *filename) {
|
||||
#ifdef VERBOSE_FUNCTION_ACTUALFILE
|
||||
PrintLog("USBqemu file: ActualFileDelete(%s)", filename);
|
||||
#endif /* VERBOSE_FUNCTION_ACTUALFILE */
|
||||
|
||||
unlink(filename);
|
||||
} // END ActualFileDelete()
|
||||
|
||||
|
||||
void ActualFileRename(const char *origname, const char *newname) {
|
||||
#ifdef VERBOSE_FUNCTION_ACTUALFILE
|
||||
PrintLog("USBqemu file: ActualFileRename(%s->%s)", origname, newname);
|
||||
#endif /* VERBOSE_FUNCTION_ACTUALFILE */
|
||||
|
||||
rename(origname, newname);
|
||||
return;
|
||||
|
@ -71,17 +57,9 @@ ACTUALHANDLE ActualFileOpenForRead(const char *filename) {
|
|||
|
||||
if(filename == NULL) return(-1);
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_ACTUALFILE
|
||||
PrintLog("USBqemu file: ActualFileOpenForRead(%s)", filename);
|
||||
#endif /* VERBOSE_FUNCTION_ACTUALFILE */
|
||||
|
||||
errno = 0;
|
||||
newhandle = open(filename, O_RDONLY | O_LARGEFILE);
|
||||
if((newhandle < 0) || (errno != 0)) {
|
||||
#ifdef VERBOSE_WARNING_ACTUALFILE
|
||||
PrintLog("USBqemu file: Error opening file %s\n", filename);
|
||||
PrintLog("USBqemu file: (%i) %i:%s\n", newhandle, errno, strerror(errno));
|
||||
#endif /* VERBOSE_WARNING_ACTUALFILE */
|
||||
return(-1);
|
||||
} // ENDIF- Error? Abort
|
||||
|
||||
|
@ -93,10 +71,6 @@ off64_t ActualFileSize(ACTUALHANDLE handle) {
|
|||
int retval;
|
||||
struct stat64 filestat;
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_ACTUALFILE
|
||||
PrintLog("USBqemu file: ActualFileSize()\n");
|
||||
#endif /* VERBOSE_FUNCTION_ACTUALFILE */
|
||||
|
||||
errno = 0;
|
||||
retval = fstat64(handle, &filestat);
|
||||
if((retval < 0) || (errno != 0)) return(-1); // Name doesn't exist.
|
||||
|
@ -110,17 +84,9 @@ int ActualFileSeek(ACTUALHANDLE handle, off64_t position) {
|
|||
if(handle < 0) return(-1);
|
||||
if(position < 0) return(-1); // Maybe... position = 0?
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_ACTUALFILE
|
||||
PrintLog("USBqemu file: ActualFileSeek(%lli)", position);
|
||||
#endif /* VERBOSE_FUNCTION_ACTUALFILE */
|
||||
|
||||
errno = 0;
|
||||
moved = lseek64(handle, position, SEEK_SET);
|
||||
if(errno != 0) {
|
||||
#ifdef VERBOSE_WARNING_ACTUALFILE
|
||||
PrintLog("USBqemu file: Error on seek (%lli)", position);
|
||||
PrintLog("USBqemu file: %i:%s\n", errno, strerror(errno));
|
||||
#endif /* VERBOSE_WARNING_ACTUALFILE */
|
||||
return(-1);
|
||||
} // ENDIF- Error? Abort
|
||||
|
||||
|
@ -135,17 +101,9 @@ int ActualFileRead(ACTUALHANDLE handle, int bytes, char *buffer) {
|
|||
if(bytes < 1) return(-1);
|
||||
if(buffer == NULL) return(-1);
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_ACTUALFILE
|
||||
PrintLog("USBqemu file: ActualFileRead(%i)", bytes);
|
||||
#endif /* VERBOSE_FUNCTION_ACTUALFILE */
|
||||
|
||||
errno = 0;
|
||||
retval = read(handle, buffer, bytes);
|
||||
if((retval < 0) || (errno != 0)) {
|
||||
#ifdef VERBOSE_WARNING_ACTUALFILE
|
||||
PrintLog("USBqemu file: Error reading from file!");
|
||||
PrintLog("USBqemu file: %i:%s", errno, strerror(errno));
|
||||
#endif /* VERBOSE_WARNING_ACTUALFILE */
|
||||
// return(-1);
|
||||
} // ENDIF- Error? Abort
|
||||
|
||||
|
@ -156,10 +114,6 @@ int ActualFileRead(ACTUALHANDLE handle, int bytes, char *buffer) {
|
|||
void ActualFileClose(ACTUALHANDLE handle) {
|
||||
if(handle < 0) return;
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_ACTUALFILE
|
||||
PrintLog("USBqemu file: ActualFileClose()");
|
||||
#endif /* VERBOSE_FUNCTION_ACTUALFILE */
|
||||
|
||||
errno = 0;
|
||||
close(handle);
|
||||
return;
|
||||
|
@ -171,17 +125,9 @@ ACTUALHANDLE ActualFileOpenForWrite(const char *filename) {
|
|||
|
||||
if(filename == NULL) return(-1);
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_ACTUALFILE
|
||||
PrintLog("USBqemu file: ActualFileOpenForWrite(%s)", filename);
|
||||
#endif /* VERBOSE_FUNCTION_ACTUALFILE */
|
||||
|
||||
errno = 0;
|
||||
newhandle = open(filename, O_WRONLY | O_CREAT | O_LARGEFILE, 0644);
|
||||
if((newhandle < 0) || (errno != 0)) {
|
||||
#ifdef VERBOSE_WARNING_ACTUALFILE
|
||||
PrintLog("USBqemu file: Error opening file %s", filename);
|
||||
PrintLog("USBqemu file: (%i) %i:%s", newhandle, errno, strerror(errno));
|
||||
#endif /* VERBOSE_WARNING_ACTUALFILE */
|
||||
return(-1);
|
||||
} // ENDIF- Error? Abort
|
||||
|
||||
|
@ -196,17 +142,9 @@ int ActualFileWrite(ACTUALHANDLE handle, int bytes, char *buffer) {
|
|||
if(bytes < 1) return(-1);
|
||||
if(buffer == NULL) return(-1);
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_ACTUALFILE
|
||||
PrintLog("USBqemu file: ActualFileWrite(%i)", bytes);
|
||||
#endif /* VERBOSE_FUNCTION_ACTUALFILE */
|
||||
|
||||
errno = 0;
|
||||
retval = write(handle, buffer, bytes);
|
||||
if((retval < 0) || (errno != 0)) {
|
||||
#ifdef VERBOSE_WARNING_ACTUALFILE
|
||||
PrintLog("USBqemu file: Error writing to file!");
|
||||
PrintLog("USBqemu file: %i:%s", errno, strerror(errno));
|
||||
#endif /* VERBOSE_WARNING_ACTUALFILE */
|
||||
// return(-1);
|
||||
} // ENDIF- Error? Abort
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include "AppCoreThread.h"
|
||||
#include "../gtk.h"
|
||||
|
||||
#include "../osdebugout.h"
|
||||
#include "../configuration.h"
|
||||
#include "../deviceproxy.h"
|
||||
#include "../usb-pad/padproxy.h"
|
||||
|
@ -60,7 +59,6 @@ static void wheeltypeChanged(GtkComboBox* widget, gpointer data)
|
|||
uint8_t port = MIN(reinterpret_cast<uintptr_t>(data), 1);
|
||||
|
||||
conf.WheelType[port] = idx;
|
||||
DevCon.WriteLn("Selected wheel type, port %d idx: %d\n", port, idx);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,7 +83,6 @@ static void populateApiWidget(SettingsCB* settingsCB, const std::string& device)
|
|||
else
|
||||
api = it->second;
|
||||
|
||||
DevCon.WriteLn("Current api: %s\n", api.c_str());
|
||||
settingsCB->api = api;
|
||||
int i = 0;
|
||||
for (auto& it : dev->ListAPIs())
|
||||
|
@ -119,7 +116,6 @@ static void deviceChanged(GtkComboBox* widget, gpointer data)
|
|||
else
|
||||
conf.Port[0] = s;
|
||||
|
||||
DevCon.WriteLn("Selected player %d idx: %d [%s]\n", player, active, s.c_str());
|
||||
}
|
||||
|
||||
static void apiChanged(GtkComboBox* widget, gpointer data)
|
||||
|
@ -147,7 +143,6 @@ static void apiChanged(GtkComboBox* widget, gpointer data)
|
|||
changedAPIs[pair] = *it;
|
||||
settingsCB->api = *it;
|
||||
|
||||
DevCon.WriteLn("selected api: %s\n", it->c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -162,12 +157,10 @@ static void configureApi(GtkWidget* widget, gpointer data)
|
|||
auto& api = settingsCB->api;
|
||||
auto dev = RegisterDevice::instance().Device(name);
|
||||
|
||||
DevCon.WriteLn("configure api %s [%s] for player %d\n", api.c_str(), name.c_str(), player);
|
||||
if (dev)
|
||||
{
|
||||
GtkWidget* dlg = GTK_WIDGET(g_object_get_data(G_OBJECT(widget), "dlg"));
|
||||
int res = dev->Configure(port, api, dlg);
|
||||
DevCon.WriteLn("Configure returned %d\n", res);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -253,7 +246,6 @@ void USBconfigure()
|
|||
auto deviceProxy = RegisterDevice::instance().Device(device);
|
||||
if (!deviceProxy)
|
||||
{
|
||||
DevCon.WriteLn("Device '%s' is registered, but failed to get proxy!\n"), device.c_str();
|
||||
continue;
|
||||
}
|
||||
auto name = deviceProxy->Name();
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../osdebugout.h"
|
||||
#include "../configuration.h"
|
||||
#include "../deviceproxy.h"
|
||||
#include "../usb-pad/padproxy.h"
|
||||
|
@ -26,6 +25,6 @@ void SysMessage_stderr(const char* fmt, ...)
|
|||
va_list arglist;
|
||||
|
||||
va_start(arglist, fmt);
|
||||
vfprintf(stderr, fmt, arglist);
|
||||
Console.Warning(fmt, arglist);
|
||||
va_end(arglist);
|
||||
}
|
||||
|
|
|
@ -17,6 +17,5 @@
|
|||
#define LINUXCONFIG_H
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include "../osdebugout.h"
|
||||
|
||||
#endif
|
||||
|
|
|
@ -24,34 +24,12 @@
|
|||
const char INIext[] = ".ini";
|
||||
const char INInewext[] = ".new";
|
||||
|
||||
#if VERBOSE_FUNCTION_INI
|
||||
void PrintLog(const char *fmt, ...) {
|
||||
char logfiletemp[2048];
|
||||
va_list list;
|
||||
int len;
|
||||
|
||||
va_start(list, fmt);
|
||||
vsprintf(logfiletemp, fmt, list);
|
||||
va_end(list);
|
||||
len = 0;
|
||||
while((len < 2048) && (logfiletemp[len] != 0)) len++;
|
||||
if((len > 0) && (logfiletemp[len-1] == '\n')) len--;
|
||||
if((len > 0) && (logfiletemp[len-1] == '\r')) len--;
|
||||
logfiletemp[len] = 0; // Slice off the last "\r\n"...
|
||||
fprintf(stderr, "%s\n", logfiletemp);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Returns: position where new extensions should be added.
|
||||
int INIRemoveExt(const char *argname, char *tempname) {
|
||||
int i;
|
||||
int j;
|
||||
int k;
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_INI
|
||||
PrintLog("USBqemu ini: RemoveExt(%s)", argname);
|
||||
#endif /* VERBOSE_FUNCTION_INI */
|
||||
|
||||
i = 0;
|
||||
while((i <= INIMAXLEN) && (*(argname + i) != 0)) {
|
||||
*(tempname + i) = *(argname + i);
|
||||
|
@ -82,10 +60,6 @@ int INIRemoveExt(const char *argname, char *tempname) {
|
|||
void INIAddInExt(char *tempname, int temppos) {
|
||||
int i;
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_INI
|
||||
PrintLog("USBqemu ini: AddInExt(%s, %i)", tempname, temppos);
|
||||
#endif /* VERBOSE_FUNCTION_INI */
|
||||
|
||||
i = 0;
|
||||
while((i + temppos < INIMAXLEN) && (INIext[i] != 0)) {
|
||||
*(tempname + temppos + i) = INIext[i];
|
||||
|
@ -98,10 +72,6 @@ void INIAddInExt(char *tempname, int temppos) {
|
|||
void INIAddOutExt(char *tempname, int temppos) {
|
||||
int i;
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_INI
|
||||
PrintLog("USBqemu ini: AddOutExt(%s, %i)", tempname, temppos);
|
||||
#endif /* VERBOSE_FUNCTION_INI */
|
||||
|
||||
i = 0;
|
||||
while((i + temppos < INIMAXLEN) && (INInewext[i] != 0)) {
|
||||
*(tempname + temppos + i) = INInewext[i];
|
||||
|
@ -119,10 +89,6 @@ int INIReadLine(ACTUALHANDLE infile, char *buffer) {
|
|||
int retflag;
|
||||
int retval;
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_INI
|
||||
PrintLog("USBqemu ini: ReadLine()");
|
||||
#endif /* VERBOSE_FUNCTION_INI */
|
||||
|
||||
charcount = 0;
|
||||
i = 0;
|
||||
tempin[1] = 0;
|
||||
|
@ -145,10 +111,6 @@ int INIReadLine(ACTUALHANDLE infile, char *buffer) {
|
|||
} // ENDWHILE- Loading up on characters until an End-of-Line appears
|
||||
*(buffer + i) = 0; // And 0-terminate
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_INI
|
||||
PrintLog("USBqemu ini: Line: %s", buffer);
|
||||
#endif /* VERBOSE_FUNCTION_INI */
|
||||
|
||||
return(charcount);
|
||||
} // END INIReadLine()
|
||||
// Note: Do we need to back-skip a char if something other \n follows \r?
|
||||
|
@ -162,9 +124,6 @@ int INIFindSection(ACTUALHANDLE infile, const char *section) {
|
|||
int retval;
|
||||
char scanbuffer[INIMAXLEN+1];
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_INI
|
||||
PrintLog("USBqemu ini: FindSection(%s)", section);
|
||||
#endif /* VERBOSE_FUNCTION_INI */
|
||||
|
||||
charcount = 0;
|
||||
retflag = 0;
|
||||
|
@ -200,10 +159,6 @@ int INIFindKeyword(ACTUALHANDLE infile, const char *keyword, char *buffer) {
|
|||
int retval;
|
||||
char scanbuffer[INIMAXLEN+1];
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_INI
|
||||
PrintLog("USBqemu ini: FindKeyword(%s)", keyword);
|
||||
#endif /* VERBOSE_FUNCTION_INI */
|
||||
|
||||
charcount = 0;
|
||||
retflag = 0;
|
||||
|
||||
|
@ -235,10 +190,6 @@ int INIFindKeyword(ACTUALHANDLE infile, const char *keyword, char *buffer) {
|
|||
if(retflag == 0) charcount += retval;
|
||||
} // ENDWHILE- Scanning lines for the correct [Section] header.
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_INI
|
||||
PrintLog("USBqemu ini: Value: %s", buffer);
|
||||
#endif /* VERBOSE_FUNCTION_INI */
|
||||
|
||||
return(charcount);
|
||||
} // END INIFindKeyWord()
|
||||
|
||||
|
@ -250,10 +201,6 @@ int INICopy(ACTUALHANDLE infile, ACTUALHANDLE outfile, int charcount) {
|
|||
int chunk;
|
||||
int retval;
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_INI
|
||||
PrintLog("USBqemu ini: Copy(%i)", charcount);
|
||||
#endif /* VERBOSE_FUNCTION_INI */
|
||||
|
||||
i = charcount;
|
||||
chunk = 4096;
|
||||
if(i < chunk) chunk = i;
|
||||
|
@ -290,11 +237,6 @@ int INISaveString(const char *file, const char *section, const char *keyword, co
|
|||
if(keyword == NULL) return(-1);
|
||||
if(value == NULL) return(-1);
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_INI
|
||||
PrintLog("USBqemu ini: SaveString(%s, %s, %s, %s)",
|
||||
file, section, keyword, value);
|
||||
#endif /* VERBOSE_FUNCTION_INI */
|
||||
|
||||
filepos = INIRemoveExt(file, inname);
|
||||
for(i = 0; i <= filepos; i++) outname[i] = inname[i];
|
||||
INIAddInExt(inname, filepos);
|
||||
|
@ -303,9 +245,6 @@ int INISaveString(const char *file, const char *section, const char *keyword, co
|
|||
filepos = 0;
|
||||
infile = ActualFileOpenForRead(inname);
|
||||
if(infile == ACTUALHANDLENULL) {
|
||||
#ifdef VERBOSE_FUNCTION_INI
|
||||
PrintLog("USBqemu ini: creating new file");
|
||||
#endif /* VERBOSE_FUNCTION_INI */
|
||||
outfile = ActualFileOpenForWrite(inname);
|
||||
if(outfile == ACTUALHANDLENULL) return(-1); // Just a bad name? Abort.
|
||||
|
||||
|
@ -335,9 +274,6 @@ int INISaveString(const char *file, const char *section, const char *keyword, co
|
|||
|
||||
retval = INIFindSection(infile, section);
|
||||
if(retval < 0) {
|
||||
#ifdef VERBOSE_FUNCTION_INI
|
||||
PrintLog("USBqemu ini: creating new section");
|
||||
#endif /* VERBOSE_FUNCTION_INI */
|
||||
outfile = ActualFileOpenForWrite(outname);
|
||||
if(outfile == ACTUALHANDLENULL) {
|
||||
ActualFileClose(infile);
|
||||
|
@ -385,9 +321,6 @@ int INISaveString(const char *file, const char *section, const char *keyword, co
|
|||
|
||||
retval = INIFindKeyword(infile, keyword, NULL);
|
||||
if(retval < 0) {
|
||||
#ifdef VERBOSE_FUNCTION_INI
|
||||
PrintLog("USBqemu ini: creating new keyword");
|
||||
#endif /* VERBOSE_FUNCTION_INI */
|
||||
ActualFileSeek(infile, filepos);
|
||||
retval = INIReadLine(infile, templine);
|
||||
i = 0;
|
||||
|
@ -431,9 +364,6 @@ int INISaveString(const char *file, const char *section, const char *keyword, co
|
|||
} // ENDIF- Trouble writing it out? Abort.
|
||||
|
||||
} else {
|
||||
#ifdef VERBOSE_FUNCTION_INI
|
||||
PrintLog("USBqemu ini: replacing keyword");
|
||||
#endif /* VERBOSE_FUNCTION_INI */
|
||||
filepos += retval; // Position just before old version of keyword
|
||||
|
||||
outfile = ActualFileOpenForWrite(outname);
|
||||
|
@ -493,11 +423,6 @@ int INILoadString(const char *file, const char *section, const char *keyword, ch
|
|||
if(keyword == NULL) return(-1);
|
||||
if(buffer == NULL) return(-1);
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_INI
|
||||
PrintLog("USBqemu ini: LoadString(%s, %s, %s)",
|
||||
file, section, keyword);
|
||||
#endif /* VERBOSE_FUNCTION_INI */
|
||||
|
||||
filepos = INIRemoveExt(file, inname);
|
||||
INIAddInExt(inname, filepos);
|
||||
|
||||
|
@ -538,10 +463,6 @@ int INIRemove(const char *file, const char *section, const char *keyword) {
|
|||
if(file == NULL) return(-1);
|
||||
if(section == NULL) return(-1);
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_INI
|
||||
PrintLog("USBqemu ini: Remove(%s, %s, %s)",
|
||||
file, section, keyword);
|
||||
#endif /* VERBOSE_FUNCTION_INI */
|
||||
|
||||
filepos = INIRemoveExt(file, inname);
|
||||
for(i = 0; i <= filepos; i++) outname[i] = inname[i];
|
||||
|
@ -560,9 +481,6 @@ int INIRemove(const char *file, const char *section, const char *keyword) {
|
|||
|
||||
filepos = retval;
|
||||
if(keyword == NULL) {
|
||||
#ifdef VERBOSE_FUNCTION_INI
|
||||
PrintLog("USBqemu ini: removing section");
|
||||
#endif /* VERBOSE_FUNCTION_INI */
|
||||
outfile = ActualFileOpenForWrite(outname);
|
||||
if(outfile == ACTUALHANDLENULL) {
|
||||
ActualFileClose(infile);
|
||||
|
@ -614,9 +532,6 @@ int INIRemove(const char *file, const char *section, const char *keyword) {
|
|||
} // ENDIF- Couldn't find the keyword? Abort
|
||||
filepos += retval;
|
||||
|
||||
#ifdef VERBOSE_FUNCTION_INI
|
||||
PrintLog("USBqemu ini: removing keyword");
|
||||
#endif /* VERBOSE_FUNCTION_INI */
|
||||
outfile = ActualFileOpenForWrite(outname);
|
||||
if(outfile == ACTUALHANDLENULL) {
|
||||
ActualFileClose(infile);
|
||||
|
|
|
@ -1,64 +0,0 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2020 PCSX2 Dev Team
|
||||
*
|
||||
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU Lesser General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with PCSX2.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "osdebugout.h"
|
||||
|
||||
std::wostream& operator<<(std::wostream& os, const std::string& s)
|
||||
{
|
||||
std::wstring ws;
|
||||
ws.assign(s.begin(), s.end());
|
||||
return os << ws;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
static int rateLimit = 0;
|
||||
void _OSDebugOut(const TCHAR* psz_fmt, ...)
|
||||
{
|
||||
if (rateLimit > 0 && rateLimit < 100)
|
||||
{
|
||||
rateLimit++;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
//rateLimit = 1;
|
||||
}
|
||||
|
||||
va_list args;
|
||||
va_start(args, psz_fmt);
|
||||
|
||||
#ifdef UNICODE
|
||||
int bufsize = _vscwprintf(psz_fmt, args) + 1;
|
||||
std::vector<WCHAR> msg(bufsize);
|
||||
vswprintf_s(&msg[0], bufsize, psz_fmt, args);
|
||||
#else
|
||||
int bufsize = _vscprintf(psz_fmt, args) + 1;
|
||||
std::vector<char> msg(bufsize);
|
||||
vsprintf_s(&msg[0], bufsize, psz_fmt, args);
|
||||
#endif
|
||||
|
||||
//_vsnwprintf_s(&msg[0], bufsize, bufsize-1, psz_fmt, args);
|
||||
va_end(args);
|
||||
//static FILE *hfile = nullptr;
|
||||
//if (!hfile) {
|
||||
// hfile = _wfopen(L"USBqemu-wheel.log", L"wb,ccs=UNICODE");
|
||||
// if (!hfile) throw std::runtime_error("ass");
|
||||
//}
|
||||
//else
|
||||
// fwprintf(hfile, L"%s", &msg[0]);
|
||||
OutputDebugString(&msg[0]);
|
||||
}
|
||||
#endif
|
|
@ -1,89 +0,0 @@
|
|||
/* PCSX2 - PS2 Emulator for PCs
|
||||
* Copyright (C) 2002-2020 PCSX2 Dev Team
|
||||
*
|
||||
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU Lesser General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with PCSX2.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
#define USB_LOG __Log
|
||||
void __Log(const char* fmt, ...);
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#include <vector>
|
||||
void _OSDebugOut(const TCHAR* psz_fmt, ...);
|
||||
std::wostream& operator<<(std::wostream& os, const std::string& s);
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define OSDebugOut(psz_fmt, ...) _OSDebugOut(TEXT("[USBqemu] [%" SFMTs "]:%d\t") psz_fmt, __FUNCTION__, __LINE__, ##__VA_ARGS__)
|
||||
#define OSDebugOut_noprfx(psz_fmt, ...) _OSDebugOut(TEXT(psz_fmt), ##__VA_ARGS__)
|
||||
#define OSDebugOutStream_noprfx(psz_str) \
|
||||
do \
|
||||
{ \
|
||||
TSTDSTRINGSTREAM ss; \
|
||||
ss << psz_str; \
|
||||
_OSDebugOut(_T("%s\n"), ss.str().c_str()); \
|
||||
} while (0)
|
||||
#else
|
||||
#define OSDebugOut(psz_fmt, ...) \
|
||||
do \
|
||||
{ \
|
||||
} while (0)
|
||||
#define OSDebugOut_noprfx(psz_fmt, ...) \
|
||||
do \
|
||||
{ \
|
||||
} while (0)
|
||||
#define OSDebugOutStream_noprfx(str) \
|
||||
do \
|
||||
{ \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#else //_WIN32
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define OSDebugOut(psz_fmt, ...) \
|
||||
do \
|
||||
{ \
|
||||
fprintf(stderr, "[USBqemu] [%s]:%d\t" psz_fmt, __func__, __LINE__, ##__VA_ARGS__); \
|
||||
} while (0)
|
||||
#define OSDebugOut_noprfx(psz_fmt, ...) \
|
||||
do \
|
||||
{ \
|
||||
fprintf(stderr, psz_fmt, ##__VA_ARGS__); \
|
||||
} while (0)
|
||||
#define OSDebugOutStream_noprfx(str) \
|
||||
do \
|
||||
{ \
|
||||
std::cerr << str << std::endl; \
|
||||
} while (0)
|
||||
#else
|
||||
#define OSDebugOut(psz_fmt, ...) \
|
||||
do \
|
||||
{ \
|
||||
} while (0)
|
||||
#define OSDebugOut_noprfx(psz_fmt, ...) \
|
||||
do \
|
||||
{ \
|
||||
} while (0)
|
||||
#define OSDebugOutStream_noprfx(str) \
|
||||
do \
|
||||
{ \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#endif //_WIN32
|
|
@ -25,7 +25,6 @@
|
|||
*/
|
||||
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "../osdebugout.h"
|
||||
#include "../platcompat.h"
|
||||
#include "vl.h"
|
||||
#include "iov.h"
|
||||
|
@ -86,7 +85,6 @@ void usb_port_reset(USBPort* port)
|
|||
{
|
||||
USBDevice* dev = port->dev;
|
||||
|
||||
OSDebugOut(TEXT("port %d\n"), port->index);
|
||||
assert(dev != NULL);
|
||||
usb_detach(port);
|
||||
usb_attach(port);
|
||||
|
@ -149,7 +147,7 @@ static void do_token_setup(USBDevice* s, USBPacket* p)
|
|||
s->setup_len = (s->setup_buf[7] << 8) | s->setup_buf[6];
|
||||
if (s->setup_len > (int32_t)sizeof(s->data_buf))
|
||||
{
|
||||
fprintf(stderr,
|
||||
Console.Warning(
|
||||
"usb_generic_handle_packet: ctrl buffer too small (%d > %zu)\n",
|
||||
s->setup_len, sizeof(s->data_buf));
|
||||
p->status = USB_RET_STALL;
|
||||
|
@ -303,7 +301,7 @@ static void do_parameter(USBDevice* s, USBPacket* p)
|
|||
|
||||
if (s->setup_len > (int32_t)sizeof(s->data_buf))
|
||||
{
|
||||
fprintf(stderr,
|
||||
Console.Warning(
|
||||
"usb_generic_handle_packet: ctrl buffer too small (%d > %zu)\n",
|
||||
s->setup_len, sizeof(s->data_buf));
|
||||
p->status = USB_RET_STALL;
|
||||
|
@ -660,7 +658,7 @@ void usb_packet_copy(USBPacket* p, void* ptr, size_t bytes)
|
|||
iov_from_buf(iov->iov, iov->niov, p->actual_length, ptr, bytes);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "%s: invalid pid: %x\n", __func__, p->pid);
|
||||
Console.Warning("%s: invalid pid: %x\n", __func__, p->pid);
|
||||
abort();
|
||||
}
|
||||
p->actual_length += bytes;
|
||||
|
@ -746,7 +744,7 @@ void usb_ep_dump(USBDevice* dev)
|
|||
};
|
||||
int ifnum, ep, first;
|
||||
|
||||
fprintf(stderr, "Device \"%s\", config %d\n",
|
||||
Console.Warning("Device \"%s\", config %d\n",
|
||||
dev->product_desc, dev->configuration);
|
||||
for (ifnum = 0; ifnum < 16; ifnum++)
|
||||
{
|
||||
|
@ -759,10 +757,10 @@ void usb_ep_dump(USBDevice* dev)
|
|||
if (first)
|
||||
{
|
||||
first = 0;
|
||||
fprintf(stderr, " Interface %d, alternative %d\n",
|
||||
Console.Warning(" Interface %d, alternative %d\n",
|
||||
ifnum, dev->altsetting[ifnum]);
|
||||
}
|
||||
fprintf(stderr, " Endpoint %d, IN, %s, %d max\n", ep,
|
||||
Console.Warning(" Endpoint %d, IN, %s, %d max\n", ep,
|
||||
tname[dev->ep_in[ep].type],
|
||||
dev->ep_in[ep].max_packet_size);
|
||||
}
|
||||
|
@ -772,16 +770,16 @@ void usb_ep_dump(USBDevice* dev)
|
|||
if (first)
|
||||
{
|
||||
first = 0;
|
||||
fprintf(stderr, " Interface %d, alternative %d\n",
|
||||
Console.Warning(" Interface %d, alternative %d\n",
|
||||
ifnum, dev->altsetting[ifnum]);
|
||||
}
|
||||
fprintf(stderr, " Endpoint %d, OUT, %s, %d max\n", ep,
|
||||
Console.Warning(" Endpoint %d, OUT, %s, %d max\n", ep,
|
||||
tname[dev->ep_out[ep].type],
|
||||
dev->ep_out[ep].max_packet_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "--\n");
|
||||
Console.Warning("--\n");
|
||||
}
|
||||
|
||||
struct USBEndpoint* usb_ep_get(USBDevice* dev, int pid, int ep)
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#include "vl.h"
|
||||
#include "desc.h"
|
||||
#include "glib.h"
|
||||
#include "../osdebugout.h"
|
||||
//#include "trace.h"
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
@ -821,8 +820,6 @@ int usb_desc_get_descriptor(USBDevice* dev, USBPacket* p,
|
|||
break;
|
||||
|
||||
default:
|
||||
OSDebugOut(TEXT("%s: %d unknown type %d (len %zd)\n"), __func__,
|
||||
dev->addr, type, len);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -931,7 +928,6 @@ int usb_desc_handle_control(USBDevice* dev, USBPacket* p,
|
|||
ret = 0;
|
||||
break;
|
||||
case InterfaceOutRequest | USB_REQ_SET_INTERFACE:
|
||||
OSDebugOut(TEXT("usb_desc_set_interface\n"));
|
||||
ret = usb_desc_set_interface(dev, index, value);
|
||||
//trace_usb_set_interface(dev->addr, index, value, ret);
|
||||
break;
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include "PrecompiledHeader.h"
|
||||
#include "hid.h"
|
||||
#include "input-keymap.h"
|
||||
#include "../osdebugout.h"
|
||||
|
||||
#define HID_USAGE_ERROR_ROLLOVER 0x01
|
||||
#define HID_USAGE_POSTFAIL 0x02
|
||||
|
|
|
@ -548,9 +548,6 @@ static int usb_hub_handle_packet(USBDevice* dev, int pid,
|
|||
{
|
||||
USBHubState* s = (USBHubState*)dev;
|
||||
|
||||
#if defined(DEBUG) && 0
|
||||
printf("usb_hub: pid=0x%x\n", pid);
|
||||
#endif
|
||||
if (dev->state == USB_STATE_DEFAULT &&
|
||||
dev->addr != 0 &&
|
||||
devaddr != dev->addr &&
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
#include "vl.h"
|
||||
#include "queue.h"
|
||||
#include "USBinternal.h"
|
||||
#include "../osdebugout.h"
|
||||
|
||||
#define DMA_DIRECTION_TO_DEVICE 0
|
||||
#define DMA_DIRECTION_FROM_DEVICE 1
|
||||
|
@ -82,7 +81,7 @@ static void ohci_die(OHCIState* ohci)
|
|||
{
|
||||
//OHCIPCIState *dev = container_of(ohci, OHCIPCIState, state);
|
||||
|
||||
fprintf(stderr, "ohci_die: DMA error\n");
|
||||
Console.Warning("ohci_die: DMA error\n");
|
||||
|
||||
ohci_set_interrupt(ohci, OHCI_INTR_UE);
|
||||
ohci_bus_stop(ohci);
|
||||
|
@ -114,7 +113,6 @@ static void ohci_attach2(USBPort* port1, USBDevice* dev)
|
|||
dev->port = port1;
|
||||
port1->dev = dev;
|
||||
dev->state = USB_STATE_ATTACHED;
|
||||
OSDebugOut(TEXT("usb-ohci: Attached port %d\n"), port1->index);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -138,7 +136,6 @@ static void ohci_attach2(USBPort* port1, USBDevice* dev)
|
|||
dev->state = USB_STATE_NOTATTACHED;
|
||||
}
|
||||
port1->dev = NULL;
|
||||
OSDebugOut(TEXT("usb-ohci: Detached port %d\n"), port1->index);
|
||||
}
|
||||
|
||||
if (old_state != port->ctrl)
|
||||
|
@ -152,7 +149,6 @@ static void ohci_attach(USBPort* port1)
|
|||
OHCIPort* port = &s->rhport[port1->index];
|
||||
uint32_t old_state = port->ctrl;
|
||||
|
||||
OSDebugOut(TEXT("Attach port %d\n"), port1->index);
|
||||
port1->dev->port = port1;
|
||||
|
||||
/* set connect status */
|
||||
|
@ -188,7 +184,6 @@ static void ohci_detach(USBPort* port1)
|
|||
OHCIPort* port = &s->rhport[port1->index];
|
||||
uint32_t old_state = port->ctrl;
|
||||
|
||||
OSDebugOut(TEXT("Detach port %d\n"), port1->index);
|
||||
if (port1->dev)
|
||||
ohci_async_cancel_device(s, port1->dev);
|
||||
|
||||
|
@ -341,7 +336,6 @@ void ohci_hard_reset(OHCIState* ohci)
|
|||
ohci_soft_reset(ohci);
|
||||
ohci->ctl = 0;
|
||||
ohci_roothub_reset(ohci);
|
||||
OSDebugOut(TEXT("usb-ohci: Hard Reset.\n"));
|
||||
}
|
||||
|
||||
#define le32_to_cpu(x) (x)
|
||||
|
@ -1162,7 +1156,6 @@ static void ohci_process_lists(OHCIState* ohci, int completion)
|
|||
{
|
||||
if (ohci->ctrl_cur && ohci->ctrl_cur != ohci->ctrl_head)
|
||||
{
|
||||
OSDebugOut(TEXT("usb-ohci: head %x, cur %x\n"), ohci->ctrl_head, ohci->ctrl_cur);
|
||||
}
|
||||
if (!ohci_service_ed_list(ohci, ohci->ctrl_head, completion))
|
||||
{
|
||||
|
@ -1194,7 +1187,6 @@ void ohci_frame_boundary(void* opaque)
|
|||
/* TODO intr_status is interrupts that driver wants, so not quite right to us it here */
|
||||
bool hack = false; // ohci->intr_status & ohci->intr & OHCI_INTR_RHSC;
|
||||
if (hack)
|
||||
OSDebugOut(TEXT("skipping PLE\n"));
|
||||
|
||||
/* Process all the lists at the end of the frame */
|
||||
if ((ohci->ctl & OHCI_CTL_PLE) && !hack)
|
||||
|
@ -1213,7 +1205,6 @@ void ohci_frame_boundary(void* opaque)
|
|||
usb_cancel_packet(&ohci->usb_packet);
|
||||
ohci->async_td = 0;
|
||||
}
|
||||
OSDebugOut(TEXT("usb-ohci: stop endpoints\n"));
|
||||
ohci_stop_endpoints(ohci);
|
||||
}
|
||||
ohci->old_ctl = ohci->ctl;
|
||||
|
@ -1261,7 +1252,6 @@ int ohci_bus_start(OHCIState* ohci)
|
|||
{
|
||||
ohci->eof_timer = 0;
|
||||
|
||||
OSDebugOut(TEXT("usb-ohci: USB Operational\n"));
|
||||
|
||||
ohci_sof(ohci);
|
||||
|
||||
|
@ -1316,7 +1306,6 @@ static void ohci_set_frame_interval(OHCIState* ohci, uint16_t val)
|
|||
|
||||
if (val != ohci->fi)
|
||||
{
|
||||
OSDebugOut(TEXT("usb-ohci: FrameInterval = 0x%x (%u)\n"), ohci->fi, ohci->fi);
|
||||
}
|
||||
|
||||
ohci->fi = val;
|
||||
|
@ -1361,15 +1350,12 @@ static void ohci_set_ctl(OHCIState* ohci, uint32_t val)
|
|||
/* clear pending SF otherwise linux driver loops in ohci_irq() */
|
||||
ohci->intr_status &= ~OHCI_INTR_SF;
|
||||
ohci_intr_update(ohci);
|
||||
OSDebugOut(TEXT("usb-ohci: USB Suspended\n"));
|
||||
break;
|
||||
case OHCI_USB_RESUME:
|
||||
//trace_usb_ohci_resume(ohci->name);
|
||||
OSDebugOut(TEXT("usb-ohci: USB Resume\n"));
|
||||
break;
|
||||
case OHCI_USB_RESET:
|
||||
ohci_roothub_reset(ohci);
|
||||
OSDebugOut(TEXT("usb-ohci: USB Reset\n"));
|
||||
break;
|
||||
}
|
||||
//ohci_intr_update(ohci);
|
||||
|
@ -1416,7 +1402,6 @@ static void ohci_set_hub_status(OHCIState* ohci, uint32_t val)
|
|||
|
||||
for (i = 0; i < ohci->num_ports; i++)
|
||||
ohci_port_power(ohci, i, 0);
|
||||
OSDebugOut(TEXT("usb-ohci: powered down all ports\n"));
|
||||
}
|
||||
|
||||
if (val & OHCI_RHS_LPSC)
|
||||
|
@ -1425,7 +1410,6 @@ static void ohci_set_hub_status(OHCIState* ohci, uint32_t val)
|
|||
|
||||
for (i = 0; i < ohci->num_ports; i++)
|
||||
ohci_port_power(ohci, i, 1);
|
||||
OSDebugOut(TEXT("usb-ohci: powered up all ports\n"));
|
||||
}
|
||||
|
||||
if (val & OHCI_RHS_DRWE)
|
||||
|
@ -1458,12 +1442,10 @@ static void ohci_port_set_status(OHCIState* ohci, int portnum, uint32_t val)
|
|||
|
||||
if (ohci_port_set_if_connected(ohci, portnum, val & OHCI_PORT_PSS))
|
||||
{
|
||||
OSDebugOut(TEXT("usb-ohci: port %d: SUSPEND\n"), portnum);
|
||||
}
|
||||
|
||||
if (ohci_port_set_if_connected(ohci, portnum, val & OHCI_PORT_PRS))
|
||||
{
|
||||
OSDebugOut(TEXT("usb-ohci: port %d: RESET\n"), portnum);
|
||||
usb_device_reset(port->port.dev);
|
||||
port->ctrl &= ~OHCI_PORT_PRS;
|
||||
/* ??? Should this also set OHCI_PORT_PESC. */
|
||||
|
@ -1514,7 +1496,7 @@ uint32_t ohci_mem_read(OHCIState* ptr, uint32_t addr)
|
|||
int idx = (addr - ptr->mem_base) >> 2;
|
||||
if (idx < countof(reg_names))
|
||||
{
|
||||
fprintf(stderr, "ohci_mem_read %s(%d): %08x\n", reg_names[idx], idx, val);
|
||||
Console.Warning("ohci_mem_read %s(%d): %08x\n", reg_names[idx], idx, val);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
@ -1531,7 +1513,6 @@ uint32_t ohci_mem_read(OHCIState* ptr, uint32_t addr)
|
|||
/* Only aligned reads are allowed on OHCI */
|
||||
if (addr & 3)
|
||||
{
|
||||
OSDebugOut(TEXT("usb-ohci: Mis-aligned read\n"));
|
||||
return 0xffffffff;
|
||||
}
|
||||
|
||||
|
@ -1604,7 +1585,6 @@ uint32_t ohci_mem_read(OHCIState* ptr, uint32_t addr)
|
|||
return ohci->rhstatus;
|
||||
|
||||
default:
|
||||
OSDebugOut(TEXT("ohci_read: Bad offset %x\n"), (int)addr);
|
||||
return 0xffffffff;
|
||||
}
|
||||
}
|
||||
|
@ -1616,7 +1596,7 @@ void ohci_mem_write(OHCIState* ptr, uint32_t addr, uint32_t val)
|
|||
int idx = (addr - ptr->mem_base) >> 2;
|
||||
if (idx < countof(reg_names))
|
||||
{
|
||||
fprintf(stderr, "ohci_mem_write %s(%d): %08x\n", reg_names[idx], idx, val);
|
||||
Console.Warning("ohci_mem_write %s(%d): %08x\n", reg_names[idx], idx, val);
|
||||
}
|
||||
ohci_mem_write_impl(ptr, addr, val);
|
||||
}
|
||||
|
@ -1633,14 +1613,13 @@ void ohci_mem_write(OHCIState* ptr, uint32_t addr, uint32_t val)
|
|||
/* Only aligned reads are allowed on OHCI */
|
||||
if (addr & 3)
|
||||
{
|
||||
fprintf(stderr, "usb-ohci: Mis-aligned write\n");
|
||||
Console.Warning("usb-ohci: Mis-aligned write\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((addr >= 0x54) && (addr < (0x54 + ohci->num_ports * 4)))
|
||||
{
|
||||
/* HcRhPortStatus */
|
||||
OSDebugOut(TEXT("ohci_port_set_status: %d = 0x%08x\n"), (addr - 0x54) >> 2, val);
|
||||
ohci_port_set_status(ohci, (addr - 0x54) >> 2, val);
|
||||
return;
|
||||
}
|
||||
|
@ -1723,7 +1702,6 @@ void ohci_mem_write(OHCIState* ptr, uint32_t addr, uint32_t val)
|
|||
break;
|
||||
|
||||
default:
|
||||
OSDebugOut(TEXT("ohci_write: Bad offset %x\n"), (int)addr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1778,8 +1756,6 @@ OHCIState* ohci_create(uint32_t base, int ports)
|
|||
usb_bit_time = 1;
|
||||
}
|
||||
#endif
|
||||
OSDebugOut(TEXT("usb-ohci: usb_bit_time=%lli usb_frame_time=%lli\n"),
|
||||
usb_frame_time, usb_bit_time);
|
||||
}
|
||||
|
||||
ohci->num_ports = ports;
|
||||
|
|
|
@ -71,25 +71,16 @@ std::wstring str_to_wstr(const std::string& arg)
|
|||
// Helper Functions
|
||||
void RTrim(std::string& str, const std::string& chars = " \t")
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "RTrim()" << std::endl;
|
||||
#endif
|
||||
str.erase(str.find_last_not_of(chars) + 1);
|
||||
}
|
||||
|
||||
void LTrim(std::string& str, const std::string& chars = " \t")
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "LTrim()" << std::endl;
|
||||
#endif
|
||||
str.erase(0, str.find_first_not_of(chars));
|
||||
}
|
||||
|
||||
void Trim(std::string& str, const std::string& chars = " \t")
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "Trim()" << std::endl;
|
||||
#endif
|
||||
str.erase(str.find_last_not_of(chars) + 1);
|
||||
str.erase(0, str.find_first_not_of(chars));
|
||||
}
|
||||
|
@ -117,16 +108,10 @@ std::istream& operator>>(std::istream& input, CIniMergeA merger)
|
|||
|
||||
CIniFileA::CIniFileA()
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "CIniFileA::CIniFileA()" << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
CIniFileA::~CIniFileA()
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "CIniFileA::~CIniFileA()" << std::endl;
|
||||
#endif
|
||||
RemoveAllSections();
|
||||
}
|
||||
|
||||
|
@ -140,18 +125,11 @@ void CIniFileA::Save(std::ostream& output)
|
|||
{
|
||||
sSection = "[" + (*itr)->GetSectionName() + "]";
|
||||
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "Writing Section " << sSection << std::endl;
|
||||
#endif
|
||||
|
||||
output << sSection << _CRLFA;
|
||||
|
||||
for (KeyIndexA::iterator klitr = (*itr)->m_keys.begin(); klitr != (*itr)->m_keys.end(); ++klitr)
|
||||
{
|
||||
std::string sKey = (*klitr)->GetKeyName() + "=" + (*klitr)->GetValue();
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "Writing Key [" << sKey << "]" << std::endl;
|
||||
#endif
|
||||
output << sKey << _CRLFA;
|
||||
}
|
||||
}
|
||||
|
@ -159,9 +137,6 @@ void CIniFileA::Save(std::ostream& output)
|
|||
|
||||
bool CIniFileA::Save(const std::string& fileName)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "CIniFileA::Save() - " << fileName << std::endl;
|
||||
#endif
|
||||
|
||||
std::ofstream output;
|
||||
|
||||
|
@ -209,17 +184,11 @@ void CIniFileA::Load(std::istream& input, bool bMerge)
|
|||
switch (nType)
|
||||
{
|
||||
case SECTION:
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "Parsing: Secton - " << sRead << std::endl;
|
||||
#endif
|
||||
pSection = AddSection(sRead.substr(1, sRead.size() - 2));
|
||||
break;
|
||||
|
||||
case KEY:
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "Parsing: Key - " << sRead << std::endl;
|
||||
#endif
|
||||
// Check to ensure valid section... or drop the keys listed
|
||||
if (pSection)
|
||||
{
|
||||
|
@ -229,23 +198,14 @@ void CIniFileA::Load(std::istream& input, bool bMerge)
|
|||
CIniKeyA* pKey = pSection->AddKey(sKey);
|
||||
if (pKey)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "Parsing: Key Value - " << sValue << std::endl;
|
||||
#endif
|
||||
pKey->SetValue(sValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case COMMENT:
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "Parsing: Comment - " << sRead << std::endl;
|
||||
#endif
|
||||
break;
|
||||
case OTHER:
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "Parsing: Other - " << sRead << std::endl;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -254,10 +214,6 @@ void CIniFileA::Load(std::istream& input, bool bMerge)
|
|||
|
||||
bool CIniFileA::Load(const std::string& fileName, bool bMerge)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "CIniFileA::Load() - " << fileName << std::endl;
|
||||
#endif
|
||||
|
||||
std::ifstream input;
|
||||
|
||||
input.open(fileName.c_str(), std::ios::binary);
|
||||
|
@ -273,18 +229,12 @@ bool CIniFileA::Load(const std::string& fileName, bool bMerge)
|
|||
|
||||
const SecIndexA& CIniFileA::GetSections() const
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "CIniFileA::GetSections()" << std::endl;
|
||||
#endif
|
||||
return m_sections;
|
||||
}
|
||||
|
||||
|
||||
CIniSectionA* CIniFileA::GetSection(std::string sSection) const
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "CIniFileA::GetSection()" << std::endl;
|
||||
#endif
|
||||
Trim(sSection);
|
||||
SecIndexA::const_iterator itr = _find_sec(sSection);
|
||||
if (itr != m_sections.end())
|
||||
|
@ -294,9 +244,6 @@ CIniSectionA* CIniFileA::GetSection(std::string sSection) const
|
|||
|
||||
CIniSectionA* CIniFileA::AddSection(std::string sSection)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "CIniFileA::AddSection()" << std::endl;
|
||||
#endif
|
||||
|
||||
Trim(sSection);
|
||||
SecIndexA::const_iterator itr = _find_sec(sSection);
|
||||
|
@ -314,9 +261,6 @@ CIniSectionA* CIniFileA::AddSection(std::string sSection)
|
|||
|
||||
std::string CIniFileA::GetKeyValue(const std::string& sSection, const std::string& sKey) const
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "CIniFileA::GetKeyValue()" << std::endl;
|
||||
#endif
|
||||
std::string sValue;
|
||||
CIniSectionA* pSec = GetSection(sSection);
|
||||
if (pSec)
|
||||
|
@ -330,9 +274,6 @@ std::string CIniFileA::GetKeyValue(const std::string& sSection, const std::strin
|
|||
|
||||
void CIniFileA::SetKeyValue(const std::string& sSection, const std::string& sKey, const std::string& sValue)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "CIniFileA::SetKeyValue()" << std::endl;
|
||||
#endif
|
||||
CIniSectionA* pSec = AddSection(sSection);
|
||||
if (pSec)
|
||||
{
|
||||
|
@ -345,9 +286,6 @@ void CIniFileA::SetKeyValue(const std::string& sSection, const std::string& sKey
|
|||
|
||||
void CIniFileA::RemoveSection(std::string sSection)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "CIniFileA::RemoveSection()" << std::endl;
|
||||
#endif
|
||||
Trim(sSection);
|
||||
SecIndexA::iterator itr = _find_sec(sSection);
|
||||
if (itr != m_sections.end())
|
||||
|
@ -359,9 +297,6 @@ void CIniFileA::RemoveSection(std::string sSection)
|
|||
|
||||
void CIniFileA::RemoveSection(CIniSectionA* pSection)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "CIniFileA::RemoveSection()" << std::endl;
|
||||
#endif
|
||||
// No trim since internal object not from user
|
||||
SecIndexA::iterator itr = _find_sec(pSection->m_sSectionName);
|
||||
if (itr != m_sections.end())
|
||||
|
@ -373,14 +308,8 @@ void CIniFileA::RemoveSection(CIniSectionA* pSection)
|
|||
|
||||
void CIniFileA::RemoveAllSections()
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "CIniFileA::RemoveAllSections()" << std::endl;
|
||||
#endif
|
||||
for (SecIndexA::iterator itr = m_sections.begin(); itr != m_sections.end(); ++itr)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "Deleting Section: CIniSectionAName[" << (*itr)->GetSectionName() << "]" << std::endl;
|
||||
#endif
|
||||
delete *itr;
|
||||
}
|
||||
m_sections.clear();
|
||||
|
@ -389,9 +318,6 @@ void CIniFileA::RemoveAllSections()
|
|||
|
||||
bool CIniFileA::RenameSection(const std::string& sSectionName, const std::string& sNewSectionName)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "CIniFileA::RenameSection()" << std::endl;
|
||||
#endif
|
||||
// Note string trims are done in lower calls.
|
||||
bool bRval = false;
|
||||
CIniSectionA* pSec = GetSection(sSectionName);
|
||||
|
@ -404,9 +330,6 @@ bool CIniFileA::RenameSection(const std::string& sSectionName, const std::string
|
|||
|
||||
bool CIniFileA::RenameKey(const std::string& sSectionName, const std::string& sKeyName, const std::string& sNewKeyName)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "CIniFileA::RenameKey()" << std::endl;
|
||||
#endif
|
||||
// Note string trims are done in lower calls.
|
||||
bool bRval = false;
|
||||
CIniSectionA* pSec = GetSection(sSectionName);
|
||||
|
@ -441,25 +364,16 @@ CIniSectionA::CIniSectionA(CIniFileA* pIniFile, const std::string& sSectionName)
|
|||
: m_pIniFile(pIniFile)
|
||||
, m_sSectionName(sSectionName)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "CIniSectionA::CIniSectionA()" << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
CIniSectionA::~CIniSectionA()
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "CIniSectionA::~CIniSectionA()" << std::endl;
|
||||
#endif
|
||||
RemoveAllKeys();
|
||||
}
|
||||
|
||||
CIniKeyA* CIniSectionA::GetKey(std::string sKeyName) const
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "CIniSectionA::GetKey()" << std::endl;
|
||||
#endif
|
||||
Trim(sKeyName);
|
||||
KeyIndexA::const_iterator itr = _find_key(sKeyName);
|
||||
if (itr != m_keys.end())
|
||||
|
@ -469,14 +383,8 @@ CIniKeyA* CIniSectionA::GetKey(std::string sKeyName) const
|
|||
|
||||
void CIniSectionA::RemoveAllKeys()
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "CIniSectionA::RemoveAllKeys()" << std::endl;
|
||||
#endif
|
||||
for (KeyIndexA::iterator itr = m_keys.begin(); itr != m_keys.end(); ++itr)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "Deleting Key: " << (*itr)->GetKeyName() << std::endl;
|
||||
#endif
|
||||
delete *itr;
|
||||
}
|
||||
m_keys.clear();
|
||||
|
@ -484,9 +392,6 @@ void CIniSectionA::RemoveAllKeys()
|
|||
|
||||
void CIniSectionA::RemoveKey(std::string sKey)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "CIniSectionA::RemoveKey()" << std::endl;
|
||||
#endif
|
||||
Trim(sKey);
|
||||
KeyIndexA::iterator itr = _find_key(sKey);
|
||||
if (itr != m_keys.end())
|
||||
|
@ -498,9 +403,6 @@ void CIniSectionA::RemoveKey(std::string sKey)
|
|||
|
||||
void CIniSectionA::RemoveKey(CIniKeyA* pKey)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "CIniSectionA::RemoveKey()" << std::endl;
|
||||
#endif
|
||||
// No trim is done to improve efficiency since CIniKeyA* should already be trimmed
|
||||
KeyIndexA::iterator itr = _find_key(pKey->m_sKeyName);
|
||||
if (itr != m_keys.end())
|
||||
|
@ -512,9 +414,6 @@ void CIniSectionA::RemoveKey(CIniKeyA* pKey)
|
|||
|
||||
CIniKeyA* CIniSectionA::AddKey(std::string sKeyName)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "CIniSectionA::AddKey()" << std::endl;
|
||||
#endif
|
||||
Trim(sKeyName);
|
||||
KeyIndexA::const_iterator itr = _find_key(sKeyName);
|
||||
if (itr == m_keys.end())
|
||||
|
@ -530,16 +429,10 @@ CIniKeyA* CIniSectionA::AddKey(std::string sKeyName)
|
|||
|
||||
bool CIniSectionA::SetSectionName(std::string sSectionName)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "CIniSectionA::SetSectionName()" << std::endl;
|
||||
#endif
|
||||
Trim(sSectionName);
|
||||
// Does this already exist.
|
||||
if (m_pIniFile->_find_sec(sSectionName) == m_pIniFile->m_sections.end())
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "Setting Section Name: [" << m_sSectionName << "] --> [" << sSectionName << "]" << std::endl;
|
||||
#endif
|
||||
|
||||
// Find the current section if one exists and remove it since we are renaming
|
||||
SecIndexA::iterator itr = m_pIniFile->_find_sec(m_sSectionName);
|
||||
|
@ -558,34 +451,22 @@ bool CIniSectionA::SetSectionName(std::string sSectionName)
|
|||
}
|
||||
else
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "Section existed could not rename" << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
std::string CIniSectionA::GetSectionName() const
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "CIniSectionA::GetSectionName()" << std::endl;
|
||||
#endif
|
||||
return m_sSectionName;
|
||||
}
|
||||
|
||||
const KeyIndexA& CIniSectionA::GetKeys() const
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "CIniSectionA::GetKeys()" << std::endl;
|
||||
#endif
|
||||
return m_keys;
|
||||
}
|
||||
|
||||
std::string CIniSectionA::GetKeyValue(std::string sKey) const
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "CIniSectionA::GetKeyValue()" << std::endl;
|
||||
#endif
|
||||
std::string sValue;
|
||||
CIniKeyA* pKey = GetKey(sKey);
|
||||
if (pKey)
|
||||
|
@ -597,9 +478,6 @@ std::string CIniSectionA::GetKeyValue(std::string sKey) const
|
|||
|
||||
void CIniSectionA::SetKeyValue(std::string sKey, const std::string& sValue)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "CIniSectionA::SetKeyValue()" << std::endl;
|
||||
#endif
|
||||
CIniKeyA* pKey = AddKey(sKey);
|
||||
if (pKey)
|
||||
{
|
||||
|
@ -610,9 +488,6 @@ void CIniSectionA::SetKeyValue(std::string sKey, const std::string& sValue)
|
|||
// Returns a constant iterator to a key by name, string is not trimmed
|
||||
KeyIndexA::const_iterator CIniSectionA::_find_key(const std::string& sKey) const
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "CIniSectionA::_find_key() const" << std::endl;
|
||||
#endif
|
||||
CIniKeyA bogus(NULL, sKey);
|
||||
return m_keys.find(&bogus);
|
||||
}
|
||||
|
@ -620,9 +495,6 @@ KeyIndexA::const_iterator CIniSectionA::_find_key(const std::string& sKey) const
|
|||
// Returns an iterator to a key by name, string is not trimmed
|
||||
KeyIndexA::iterator CIniSectionA::_find_key(const std::string& sKey)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "CIniSectionA::_find_key()" << std::endl;
|
||||
#endif
|
||||
CIniKeyA bogus(NULL, sKey);
|
||||
return m_keys.find(&bogus);
|
||||
}
|
||||
|
@ -635,40 +507,25 @@ CIniKeyA::CIniKeyA(CIniSectionA* pSection, const std::string& sKeyName)
|
|||
: m_pSection(pSection)
|
||||
, m_sKeyName(sKeyName)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "CIniKeyA::CIniKeyA()" << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
CIniKeyA::~CIniKeyA()
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "CIniKeyA::~CIniKeyA()" << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
void CIniKeyA::SetValue(const std::string& sValue)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "CIniKeyA::SetValue()" << std::endl;
|
||||
#endif
|
||||
m_sValue = sValue;
|
||||
}
|
||||
|
||||
std::string CIniKeyA::GetValue() const
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "CIniKeyA::GetValue()" << std::endl;
|
||||
#endif
|
||||
return m_sValue;
|
||||
}
|
||||
|
||||
bool CIniKeyA::SetKeyName(std::string sKeyName)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "CIniKeyA::SetKeyName()" << std::endl;
|
||||
#endif
|
||||
Trim(sKeyName);
|
||||
|
||||
// Check for key name conflict
|
||||
|
@ -689,18 +546,12 @@ bool CIniKeyA::SetKeyName(std::string sKeyName)
|
|||
}
|
||||
else
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "Could not set key name, key by that name already exists!" << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
std::string CIniKeyA::GetKeyName() const
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::cout << "CIniKeyA::GetKeyName()" << std::endl;
|
||||
#endif
|
||||
return m_sKeyName;
|
||||
}
|
||||
|
||||
|
@ -716,25 +567,16 @@ std::string CIniKeyA::GetKeyName() const
|
|||
// Helper Functions
|
||||
void RTrim(std::wstring& str, const std::wstring& chars = L" \t")
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"RTrim()" << std::endl;
|
||||
#endif
|
||||
str.erase(str.find_last_not_of(chars) + 1);
|
||||
}
|
||||
|
||||
void LTrim(std::wstring& str, const std::wstring& chars = L" \t")
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"LTrim()" << std::endl;
|
||||
#endif
|
||||
str.erase(0, str.find_first_not_of(chars));
|
||||
}
|
||||
|
||||
void Trim(std::wstring& str, const std::wstring& chars = L" \t")
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"Trim()" << std::endl;
|
||||
#endif
|
||||
str.erase(str.find_last_not_of(chars) + 1);
|
||||
str.erase(0, str.find_first_not_of(chars));
|
||||
}
|
||||
|
@ -759,16 +601,10 @@ std::wistream& operator>>(std::wistream& input, CIniMergeW merger)
|
|||
|
||||
CIniFileW::CIniFileW()
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"CIniFileW::CIniFileW()" << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
CIniFileW::~CIniFileW()
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"CIniFileW::~CIniFileW()" << std::endl;
|
||||
#endif
|
||||
RemoveAllSections();
|
||||
}
|
||||
|
||||
|
@ -782,18 +618,11 @@ void CIniFileW::Save(std::wostream& output)
|
|||
{
|
||||
sSection = L"[" + (*itr)->GetSectionName() + L"]";
|
||||
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"Writing Section " << sSection << std::endl;
|
||||
#endif
|
||||
|
||||
output << sSection << _CRLFA;
|
||||
|
||||
for (KeyIndexW::iterator klitr = (*itr)->m_keys.begin(); klitr != (*itr)->m_keys.end(); ++klitr)
|
||||
{
|
||||
std::wstring sKey = (*klitr)->GetKeyName() + L"=" + (*klitr)->GetValue();
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"Writing Key [" << sKey << L"]" << std::endl;
|
||||
#endif
|
||||
output << sKey << _CRLFA;
|
||||
}
|
||||
}
|
||||
|
@ -801,9 +630,6 @@ void CIniFileW::Save(std::wostream& output)
|
|||
|
||||
bool CIniFileW::Save(const std::wstring& fileName)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"CIniFileW::Save() - " << fileName << std::endl;
|
||||
#endif
|
||||
|
||||
std::wofstream output;
|
||||
|
||||
|
@ -855,17 +681,11 @@ void CIniFileW::Load(std::wistream& input, bool bMerge)
|
|||
switch (nType)
|
||||
{
|
||||
case SECTION:
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"Parsing: Secton - " << sRead << std::endl;
|
||||
#endif
|
||||
pSection = AddSection(sRead.substr(1, sRead.size() - 2));
|
||||
break;
|
||||
|
||||
case KEY:
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"Parsing: Key - " << sRead << std::endl;
|
||||
#endif
|
||||
// Check to ensure valid section... or drop the keys listed
|
||||
if (pSection)
|
||||
{
|
||||
|
@ -875,23 +695,14 @@ void CIniFileW::Load(std::wistream& input, bool bMerge)
|
|||
CIniKeyW* pKey = pSection->AddKey(sKey);
|
||||
if (pKey)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"Parsing: Key Value - " << sValue << std::endl;
|
||||
#endif
|
||||
pKey->SetValue(sValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case COMMENT:
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"Parsing: Comment - " << sRead << std::endl;
|
||||
#endif
|
||||
break;
|
||||
case OTHER:
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"Parsing: Other - " << sRead << std::endl;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -900,9 +711,6 @@ void CIniFileW::Load(std::wistream& input, bool bMerge)
|
|||
|
||||
bool CIniFileW::Load(const std::wstring& fileName, bool bMerge)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"CIniFileW::Load() - " << fileName << std::endl;
|
||||
#endif
|
||||
|
||||
std::wifstream input;
|
||||
|
||||
|
@ -923,18 +731,12 @@ bool CIniFileW::Load(const std::wstring& fileName, bool bMerge)
|
|||
|
||||
const SecIndexW& CIniFileW::GetSections() const
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"CIniFileW::GetSections()" << std::endl;
|
||||
#endif
|
||||
return m_sections;
|
||||
}
|
||||
|
||||
|
||||
CIniSectionW* CIniFileW::GetSection(std::wstring sSection) const
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"CIniFileW::GetSection()" << std::endl;
|
||||
#endif
|
||||
Trim(sSection);
|
||||
SecIndexW::const_iterator itr = _find_sec(sSection);
|
||||
if (itr != m_sections.end())
|
||||
|
@ -944,10 +746,6 @@ CIniSectionW* CIniFileW::GetSection(std::wstring sSection) const
|
|||
|
||||
CIniSectionW* CIniFileW::AddSection(std::wstring sSection)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"CIniFileW::AddSection()" << std::endl;
|
||||
#endif
|
||||
|
||||
Trim(sSection);
|
||||
SecIndexW::const_iterator itr = _find_sec(sSection);
|
||||
if (itr == m_sections.end())
|
||||
|
@ -964,9 +762,6 @@ CIniSectionW* CIniFileW::AddSection(std::wstring sSection)
|
|||
|
||||
std::wstring CIniFileW::GetKeyValue(const std::wstring& sSection, const std::wstring& sKey) const
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"CIniFileW::GetKeyValue()" << std::endl;
|
||||
#endif
|
||||
std::wstring sValue;
|
||||
CIniSectionW* pSec = GetSection(sSection);
|
||||
if (pSec)
|
||||
|
@ -980,9 +775,6 @@ std::wstring CIniFileW::GetKeyValue(const std::wstring& sSection, const std::wst
|
|||
|
||||
void CIniFileW::SetKeyValue(const std::wstring& sSection, const std::wstring& sKey, const std::wstring& sValue)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"CIniFileW::SetKeyValue()" << std::endl;
|
||||
#endif
|
||||
CIniSectionW* pSec = AddSection(sSection);
|
||||
if (pSec)
|
||||
{
|
||||
|
@ -995,9 +787,6 @@ void CIniFileW::SetKeyValue(const std::wstring& sSection, const std::wstring& sK
|
|||
|
||||
void CIniFileW::RemoveSection(std::wstring sSection)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"CIniFileW::RemoveSection()" << std::endl;
|
||||
#endif
|
||||
Trim(sSection);
|
||||
SecIndexW::iterator itr = _find_sec(sSection);
|
||||
if (itr != m_sections.end())
|
||||
|
@ -1009,9 +798,6 @@ void CIniFileW::RemoveSection(std::wstring sSection)
|
|||
|
||||
void CIniFileW::RemoveSection(CIniSectionW* pSection)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"CIniFileW::RemoveSection()" << std::endl;
|
||||
#endif
|
||||
// No trim since internal object not from user
|
||||
SecIndexW::iterator itr = _find_sec(pSection->m_sSectionName);
|
||||
if (itr != m_sections.end())
|
||||
|
@ -1023,14 +809,8 @@ void CIniFileW::RemoveSection(CIniSectionW* pSection)
|
|||
|
||||
void CIniFileW::RemoveAllSections()
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"CIniFileW::RemoveAllSections()" << std::endl;
|
||||
#endif
|
||||
for (SecIndexW::iterator itr = m_sections.begin(); itr != m_sections.end(); ++itr)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"Deleting Section: CIniSectionWName[" << (*itr)->GetSectionName() << L"]" << std::endl;
|
||||
#endif
|
||||
delete *itr;
|
||||
}
|
||||
m_sections.clear();
|
||||
|
@ -1039,9 +819,6 @@ void CIniFileW::RemoveAllSections()
|
|||
|
||||
bool CIniFileW::RenameSection(const std::wstring& sSectionName, const std::wstring& sNewSectionName)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"CIniFileW::RenameSection()" << std::endl;
|
||||
#endif
|
||||
// Note string trims are done in lower calls.
|
||||
bool bRval = false;
|
||||
CIniSectionW* pSec = GetSection(sSectionName);
|
||||
|
@ -1054,9 +831,6 @@ bool CIniFileW::RenameSection(const std::wstring& sSectionName, const std::wstri
|
|||
|
||||
bool CIniFileW::RenameKey(const std::wstring& sSectionName, const std::wstring& sKeyName, const std::wstring& sNewKeyName)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"CIniFileW::RenameKey()" << std::endl;
|
||||
#endif
|
||||
// Note string trims are done in lower calls.
|
||||
bool bRval = false;
|
||||
CIniSectionW* pSec = GetSection(sSectionName);
|
||||
|
@ -1091,25 +865,16 @@ CIniSectionW::CIniSectionW(CIniFileW* pIniFile, const std::wstring& sSectionName
|
|||
: m_pIniFile(pIniFile)
|
||||
, m_sSectionName(sSectionName)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"CIniSectionW::CIniSectionW()" << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
CIniSectionW::~CIniSectionW()
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"CIniSectionW::~CIniSectionW()" << std::endl;
|
||||
#endif
|
||||
RemoveAllKeys();
|
||||
}
|
||||
|
||||
CIniKeyW* CIniSectionW::GetKey(std::wstring sKeyName) const
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"CIniSectionW::GetKey()" << std::endl;
|
||||
#endif
|
||||
Trim(sKeyName);
|
||||
KeyIndexW::const_iterator itr = _find_key(sKeyName);
|
||||
if (itr != m_keys.end())
|
||||
|
@ -1119,14 +884,8 @@ CIniKeyW* CIniSectionW::GetKey(std::wstring sKeyName) const
|
|||
|
||||
void CIniSectionW::RemoveAllKeys()
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"CIniSectionW::RemoveAllKeys()" << std::endl;
|
||||
#endif
|
||||
for (KeyIndexW::iterator itr = m_keys.begin(); itr != m_keys.end(); ++itr)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"Deleting Key: " << (*itr)->GetKeyName() << std::endl;
|
||||
#endif
|
||||
delete *itr;
|
||||
}
|
||||
m_keys.clear();
|
||||
|
@ -1134,9 +893,6 @@ void CIniSectionW::RemoveAllKeys()
|
|||
|
||||
void CIniSectionW::RemoveKey(std::wstring sKey)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"CIniSectionW::RemoveKey()" << std::endl;
|
||||
#endif
|
||||
Trim(sKey);
|
||||
KeyIndexW::iterator itr = _find_key(sKey);
|
||||
if (itr != m_keys.end())
|
||||
|
@ -1148,9 +904,6 @@ void CIniSectionW::RemoveKey(std::wstring sKey)
|
|||
|
||||
void CIniSectionW::RemoveKey(CIniKeyW* pKey)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"CIniSectionW::RemoveKey()" << std::endl;
|
||||
#endif
|
||||
// No trim is done to improve efficiency since CIniKeyW* should already be trimmed
|
||||
KeyIndexW::iterator itr = _find_key(pKey->m_sKeyName);
|
||||
if (itr != m_keys.end())
|
||||
|
@ -1162,9 +915,6 @@ void CIniSectionW::RemoveKey(CIniKeyW* pKey)
|
|||
|
||||
CIniKeyW* CIniSectionW::AddKey(std::wstring sKeyName)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"CIniSectionW::AddKey()" << std::endl;
|
||||
#endif
|
||||
Trim(sKeyName);
|
||||
KeyIndexW::const_iterator itr = _find_key(sKeyName);
|
||||
if (itr == m_keys.end())
|
||||
|
@ -1180,17 +930,10 @@ CIniKeyW* CIniSectionW::AddKey(std::wstring sKeyName)
|
|||
|
||||
bool CIniSectionW::SetSectionName(std::wstring sSectionName)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"CIniSectionW::SetSectionName()" << std::endl;
|
||||
#endif
|
||||
Trim(sSectionName);
|
||||
// Does this already exist.
|
||||
if (m_pIniFile->_find_sec(sSectionName) == m_pIniFile->m_sections.end())
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"Setting Section Name: [" << m_sSectionName << L"] --> [" << sSectionName << L"]" << std::endl;
|
||||
#endif
|
||||
|
||||
// Find the current section if one exists and remove it since we are renaming
|
||||
SecIndexW::iterator itr = m_pIniFile->_find_sec(m_sSectionName);
|
||||
|
||||
|
@ -1208,34 +951,22 @@ bool CIniSectionW::SetSectionName(std::wstring sSectionName)
|
|||
}
|
||||
else
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"Section existed could not rename" << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
std::wstring CIniSectionW::GetSectionName() const
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"CIniSectionW::GetSectionName()" << std::endl;
|
||||
#endif
|
||||
return m_sSectionName;
|
||||
}
|
||||
|
||||
const KeyIndexW& CIniSectionW::GetKeys() const
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"CIniSectionW::GetKeys()" << std::endl;
|
||||
#endif
|
||||
return m_keys;
|
||||
}
|
||||
|
||||
std::wstring CIniSectionW::GetKeyValue(std::wstring sKey) const
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"CIniSectionW::GetKeyValue()" << std::endl;
|
||||
#endif
|
||||
std::wstring sValue;
|
||||
CIniKeyW* pKey = GetKey(sKey);
|
||||
if (pKey)
|
||||
|
@ -1247,9 +978,6 @@ std::wstring CIniSectionW::GetKeyValue(std::wstring sKey) const
|
|||
|
||||
void CIniSectionW::SetKeyValue(std::wstring sKey, const std::wstring& sValue)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"CIniSectionW::SetKeyValue()" << std::endl;
|
||||
#endif
|
||||
CIniKeyW* pKey = AddKey(sKey);
|
||||
if (pKey)
|
||||
{
|
||||
|
@ -1260,9 +988,6 @@ void CIniSectionW::SetKeyValue(std::wstring sKey, const std::wstring& sValue)
|
|||
// Returns a constant iterator to a key by name, string is not trimmed
|
||||
KeyIndexW::const_iterator CIniSectionW::_find_key(const std::wstring& sKey) const
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"CIniSectionW::_find_key() const" << std::endl;
|
||||
#endif
|
||||
CIniKeyW bogus(NULL, sKey);
|
||||
return m_keys.find(&bogus);
|
||||
}
|
||||
|
@ -1270,9 +995,6 @@ KeyIndexW::const_iterator CIniSectionW::_find_key(const std::wstring& sKey) cons
|
|||
// Returns an iterator to a key by name, string is not trimmed
|
||||
KeyIndexW::iterator CIniSectionW::_find_key(const std::wstring& sKey)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"CIniSectionW::_find_key()" << std::endl;
|
||||
#endif
|
||||
CIniKeyW bogus(NULL, sKey);
|
||||
return m_keys.find(&bogus);
|
||||
}
|
||||
|
@ -1285,40 +1007,25 @@ CIniKeyW::CIniKeyW(CIniSectionW* pSection, const std::wstring& sKeyName)
|
|||
: m_pSection(pSection)
|
||||
, m_sKeyName(sKeyName)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"CIniKeyW::CIniKeyW()" << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
CIniKeyW::~CIniKeyW()
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"CIniKeyW::~CIniKeyW()" << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
void CIniKeyW::SetValue(const std::wstring& sValue)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"CIniKeyW::SetValue()" << std::endl;
|
||||
#endif
|
||||
m_sValue = sValue;
|
||||
}
|
||||
|
||||
std::wstring CIniKeyW::GetValue() const
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"CIniKeyW::GetValue()" << std::endl;
|
||||
#endif
|
||||
return m_sValue;
|
||||
}
|
||||
|
||||
bool CIniKeyW::SetKeyName(std::wstring sKeyName)
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"CIniKeyW::SetKeyName()" << std::endl;
|
||||
#endif
|
||||
Trim(sKeyName);
|
||||
|
||||
// Check for key name conflict
|
||||
|
@ -1339,18 +1046,12 @@ bool CIniKeyW::SetKeyName(std::wstring sKeyName)
|
|||
}
|
||||
else
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"Could not set key name, key by that name already exists!" << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
std::wstring CIniKeyW::GetKeyName() const
|
||||
{
|
||||
#ifdef _CINIFILE_DEBUG
|
||||
std::wcout << L"CIniKeyW::GetKeyName()" << std::endl;
|
||||
#endif
|
||||
return m_sKeyName;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include <cstdio>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include "../osdebugout.h"
|
||||
#include "../platcompat.h"
|
||||
|
||||
extern HINSTANCE hInst;
|
||||
|
@ -136,7 +135,7 @@ namespace shared
|
|||
if (RegisterRawInputDevices(Rid, countof(Rid), sizeof(Rid[0])) == FALSE)
|
||||
{
|
||||
//registration failed. Call GetLastError for the cause of the error.
|
||||
fprintf(stderr, "Could not (de)register raw input devices.\n");
|
||||
Console.Warning("Could not (de)register raw input devices.\n");
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
|
@ -233,7 +232,7 @@ namespace shared
|
|||
{
|
||||
MSG* msg = reinterpret_cast<MSG*>(lParam);
|
||||
|
||||
//fprintf(stderr, "hook: %d, %d, %d\n", code, wParam, lParam);
|
||||
//Console.Warning("hook: %d, %d, %d\n", code, wParam, lParam);
|
||||
if (code == HC_ACTION)
|
||||
RawInputProc(msg->hwnd, msg->message, msg->wParam, msg->lParam);
|
||||
return CallNextHookEx(hHook, code, wParam, lParam);
|
||||
|
@ -243,7 +242,7 @@ namespace shared
|
|||
{
|
||||
MSG* msg = reinterpret_cast<MSG*>(lParam);
|
||||
|
||||
//fprintf(stderr, "hook: %d, %d, %d\n", code, wParam, lParam);
|
||||
//Console.Warning("hook: %d, %d, %d\n", code, wParam, lParam);
|
||||
if (code == HC_ACTION)
|
||||
MyWndProc(msg->hwnd, msg->message, msg->wParam, msg->lParam);
|
||||
return CallNextHookEx(hHookWnd, code, wParam, lParam);
|
||||
|
@ -251,7 +250,7 @@ namespace shared
|
|||
|
||||
static LRESULT CALLBACK KBHookProc(INT code, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
fprintf(stderr, "kb hook: %d, %zd, %zd\n", code, wParam, lParam);
|
||||
Console.Warning("kb hook: %d, %zd, %zd\n", code, wParam, lParam);
|
||||
KBDLLHOOKSTRUCT* kb = reinterpret_cast<KBDLLHOOKSTRUCT*>(lParam);
|
||||
//if(code == HC_ACTION)
|
||||
// RawInputProc(msg->hwnd, msg->message, msg->wParam, msg->lParam);
|
||||
|
|
|
@ -17,16 +17,7 @@
|
|||
#include "ringbuffer.h"
|
||||
#include <cstring>
|
||||
#include <cassert>
|
||||
#include "../osdebugout.h"
|
||||
|
||||
#if 0
|
||||
#define DPRINTF OSDebugOut
|
||||
#else
|
||||
#define DPRINTF(...) \
|
||||
do \
|
||||
{ \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
RingBuffer::RingBuffer()
|
||||
: m_begin(0)
|
||||
|
@ -54,7 +45,6 @@ void RingBuffer::reserve(size_t capacity)
|
|||
m_data = new char[capacity];
|
||||
memset(m_data, 0, capacity);
|
||||
m_capacity = capacity;
|
||||
DPRINTF(TEXT("RingBuffer %p m_data %p\n"), this, m_data);
|
||||
}
|
||||
|
||||
size_t RingBuffer::size() const
|
||||
|
@ -72,7 +62,6 @@ size_t RingBuffer::size() const
|
|||
else
|
||||
size = m_capacity - m_begin + m_end; // [...e b...]
|
||||
|
||||
DPRINTF(TEXT("size %zu\n"), size);
|
||||
return size;
|
||||
}
|
||||
|
||||
|
@ -117,7 +106,6 @@ size_t RingBuffer::peek_write(bool overwrite) const
|
|||
else
|
||||
peek = m_begin; // [ b.......e]
|
||||
|
||||
DPRINTF(TEXT("peek_write %zu\n"), peek);
|
||||
return peek;
|
||||
}
|
||||
|
||||
|
@ -138,7 +126,6 @@ size_t RingBuffer::peek_read() const
|
|||
else
|
||||
peek = m_end; // [...e b]
|
||||
|
||||
DPRINTF(TEXT("peek_read %zu\n"), peek);
|
||||
return peek;
|
||||
}
|
||||
|
||||
|
@ -186,7 +173,6 @@ void RingBuffer::write(size_t bytes)
|
|||
m_end = (m_end + bytes) % m_capacity;
|
||||
|
||||
mLastWrite = hrc::now();
|
||||
DPRINTF(TEXT("write %zu begin %zu end %zu -> %zu\n"), bytes, m_begin, before, m_end);
|
||||
}
|
||||
|
||||
void RingBuffer::read(size_t bytes)
|
||||
|
@ -202,5 +188,4 @@ void RingBuffer::read(size_t bytes)
|
|||
}
|
||||
|
||||
m_begin = (m_begin + bytes) % m_capacity;
|
||||
DPRINTF(TEXT("read %zu begin %zu -> %zu end %zu\n"), bytes, before, m_begin, m_end);
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ namespace usb_eyetoy
|
|||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "unk format %c%c%c%c\n", pixelformat, pixelformat >> 8, pixelformat >> 16, pixelformat >> 24);
|
||||
Console.Warning("unk format %c%c%c%c\n", pixelformat, pixelformat >> 8, pixelformat >> 16, pixelformat >> 24);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ namespace usb_eyetoy
|
|||
|
||||
case EIO:
|
||||
default:
|
||||
fprintf(stderr, "%s error %d, %s\n", "VIDIOC_DQBUF", errno, strerror(errno));
|
||||
Console.Warning("%s error %d, %s\n", "VIDIOC_DQBUF", errno, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ namespace usb_eyetoy
|
|||
|
||||
if (-1 == xioctl(fd, VIDIOC_QBUF, &buf))
|
||||
{
|
||||
fprintf(stderr, "%s error %d, %s\n", "VIDIOC_QBUF", errno, strerror(errno));
|
||||
Console.Warning("%s error %d, %s\n", "VIDIOC_QBUF", errno, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,7 @@ namespace usb_eyetoy
|
|||
CLEAR(cap);
|
||||
if (ioctl(fd, VIDIOC_QUERYCAP, &cap) >= 0)
|
||||
{
|
||||
fprintf(stderr, "Camera: %s / %s\n", dev_name, (char*)cap.card);
|
||||
Console.Warning("Camera: %s / %s\n", dev_name, (char*)cap.card);
|
||||
if (!selectedDevice.empty() && strcmp(selectedDevice.c_str(), (char*)cap.card) == 0)
|
||||
{
|
||||
goto cont;
|
||||
|
@ -193,7 +193,7 @@ namespace usb_eyetoy
|
|||
fd = open(dev_name, O_RDWR | O_NONBLOCK, 0);
|
||||
if (-1 == fd)
|
||||
{
|
||||
fprintf(stderr, "Cannot open '%s': %d, %s\n", dev_name, errno, strerror(errno));
|
||||
Console.Warning("Cannot open '%s': %d, %s\n", dev_name, errno, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -205,25 +205,25 @@ namespace usb_eyetoy
|
|||
{
|
||||
if (EINVAL == errno)
|
||||
{
|
||||
fprintf(stderr, "%s is no V4L2 device\n", dev_name);
|
||||
Console.Warning("%s is no V4L2 device\n", dev_name);
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "%s error %d, %s\n", "VIDIOC_QUERYCAP", errno, strerror(errno));
|
||||
Console.Warning("%s error %d, %s\n", "VIDIOC_QUERYCAP", errno, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(cap.capabilities & V4L2_CAP_VIDEO_CAPTURE))
|
||||
{
|
||||
fprintf(stderr, "%s is no video capture device\n", dev_name);
|
||||
Console.Warning("%s is no video capture device\n", dev_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!(cap.capabilities & V4L2_CAP_STREAMING))
|
||||
{
|
||||
fprintf(stderr, "%s does not support streaming i/o\n", dev_name);
|
||||
Console.Warning("%s does not support streaming i/o\n", dev_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -258,11 +258,11 @@ namespace usb_eyetoy
|
|||
|
||||
if (-1 == xioctl(fd, VIDIOC_S_FMT, &fmt))
|
||||
{
|
||||
fprintf(stderr, "%s error %d, %s\n", "VIDIOC_S_FMT", errno, strerror(errno));
|
||||
Console.Warning("%s error %d, %s\n", "VIDIOC_S_FMT", errno, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
pixelformat = fmt.fmt.pix.pixelformat;
|
||||
fprintf(stderr, "VIDIOC_S_FMT res=%dx%d, fmt=%c%c%c%c\n", fmt.fmt.pix.width, fmt.fmt.pix.height,
|
||||
Console.Warning("VIDIOC_S_FMT res=%dx%d, fmt=%c%c%c%c\n", fmt.fmt.pix.width, fmt.fmt.pix.height,
|
||||
pixelformat, pixelformat >> 8, pixelformat >> 16, pixelformat >> 24);
|
||||
|
||||
struct v4l2_requestbuffers req;
|
||||
|
@ -275,19 +275,19 @@ namespace usb_eyetoy
|
|||
{
|
||||
if (EINVAL == errno)
|
||||
{
|
||||
fprintf(stderr, "%s does not support memory mapping\n", dev_name);
|
||||
Console.Warning("%s does not support memory mapping\n", dev_name);
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "%s error %d, %s\n", "VIDIOC_REQBUFS", errno, strerror(errno));
|
||||
Console.Warning("%s error %d, %s\n", "VIDIOC_REQBUFS", errno, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (req.count < 2)
|
||||
{
|
||||
fprintf(stderr, "Insufficient buffer memory on %s\n", dev_name);
|
||||
Console.Warning("Insufficient buffer memory on %s\n", dev_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -295,7 +295,7 @@ namespace usb_eyetoy
|
|||
|
||||
if (!buffers)
|
||||
{
|
||||
fprintf(stderr, "Out of memory\n");
|
||||
Console.Warning("Out of memory\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -310,7 +310,7 @@ namespace usb_eyetoy
|
|||
|
||||
if (-1 == xioctl(fd, VIDIOC_QUERYBUF, &buf))
|
||||
{
|
||||
fprintf(stderr, "%s error %d, %s\n", "VIDIOC_QUERYBUF", errno, strerror(errno));
|
||||
Console.Warning("%s error %d, %s\n", "VIDIOC_QUERYBUF", errno, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -319,7 +319,7 @@ namespace usb_eyetoy
|
|||
|
||||
if (MAP_FAILED == buffers[n_buffers].start)
|
||||
{
|
||||
fprintf(stderr, "%s error %d, %s\n", "mmap", errno, strerror(errno));
|
||||
Console.Warning("%s error %d, %s\n", "mmap", errno, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -334,7 +334,7 @@ namespace usb_eyetoy
|
|||
|
||||
if (-1 == xioctl(fd, VIDIOC_QBUF, &buf))
|
||||
{
|
||||
fprintf(stderr, "%s error %d, %s\n", "VIDIOC_QBUF", errno, strerror(errno));
|
||||
Console.Warning("%s error %d, %s\n", "VIDIOC_QBUF", errno, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -343,7 +343,7 @@ namespace usb_eyetoy
|
|||
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
if (-1 == xioctl(fd, VIDIOC_STREAMON, &type))
|
||||
{
|
||||
fprintf(stderr, "%s error %d, %s\n", "VIDIOC_STREAMON", errno, strerror(errno));
|
||||
Console.Warning("%s error %d, %s\n", "VIDIOC_STREAMON", errno, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -368,13 +368,13 @@ namespace usb_eyetoy
|
|||
{
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
fprintf(stderr, "%s error %d, %s\n", "select", errno, strerror(errno));
|
||||
Console.Warning("%s error %d, %s\n", "select", errno, strerror(errno));
|
||||
break;
|
||||
}
|
||||
|
||||
if (ret == 0)
|
||||
{
|
||||
fprintf(stderr, "select timeout\n");
|
||||
Console.Warning("select timeout\n");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -383,7 +383,7 @@ namespace usb_eyetoy
|
|||
}
|
||||
}
|
||||
eyetoy_running = 0;
|
||||
fprintf(stderr, "V4L2 thread quit\n");
|
||||
Console.Warning("V4L2 thread quit\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -393,7 +393,7 @@ namespace usb_eyetoy
|
|||
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
if (-1 == xioctl(fd, VIDIOC_STREAMOFF, &type))
|
||||
{
|
||||
fprintf(stderr, "%s error %d, %s\n", "VIDIOC_STREAMOFF", errno, strerror(errno));
|
||||
Console.Warning("%s error %d, %s\n", "VIDIOC_STREAMOFF", errno, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -401,7 +401,7 @@ namespace usb_eyetoy
|
|||
{
|
||||
if (-1 == munmap(buffers[i].start, buffers[i].length))
|
||||
{
|
||||
fprintf(stderr, "%s error %d, %s\n", "munmap", errno, strerror(errno));
|
||||
Console.Warning("%s error %d, %s\n", "munmap", errno, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -409,7 +409,7 @@ namespace usb_eyetoy
|
|||
|
||||
if (-1 == close(fd))
|
||||
{
|
||||
fprintf(stderr, "%s error %d, %s\n", "close", errno, strerror(errno));
|
||||
Console.Warning("%s error %d, %s\n", "close", errno, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
fd = -1;
|
||||
|
|
|
@ -59,7 +59,7 @@ namespace usb_eyetoy
|
|||
HRESULT hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pCreateDevEnum));
|
||||
if (FAILED(hr))
|
||||
{
|
||||
fprintf(stderr, "Error Creating Device Enumerator");
|
||||
Console.Warning("Error Creating Device Enumerator");
|
||||
return devList;
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ namespace usb_eyetoy
|
|||
hr = pCreateDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pEnum, NULL);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
fprintf(stderr, "You have no video capture hardware");
|
||||
Console.Warning("You have no video capture hardware");
|
||||
return devList;
|
||||
};
|
||||
|
||||
|
@ -112,7 +112,7 @@ namespace usb_eyetoy
|
|||
HRESULT hr = CoCreateInstance(CLSID_CaptureGraphBuilder2, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pGraphBuilder));
|
||||
if (FAILED(hr))
|
||||
{
|
||||
fprintf(stderr, "CoCreateInstance CLSID_CaptureGraphBuilder2 err : %x\n", hr);
|
||||
Console.Warning("CoCreateInstance CLSID_CaptureGraphBuilder2 err : %x\n", hr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -120,21 +120,21 @@ namespace usb_eyetoy
|
|||
hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pGraph));
|
||||
if (FAILED(hr))
|
||||
{
|
||||
fprintf(stderr, "CoCreateInstance CLSID_FilterGraph err : %x\n", hr);
|
||||
Console.Warning("CoCreateInstance CLSID_FilterGraph err : %x\n", hr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
hr = pGraphBuilder->SetFiltergraph(pGraph);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
fprintf(stderr, "SetFiltergraph err : %x\n", hr);
|
||||
Console.Warning("SetFiltergraph err : %x\n", hr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
hr = pGraph->QueryInterface(IID_IMediaControl, (void**)&pControl);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
fprintf(stderr, "QueryInterface IID_IMediaControl err : %x\n", hr);
|
||||
Console.Warning("QueryInterface IID_IMediaControl err : %x\n", hr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,7 @@ namespace usb_eyetoy
|
|||
hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pCreateDevEnum));
|
||||
if (FAILED(hr))
|
||||
{
|
||||
fprintf(stderr, "Error Creating Device Enumerator");
|
||||
Console.Warning("Error Creating Device Enumerator");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ namespace usb_eyetoy
|
|||
hr = pCreateDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pEnum, NULL);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
fprintf(stderr, "You have no video capture hardware");
|
||||
Console.Warning("You have no video capture hardware");
|
||||
return -1;
|
||||
};
|
||||
|
||||
|
@ -164,7 +164,7 @@ namespace usb_eyetoy
|
|||
hr = pMoniker->BindToStorage(0, 0, IID_PPV_ARGS(&pPropBag));
|
||||
if (FAILED(hr))
|
||||
{
|
||||
fprintf(stderr, "BindToStorage err : %x\n", hr);
|
||||
Console.Warning("BindToStorage err : %x\n", hr);
|
||||
goto freeMoniker;
|
||||
}
|
||||
|
||||
|
@ -178,10 +178,10 @@ namespace usb_eyetoy
|
|||
}
|
||||
if (FAILED(hr))
|
||||
{
|
||||
fprintf(stderr, "Read name err : %x\n", hr);
|
||||
Console.Warning("Read name err : %x\n", hr);
|
||||
goto freeVar;
|
||||
}
|
||||
fprintf(stderr, "Camera: '%ls'\n", var.bstrVal);
|
||||
Console.Warning("Camera: '%ls'\n", var.bstrVal);
|
||||
if (!selectedDevice.empty() && selectedDevice != var.bstrVal)
|
||||
{
|
||||
goto freeVar;
|
||||
|
@ -191,7 +191,7 @@ namespace usb_eyetoy
|
|||
hr = pGraph->AddSourceFilterForMoniker(pMoniker, NULL, L"sourcefilter", &sourcefilter);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
fprintf(stderr, "AddSourceFilterForMoniker err : %x\n", hr);
|
||||
Console.Warning("AddSourceFilterForMoniker err : %x\n", hr);
|
||||
goto freeVar;
|
||||
}
|
||||
|
||||
|
@ -210,7 +210,7 @@ namespace usb_eyetoy
|
|||
VIDEO_STREAM_CONFIG_CAPS scc;
|
||||
AM_MEDIA_TYPE* pmtConfig;
|
||||
hr = pSourceConfig->GetStreamCaps(iFormat, &pmtConfig, (BYTE*)&scc);
|
||||
fprintf(stderr, "GetStreamCaps min=%dx%d max=%dx%d, fmt=%x\n",
|
||||
Console.Warning("GetStreamCaps min=%dx%d max=%dx%d, fmt=%x\n",
|
||||
scc.MinOutputSize.cx, scc.MinOutputSize.cy,
|
||||
scc.MaxOutputSize.cx, scc.MaxOutputSize.cy,
|
||||
pmtConfig->subtype);
|
||||
|
@ -239,14 +239,14 @@ namespace usb_eyetoy
|
|||
hr = CoCreateInstance(CLSID_SampleGrabber, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&samplegrabberfilter));
|
||||
if (FAILED(hr))
|
||||
{
|
||||
fprintf(stderr, "CoCreateInstance CLSID_SampleGrabber err : %x\n", hr);
|
||||
Console.Warning("CoCreateInstance CLSID_SampleGrabber err : %x\n", hr);
|
||||
goto freeVar;
|
||||
}
|
||||
|
||||
hr = pGraph->AddFilter(samplegrabberfilter, L"samplegrabberfilter");
|
||||
if (FAILED(hr))
|
||||
{
|
||||
fprintf(stderr, "AddFilter samplegrabberfilter err : %x\n", hr);
|
||||
Console.Warning("AddFilter samplegrabberfilter err : %x\n", hr);
|
||||
goto freeVar;
|
||||
}
|
||||
|
||||
|
@ -254,7 +254,7 @@ namespace usb_eyetoy
|
|||
hr = samplegrabberfilter->QueryInterface(IID_PPV_ARGS(&samplegrabber));
|
||||
if (FAILED(hr))
|
||||
{
|
||||
fprintf(stderr, "QueryInterface err : %x\n", hr);
|
||||
Console.Warning("QueryInterface err : %x\n", hr);
|
||||
goto freeVar;
|
||||
}
|
||||
|
||||
|
@ -265,7 +265,7 @@ namespace usb_eyetoy
|
|||
hr = samplegrabber->SetMediaType(&mt);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
fprintf(stderr, "SetMediaType err : %x\n", hr);
|
||||
Console.Warning("SetMediaType err : %x\n", hr);
|
||||
goto freeVar;
|
||||
}
|
||||
|
||||
|
@ -273,7 +273,7 @@ namespace usb_eyetoy
|
|||
hr = samplegrabber->SetCallback(callbackhandler, 0);
|
||||
if (hr != S_OK)
|
||||
{
|
||||
fprintf(stderr, "SetCallback err : %x\n", hr);
|
||||
Console.Warning("SetCallback err : %x\n", hr);
|
||||
goto freeVar;
|
||||
}
|
||||
|
||||
|
@ -281,14 +281,14 @@ namespace usb_eyetoy
|
|||
hr = CoCreateInstance(CLSID_NullRenderer, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&nullrenderer));
|
||||
if (FAILED(hr))
|
||||
{
|
||||
fprintf(stderr, "CoCreateInstance CLSID_NullRenderer err : %x\n", hr);
|
||||
Console.Warning("CoCreateInstance CLSID_NullRenderer err : %x\n", hr);
|
||||
goto freeVar;
|
||||
}
|
||||
|
||||
hr = pGraph->AddFilter(nullrenderer, L"nullrenderer");
|
||||
if (FAILED(hr))
|
||||
{
|
||||
fprintf(stderr, "AddFilter nullrenderer err : %x\n", hr);
|
||||
Console.Warning("AddFilter nullrenderer err : %x\n", hr);
|
||||
goto freeVar;
|
||||
}
|
||||
|
||||
|
@ -296,7 +296,7 @@ namespace usb_eyetoy
|
|||
hr = pGraphBuilder->RenderStream(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Video, sourcefilter, samplegrabberfilter, nullrenderer);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
fprintf(stderr, "RenderStream err : %x\n", hr);
|
||||
Console.Warning("RenderStream err : %x\n", hr);
|
||||
goto freeVar;
|
||||
}
|
||||
|
||||
|
@ -305,7 +305,7 @@ namespace usb_eyetoy
|
|||
hr = pGraphBuilder->ControlStream(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, sourcefilter, &start, &stop, 1, 2);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
fprintf(stderr, "ControlStream err : %x\n", hr);
|
||||
Console.Warning("ControlStream err : %x\n", hr);
|
||||
goto freeVar;
|
||||
}
|
||||
|
||||
|
@ -376,7 +376,7 @@ namespace usb_eyetoy
|
|||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "dshow_callback: unk format: len=%d bpp=%d\n", len, bitsperpixel);
|
||||
Console.Warning("dshow_callback: unk format: len=%d bpp=%d\n", len, bitsperpixel);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -431,7 +431,7 @@ namespace usb_eyetoy
|
|||
int ret = InitializeDevice(selectedDevice);
|
||||
if (ret < 0)
|
||||
{
|
||||
fprintf(stderr, "Camera: cannot find '%ls'\n", selectedDevice.c_str());
|
||||
Console.Warning("Camera: cannot find '%ls'\n", selectedDevice.c_str());
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "videodeviceproxy.h"
|
||||
#include "../osdebugout.h"
|
||||
#include "usb-eyetoy-webcam.h"
|
||||
#include "ov519.h"
|
||||
#include "../qemu-usb/desc.h"
|
||||
|
@ -341,14 +340,12 @@ namespace usb_eyetoy
|
|||
{
|
||||
case VendorDeviceRequest | 0x1: //Read register
|
||||
data[0] = s->regs[index & 0xFF];
|
||||
OSDebugOut(TEXT("=== READ reg 0x%02x = 0x%02x (%d)\n"), index, data[0], data[0]);
|
||||
p->actual_length = 1;
|
||||
break;
|
||||
|
||||
case VendorDeviceOutRequest | 0x1: //Write register
|
||||
if (!(index >= R51x_I2C_SADDR_3 && index <= R518_I2C_CTL))
|
||||
{
|
||||
OSDebugOut(TEXT("*** WRITE reg 0x%02x = 0x%02x (%d)\n"), index, data[0], data[0]);
|
||||
}
|
||||
|
||||
switch (index)
|
||||
|
@ -361,13 +358,10 @@ namespace usb_eyetoy
|
|||
}
|
||||
break;
|
||||
case OV519_R10_H_SIZE:
|
||||
OSDebugOut(TEXT("Set width %d\n"), data[0] << 4);
|
||||
break;
|
||||
case OV519_R11_V_SIZE:
|
||||
OSDebugOut(TEXT("Set height %d\n"), data[0] << 3);
|
||||
break;
|
||||
case R518_I2C_CTL:
|
||||
//OSDebugOut(TEXT("Set R518_I2C_CTL %d %d\n"), s->regs[R518_I2C_CTL], data[0]);
|
||||
if (data[0] == 1) // Commit I2C write
|
||||
{
|
||||
//uint8_t reg = s->regs[s->regs[R51x_I2C_W_SID]];
|
||||
|
@ -381,10 +375,7 @@ namespace usb_eyetoy
|
|||
else if (reg < sizeof(s->i2c_regs))
|
||||
{
|
||||
s->i2c_regs[reg] = val;
|
||||
OSDebugOut(TEXT("I2C write to 0x%02x = 0x%02x\n"), reg, val);
|
||||
}
|
||||
else
|
||||
OSDebugOut(TEXT("I2C write out-of-bounds\n"));
|
||||
}
|
||||
else if (s->regs[R518_I2C_CTL] == 0x03 && data[0] == 0x05)
|
||||
{
|
||||
|
@ -395,10 +386,7 @@ namespace usb_eyetoy
|
|||
if (i2c_reg < sizeof(s->i2c_regs))
|
||||
{
|
||||
s->regs[R51x_I2C_DATA] = s->i2c_regs[i2c_reg];
|
||||
OSDebugOut(TEXT("I2C read from 0x%02x = 0x%02x\n"), i2c_reg, s->regs[R51x_I2C_DATA]);
|
||||
}
|
||||
else
|
||||
OSDebugOut(TEXT("Unhandled read from I2C: 0x%02x\n"), s->regs[R51x_I2C_SADDR_2]);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -411,7 +399,6 @@ namespace usb_eyetoy
|
|||
|
||||
break;
|
||||
default:
|
||||
OSDebugOut(TEXT("default ******************* %04x\n"), request);
|
||||
p->status = USB_RET_STALL;
|
||||
break;
|
||||
}
|
||||
|
@ -480,7 +467,7 @@ namespace usb_eyetoy
|
|||
else if (devep == 2)
|
||||
{
|
||||
// get audio
|
||||
//fprintf(stderr, "get audio %d\n", len);
|
||||
//Console.Warning("get audio %d\n", len);
|
||||
memset(data, 0, p->iov.size);
|
||||
usb_packet_copy(p, data, p->iov.size);
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../../osdebugout.h"
|
||||
#include "../usb-hid.h"
|
||||
#include "evdev.h"
|
||||
#include <linux/input.h>
|
||||
|
@ -50,7 +49,7 @@ namespace usb_hid
|
|||
DIR* dirp = opendir(EVDEV_DIR);
|
||||
if (dirp == NULL)
|
||||
{
|
||||
fprintf(stderr, "Error opening " EVDEV_DIR ": %s\n", strerror(errno));
|
||||
Console.Warning("Error opening " EVDEV_DIR ": %s\n", strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -65,7 +64,6 @@ namespace usb_hid
|
|||
const char* const start = dp->d_name + devlen - len;
|
||||
if (strncmp(start, devstr[hid_type], len) == 0)
|
||||
{
|
||||
OSDebugOut("%s%s\n", EVDEV_DIR, dp->d_name);
|
||||
|
||||
str.clear();
|
||||
str.str("");
|
||||
|
@ -75,13 +73,11 @@ namespace usb_hid
|
|||
std::string dev_path = str.str();
|
||||
if (!GetEvdevName(dev_path, name))
|
||||
{
|
||||
OSDebugOut("Failed to get name: %s\n", dev_path.c_str());
|
||||
//XXX though it also could mean that controller is unusable
|
||||
cfg.devs.push_back(std::make_pair(dp->d_name, dev_path));
|
||||
}
|
||||
else
|
||||
{
|
||||
OSDebugOut("Name: %s\n", name);
|
||||
cfg.devs.push_back(std::make_pair(std::string(name), dev_path));
|
||||
}
|
||||
}
|
||||
|
@ -104,7 +100,6 @@ namespace usb_hid
|
|||
if (idx > 0)
|
||||
{
|
||||
}
|
||||
OSDebugOut("Selected player %d idx: %d dev: '%s'\n", 2 - cfg->port, idx, name.c_str());
|
||||
}
|
||||
|
||||
int GtkHidConfigure(int port, const char* dev_type, HIDType hid_type, GtkWindow* parent)
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
*/
|
||||
|
||||
#include "evdev.h"
|
||||
#include "../../osdebugout.h"
|
||||
#include <cassert>
|
||||
#include <sstream>
|
||||
#include "../hidproxy.h"
|
||||
|
@ -47,7 +46,7 @@ namespace usb_hid
|
|||
DIR* dirp = opendir("/dev/input/");
|
||||
if (dirp == NULL)
|
||||
{
|
||||
perror("Error opening /dev/input/");
|
||||
Console.Warning("Error opening /dev/input/");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -55,7 +54,6 @@ namespace usb_hid
|
|||
{
|
||||
if (strncmp(dp->d_name, "hidraw", 6) == 0)
|
||||
{
|
||||
OSDebugOut("%s\n", dp->d_name);
|
||||
|
||||
str.clear();
|
||||
str.str("");
|
||||
|
@ -64,7 +62,7 @@ namespace usb_hid
|
|||
|
||||
if (fd < 0)
|
||||
{
|
||||
perror("Unable to open device");
|
||||
Console.Warning("Unable to open device");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -73,9 +71,9 @@ namespace usb_hid
|
|||
|
||||
/* res = ioctl(fd, HIDIOCGRAWPHYS(256), buf);
|
||||
if (res < 0)
|
||||
perror("HIDIOCGRAWPHYS");
|
||||
Console.Warning("HIDIOCGRAWPHYS");
|
||||
else
|
||||
OSDebugOut("Raw Phys: %s\n", buf);*/
|
||||
*/
|
||||
close(fd);
|
||||
if (evphys == buf)
|
||||
{
|
||||
|
@ -106,7 +104,6 @@ namespace usb_hid
|
|||
std::string path;
|
||||
if (!LoadSetting(mDevType, mPort, APINAME, N_DEVICE, path))
|
||||
{
|
||||
OSDebugOut("Cannot load evdev hid device setting!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -115,7 +112,6 @@ namespace usb_hid
|
|||
|
||||
if ((mHandle = open(path.c_str(), O_RDWR | O_NONBLOCK)) < 0)
|
||||
{
|
||||
OSDebugOut("Cannot open device: %s\n", path.c_str());
|
||||
goto quit;
|
||||
}
|
||||
|
||||
|
@ -165,7 +161,6 @@ namespace usb_hid
|
|||
{
|
||||
case EV_ABS:
|
||||
{
|
||||
OSDebugOut("EV_ABS: %d, val: %d\n", event.code, event.value);
|
||||
|
||||
if (dev->mHIDType == HIDTYPE_MOUSE) // usually mouse position is expected to be relative
|
||||
continue;
|
||||
|
@ -190,7 +185,6 @@ namespace usb_hid
|
|||
break;
|
||||
case EV_REL:
|
||||
{
|
||||
OSDebugOut("EV_REL: %d, val: %d\n", event.code, event.value);
|
||||
if (!hs->ptr.eh_entry)
|
||||
continue;
|
||||
|
||||
|
@ -210,7 +204,6 @@ namespace usb_hid
|
|||
break;
|
||||
case EV_KEY:
|
||||
{
|
||||
OSDebugOut("EV_KEY: 0x%02x (%d), val: %d\n", event.code, event.code, event.value);
|
||||
|
||||
#ifdef USING_X11 //FIXME not thread-safe
|
||||
if (event.code == KEY_LEFTSHIFT || event.code == KEY_RIGHTSHIFT)
|
||||
|
@ -282,7 +275,6 @@ namespace usb_hid
|
|||
break;
|
||||
case EV_SYN: //TODO useful?
|
||||
{
|
||||
OSDebugOut("EV_SYN: %d, val: %d\n", event.code, event.value);
|
||||
switch (event.code)
|
||||
{
|
||||
case SYN_REPORT:
|
||||
|
@ -302,14 +294,12 @@ namespace usb_hid
|
|||
|
||||
if (len < sizeof(input_event) && errno != EAGAIN)
|
||||
{
|
||||
OSDebugOut("%s: evdev read error %d\n", APINAME, errno);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
}
|
||||
OSDebugOut(TEXT("ReaderThread exited.\n"));
|
||||
|
||||
dev->mReaderThreadIsRunning = false;
|
||||
}
|
||||
|
|
|
@ -68,13 +68,13 @@ namespace usb_hid
|
|||
int fd = 0;
|
||||
if ((fd = open(path.c_str(), O_RDONLY)) < 0)
|
||||
{
|
||||
fprintf(stderr, "Cannot open %s\n", path.c_str());
|
||||
Console.Warning("Cannot open %s\n", path.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ioctl(fd, EVIOCGNAME(_Size), name) < -1)
|
||||
{
|
||||
fprintf(stderr, "Cannot get controller's name\n");
|
||||
Console.Warning("Cannot get controller's name\n");
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ namespace usb_hid
|
|||
//int axis = (value * 0x3FFF) / pValueCaps[i].LogicalMax;
|
||||
break;
|
||||
case HID_USAGE_GENERIC_HATSWITCH:
|
||||
//fprintf(stderr, "Hat: %02X\n", value);
|
||||
//Console.Warning("Hat: %02X\n", value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -141,7 +141,6 @@ namespace usb_hid
|
|||
if (!hs->kbd.eh_entry)
|
||||
return;
|
||||
static uint32_t nr = 0;
|
||||
OSDebugOut(TEXT("%ud kb: %hu %hu %hu %u\n"), nr, k.MakeCode, k.VKey, k.Flags, k.ExtraInformation);
|
||||
|
||||
nr++;
|
||||
if (nr > 10)
|
||||
|
@ -189,7 +188,6 @@ namespace usb_hid
|
|||
if (m.usButtonFlags & RI_MOUSE_WHEEL)
|
||||
z = (short)m.usButtonData / WHEEL_DELTA;
|
||||
|
||||
//OSDebugOut(TEXT("mouse: %d %d %u %hd\n"), m.lLastX, m.lLastY, m.ulButtons, z);
|
||||
|
||||
ev.type = INPUT_EVENT_KIND_BTN;
|
||||
|
||||
|
|
|
@ -653,8 +653,6 @@ static int usb_keyboard_poll(USBKeyboardState *s, uint8_t *buf, int len)
|
|||
buf[3]=data[4];
|
||||
buf[4]=data[5]|0xF0;
|
||||
|
||||
// printf("Got buzzer event !!!\nData %02X %02X %02X %02X %02X %02X\n", data[0], data[1], data[2], data[3], data[4], data[5]);
|
||||
|
||||
return 16;
|
||||
}
|
||||
|
||||
|
@ -784,7 +782,6 @@ static int usb_keyboard_handle_control(USBDevice *dev, int request, int value,
|
|||
buf[3]=data[2];
|
||||
buf[4]=data[3];
|
||||
buf[5]=data[4];
|
||||
// printf("Lamps %02X %02X %02X %02X %02X %02X %02X\nlen = %i\n", data[0], data[1], data[2], data[3], data[4], data[5], data[6], length);
|
||||
CancelIo(usb_buzzer);
|
||||
WriteFile(usb_buzzer, buf, 8, 0, &ovl);
|
||||
break;
|
||||
|
@ -792,7 +789,6 @@ static int usb_keyboard_handle_control(USBDevice *dev, int request, int value,
|
|||
ret = 0;
|
||||
break;
|
||||
default:
|
||||
printf("Bad request value %08X", request);
|
||||
fail:
|
||||
ret = USB_RET_STALL;
|
||||
break;
|
||||
|
@ -822,7 +818,6 @@ static int usb_keyboard_handle_data(USBDevice *dev, int pid,
|
|||
buf[3]=data[2];
|
||||
buf[4]=data[3];
|
||||
buf[5]=data[4];
|
||||
// printf("Lamps %02X %02X %02X %02X %02X %02X %02X %02X", data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]);
|
||||
CancelIo(usb_buzzer);
|
||||
WriteFile(usb_buzzer, buf, 8, 0, &ovl);
|
||||
break;
|
||||
|
@ -897,7 +892,6 @@ USBDevice *usb_keyboard_init(void)
|
|||
|
||||
usb_buzzer=CreateFile(didData->DevicePath, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0);
|
||||
if(usb_buzzer==INVALID_HANDLE_VALUE){
|
||||
printf("Could not open device %i\n", i);
|
||||
free(didData);
|
||||
i++;
|
||||
continue;
|
||||
|
@ -905,12 +899,10 @@ USBDevice *usb_keyboard_init(void)
|
|||
|
||||
HidD_GetAttributes(usb_buzzer, &attr);
|
||||
|
||||
printf("Device %i : VID %04X PID %04X\n", i, attr.VendorID, attr.ProductID);
|
||||
|
||||
if((attr.VendorID==BUZZER_VID) && (attr.ProductID==BUZZER_PID || attr.ProductID==BUZZER_PID2)){
|
||||
//We've found our buzzers !!!
|
||||
free(didData);
|
||||
printf("Buzzers found !!!\n");
|
||||
|
||||
memset(buf, 0, 8);
|
||||
buf[2]=0xFF;
|
||||
|
@ -939,9 +931,6 @@ USBDevice *usb_keyboard_init(void)
|
|||
i++;
|
||||
}
|
||||
|
||||
if(usb_buzzer==INVALID_HANDLE_VALUE)
|
||||
printf("Could not find buzzers\n");
|
||||
|
||||
return (USBDevice *)s;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include "hidproxy.h"
|
||||
#include "../qemu-usb/desc.h"
|
||||
#include "usb-hid.h"
|
||||
#include "../osdebugout.h"
|
||||
#include "../shared/inifile_usb.h"
|
||||
|
||||
#define CONTAINER_OF(p, type, field) ((type*)((char*)p - ((ptrdiff_t) & ((type*)0)->field)))
|
||||
|
|
|
@ -32,7 +32,6 @@ namespace usb_mic
|
|||
int* pa_ready = (int*)userdata;
|
||||
|
||||
state = pa_context_get_state(c);
|
||||
OSDebugOut("pa_context_get_state() %d\n", state);
|
||||
switch (state)
|
||||
{
|
||||
// There are just here for reference
|
||||
|
@ -98,13 +97,12 @@ namespace usb_mic
|
|||
|
||||
pa_ml = pa_mainloop_new();
|
||||
pa_mlapi = pa_mainloop_get_api(pa_ml);
|
||||
pa_ctx = pa_context_new(pa_mlapi, "USBqemu-devicelist");
|
||||
pa_ctx = pa_context_new(pa_mlapi, "USB-devicelist");
|
||||
|
||||
pa_context_connect(pa_ctx, NULL, PA_CONTEXT_NOFLAGS, NULL);
|
||||
|
||||
pa_context_set_state_callback(pa_ctx, pa_context_state_cb, &pa_ready);
|
||||
|
||||
OSDebugOut("pa_get_devicelist\n");
|
||||
for (;;)
|
||||
{
|
||||
|
||||
|
@ -184,14 +182,12 @@ namespace usb_mic
|
|||
AudioDeviceInfoList srcDevs;
|
||||
if (pa_get_devicelist(srcDevs, AUDIODIR_SOURCE) != 0)
|
||||
{
|
||||
OSDebugOut("pa_get_devicelist failed\n");
|
||||
return RESULT_FAILED;
|
||||
}
|
||||
|
||||
AudioDeviceInfoList sinkDevs;
|
||||
if (pa_get_devicelist(sinkDevs, AUDIODIR_SINK) != 0)
|
||||
{
|
||||
OSDebugOut("pa_get_devicelist failed\n");
|
||||
return RESULT_FAILED;
|
||||
}
|
||||
|
||||
|
@ -345,7 +341,6 @@ namespace usb_mic
|
|||
|
||||
//TODO reconnect stream as well?
|
||||
|
||||
OSDebugOut("pa_context_connect %s\n", pa_strerror(ret));
|
||||
}
|
||||
else
|
||||
mLastGetBuffer = now;
|
||||
|
@ -365,10 +360,6 @@ namespace usb_mic
|
|||
pDst += samples;
|
||||
samples_to_read -= samples;
|
||||
}
|
||||
OSDebugOut("Since last write: %lld ms, left in buffer: %0.03f ms / %d bytes\n",
|
||||
mOutBuffer.MilliSecsSinceLastWrite(),
|
||||
1000.f * mOutBuffer.peek_read<short>() / mSamplesPerSec / mSSpec.channels,
|
||||
mOutBuffer.peek_read());
|
||||
return (frames - (samples_to_read / GetChannels()));
|
||||
}
|
||||
|
||||
|
@ -392,7 +383,6 @@ namespace usb_mic
|
|||
|
||||
//TODO reconnect stream as well?
|
||||
|
||||
OSDebugOut("pa_context_connect %s\n", pa_strerror(ret));
|
||||
if (ret != PA_OK)
|
||||
return frames;
|
||||
}
|
||||
|
@ -504,7 +494,7 @@ namespace usb_mic
|
|||
mPMainLoop = pa_threaded_mainloop_new();
|
||||
pa_mainloop_api* mlapi = pa_threaded_mainloop_get_api(mPMainLoop);
|
||||
|
||||
mPContext = pa_context_new(mlapi, "USBqemu");
|
||||
mPContext = pa_context_new(mlapi, "USB");
|
||||
|
||||
pa_context_set_state_callback(mPContext,
|
||||
context_state_cb,
|
||||
|
@ -519,7 +509,6 @@ namespace usb_mic
|
|||
PA_CONTEXT_NOFLAGS,
|
||||
NULL);
|
||||
|
||||
OSDebugOut("pa_context_connect %s\n", pa_strerror(ret));
|
||||
if (ret != PA_OK)
|
||||
goto unlock_and_fail;
|
||||
|
||||
|
@ -534,7 +523,7 @@ namespace usb_mic
|
|||
}
|
||||
|
||||
mStream = pa_stream_new(mPContext,
|
||||
"USBqemu-pulse",
|
||||
"USB-pulse",
|
||||
&mSSpec,
|
||||
NULL);
|
||||
|
||||
|
@ -552,7 +541,6 @@ namespace usb_mic
|
|||
buffer_attr.prebuf = (uint32_t)-1;
|
||||
buffer_attr.minreq = (uint32_t)-1;
|
||||
buffer_attr.fragsize = pa_usec_to_bytes(mBuffering * 1000, &mSSpec);
|
||||
OSDebugOut("usec_to_bytes %zu\n", buffer_attr.fragsize);
|
||||
|
||||
if (mAudioDir == AUDIODIR_SOURCE)
|
||||
{
|
||||
|
@ -564,7 +552,6 @@ namespace usb_mic
|
|||
mDeviceName.c_str(),
|
||||
&buffer_attr,
|
||||
PA_STREAM_ADJUST_LATENCY);
|
||||
OSDebugOut("pa_stream_connect_record %s\n", pa_strerror(ret));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -588,7 +575,6 @@ namespace usb_mic
|
|||
flags,
|
||||
nullptr,
|
||||
nullptr);
|
||||
OSDebugOut("pa_stream_connect_playback %s\n", pa_strerror(ret));
|
||||
}
|
||||
|
||||
if (ret != PA_OK)
|
||||
|
@ -606,8 +592,6 @@ namespace usb_mic
|
|||
pa_threaded_mainloop_wait(mPMainLoop);
|
||||
}
|
||||
|
||||
OSDebugOut("pa_stream_is_corked %d\n", pa_stream_is_corked(mStream));
|
||||
OSDebugOut("pa_stream_is_suspended %d\n", pa_stream_is_suspended(mStream));
|
||||
|
||||
pa_op = pa_stream_cork(mStream, 0, stream_success_cb, this);
|
||||
if (pa_op)
|
||||
|
@ -623,7 +607,6 @@ namespace usb_mic
|
|||
pa_usec_t r_usec;
|
||||
int negative;
|
||||
ret = pa_stream_get_latency(mStream, &r_usec, &negative);
|
||||
OSDebugOut("Latency %llu\n", r_usec);
|
||||
|
||||
// Setup resampler
|
||||
mResampler = src_delete(mResampler);
|
||||
|
@ -631,7 +614,6 @@ namespace usb_mic
|
|||
mResampler = src_new(SRC_SINC_FASTEST, GetChannels(), &ret);
|
||||
if (!mResampler)
|
||||
{
|
||||
OSDebugOut("Failed to create resampler: error %08X\n", ret);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -672,9 +654,6 @@ namespace usb_mic
|
|||
mInBuffer.reserve(bytes);
|
||||
}
|
||||
|
||||
OSDebugOut("Ringbuffer size, in: %zu, out: %zu\n",
|
||||
mInBuffer.capacity(), mOutBuffer.capacity());
|
||||
|
||||
src_reset(mResampler);
|
||||
}
|
||||
|
||||
|
@ -716,7 +695,6 @@ namespace usb_mic
|
|||
PulseAudioDevice* padev = (PulseAudioDevice*)userdata;
|
||||
|
||||
state = pa_context_get_state(c);
|
||||
OSDebugOut("pa_context_get_state %d\n", state);
|
||||
switch (state)
|
||||
{
|
||||
case PA_CONTEXT_CONNECTING:
|
||||
|
@ -755,10 +733,8 @@ namespace usb_mic
|
|||
if (padev->mQuit)
|
||||
return;
|
||||
|
||||
//OSDebugOut("stream_read_callback %d bytes\n", nbytes);
|
||||
|
||||
int ret = pa_stream_peek(p, &padata, &nbytes);
|
||||
//OSDebugOut("pa_stream_peek %zu %s\n", nbytes, pa_strerror(ret));
|
||||
|
||||
if (ret != PA_OK)
|
||||
return;
|
||||
|
@ -768,19 +744,15 @@ namespace usb_mic
|
|||
{
|
||||
ret = pa_stream_drop(p);
|
||||
if (ret != PA_OK)
|
||||
OSDebugOut("pa_stream_drop %d: %s\n", ret, pa_strerror(ret));
|
||||
return;
|
||||
}
|
||||
|
||||
if (padev->mInBuffer.capacity() < nbytes)
|
||||
OSDebugOut("input ringbuffer overrun: %zu < %zu\n", padev->mInBuffer.capacity(), nbytes);
|
||||
|
||||
padev->mInBuffer.write((uint8_t*)padata, nbytes);
|
||||
|
||||
//if copy succeeded, drop samples at pulse's side
|
||||
ret = pa_stream_drop(p);
|
||||
if (ret != PA_OK)
|
||||
OSDebugOut("pa_stream_drop %s\n", pa_strerror(ret));
|
||||
|
||||
size_t resampled = static_cast<size_t>(padev->mInBuffer.size<float>() * padev->mResampleRatio * padev->mTimeAdjust);
|
||||
if (resampled == 0)
|
||||
|
@ -812,12 +784,12 @@ namespace usb_mic
|
|||
padev->mInBuffer.read<float>(samples);
|
||||
}
|
||||
|
||||
/* OSDebugOut("input %zu frames: %zu, used %zu, left %zu bytes, output frames: %zu\n",
|
||||
nbytes,
|
||||
nbytes / sizeof(float) / padev->GetChannels(),
|
||||
input_frames_used,
|
||||
padev->mInBuffer.peek_read(),
|
||||
output_frames_gen);*/
|
||||
/*
|
||||
nbytes,
|
||||
nbytes / sizeof(float) / padev->GetChannels(),
|
||||
input_frames_used,
|
||||
padev->mInBuffer.peek_read(),
|
||||
output_frames_gen);*/
|
||||
|
||||
std::lock_guard<std::mutex> lock(padev->mMutex);
|
||||
|
||||
|
@ -897,7 +869,6 @@ namespace usb_mic
|
|||
ret = pa_stream_begin_write(padev->mStream, &pa_buffer, &pa_bytes);
|
||||
if (ret != PA_OK)
|
||||
{
|
||||
OSDebugOut("pa_stream_begin_write %d: %s\n", ret, pa_strerror(ret));
|
||||
goto exit;
|
||||
}
|
||||
|
||||
|
@ -920,7 +891,6 @@ namespace usb_mic
|
|||
ret = pa_stream_write(padev->mStream, pa_buffer, pa_bytes, NULL, 0LL, PA_SEEK_RELATIVE);
|
||||
if (ret != PA_OK)
|
||||
{
|
||||
OSDebugOut("pa_stream_write %d: %s\n", ret, pa_strerror(ret));
|
||||
pa_stream_cancel_write(padev->mStream); //TODO needed?
|
||||
goto exit;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#include <cstring>
|
||||
#include <pulse/pulseaudio.h>
|
||||
#include "../shared/ringbuffer.h"
|
||||
#include "../osdebugout.h"
|
||||
#include "audiodeviceproxy.h"
|
||||
#include <samplerate.h>
|
||||
//#include <typeinfo>
|
||||
|
|
|
@ -61,7 +61,6 @@ namespace usb_mic
|
|||
QueryPerformanceCounter(¤tTime);
|
||||
|
||||
if (currentTime.QuadPart < lastQPCTime)
|
||||
OSDebugOut(TEXT("GetQPCTimeMS: WTF, clock went backwards! %I64d < %I64d"), currentTime.QuadPart, lastQPCTime);
|
||||
|
||||
lastQPCTime = currentTime.QuadPart;
|
||||
|
||||
|
@ -78,7 +77,6 @@ namespace usb_mic
|
|||
QueryPerformanceCounter(¤tTime);
|
||||
|
||||
if (currentTime.QuadPart < lastQPCTime)
|
||||
OSDebugOut(TEXT("GetQPCTime100NS: WTF, clock went backwards! %I64d < %I64d"), currentTime.QuadPart, lastQPCTime);
|
||||
|
||||
lastQPCTime = currentTime.QuadPart;
|
||||
|
||||
|
@ -259,7 +257,6 @@ namespace usb_mic
|
|||
if (mBuffering == 0)
|
||||
mBuffering = 50;
|
||||
mBuffering = std::min(std::max(mBuffering, 1LL), 1000LL);
|
||||
OSDebugOut(TEXT("Buffering: %d\n"), mBuffering);
|
||||
|
||||
err = mmClient->Initialize(AUDCLNT_SHAREMODE_SHARED, flags, ConvertMSTo100NanoSec(mBuffering), 0, pwfx, NULL);
|
||||
//err = AUDCLNT_E_UNSUPPORTED_FORMAT;
|
||||
|
@ -308,9 +305,8 @@ namespace usb_mic
|
|||
|
||||
if (!mResampler)
|
||||
{
|
||||
OSDebugOut(TEXT("Failed to create resampler: error %08lX\n"), errVal);
|
||||
#ifndef _DEBUG
|
||||
Console.WriteLn("USBqemu: Failed to create resampler: error %08lX", errVal);
|
||||
Console.WriteLn("USB: Failed to create resampler: error %08lX", errVal);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
@ -344,7 +340,6 @@ namespace usb_mic
|
|||
{
|
||||
if (WaitForSingleObject(mMutex, 5000) != WAIT_OBJECT_0)
|
||||
{
|
||||
OSDebugOut(TEXT("Failed to wait for mutex\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -378,7 +373,6 @@ namespace usb_mic
|
|||
{
|
||||
if (WaitForSingleObject(mMutex, 5000) != WAIT_OBJECT_0)
|
||||
{
|
||||
OSDebugOut(TEXT("Failed to wait for mutex\n"));
|
||||
*size = 0;
|
||||
return false;
|
||||
}
|
||||
|
@ -398,7 +392,6 @@ namespace usb_mic
|
|||
HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
|
||||
if ((S_OK != hr) && (S_FALSE != hr) /* already inited */ && (hr != RPC_E_CHANGED_MODE))
|
||||
{
|
||||
OSDebugOut(TEXT("Com initialization failed with %d\n"), hr);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -453,7 +446,6 @@ namespace usb_mic
|
|||
DWORD resMutex = WaitForSingleObject(src->mMutex, 30000);
|
||||
if (resMutex != WAIT_OBJECT_0)
|
||||
{
|
||||
OSDebugOut(TEXT("Mutex wait failed: %d\n"), resMutex);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -470,7 +462,6 @@ namespace usb_mic
|
|||
|
||||
if (!ReleaseMutex(src->mMutex))
|
||||
{
|
||||
OSDebugOut(TEXT("Mutex release failed\n"));
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
@ -504,7 +495,6 @@ namespace usb_mic
|
|||
hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
|
||||
if ((S_OK != hr) && (S_FALSE != hr) /* already inited */ && (hr != RPC_E_CHANGED_MODE))
|
||||
{
|
||||
OSDebugOut(TEXT("Com initialization failed with %d\n"), hr);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -531,7 +521,6 @@ namespace usb_mic
|
|||
DWORD resMutex = WaitForSingleObject(src->mMutex, 5000);
|
||||
if (resMutex != WAIT_OBJECT_0)
|
||||
{
|
||||
OSDebugOut(TEXT("Mutex wait failed: %d\n"), resMutex);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -583,7 +572,6 @@ namespace usb_mic
|
|||
if (numFramesPadding < src->mDeviceSamplesPerSec / 1000)
|
||||
{
|
||||
numFramesAvailable = std::min(bufferFrameCount - numFramesPadding, (src->mDeviceSamplesPerSec / 1000));
|
||||
OSDebugOut(TEXT("Writing silence %u\n"), numFramesAvailable);
|
||||
|
||||
hr = src->mmRender->GetBuffer(numFramesAvailable, &pData);
|
||||
if (FAILED(hr))
|
||||
|
@ -595,7 +583,6 @@ namespace usb_mic
|
|||
device_error:
|
||||
if (!ReleaseMutex(src->mMutex))
|
||||
{
|
||||
OSDebugOut(TEXT("Mutex release failed\n"));
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -604,7 +591,6 @@ namespace usb_mic
|
|||
if (hr == AUDCLNT_E_DEVICE_INVALIDATED)
|
||||
{
|
||||
src->mDeviceLost = true;
|
||||
OSDebugOut(TEXT("Audio device has been lost, attempting to reinitialize\n"));
|
||||
}
|
||||
else
|
||||
goto error;
|
||||
|
@ -634,7 +620,6 @@ namespace usb_mic
|
|||
DWORD resMutex = WaitForSingleObject(mMutex, 1000);
|
||||
if (resMutex != WAIT_OBJECT_0)
|
||||
{
|
||||
OSDebugOut(TEXT("Mutex wait failed: %d\n"), resMutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -646,7 +631,6 @@ namespace usb_mic
|
|||
//{
|
||||
// mTimeAdjust = (mSamples / (diff / 1e7)) / mSamplesPerSec;
|
||||
// //if(mTimeAdjust > 1.0) mTimeAdjust = 1.0; //If game is in 'turbo mode', just return zero samples or...?
|
||||
// OSDebugOut(TEXT("timespan: %") TEXT(PRId64) TEXT(" sampling: %f adjust: %f\n"), diff, float(mSamples) / diff * 1e7, mTimeAdjust);
|
||||
// mLastTimeNS = mTime;
|
||||
// mSamples = 0;
|
||||
//}
|
||||
|
@ -666,11 +650,9 @@ namespace usb_mic
|
|||
pDst += samples;
|
||||
samples_to_read -= samples;
|
||||
}
|
||||
OSDebugOut(TEXT("Since last write: %lld ms, left in buffer: %d bytes / %d ms\n"),
|
||||
mOutBuffer.MilliSecsSinceLastWrite(), mOutBuffer.peek_read(),
|
||||
1000 * mOutBuffer.peek_read<short>() / mSamplesPerSec / mDeviceChannels);
|
||||
if (!ReleaseMutex(mMutex))
|
||||
OSDebugOut(TEXT("Mutex release failed\n"));
|
||||
|
||||
return (outFrames - (samples_to_read / mDeviceChannels));
|
||||
}
|
||||
|
@ -686,7 +668,6 @@ namespace usb_mic
|
|||
DWORD resMutex = WaitForSingleObject(mMutex, 1000);
|
||||
if (resMutex != WAIT_OBJECT_0)
|
||||
{
|
||||
OSDebugOut(TEXT("Mutex wait failed: %d\n"), resMutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -695,7 +676,6 @@ namespace usb_mic
|
|||
|
||||
if (!ReleaseMutex(mMutex))
|
||||
{
|
||||
OSDebugOut(TEXT("Mutex release failed\n"));
|
||||
}
|
||||
|
||||
return inFrames;
|
||||
|
@ -716,7 +696,6 @@ namespace usb_mic
|
|||
FreeData();
|
||||
if (Reinitialize())
|
||||
{
|
||||
OSDebugOut(TEXT("Device reacquired.\n"));
|
||||
Start();
|
||||
}
|
||||
else
|
||||
|
@ -734,7 +713,6 @@ namespace usb_mic
|
|||
{
|
||||
mDeviceLost = true;
|
||||
FreeData();
|
||||
OSDebugOut(TEXT("Audio device has been lost, attempting to reinitialize\n"));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include "../helpers.h"
|
||||
#include "../configuration.h"
|
||||
#include "../deviceproxy.h"
|
||||
#include "../osdebugout.h"
|
||||
#include "audiodev.h"
|
||||
|
||||
namespace usb_mic
|
||||
|
@ -65,7 +64,7 @@ namespace usb_mic
|
|||
: AudioDeviceProxyBase(name)
|
||||
{
|
||||
} //Why can't it automagically, ugh
|
||||
~AudioDeviceProxy() { OSDebugOut(TEXT("%p\n"), this); }
|
||||
~AudioDeviceProxy() { }
|
||||
|
||||
AudioDevice* CreateObject(int port, const char* dev_type, int mic, AudioDir dir) const
|
||||
{
|
||||
|
@ -75,7 +74,6 @@ namespace usb_mic
|
|||
}
|
||||
catch (AudioDeviceError& err)
|
||||
{
|
||||
OSDebugOut(TEXT("AudioDevice port %d mic %d: %") TEXT(SFMTs) TEXT("\n"), port, mic, err.what());
|
||||
(void)err;
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -476,7 +476,6 @@ namespace usb_mic
|
|||
uint32_t aid = ATTRIB_ID(cs, attrib, idif);
|
||||
int ret = USB_RET_STALL;
|
||||
|
||||
OSDebugOut(TEXT("cs: %02x attr: %02x cn: %d, unit: %04x\n"), cs, attrib, cn, idif);
|
||||
switch (aid)
|
||||
{
|
||||
case ATTRIB_ID(AUDIO_MUTE_CONTROL, AUDIO_REQUEST_GET_CUR, 0x0600):
|
||||
|
@ -600,12 +599,10 @@ namespace usb_mic
|
|||
s->f.in.mute = data[0] & 1;
|
||||
set_vol = true;
|
||||
ret = 0;
|
||||
OSDebugOut(TEXT("=> mic set cn %d mute %d\n"), cn, s->f.in.mute);
|
||||
break;
|
||||
case ATTRIB_ID(AUDIO_VOLUME_CONTROL, AUDIO_REQUEST_SET_CUR, 0x0600):
|
||||
case ATTRIB_ID(AUDIO_VOLUME_CONTROL, AUDIO_REQUEST_SET_CUR, 0x0200):
|
||||
vol = data[0] + (data[1] << 8);
|
||||
OSDebugOut(TEXT("=> mic set cn %d volume %d\n"), cn, vol);
|
||||
//qemu usb audiocard formula
|
||||
vol -= 0x8000;
|
||||
vol = (vol * 255 + 0x4400) / 0x8800;
|
||||
|
@ -625,11 +622,9 @@ namespace usb_mic
|
|||
s->f.out.mute = data[0] & 1;
|
||||
set_vol = true;
|
||||
ret = 0;
|
||||
OSDebugOut(TEXT("=> headphones set cn %d mute %04x\n"), cn, s->f.out.mute);
|
||||
break;
|
||||
case ATTRIB_ID(AUDIO_VOLUME_CONTROL, AUDIO_REQUEST_SET_CUR, 0x0100):
|
||||
vol = data[0] + (data[1] << 8);
|
||||
OSDebugOut(TEXT("=> headphones set cn %d volume %04x\n"), cn, vol);
|
||||
if (cn < 2)
|
||||
{
|
||||
|
||||
|
@ -654,9 +649,6 @@ namespace usb_mic
|
|||
if (set_vol)
|
||||
{
|
||||
//if (s->f.debug) {
|
||||
OSDebugOut(TEXT("headset: mute %d, vol %3d; mute %d vol %d %d\n"),
|
||||
s->f.in.mute, s->f.in.vol,
|
||||
s->f.out.mute, s->f.out.vol[0], s->f.out.vol[1]);
|
||||
//}
|
||||
}
|
||||
|
||||
|
@ -673,22 +665,19 @@ namespace usb_mic
|
|||
int ret = USB_RET_STALL;
|
||||
|
||||
//cs 1 cn 0xFF, ep 0x81 attrib 1
|
||||
OSDebugOut(TEXT("headset: ep control cs %x, cn %X, attr: %02X ep: %04X\n"), cs, cn, attrib, ep);
|
||||
/*for(int i=0; i<length; i++)
|
||||
fprintf(stderr, "%02X ", data[i]);
|
||||
fprintf(stderr, "\n");*/
|
||||
Console.Warning("%02X ", data[i]);
|
||||
Console.Warning("\n");*/
|
||||
|
||||
switch (aid)
|
||||
{
|
||||
case ATTRIB_ID(AUDIO_SAMPLING_FREQ_CONTROL, AUDIO_REQUEST_SET_CUR, 0x84):
|
||||
s->f.in.srate = data[0] | (data[1] << 8) | (data[2] << 16);
|
||||
OSDebugOut(TEXT("=> mic set cn %d sampling to %d\n"), cn, s->f.in.srate);
|
||||
if (s->audsrc)
|
||||
s->audsrc->SetResampling(s->f.in.srate);
|
||||
ret = 0;
|
||||
break;
|
||||
case ATTRIB_ID(AUDIO_SAMPLING_FREQ_CONTROL, AUDIO_REQUEST_GET_CUR, 0x84):
|
||||
OSDebugOut(TEXT("=> mic get cn %d sampling %d\n"), cn, s->f.in.srate);
|
||||
data[0] = s->f.in.srate & 0xFF;
|
||||
data[1] = (s->f.in.srate >> 8) & 0xFF;
|
||||
data[2] = (s->f.in.srate >> 16) & 0xFF;
|
||||
|
@ -697,13 +686,11 @@ namespace usb_mic
|
|||
|
||||
case ATTRIB_ID(AUDIO_SAMPLING_FREQ_CONTROL, AUDIO_REQUEST_SET_CUR, 0x01):
|
||||
s->f.out.srate = data[0] | (data[1] << 8) | (data[2] << 16);
|
||||
OSDebugOut(TEXT("=> headphones set cn %d sampling to %d\n"), cn, s->f.out.srate);
|
||||
if (s->audsink)
|
||||
s->audsink->SetResampling(s->f.out.srate);
|
||||
ret = 0;
|
||||
break;
|
||||
case ATTRIB_ID(AUDIO_SAMPLING_FREQ_CONTROL, AUDIO_REQUEST_GET_CUR, 0x01):
|
||||
OSDebugOut(TEXT("=> headphones get cn %d sampling %d\n"), cn, s->f.out.srate);
|
||||
data[0] = s->f.out.srate & 0xFF;
|
||||
data[1] = (s->f.out.srate >> 8) & 0xFF;
|
||||
data[2] = (s->f.out.srate >> 16) & 0xFF;
|
||||
|
@ -720,7 +707,6 @@ namespace usb_mic
|
|||
HeadsetState* s = (HeadsetState*)dev;
|
||||
int ret = 0;
|
||||
|
||||
OSDebugOut(TEXT("headset: req %04X val: %04X idx: %04X len: %d\n"), request, value, index, length);
|
||||
|
||||
ret = usb_desc_handle_control(dev, p, request, value, index, length, data);
|
||||
if (ret >= 0)
|
||||
|
@ -742,7 +728,7 @@ namespace usb_mic
|
|||
if (ret < 0)
|
||||
{
|
||||
//if (s->debug) {
|
||||
fprintf(stderr, "headset: fail: get control\n");
|
||||
Console.Warning("headset: fail: get control\n");
|
||||
//}
|
||||
goto fail;
|
||||
}
|
||||
|
@ -758,7 +744,7 @@ namespace usb_mic
|
|||
if (ret < 0)
|
||||
{
|
||||
//if (s->debug) {
|
||||
fprintf(stderr, "headset: fail: set control\n data:");
|
||||
Console.Warning("headset: fail: set control\n data:");
|
||||
//}
|
||||
goto fail;
|
||||
}
|
||||
|
@ -800,8 +786,7 @@ namespace usb_mic
|
|||
switch (p->pid)
|
||||
{
|
||||
case USB_TOKEN_IN:
|
||||
//fprintf(stderr, "token in ep: %d len: %zd\n", devep, p->iov.size);
|
||||
OSDebugOut(TEXT("token in ep: %d len: %zd\n"), devep, p->iov.size);
|
||||
//Console.Warning("token in ep: %d len: %zd\n", devep, p->iov.size);
|
||||
if (devep == 4 && s->dev.altsetting[2] && s->audsrc)
|
||||
{
|
||||
|
||||
|
@ -862,7 +847,6 @@ namespace usb_mic
|
|||
break;
|
||||
case USB_TOKEN_OUT:
|
||||
|
||||
//OSDebugOut(TEXT("token out ep: %d len: %d\n"), devep, p->iov.size);
|
||||
if (!s->audsink)
|
||||
return;
|
||||
|
||||
|
|
|
@ -418,10 +418,6 @@ namespace usb_mic
|
|||
if (set_vol)
|
||||
{
|
||||
//if (s->debug) {
|
||||
fprintf(stderr, "singstar: mute %d, lvol %3d, rvol %3d\n",
|
||||
s->f.mute, s->f.vol[0], s->f.vol[1]);
|
||||
OSDebugOut(TEXT("singstar: mute %d, lvol %3d, rvol %3d\n"),
|
||||
s->f.mute, s->f.vol[0], s->f.vol[1]);
|
||||
//}
|
||||
}
|
||||
|
||||
|
@ -438,11 +434,10 @@ namespace usb_mic
|
|||
int ret = USB_RET_STALL;
|
||||
|
||||
//cs 1 cn 0xFF, ep 0x81 attrib 1
|
||||
fprintf(stderr, "singstar: ep control cs %x, cn %X, %X %X data:", cs, cn, attrib, ep);
|
||||
OSDebugOut(TEXT("singstar: ep control cs %x, cn %X, attr: %02X ep: %04X\n"), cs, cn, attrib, ep);
|
||||
Console.Warning("singstar: ep control cs %x, cn %X, %X %X data:", cs, cn, attrib, ep);
|
||||
/*for(int i=0; i<length; i++)
|
||||
fprintf(stderr, "%02X ", data[i]);
|
||||
fprintf(stderr, "\n");*/
|
||||
Console.Warning("%02X ", data[i]);
|
||||
Console.Warning("\n");*/
|
||||
|
||||
switch (aid)
|
||||
{
|
||||
|
@ -458,13 +453,11 @@ namespace usb_mic
|
|||
if (s->audsrc[1])
|
||||
s->audsrc[1]->SetResampling(s->f.srate[1]);
|
||||
|
||||
OSDebugOut(TEXT("singstar: set sampling to %d\n"), s->f.srate[0]);
|
||||
}
|
||||
else if (cn < 2)
|
||||
{
|
||||
|
||||
s->f.srate[cn] = data[0] | (data[1] << 8) | (data[2] << 16);
|
||||
OSDebugOut(TEXT("singstar: set cn %d sampling to %d\n"), cn, s->f.srate[cn]);
|
||||
if (s->audsrc[cn])
|
||||
s->audsrc[cn]->SetResampling(s->f.srate[cn]);
|
||||
}
|
||||
|
@ -486,7 +479,6 @@ namespace usb_mic
|
|||
{
|
||||
SINGSTARMICState* s = (SINGSTARMICState*)dev;
|
||||
s->f.intf = alt_new;
|
||||
OSDebugOut(TEXT("singstar: intf:%d alt:%d -> %d\n"), intf, alt_old, alt_new);
|
||||
#if defined(_DEBUG)
|
||||
/* close previous debug audio output file */
|
||||
if (file && intf > 0 && alt_old != alt_new)
|
||||
|
@ -503,7 +495,6 @@ namespace usb_mic
|
|||
SINGSTARMICState* s = (SINGSTARMICState*)dev;
|
||||
int ret = 0;
|
||||
|
||||
OSDebugOut(TEXT("singstar: req %04X val: %04X idx: %04X len: %d\n"), request, value, index, length);
|
||||
|
||||
ret = usb_desc_handle_control(dev, p, request, value, index, length, data);
|
||||
if (ret >= 0)
|
||||
|
@ -525,7 +516,7 @@ namespace usb_mic
|
|||
if (ret < 0)
|
||||
{
|
||||
//if (s->debug) {
|
||||
fprintf(stderr, "singstar: fail: get control\n");
|
||||
Console.Warning("singstar: fail: get control\n");
|
||||
//}
|
||||
goto fail;
|
||||
}
|
||||
|
@ -541,7 +532,7 @@ namespace usb_mic
|
|||
if (ret < 0)
|
||||
{
|
||||
//if (s->debug) {
|
||||
fprintf(stderr, "singstar: fail: set control\n data:");
|
||||
Console.Warning("singstar: fail: set control\n data:");
|
||||
//}
|
||||
goto fail;
|
||||
}
|
||||
|
@ -583,8 +574,7 @@ namespace usb_mic
|
|||
switch (p->pid)
|
||||
{
|
||||
case USB_TOKEN_IN:
|
||||
//fprintf(stderr, "token in ep: %d len: %zd\n", devep, p->iov.size);
|
||||
//OSDebugOut(TEXT("token in ep: %d len: %zd\n"), devep, p->iov.size);
|
||||
//Console.Warning("token in ep: %d len: %zd\n", devep, p->iov.size);
|
||||
if (devep == 1)
|
||||
{
|
||||
|
||||
|
@ -626,7 +616,6 @@ namespace usb_mic
|
|||
return;
|
||||
}
|
||||
|
||||
OSDebugOut(TEXT("data len: %zu bytes, src[0]: %d frames, src[1]: %d frames\n"), len, out_frames[0], out_frames[1]);
|
||||
|
||||
//TODO well, it is 16bit interleaved, right?
|
||||
//Merge with MIC_MODE_SHARED case?
|
||||
|
@ -647,7 +636,6 @@ namespace usb_mic
|
|||
}
|
||||
|
||||
ret = i;
|
||||
OSDebugOut("RET %d == %d/%d\n", ret, frames, max_frames);
|
||||
}
|
||||
break;
|
||||
case MIC_MODE_SHARED:
|
||||
|
@ -718,8 +706,6 @@ namespace usb_mic
|
|||
}
|
||||
break;
|
||||
case USB_TOKEN_OUT:
|
||||
printf("token out ep: %d\n", devep);
|
||||
OSDebugOut(TEXT("token out ep: %d len: %d\n"), devep, p->actual_length);
|
||||
break;
|
||||
default:
|
||||
p->status = USB_RET_STALL;
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace usb_msd
|
|||
{
|
||||
#ifndef NDEBUG
|
||||
const gchar* text = gtk_entry_get_text(GTK_ENTRY(widget));
|
||||
fprintf(stderr, "Entry text:%s\n", text);
|
||||
Console.Warning("Entry text:%s\n", text);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ namespace usb_msd
|
|||
char* filename;
|
||||
|
||||
filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
|
||||
fprintf(stderr, "%s\n", filename);
|
||||
Console.Warning("%s\n", filename);
|
||||
gtk_entry_set_text(GTK_ENTRY(entry), filename);
|
||||
g_free(filename);
|
||||
}
|
||||
|
|
|
@ -42,8 +42,6 @@ namespace usb_msd
|
|||
|
||||
#define LBA_BLOCK_SIZE 512
|
||||
|
||||
#define DPRINTF(fmt, ...) OSDebugOut(TEXT(fmt), ##__VA_ARGS__)
|
||||
|
||||
/* USB requests. */
|
||||
#define MassStorageReset 0xff
|
||||
#define GetMaxLun 0xfe
|
||||
|
@ -438,7 +436,6 @@ namespace usb_msd
|
|||
{
|
||||
MSDState* s = (MSDState*)dev;
|
||||
|
||||
DPRINTF("Reset\n");
|
||||
s->f.mode = USB_MSDM_CBW;
|
||||
}
|
||||
|
||||
|
@ -474,9 +471,6 @@ namespace usb_msd
|
|||
{
|
||||
size_t len;
|
||||
|
||||
DPRINTF("Command status %d tag 0x%x, len %zd\n",
|
||||
s->f.csw.status, le32_to_cpu(s->f.csw.tag), p->iov.size);
|
||||
|
||||
assert(s->f.csw.sig == cpu_to_le32(0x53425355));
|
||||
len = MIN(sizeof(s->f.csw), p->iov.size);
|
||||
usb_packet_copy(p, &s->f.csw, len);
|
||||
|
@ -490,7 +484,6 @@ namespace usb_msd
|
|||
/* Set s->packet to NULL before calling usb_packet_complete
|
||||
because another request may be issued before
|
||||
usb_packet_complete returns. */
|
||||
DPRINTF("Packet complete %p\n", p);
|
||||
s->packet = NULL;
|
||||
usb_packet_complete(&s->dev, p);
|
||||
}
|
||||
|
@ -518,8 +511,6 @@ namespace usb_msd
|
|||
MSDState* s = req;
|
||||
USBPacket* p = s->packet;
|
||||
|
||||
DPRINTF("Command complete %d tag 0x%x\n", status, s->f.file_op_tag);
|
||||
|
||||
s->f.csw.sig = cpu_to_le32(0x53425355);
|
||||
s->f.csw.tag = cpu_to_le32(s->f.req.tag);
|
||||
s->f.csw.residue = cpu_to_le32(s->f.data_len);
|
||||
|
@ -581,7 +572,6 @@ namespace usb_msd
|
|||
usb_packet_copy(p, s->f.buf, len);
|
||||
if (len > 0 && (file_ret = fwrite(s->f.buf, 1, len, s->file)) < len)
|
||||
{
|
||||
DPRINTF("Write failed: %d!=%d\n", len, file_ret);
|
||||
s->f.result = COMMAND_FAILED; //PHASE_ERROR;
|
||||
set_sense(s, SENSE_CODE(WRITE_FAULT));
|
||||
goto fail;
|
||||
|
@ -617,7 +607,6 @@ namespace usb_msd
|
|||
static void send_command(void* opaque, struct usb_msd_cbw* cbw)
|
||||
{
|
||||
MSDState* s = (MSDState*)opaque;
|
||||
DPRINTF("Command: lun=%d tag=0x%x len %zd data=0x%02x\n", cbw->lun, cbw->tag, cbw->data_len, cbw->cmd[0]);
|
||||
|
||||
int64_t lba;
|
||||
uint32_t xfer_len;
|
||||
|
@ -637,13 +626,11 @@ namespace usb_msd
|
|||
//set_sense(s, SENSE_CODE(LUN_NOT_READY));
|
||||
break;
|
||||
case REQUEST_SENSE: //device shall keep old sense data
|
||||
DPRINTF("REQUEST_SENSE allocation length: %d\n", (int)cbw->cmd[4]);
|
||||
memcpy(s->f.buf, s->f.sense_buf,
|
||||
/* XXX the UFI device shall return only the number of bytes requested, as is */
|
||||
cbw->cmd[4] < sizeof(s->f.sense_buf) ? (size_t)cbw->cmd[4] : sizeof(s->f.sense_buf));
|
||||
break;
|
||||
case INQUIRY:
|
||||
DPRINTF("INQUIRY evpd: %d page: %d\n", (int)cbw->cmd[1], (int)cbw->cmd[2]);
|
||||
memset(s->f.buf, 0, sizeof(s->f.buf));
|
||||
s->f.buf[0] = 0; //SCSI Peripheral Device Type: 0x0 - direct access device, 0x1f - unknown/no device
|
||||
s->f.buf[1] = 1 << 7; //removable
|
||||
|
@ -677,7 +664,6 @@ namespace usb_msd
|
|||
lbas = fsize / LBA_BLOCK_SIZE;
|
||||
if (lbas > 0xFFFFFFFF)
|
||||
{
|
||||
DPRINTF("Maximum LBA is out of range!\n");
|
||||
s->f.result = COMMAND_FAILED;
|
||||
set_sense(s, SENSE_CODE(OUT_OF_RANGE));
|
||||
*last_lba = 0xFFFFFFFF;
|
||||
|
@ -685,7 +671,6 @@ namespace usb_msd
|
|||
else
|
||||
*last_lba = static_cast<uint32_t>(lbas);
|
||||
|
||||
DPRINTF("read capacity lba=0x%x, block=0x%x\n", *last_lba, *blk_len);
|
||||
|
||||
*last_lba = bswap32(*last_lba);
|
||||
*blk_len = bswap32(*blk_len);
|
||||
|
@ -702,7 +687,6 @@ namespace usb_msd
|
|||
s->f.data_len = xfer_len * LBA_BLOCK_SIZE;
|
||||
s->f.file_op_tag = s->f.tag;
|
||||
|
||||
DPRINTF("read lba=0x%llx, len=0x%x\n", lba, xfer_len * LBA_BLOCK_SIZE);
|
||||
|
||||
if (xfer_len == 0) // nothing to do
|
||||
break;
|
||||
|
@ -735,7 +719,6 @@ namespace usb_msd
|
|||
xfer_len = bswap16(*(uint16_t*)&cbw->cmd[7]);
|
||||
else
|
||||
xfer_len = bswap32(*(uint32_t*)&cbw->cmd[6]);
|
||||
DPRINTF("write lba=0x%x, len=0x%x\n", lba, xfer_len * LBA_BLOCK_SIZE);
|
||||
|
||||
s->f.data_len = xfer_len * LBA_BLOCK_SIZE;
|
||||
s->f.file_op_tag = s->f.tag;
|
||||
|
@ -757,7 +740,6 @@ namespace usb_msd
|
|||
//Actual write comes with next command in USB_MSDM_DATAOUT
|
||||
break;
|
||||
default:
|
||||
DPRINTF("usb-msd: invalid command %d\n", cbw->cmd[0]);
|
||||
s->f.result = COMMAND_FAILED;
|
||||
set_sense(s, SENSE_CODE(INVALID_OPCODE));
|
||||
s->f.mode = USB_MSDM_CSW; //TODO
|
||||
|
@ -777,14 +759,11 @@ namespace usb_msd
|
|||
return;
|
||||
}
|
||||
|
||||
OSDebugOut(TEXT("request %04x %04x %04x\n"), request, value, index);
|
||||
|
||||
switch (request)
|
||||
{
|
||||
/* Class specific requests. */
|
||||
case ClassInterfaceOutRequest | MassStorageReset:
|
||||
/* Reset state ready for the next CBW. */
|
||||
DPRINTF("Resetting msd...\n");
|
||||
s->f.mode = USB_MSDM_CBW;
|
||||
ret = 0;
|
||||
break;
|
||||
|
@ -834,20 +813,19 @@ namespace usb_msd
|
|||
case USB_MSDM_CBW:
|
||||
if (p->iov.size != 31)
|
||||
{
|
||||
fprintf(stderr, "usb-msd: Bad CBW size\n");
|
||||
Console.Warning("usb-msd: Bad CBW size\n");
|
||||
goto fail;
|
||||
}
|
||||
usb_packet_copy(p, &cbw, 31);
|
||||
if (le32_to_cpu(cbw.sig) != 0x43425355)
|
||||
{
|
||||
fprintf(stderr, "usb-msd: Bad signature %08x\n",
|
||||
Console.Warning("usb-msd: Bad signature %08x\n",
|
||||
le32_to_cpu(cbw.sig));
|
||||
goto fail;
|
||||
}
|
||||
DPRINTF("Command on LUN %d\n", cbw.lun);
|
||||
if (cbw.lun != 0)
|
||||
{
|
||||
fprintf(stderr, "usb-msd: Bad LUN %d\n", cbw.lun);
|
||||
Console.Warning("usb-msd: Bad LUN %d\n", cbw.lun);
|
||||
goto fail;
|
||||
}
|
||||
s->f.tag = le32_to_cpu(cbw.tag);
|
||||
|
@ -864,8 +842,6 @@ namespace usb_msd
|
|||
{
|
||||
s->f.mode = USB_MSDM_DATAOUT;
|
||||
}
|
||||
DPRINTF("Command tag 0x%x flags %08x len %d data %d\n",
|
||||
s->f.tag, cbw.flags, cbw.cmd_len, s->f.data_len);
|
||||
|
||||
//async fread/fwrite handle or something
|
||||
s->f.req.valid = true;
|
||||
|
@ -874,9 +850,7 @@ namespace usb_msd
|
|||
break;
|
||||
|
||||
case USB_MSDM_DATAOUT:
|
||||
DPRINTF("Data out: write %d bytes of %d remaining\n", p->iov.size, s->f.data_len);
|
||||
//TODO check if CBW still falls into here on write error a.k.a s->f.mode is set wrong
|
||||
DPRINTF("Data out %zd/%d\n", p->iov.size, s->f.data_len);
|
||||
if (p->iov.size > s->f.data_len)
|
||||
{
|
||||
goto fail;
|
||||
|
@ -904,7 +878,6 @@ namespace usb_msd
|
|||
}
|
||||
if ((size_t)p->actual_length < p->iov.size)
|
||||
{
|
||||
DPRINTF("Deferring packet %p [wait data-out]\n", p);
|
||||
s->packet = p;
|
||||
p->status = USB_RET_ASYNC;
|
||||
}
|
||||
|
@ -914,7 +887,6 @@ namespace usb_msd
|
|||
break;
|
||||
|
||||
default:
|
||||
DPRINTF("Unexpected write (len %d, mode %d)\n", p->iov.size, s->f.mode);
|
||||
goto fail;
|
||||
}
|
||||
break;
|
||||
|
@ -937,8 +909,6 @@ namespace usb_msd
|
|||
|
||||
case USB_MSDM_CSW:
|
||||
send_csw:
|
||||
DPRINTF("Command status %d tag 0x%x, len %d\n",
|
||||
s->f.result, s->f.tag, p->iov.size);
|
||||
if (p->iov.size < 13)
|
||||
{
|
||||
goto fail;
|
||||
|
@ -947,7 +917,6 @@ namespace usb_msd
|
|||
if (false && s->f.req.valid)
|
||||
{ // If reading/writing using something asynchronous
|
||||
/* still in flight */
|
||||
DPRINTF("Deferring packet %p [wait status]\n", p);
|
||||
s->packet = p;
|
||||
p->status = USB_RET_ASYNC;
|
||||
}
|
||||
|
@ -963,7 +932,6 @@ namespace usb_msd
|
|||
|
||||
case USB_MSDM_DATAIN:
|
||||
//if (len == 13) goto send_csw;
|
||||
DPRINTF("Data in: reading %d bytes of remaining %d bytes\n", p->iov.size, s->f.data_len);
|
||||
if (p->iov.size > s->f.data_len)
|
||||
{
|
||||
//len = s->f.data_len;
|
||||
|
@ -992,20 +960,17 @@ namespace usb_msd
|
|||
|
||||
if ((size_t)p->actual_length < p->iov.size)
|
||||
{
|
||||
DPRINTF("Deferring packet %p [wait data-in]\n", p);
|
||||
s->packet = p;
|
||||
p->status = USB_RET_ASYNC;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
DPRINTF("Unexpected read (len %d, mode %d)\n", p->iov.size, s->f.mode);
|
||||
goto fail;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
DPRINTF("Bad token\n");
|
||||
fail:
|
||||
p->status = USB_RET_STALL;
|
||||
//s->f.mode = USB_MSDM_CSW;
|
||||
|
@ -1036,7 +1001,7 @@ namespace usb_msd
|
|||
|
||||
if (!LoadSetting(TypeName(), port, api, N_CONFIG_PATH, var))
|
||||
{
|
||||
fprintf(stderr, "usb-msd: Could not load settings\n");
|
||||
Console.Warning("usb-msd: Could not load settings\n");
|
||||
delete s;
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1120,5 +1085,4 @@ namespace usb_msd
|
|||
return 0;
|
||||
}
|
||||
|
||||
#undef DPRINTF
|
||||
} // namespace usb_msd
|
||||
|
|
|
@ -23,5 +23,4 @@ void usb_pad::RegisterPad::Register()
|
|||
auto& inst = RegisterPad::instance();
|
||||
inst.Add(raw::APINAME, new PadProxy<raw::RawInputPad>());
|
||||
inst.Add(dx::APINAME, new PadProxy<dx::DInputPad>());
|
||||
OSDebugOut(TEXT("yep!\n"));
|
||||
}
|
||||
|
|
|
@ -169,17 +169,6 @@ namespace usb_pad
|
|||
return false;
|
||||
|
||||
DIJOYSTATE2 js = g_pJoysticks[ijoy]->GetDeviceState();
|
||||
std::cerr << __func__ << ": joystick[" << ijoy << "]: "
|
||||
<< "\tlX " << js.lX << "\n"
|
||||
<< "\tlY " << js.lY << "\n"
|
||||
<< "\tlZ " << js.lZ << "\n"
|
||||
<< "\tlRx " << js.lRx << "\n"
|
||||
<< "\tlRy " << js.lRy << "\n"
|
||||
<< "\tlRz " << js.lRz << "\n"
|
||||
<< "\trglSlider0 " << js.rglSlider[0] << "\n"
|
||||
<< "\trglSlider1 " << js.rglSlider[1] << "\n"
|
||||
<< std::endl;
|
||||
|
||||
LONG detectrange = 2000;
|
||||
for (int32_t axisid = 0; axisid < DINPUT_AXES_COUNT; axisid++)
|
||||
{
|
||||
|
@ -434,7 +423,6 @@ namespace usb_pad
|
|||
CID = controlid;
|
||||
swprintf_s(text, L"Listening...");
|
||||
SetWindowText(GetDlgItem(hWnd, LABELS[CID]), text);
|
||||
OSDebugOut(TEXT("Begin Listen %i\n"), -1);
|
||||
ListenAxis();
|
||||
}
|
||||
|
||||
|
@ -1323,7 +1311,6 @@ namespace usb_pad
|
|||
|
||||
if (im.type == MT_NONE)
|
||||
{
|
||||
OSDebugOut(TEXT("Skipping control %d (%s), mapping type is None\n"), cid, g_pJoysticks[im.index]->Product().c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1349,7 +1336,6 @@ namespace usb_pad
|
|||
}
|
||||
catch (std::exception& err)
|
||||
{
|
||||
OSDebugOut(TEXT("%" SFMTs "\n"), err.what());
|
||||
}
|
||||
|
||||
LoadSetting(section, TEXT("UseRamp"), useRamp);
|
||||
|
|
|
@ -431,7 +431,6 @@ namespace usb_pad
|
|||
//start the effect
|
||||
if (g_pEffectConstant[port])
|
||||
{
|
||||
OSDebugOut(TEXT("DINPUT: Start Effect\n"));
|
||||
g_pEffectConstant[port]->SetParameters(&eff, DIEP_START | DIEP_GAIN | DIEP_AXES | DIEP_DIRECTION);
|
||||
}
|
||||
}
|
||||
|
@ -687,7 +686,6 @@ namespace usb_pad
|
|||
|
||||
void JoystickDeviceFF::SetConstantForce(int level)
|
||||
{
|
||||
OSDebugOut(TEXT("constant force: %d\n"), level);
|
||||
|
||||
//FIXME either this or usb-pad-ff was inverted
|
||||
if (INVERTFORCES[m_port])
|
||||
|
@ -723,7 +721,6 @@ namespace usb_pad
|
|||
cSpring.lOffset = ff.u.condition.center * DI_FFNOMINALMAX / SHRT_MAX;
|
||||
cSpring.lDeadBand = ff.u.condition.deadband * DI_FFNOMINALMAX / USHRT_MAX;
|
||||
|
||||
OSDebugOut(TEXT("spring: %d %d coeff:%d/%d sat:%d/%d\n"),
|
||||
cSpring.lOffset, cSpring.lDeadBand,
|
||||
cSpring.lNegativeCoefficient, cSpring.lPositiveCoefficient,
|
||||
cSpring.dwNegativeSaturation, cSpring.dwPositiveSaturation);
|
||||
|
@ -759,7 +756,6 @@ namespace usb_pad
|
|||
cFriction.lOffset = ff.u.condition.center * DI_FFNOMINALMAX / SHRT_MAX;
|
||||
cFriction.lDeadBand = ff.u.condition.deadband * DI_FFNOMINALMAX / USHRT_MAX;
|
||||
|
||||
OSDebugOut(TEXT("friction %d/%d %d\n"),
|
||||
cFriction.lNegativeCoefficient, cFriction.lPositiveCoefficient,
|
||||
cFriction.dwNegativeSaturation);
|
||||
|
||||
|
@ -828,17 +824,14 @@ namespace usb_pad
|
|||
LPDIRECTINPUTDEVICE8 pMouse = NULL;
|
||||
|
||||
//release any previous resources
|
||||
OSDebugOut(TEXT("DINPUT: FreeDirectInput %p\n"), hWindow);
|
||||
|
||||
if (refCount == 0)
|
||||
{
|
||||
// Create a DInput object
|
||||
OSDebugOut(TEXT("DINPUT: DirectInput8Create %p\n"), hWindow);
|
||||
if (FAILED(hr = DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION,
|
||||
IID_IDirectInput8, (VOID**)&g_pDI, NULL)))
|
||||
return hr;
|
||||
|
||||
OSDebugOut(TEXT("DINPUT: CreateDevice Keyboard %p\n"), hWindow);
|
||||
//Create Keyboard
|
||||
g_pDI->CreateDevice(GUID_SysKeyboard, &pKeyboard, NULL);
|
||||
if (pKeyboard)
|
||||
|
@ -849,7 +842,6 @@ namespace usb_pad
|
|||
g_pJoysticks.push_back(new JoystickDevice(CT_KEYBOARD, pKeyboard, GUID_SysKeyboard, TEXT("SysKeyboard")));
|
||||
}
|
||||
|
||||
OSDebugOut(TEXT("DINPUT: CreateDevice Mouse %p\n"), hWindow);
|
||||
//Create Mouse
|
||||
g_pDI->CreateDevice(GUID_SysMouse, &pMouse, NULL);
|
||||
if (pMouse)
|
||||
|
@ -861,7 +853,6 @@ namespace usb_pad
|
|||
}
|
||||
|
||||
//enumerate attached only
|
||||
OSDebugOut(TEXT("DINPUT: EnumDevices Joystick %p\n"), hWindow);
|
||||
g_pDI->EnumDevices(DI8DEVCLASS_GAMECTRL, EnumJoysticksCallback, NULL, DIEDFL_ATTACHEDONLY);
|
||||
|
||||
//loop through all attached joysticks
|
||||
|
@ -869,7 +860,6 @@ namespace usb_pad
|
|||
{
|
||||
auto joy = g_pJoysticks[i];
|
||||
auto device = joy->GetDevice();
|
||||
OSDebugOut(TEXT("DINPUT: SetDataFormat Joystick %s\n"), joy->Product().c_str());
|
||||
device->SetDataFormat(&c_dfDIJoystick2);
|
||||
|
||||
DIDEVCAPS diCaps;
|
||||
|
@ -878,7 +868,6 @@ namespace usb_pad
|
|||
|
||||
if (diCaps.dwFlags & DIDC_FORCEFEEDBACK)
|
||||
{
|
||||
OSDebugOut(TEXT("DINPUT: SetCooperativeLevel Joystick %s\n"), joy->Product().c_str());
|
||||
//Exclusive
|
||||
device->SetCooperativeLevel(hWindow, DISCL_EXCLUSIVE | DISCL_BACKGROUND);
|
||||
|
||||
|
@ -892,9 +881,7 @@ namespace usb_pad
|
|||
else
|
||||
device->SetCooperativeLevel(hWindow, DISCL_NONEXCLUSIVE | DISCL_BACKGROUND);
|
||||
|
||||
OSDebugOut(TEXT("DINPUT: EnumObjects Joystick %i\n"), i);
|
||||
device->EnumObjects(EnumObjectsCallback, device, DIDFT_ALL);
|
||||
OSDebugOut(TEXT("DINPUT: Acquire Joystick %i\n"), i);
|
||||
device->Acquire();
|
||||
}
|
||||
}
|
||||
|
@ -1031,7 +1018,6 @@ namespace usb_pad
|
|||
//set left/right ffb torque
|
||||
void SetConstantForce(int port, LONG magnitude)
|
||||
{
|
||||
OSDebugOut(TEXT("constant force: %d\n"), magnitude);
|
||||
if (!FFB[port])
|
||||
return;
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
#include "../usb-pad.h"
|
||||
#include "../../configuration.h"
|
||||
#include "../../osdebugout.h"
|
||||
#include "../../usb-pad/lg/lg_ff.h"
|
||||
|
||||
#define DINPUT_AXES_COUNT 32
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
*/
|
||||
|
||||
#include "evdev-ff.h"
|
||||
#include "../../osdebugout.h"
|
||||
#include "../../usb-pad/lg/lg_ff.h"
|
||||
#include <unistd.h>
|
||||
#include <cerrno>
|
||||
|
@ -42,40 +41,33 @@ namespace usb_pad
|
|||
unsigned char features[BITS_TO_UCHAR(FF_MAX)];
|
||||
if (ioctl(mHandle, EVIOCGBIT(EV_FF, sizeof(features)), features) < 0)
|
||||
{
|
||||
OSDebugOut("Get features failed: %s\n", strerror(errno));
|
||||
}
|
||||
|
||||
int effects = 0;
|
||||
if (ioctl(mHandle, EVIOCGEFFECTS, &effects) < 0)
|
||||
{
|
||||
OSDebugOut("Get effects failed: %s\n", strerror(errno));
|
||||
}
|
||||
|
||||
if (!testBit(FF_CONSTANT, features))
|
||||
{
|
||||
OSDebugOut("device does not support FF_CONSTANT\n");
|
||||
if (testBit(FF_RUMBLE, features))
|
||||
mUseRumble = true;
|
||||
}
|
||||
|
||||
if (!testBit(FF_SPRING, features))
|
||||
{
|
||||
OSDebugOut("device does not support FF_SPRING\n");
|
||||
}
|
||||
|
||||
if (!testBit(FF_DAMPER, features))
|
||||
{
|
||||
OSDebugOut("device does not support FF_DAMPER\n");
|
||||
}
|
||||
|
||||
if (!testBit(FF_GAIN, features))
|
||||
{
|
||||
OSDebugOut("device does not support FF_GAIN\n");
|
||||
}
|
||||
|
||||
if (!testBit(FF_AUTOCENTER, features))
|
||||
{
|
||||
OSDebugOut("device does not support FF_AUTOCENTER\n");
|
||||
}
|
||||
|
||||
memset(&mEffect, 0, sizeof(mEffect));
|
||||
|
@ -109,7 +101,6 @@ namespace usb_pad
|
|||
{
|
||||
if (mEffIds[i] != -1 && ioctl(mHandle, EVIOCRMFF, mEffIds[i]) == -1)
|
||||
{
|
||||
OSDebugOut("Failed to unload EffectID(%d) effect.\n", i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -122,7 +113,6 @@ namespace usb_pad
|
|||
play.value = 0;
|
||||
if (write(mHandle, (const void*)&play, sizeof(play)) == -1)
|
||||
{
|
||||
OSDebugOut("Stop effect failed: %s\n", strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,10 +133,8 @@ namespace usb_pad
|
|||
// mEffect.u.constant.envelope.fade_length = 0;//0x100;
|
||||
// mEffect.u.constant.envelope.fade_level = 0;
|
||||
|
||||
OSDebugOut("Constant force: %d\n", level);
|
||||
if (ioctl(mHandle, EVIOCSFF, &(mEffect)) < 0)
|
||||
{
|
||||
OSDebugOut("Failed to upload constant effect: %s\n", strerror(errno));
|
||||
return;
|
||||
}
|
||||
play.code = mEffect.id;
|
||||
|
@ -176,7 +164,6 @@ namespace usb_pad
|
|||
|
||||
if (ioctl(mHandle, EVIOCSFF, &(mEffect)) < 0)
|
||||
{
|
||||
OSDebugOut("Failed to upload constant effect: %s\n", strerror(errno));
|
||||
return;
|
||||
}
|
||||
play.code = mEffect.id;
|
||||
|
@ -185,7 +172,6 @@ namespace usb_pad
|
|||
|
||||
if (write(mHandle, (const void*)&play, sizeof(play)) == -1)
|
||||
{
|
||||
OSDebugOut("Play effect failed: %s\n", strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -205,13 +191,8 @@ namespace usb_pad
|
|||
mEffect.u.condition[0].center = ff.u.condition.center;
|
||||
mEffect.u.condition[0].deadband = ff.u.condition.deadband;
|
||||
|
||||
OSDebugOut("Spring force: coef %d/%d sat %d/%d\n",
|
||||
mEffect.u.condition[0].left_coeff, mEffect.u.condition[0].right_coeff,
|
||||
mEffect.u.condition[0].left_saturation, mEffect.u.condition[0].right_saturation);
|
||||
|
||||
if (ioctl(mHandle, EVIOCSFF, &(mEffect)) < 0)
|
||||
{
|
||||
OSDebugOut("Failed to upload spring effect: %s\n", strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -220,7 +201,6 @@ namespace usb_pad
|
|||
|
||||
if (write(mHandle, (const void*)&play, sizeof(play)) == -1)
|
||||
{
|
||||
OSDebugOut("Play effect failed: %s\n", strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -240,11 +220,9 @@ namespace usb_pad
|
|||
mEffect.u.condition[0].center = ff.u.condition.center;
|
||||
mEffect.u.condition[0].deadband = ff.u.condition.deadband;
|
||||
|
||||
OSDebugOut("Damper force: %d/%d\n", mEffect.u.condition[0].left_coeff, mEffect.u.condition[0].right_coeff);
|
||||
|
||||
if (ioctl(mHandle, EVIOCSFF, &(mEffect)) < 0)
|
||||
{
|
||||
OSDebugOut("Failed to upload damper effect: %s\n", strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -253,7 +231,6 @@ namespace usb_pad
|
|||
|
||||
if (write(mHandle, (const void*)&play, sizeof(play)) == -1)
|
||||
{
|
||||
OSDebugOut("Play effect failed: %s\n", strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -273,10 +250,8 @@ namespace usb_pad
|
|||
mEffect.u.condition[0].center = ff.u.condition.center;
|
||||
mEffect.u.condition[0].deadband = ff.u.condition.deadband;
|
||||
|
||||
OSDebugOut("Friction force: %d/%d\n", mEffect.u.condition[0].left_coeff, mEffect.u.condition[0].right_coeff);
|
||||
if (ioctl(mHandle, EVIOCSFF, &(mEffect)) < 0)
|
||||
{
|
||||
OSDebugOut("Failed to upload friction effect: %s\n", strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -285,7 +260,6 @@ namespace usb_pad
|
|||
|
||||
if (write(mHandle, (const void*)&play, sizeof(play)) == -1)
|
||||
{
|
||||
OSDebugOut("Play effect failed: %s\n", strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -300,9 +274,6 @@ namespace usb_pad
|
|||
ie.code = FF_AUTOCENTER;
|
||||
ie.value = value * 0xFFFFUL / 100;
|
||||
|
||||
OSDebugOut("Autocenter: %d\n", value);
|
||||
if (write(mHandle, &ie, sizeof(ie)) == -1)
|
||||
OSDebugOut("Failed to set autocenter: %s\n", strerror(errno));
|
||||
}
|
||||
|
||||
void EvdevFF::SetGain(int gain /* between 0 and 100 */)
|
||||
|
@ -313,9 +284,6 @@ namespace usb_pad
|
|||
ie.code = FF_GAIN;
|
||||
ie.value = 0xFFFFUL * gain / 100;
|
||||
|
||||
OSDebugOut("Gain: %d\n", gain);
|
||||
if (write(mHandle, &ie, sizeof(ie)) == -1)
|
||||
OSDebugOut("Failed to set gain: %s\n", strerror(errno));
|
||||
}
|
||||
|
||||
} // namespace evdev
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
*/
|
||||
|
||||
#include "evdev.h"
|
||||
#include "../../osdebugout.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
@ -657,7 +656,6 @@ namespace usb_pad
|
|||
continue;
|
||||
}
|
||||
|
||||
OSDebugOut("Axis %d absinfo min %d max %d\n", i, absinfo.minimum, absinfo.maximum);
|
||||
//TODO from SDL2, usable here?
|
||||
CalcAxisCorr(abs_correct[i], absinfo);
|
||||
}
|
||||
|
@ -682,7 +680,6 @@ namespace usb_pad
|
|||
event_fd = js.second.fd;
|
||||
dev_name = js.first;
|
||||
|
||||
OSDebugOut("PollInput: polling...%s\n", dev_name.c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -690,7 +687,6 @@ namespace usb_pad
|
|||
|
||||
if (event_fd > -1 && (len = read(event_fd, &event, sizeof(event))) > -1 && (len == sizeof(event)))
|
||||
{
|
||||
OSDebugOut("PollInput: event...%d\n", event.type);
|
||||
if (isaxis && event.type == EV_ABS)
|
||||
{
|
||||
auto& val = axisVal[event.code];
|
||||
|
@ -706,7 +702,6 @@ namespace usb_pad
|
|||
{
|
||||
int ac_val = AxisCorrect(abs_correct[event.code], event.value);
|
||||
int diff = ac_val - val.value;
|
||||
OSDebugOut("Axis %d value initial: %d, diff: %d, corr: %d raw %d\n", event.code, val.value, diff, ac_val, event.value);
|
||||
if (std::abs(diff) > 2047)
|
||||
{
|
||||
value = event.code;
|
||||
|
@ -727,7 +722,6 @@ namespace usb_pad
|
|||
}
|
||||
else if (errno != EAGAIN)
|
||||
{
|
||||
OSDebugOut("PollInput: read error %d\n", errno);
|
||||
goto error;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
*/
|
||||
|
||||
#include "evdev.h"
|
||||
#include "../../osdebugout.h"
|
||||
#include <cassert>
|
||||
#include <sstream>
|
||||
#include <linux/hidraw.h>
|
||||
|
@ -57,7 +56,7 @@ namespace usb_pad
|
|||
DIR* dirp = opendir("/dev/");
|
||||
if (!dirp)
|
||||
{
|
||||
perror("Error opening /dev/");
|
||||
Console.Warning("Error opening /dev/");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -65,7 +64,6 @@ namespace usb_pad
|
|||
{
|
||||
if (strncmp(dp->d_name, "hidraw", 6) == 0)
|
||||
{
|
||||
OSDebugOut("%s\n", dp->d_name);
|
||||
|
||||
str.clear();
|
||||
str.str("");
|
||||
|
@ -75,7 +73,7 @@ namespace usb_pad
|
|||
|
||||
if (fd < 0)
|
||||
{
|
||||
perror("Unable to open device");
|
||||
Console.Warning("Unable to open device");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -84,16 +82,14 @@ namespace usb_pad
|
|||
|
||||
res = ioctl(fd, HIDIOCGRAWPHYS(sizeof(buf)), buf);
|
||||
if (res < 0)
|
||||
perror("HIDIOCGRAWPHYS");
|
||||
else
|
||||
OSDebugOut("Raw Phys: %s\n", buf);
|
||||
Console.Warning("HIDIOCGRAWPHYS");
|
||||
|
||||
struct hidraw_devinfo info;
|
||||
memset(&info, 0x0, sizeof(info));
|
||||
|
||||
if (ioctl(fd, HIDIOCGRAWINFO, &info) < 0)
|
||||
{
|
||||
perror("HIDIOCGRAWINFO");
|
||||
Console.Warning("HIDIOCGRAWINFO");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -133,7 +129,7 @@ namespace usb_pad
|
|||
DIR* dirp = opendir(EVDEV_DIR);
|
||||
if (!dirp)
|
||||
{
|
||||
perror("Error opening " EVDEV_DIR);
|
||||
Console.Warning("Error opening " EVDEV_DIR);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -151,7 +147,6 @@ namespace usb_pad
|
|||
//if (strncmp(dp->d_name, "event", 5) == 0) {
|
||||
if (str_ends_with(dp->d_name, "event-kbd") || str_ends_with(dp->d_name, "event-mouse") || str_ends_with(dp->d_name, "event-joystick"))
|
||||
{
|
||||
OSDebugOut(EVDEV_DIR "%s\n", dp->d_name);
|
||||
|
||||
str.clear();
|
||||
str.str("");
|
||||
|
@ -169,7 +164,7 @@ namespace usb_pad
|
|||
|
||||
if (fd < 0)
|
||||
{
|
||||
perror("Unable to open device");
|
||||
Console.Warning("Unable to open device");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -177,10 +172,9 @@ namespace usb_pad
|
|||
|
||||
res = ioctl(fd, EVIOCGNAME(sizeof(buf)), buf);
|
||||
if (res < 0)
|
||||
perror("EVIOCGNAME");
|
||||
Console.Warning("EVIOCGNAME");
|
||||
else
|
||||
{
|
||||
OSDebugOut("Evdev device name: %s\n", buf);
|
||||
list_cache.push_back({buf, dp->d_name, path});
|
||||
}
|
||||
|
||||
|
@ -330,7 +324,6 @@ namespace usb_pad
|
|||
|
||||
value = AxisCorrect(device.abs_correct[event.code], event.value);
|
||||
/*if (event.code == 0)
|
||||
OSDebugOut("Axis: %d, mapped: 0x%02x, val: %d, corrected: %d\n",
|
||||
event.code, device.axis_map[event.code] & ~0x80, event.value, value);
|
||||
*/
|
||||
SetAxis(device, event.code, value);
|
||||
|
@ -339,12 +332,9 @@ namespace usb_pad
|
|||
case EV_KEY:
|
||||
{
|
||||
code = device.btn_map[event.code] != (uint16_t)-1 ? device.btn_map[event.code] : event.code;
|
||||
OSDebugOut("%s Button: 0x%02x, mapped: 0x%02x, val: %d\n",
|
||||
device.name.c_str(), event.code, device.btn_map[event.code], event.value);
|
||||
|
||||
if (mType == WT_BUZZ_CONTROLLER)
|
||||
{
|
||||
OSDebugOut("evdev buzz: code: %d, map: %08x\n", event.code, device.btn_map[event.code]);
|
||||
if (device.btn_map[event.code] != (uint16_t)-1)
|
||||
{
|
||||
if (event.value)
|
||||
|
@ -416,7 +406,6 @@ namespace usb_pad
|
|||
button = PAD_L2;
|
||||
break;
|
||||
default:
|
||||
OSDebugOut("Unmapped Button: %d, %d\n", code, event.value);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
@ -450,7 +439,6 @@ namespace usb_pad
|
|||
|
||||
if (len <= 0)
|
||||
{
|
||||
OSDebugOut("%s: TokenIn: read error %d\n", APINAME, errno);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -500,9 +488,6 @@ namespace usb_pad
|
|||
if (mUseRawFF)
|
||||
{
|
||||
|
||||
OSDebugOut("FF: %02x %02x %02x %02x %02x %02x %02x\n",
|
||||
data[0], data[1], data[2], data[3], data[4], data[5], data[6]);
|
||||
|
||||
if (data[0] == 0x8 || data[0] == 0xB)
|
||||
return len;
|
||||
if (data[0] == 0xF8 &&
|
||||
|
@ -516,7 +501,6 @@ namespace usb_pad
|
|||
|
||||
if (!mFFData.enqueue(report))
|
||||
{
|
||||
OSDebugOut("Failed to enqueue ffb command\n");
|
||||
return 0;
|
||||
}
|
||||
return len;
|
||||
|
@ -580,7 +564,6 @@ namespace usb_pad
|
|||
std::string joypath;
|
||||
if (!LoadSetting(mDevType, mPort, APINAME, N_JOYSTICK, joypath))
|
||||
{
|
||||
OSDebugOut("Cannot load device setting: %s\n", N_JOYSTICK);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -590,7 +573,6 @@ namespace usb_pad
|
|||
int fd = -1;
|
||||
if ((fd = open(joypath.c_str(), O_RDWR | O_NONBLOCK)) < 0)
|
||||
{
|
||||
OSDebugOut("Cannot open device: %s\n", joypath.c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -598,7 +580,6 @@ namespace usb_pad
|
|||
if (ioctl(fd, EVIOCGPHYS(sizeof(buf) - 1), buf) > 0)
|
||||
{
|
||||
evphys = buf;
|
||||
OSDebugOut("Evdev Phys: %s\n", evphys.c_str());
|
||||
|
||||
int pid, vid;
|
||||
if ((mUseRawFF = FindHidraw(evphys, hid_dev, &vid, &pid)))
|
||||
|
@ -624,7 +605,7 @@ namespace usb_pad
|
|||
}
|
||||
else
|
||||
{
|
||||
perror("EVIOCGPHYS failed");
|
||||
Console.Warning("EVIOCGPHYS failed");
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
|
@ -641,7 +622,6 @@ namespace usb_pad
|
|||
|
||||
if ((device.cfg.fd = open(it.path.c_str(), O_RDWR | O_NONBLOCK)) < 0)
|
||||
{
|
||||
OSDebugOut("Cannot open device: %s\n", it.path.c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -703,7 +683,6 @@ namespace usb_pad
|
|||
continue;
|
||||
}
|
||||
|
||||
OSDebugOut("Axis %d absinfo min %d max %d\n", i, absinfo.minimum, absinfo.maximum);
|
||||
|
||||
//device.axis_map[i] = device.axes;
|
||||
|
||||
|
@ -739,8 +718,6 @@ namespace usb_pad
|
|||
#ifndef NDEBUG
|
||||
for (int i = 0; i < ABS_MAX; ++i)
|
||||
{
|
||||
if (device.axis_map[i] != (uint8_t)-1 && (device.axis_map[i] & 0x80))
|
||||
OSDebugOut("Axis: 0x%02x -> %s\n", i, JoystickMapNames[device.axis_map[i] & ~0x80]);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -748,12 +725,10 @@ namespace usb_pad
|
|||
{
|
||||
if (test_bit(i, keybit))
|
||||
{
|
||||
//OSDebugOut("Device has button: 0x%x\n", i);
|
||||
device.btn_map[i] = -1; //device.buttons;
|
||||
if (i == BTN_GAMEPAD)
|
||||
{
|
||||
device.is_gamepad = true;
|
||||
OSDebugOut("Device is a gamepad\n");
|
||||
}
|
||||
for (int k = 0; k < max_buttons; k++)
|
||||
{
|
||||
|
@ -761,7 +736,6 @@ namespace usb_pad
|
|||
{
|
||||
has_mappings = true;
|
||||
device.btn_map[i] = 0x8000 | k;
|
||||
OSDebugOut("Remap button: 0x%x -> %s\n", i, JoystickMapNames[k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -770,7 +744,6 @@ namespace usb_pad
|
|||
{
|
||||
if (test_bit(i, keybit))
|
||||
{
|
||||
OSDebugOut("Device has button: 0x%x\n", i);
|
||||
device.btn_map[i] = -1; //device.buttons;
|
||||
for (int k = 0; k < max_buttons; k++)
|
||||
{
|
||||
|
@ -784,7 +757,6 @@ namespace usb_pad
|
|||
}
|
||||
if (!has_mappings)
|
||||
{
|
||||
OSDebugOut("Device %s [%s] has no mappings, discarding\n", device.name.c_str(), ""); //it.second.c_str());
|
||||
close(device.cfg.fd);
|
||||
mDevices.pop_back();
|
||||
}
|
||||
|
@ -835,8 +807,7 @@ namespace usb_pad
|
|||
res = write(mHidHandle, buf.data(), buf.size());
|
||||
if (res < 0)
|
||||
{
|
||||
printf("Error: %d\n", errno);
|
||||
perror("write");
|
||||
Console.Warning("write");
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -844,7 +815,6 @@ namespace usb_pad
|
|||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
}
|
||||
}
|
||||
OSDebugOut(TEXT("WriterThread exited.\n"));
|
||||
|
||||
mWriterThreadIsRunning = false;
|
||||
}
|
||||
|
|
|
@ -82,13 +82,13 @@ namespace usb_pad
|
|||
int fd = 0;
|
||||
if ((fd = open(path.c_str(), O_RDONLY)) < 0)
|
||||
{
|
||||
fprintf(stderr, "Cannot open %s\n", path.c_str());
|
||||
Console.Warning("Cannot open %s\n", path.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ioctl(fd, EVIOCGNAME(_Size), name) < -1)
|
||||
{
|
||||
fprintf(stderr, "Cannot get controller's name\n");
|
||||
Console.Warning("Cannot get controller's name\n");
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
*/
|
||||
|
||||
#include "shared.h"
|
||||
#include "../../osdebugout.h"
|
||||
#include "../../icon_buzz_24.h"
|
||||
|
||||
#include <chrono>
|
||||
|
@ -229,7 +228,6 @@ namespace usb_pad
|
|||
{
|
||||
std::string name = (cfg->joysticks.begin() + idx)->name;
|
||||
cfg->js_iter = (cfg->joysticks.begin() + idx);
|
||||
OSDebugOut("Selected player %d idx: %d dev: '%s'\n", 2 - port, idx, name.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -246,7 +244,6 @@ namespace usb_pad
|
|||
bool is_axis = (type >= JOY_STEERING && type <= JOY_BRAKE);
|
||||
|
||||
gtk_label_set_text(GTK_LABEL(cfg->label), "Polling for input for 5 seconds...");
|
||||
OSDebugOut("Polling: isaxis:%d %d\n", is_axis, type);
|
||||
|
||||
// let label change its text
|
||||
while (gtk_events_pending())
|
||||
|
@ -286,7 +283,6 @@ namespace usb_pad
|
|||
bool inverted = false;
|
||||
|
||||
gtk_label_set_text(GTK_LABEL(cfg->label), "Polling for input for 5 seconds...");
|
||||
OSDebugOut("Polling: %s\n", buzz_map_names[type]);
|
||||
|
||||
// let label change its text
|
||||
while (gtk_events_pending())
|
||||
|
@ -301,9 +297,6 @@ namespace usb_pad
|
|||
|
||||
if (it != cfg->jsconf.end() && type < it->second.controls.size())
|
||||
{
|
||||
OSDebugOut("setting mappings for %s %s_%lu=%d\n", dev_name.c_str(),
|
||||
buzz_map_names[type % countof(buzz_map_names)],
|
||||
type / countof(buzz_map_names), value);
|
||||
it->second.controls[type] = value;
|
||||
refresh_store(cfg);
|
||||
}
|
||||
|
@ -329,7 +322,6 @@ namespace usb_pad
|
|||
int binding;
|
||||
|
||||
gtk_tree_model_get(model, iter, COL_NAME, &dev_name, COL_BINDING, &binding, -1);
|
||||
OSDebugOut("name: %s, bind: %d\n", dev_name, binding);
|
||||
|
||||
auto& js = cfg->jsconf;
|
||||
auto it = std::find_if(js.begin(), js.end(),
|
||||
|
@ -339,7 +331,6 @@ namespace usb_pad
|
|||
if (it != js.end())
|
||||
{
|
||||
it->second.controls[binding] = (uint16_t)-1;
|
||||
OSDebugOut("Delete binding '%d' for '%s'\n", binding, it->first.c_str());
|
||||
}
|
||||
gtk_list_store_remove(GTK_LIST_STORE(model), iter);
|
||||
//refresh_store(cfg);
|
||||
|
@ -425,14 +416,12 @@ namespace usb_pad
|
|||
{
|
||||
if ((fd = open(it.path.c_str(), O_RDONLY | O_NONBLOCK)) < 0)
|
||||
{
|
||||
OSDebugOut("Cannot open device: %s\n", it.path.c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
ConfigMapping c(fd);
|
||||
LoadMappings(cfg.dev_type, port, it.id, c);
|
||||
cfg.jsconf.push_back(std::make_pair(it.id, c));
|
||||
OSDebugOut("mappings for '%s': %zu\n", it.name.c_str(), c.controls.size());
|
||||
}
|
||||
|
||||
refresh_store(&cfg);
|
||||
|
@ -761,7 +750,6 @@ namespace usb_pad
|
|||
{
|
||||
if ((fd = open(it.path.c_str(), O_RDONLY | O_NONBLOCK)) < 0)
|
||||
{
|
||||
OSDebugOut("Cannot open device: %s\n", it.path.c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -769,7 +757,6 @@ namespace usb_pad
|
|||
c.fd = fd;
|
||||
LoadBuzzMappings(cfg.dev_type, port, it.id, c);
|
||||
cfg.jsconf.push_back(std::make_pair(it.id, c));
|
||||
OSDebugOut("mappings for '%s': %lu\n", it.name.c_str(), c.controls.size());
|
||||
}
|
||||
|
||||
refresh_store(&cfg);
|
||||
|
@ -882,7 +869,6 @@ namespace usb_pad
|
|||
gtk_button_set_image_position(GTK_BUTTON(button), GTK_POS_LEFT);
|
||||
|
||||
GList* children = gtk_container_get_children(GTK_CONTAINER(button));
|
||||
//OSDebugOut("widget: %s\n", gtk_widget_get_name(GTK_WIDGET(children->data)));
|
||||
|
||||
//Gtk 3.16+
|
||||
//gtk_label_set_xalign (GTK_WIDGET(children), 0.0)
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
*/
|
||||
|
||||
#include "joydev.h"
|
||||
#include "../../osdebugout.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
@ -129,7 +128,6 @@ namespace usb_pad
|
|||
else
|
||||
{
|
||||
int diff = event.value - val.value;
|
||||
OSDebugOut("Axis %d value: %d, difference: %d\n", event.number, event.value, diff);
|
||||
if (std::abs(diff) > 2047)
|
||||
{
|
||||
value = event.number;
|
||||
|
@ -150,7 +148,6 @@ namespace usb_pad
|
|||
}
|
||||
else if (errno != EAGAIN)
|
||||
{
|
||||
OSDebugOut("PollInput: read error %d\n", errno);
|
||||
goto error;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
*/
|
||||
|
||||
#include "joydev.h"
|
||||
#include "../../osdebugout.h"
|
||||
#include <cassert>
|
||||
#include <sstream>
|
||||
#include "../../linux/util.h"
|
||||
|
@ -41,7 +40,7 @@ namespace usb_pad
|
|||
DIR* dirp = opendir("/dev/input/");
|
||||
if (!dirp)
|
||||
{
|
||||
perror("Error opening /dev/input/");
|
||||
Console.Warning("Error opening /dev/input/");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -49,7 +48,6 @@ namespace usb_pad
|
|||
{
|
||||
if (strncmp(dp->d_name, "js", 2) == 0)
|
||||
{
|
||||
OSDebugOut("%s\n", dp->d_name);
|
||||
|
||||
str.clear();
|
||||
str.str("");
|
||||
|
@ -59,16 +57,15 @@ namespace usb_pad
|
|||
|
||||
if (fd < 0)
|
||||
{
|
||||
perror("Unable to open device");
|
||||
Console.Warning("Unable to open device");
|
||||
continue;
|
||||
}
|
||||
|
||||
res = ioctl(fd, JSIOCGNAME(sizeof(buf)), buf);
|
||||
if (res < 0)
|
||||
perror("JSIOCGNAME");
|
||||
Console.Warning("JSIOCGNAME");
|
||||
else
|
||||
{
|
||||
OSDebugOut("Joydev device name: %s\n", buf);
|
||||
list.push_back({buf, buf, path});
|
||||
}
|
||||
|
||||
|
@ -123,7 +120,6 @@ namespace usb_pad
|
|||
js_event& event = events[i];
|
||||
if ((event.type & ~JS_EVENT_INIT) == JS_EVENT_AXIS)
|
||||
{
|
||||
OSDebugOut("Axis: %d, mapped: 0x%02x, val: %d\n", event.number, device.axis_map[event.number], event.value);
|
||||
switch (device.axis_map[event.number])
|
||||
{
|
||||
case 0x80 | JOY_STEERING:
|
||||
|
@ -189,7 +185,6 @@ namespace usb_pad
|
|||
}
|
||||
else if ((event.type & ~JS_EVENT_INIT) == JS_EVENT_BUTTON)
|
||||
{
|
||||
OSDebugOut("Button: %d, mapped: 0x%02x, val: %d\n", event.number, device.btn_map[event.number], event.value);
|
||||
PS2Buttons button = PAD_BUTTON_COUNT;
|
||||
if (device.btn_map[event.number] >= (0x8000 | JOY_CROSS) &&
|
||||
device.btn_map[event.number] <= (0x8000 | JOY_L3))
|
||||
|
@ -251,7 +246,6 @@ namespace usb_pad
|
|||
button = PAD_L2;
|
||||
break;
|
||||
default:
|
||||
OSDebugOut("Unmapped Button: %d, %d\n", event.number, event.value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -268,7 +262,6 @@ namespace usb_pad
|
|||
|
||||
if (len <= 0)
|
||||
{
|
||||
OSDebugOut("%s: TokenIn: read error %d\n", APINAME, errno);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -344,7 +337,6 @@ namespace usb_pad
|
|||
std::string joypath;
|
||||
/*if (!LoadSetting(mDevType, mPort, APINAME, N_JOYSTICK, joypath))
|
||||
{
|
||||
OSDebugOut("Cannot load joystick setting: %s\n", N_JOYSTICK);
|
||||
return 1;
|
||||
}*/
|
||||
|
||||
|
@ -369,7 +361,6 @@ namespace usb_pad
|
|||
|
||||
if ((device.cfg.fd = open(it.path.c_str(), O_RDWR | O_NONBLOCK)) < 0)
|
||||
{
|
||||
OSDebugOut("Cannot open device: %s\n", it.path.c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -402,7 +393,6 @@ namespace usb_pad
|
|||
if (ioctl(device.cfg.fd, JSIOCGAXES, &(count)) >= 0)
|
||||
{
|
||||
for (int i = 0; i < count; ++i)
|
||||
OSDebugOut("Axis: %d -> %d\n", i, device.axis_map[i]);
|
||||
|
||||
for (int k = 0; k < count; k++)
|
||||
{
|
||||
|
@ -431,7 +421,6 @@ namespace usb_pad
|
|||
{
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
OSDebugOut("Button: %d -> %d BTN_[GAMEPAD|SOUTH]: %d\n", i, device.btn_map[i], device.btn_map[i] == BTN_GAMEPAD);
|
||||
if (device.btn_map[i] == BTN_GAMEPAD)
|
||||
device.is_gamepad = true;
|
||||
}
|
||||
|
@ -455,7 +444,6 @@ namespace usb_pad
|
|||
tmp++;
|
||||
|
||||
sscanf(tmp, "%d", &index);
|
||||
OSDebugOut("input index: %d of '%s'\n", index, it.path.c_str());
|
||||
|
||||
//TODO kernel limit is 32?
|
||||
for (int j = 0; j <= 99; j++)
|
||||
|
@ -478,7 +466,6 @@ namespace usb_pad
|
|||
{
|
||||
if ((mHandleFF = open(event.str().c_str(), /*O_WRONLY*/ O_RDWR)) < 0)
|
||||
{
|
||||
OSDebugOut("%s: Cannot open '%s'\n", APINAME, event.str().c_str());
|
||||
}
|
||||
else
|
||||
mFFdev = new evdev::EvdevFF(mHandleFF, b_gain, gain, b_ac, ac);
|
||||
|
|
|
@ -63,13 +63,13 @@ namespace usb_pad
|
|||
int fd = 0;
|
||||
if ((fd = open(path.c_str(), O_RDONLY)) < 0)
|
||||
{
|
||||
fprintf(stderr, "Cannot open %s\n", path.c_str());
|
||||
Console.Warning("Cannot open %s\n", path.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ioctl(fd, JSIOCGNAME(_Size), name) < -1)
|
||||
{
|
||||
fprintf(stderr, "Cannot get controller's name\n");
|
||||
Console.Warning("Cannot get controller's name\n");
|
||||
close(fd);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -54,8 +54,8 @@ namespace usb_pad
|
|||
PadProxy(const PadProxy&) = delete;
|
||||
|
||||
public:
|
||||
PadProxy() { OSDebugOut(TEXT("%s\n"), T::Name()); }
|
||||
~PadProxy() { OSDebugOut(TEXT("%p\n"), this); }
|
||||
PadProxy() { }
|
||||
~PadProxy() { }
|
||||
Pad* CreateObject(int port, const char* dev_type) const
|
||||
{
|
||||
try
|
||||
|
|
|
@ -299,7 +299,7 @@ namespace usb_pad
|
|||
|
||||
if (usbHandle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
fprintf(stderr, "Could not open device %i\n", i);
|
||||
Console.Warning("Could not open device %i\n", i);
|
||||
free(didData);
|
||||
i++;
|
||||
continue;
|
||||
|
@ -312,7 +312,6 @@ namespace usb_pad
|
|||
if (caps.UsagePage == HID_USAGE_PAGE_GENERIC &&
|
||||
caps.Usage == HID_USAGE_GENERIC_JOYSTICK)
|
||||
{
|
||||
OSDebugOut(TEXT("Joystick found %04X:%04X\n"), attr.VendorID, attr.ProductID);
|
||||
std::wstring strPath(didData->DevicePath);
|
||||
std::transform(strPath.begin(), strPath.end(), strPath.begin(), ::toupper);
|
||||
joysDev.push_back(strPath);
|
||||
|
@ -610,7 +609,6 @@ namespace usb_pad
|
|||
{
|
||||
mapping->axisMap[axis] = PLY_SET_MAPPED(plyCapturing, axisCapturing);
|
||||
axisPass2 = false;
|
||||
OSDebugOut(TEXT("Selected axis %d\n"), axis);
|
||||
swprintf_s(buf, TEXT("Captured wheel axis %d"), axis);
|
||||
SendDlgItemMessage(dgHwnd, IDC_STATIC_CAP, WM_SETTEXT, 0, (LPARAM)buf);
|
||||
axisCapturing = PAD_AXIS_COUNT;
|
||||
|
@ -626,7 +624,6 @@ namespace usb_pad
|
|||
{
|
||||
mapping->axisMap[6] = PLY_SET_MAPPED(plyCapturing, axisCapturing);
|
||||
axisPass2 = false;
|
||||
OSDebugOut(TEXT("Selected hat switch\n"));
|
||||
swprintf_s(buf, TEXT("Captured wheel hat switch"));
|
||||
SendDlgItemMessage(dgHwnd, IDC_STATIC_CAP, WM_SETTEXT, 0, (LPARAM)buf);
|
||||
axisCapturing = PAD_AXIS_COUNT;
|
||||
|
|
|
@ -37,15 +37,12 @@ namespace usb_pad
|
|||
{
|
||||
res = WriteFile(pad->mUsbHandle, buf.data(), buf.size(), &written, &pad->mOLWrite);
|
||||
uint8_t* d = buf.data();
|
||||
OSDebugOut(TEXT("FFB %02X, %02X : %02X, %02X : %02X, %02X : %02X\n"),
|
||||
d[1], d[2], d[3], d[4], d[5], d[6], d[7]);
|
||||
|
||||
WaitForSingleObject(pad->mOLWrite.hEvent, 1000);
|
||||
if (GetOverlappedResult(pad->mUsbHandle, &pad->mOLWrite, &written, FALSE))
|
||||
OSDebugOut(TEXT("last write ffb: %d %d, written %d\n"), res, res2, written);
|
||||
}
|
||||
}
|
||||
OSDebugOut(TEXT("WriterThread exited.\n"));
|
||||
|
||||
pad->mWriterThreadIsRunning = false;
|
||||
}
|
||||
|
@ -69,12 +66,11 @@ namespace usb_pad
|
|||
if (!pad->mReportData.try_enqueue(report)) // TODO May leave queue with too stale data. Use multi-producer/consumer queue?
|
||||
{
|
||||
if (!errCount)
|
||||
fprintf(stderr, "%s: Could not enqueue report data: %zd\n", APINAME, pad->mReportData.size_approx());
|
||||
Console.Warning("%s: Could not enqueue report data: %zd\n", APINAME, pad->mReportData.size_approx());
|
||||
errCount = (++errCount) % 16;
|
||||
}
|
||||
}
|
||||
}
|
||||
OSDebugOut(TEXT("ReaderThread exited.\n"));
|
||||
|
||||
pad->mReaderThreadIsRunning = false;
|
||||
}
|
||||
|
@ -84,7 +80,7 @@ namespace usb_pad
|
|||
ULONG value = 0;
|
||||
int player = 1 - mPort;
|
||||
|
||||
//fprintf(stderr,"usb-pad: poll len=%li\n", len);
|
||||
//Console.Warning("usb-pad: poll len=%li\n", len);
|
||||
if (mDoPassthrough)
|
||||
{
|
||||
std::array<uint8_t, 32> report; //32 is random
|
||||
|
@ -175,7 +171,6 @@ namespace usb_pad
|
|||
|
||||
if (!mFFData.enqueue(report))
|
||||
{
|
||||
OSDebugOut(TEXT("Failed to enqueue ffb command\n"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -285,7 +280,7 @@ namespace usb_pad
|
|||
continue; // if here then maybe something is up with HIDP_CAPS.NumberInputValueCaps
|
||||
}
|
||||
|
||||
//fprintf(stderr, "Min/max %d/%d\t", pValueCaps[i].LogicalMin, pValueCaps[i].LogicalMax);
|
||||
//Console.Warning("Min/max %d/%d\t", pValueCaps[i].LogicalMin, pValueCaps[i].LogicalMax);
|
||||
|
||||
//Get mapped axis for physical axis
|
||||
uint16_t v = 0;
|
||||
|
@ -300,7 +295,7 @@ namespace usb_pad
|
|||
v = mapping->axisMap[pValueCaps[i].Range.UsageMin - HID_USAGE_GENERIC_X];
|
||||
break;
|
||||
case HID_USAGE_GENERIC_HATSWITCH:
|
||||
//fprintf(stderr, "Hat: %02X\n", value);
|
||||
//Console.Warning("Hat: %02X\n", value);
|
||||
v = mapping->axisMap[6];
|
||||
break;
|
||||
}
|
||||
|
@ -316,7 +311,7 @@ namespace usb_pad
|
|||
switch (PLY_GET_VALUE(j, v))
|
||||
{
|
||||
case PAD_AXIS_X: // X-axis
|
||||
//fprintf(stderr, "X: %d\n", value);
|
||||
//Console.Warning("X: %d\n", value);
|
||||
// Need for logical min too?
|
||||
//generic_data.axis_x = ((value - pValueCaps[i].LogicalMin) * 0x3FF) / (pValueCaps[i].LogicalMax - pValueCaps[i].LogicalMin);
|
||||
if (type == WT_DRIVING_FORCE_PRO || type == WT_DRIVING_FORCE_PRO_1102)
|
||||
|
@ -332,19 +327,19 @@ namespace usb_pad
|
|||
break;
|
||||
|
||||
case PAD_AXIS_Z: // Z-axis
|
||||
//fprintf(stderr, "Z: %d\n", value);
|
||||
//Console.Warning("Z: %d\n", value);
|
||||
//XXX Limit value range to 0..255
|
||||
mapping->data[j].throttle = (value * 0xFF) / pValueCaps[i].LogicalMax;
|
||||
break;
|
||||
|
||||
case PAD_AXIS_RZ: // Rotate-Z
|
||||
//fprintf(stderr, "Rz: %d\n", value);
|
||||
//Console.Warning("Rz: %d\n", value);
|
||||
//XXX Limit value range to 0..255
|
||||
mapping->data[j].brake = (value * 0xFF) / pValueCaps[i].LogicalMax;
|
||||
break;
|
||||
|
||||
case PAD_AXIS_HAT: // TODO Hat Switch
|
||||
//fprintf(stderr, "Hat: %02X\n", value);
|
||||
//Console.Warning("Hat: %02X\n", value);
|
||||
//TODO 4 vs 8 direction hat switch
|
||||
if (pValueCaps[i].LogicalMax == 4 && value < 4)
|
||||
mapping->data[j].hatswitch = HATS_8TO4[value];
|
||||
|
@ -455,7 +450,7 @@ namespace usb_pad
|
|||
HidD_GetAttributes(mUsbHandle, &(attr));
|
||||
if (attr.VendorID != PAD_VID || attr.ProductID == 0xC262)
|
||||
{
|
||||
fwprintf(stderr, TEXT("USBqemu: Vendor is not Logitech or wheel is G920. Not sending force feedback commands for safety reasons.\n"));
|
||||
Console.Warning("USB: Vendor is not Logitech or wheel is G920. Not sending force feedback commands for safety reasons.\n");
|
||||
mDoPassthrough = 0;
|
||||
Close();
|
||||
}
|
||||
|
@ -485,7 +480,7 @@ namespace usb_pad
|
|||
return 0;
|
||||
}
|
||||
else
|
||||
fwprintf(stderr, TEXT("USBqemu: Could not open device '%s'.\nPassthrough and FFB will not work.\n"), path.c_str());
|
||||
Console.Warning("USB: Could not open device '%s'.\nPassthrough and FFB will not work.\n", path.c_str());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#include "PrecompiledHeader.h"
|
||||
#include "usb-pad.h"
|
||||
#include "lg/lg_ff.h"
|
||||
#include "../osdebugout.h"
|
||||
|
||||
namespace usb_pad
|
||||
{
|
||||
|
|
|
@ -101,7 +101,6 @@ namespace usb_pad
|
|||
}
|
||||
*ptrB = '\0';
|
||||
|
||||
OSDebugOut(TEXT("%" SFMTs "\n"), bits);
|
||||
}
|
||||
|
||||
#else
|
||||
|
@ -207,9 +206,9 @@ namespace usb_pad
|
|||
break;
|
||||
case USB_TOKEN_OUT:
|
||||
usb_packet_copy(p, data, MIN(p->iov.size, sizeof(data)));
|
||||
/*fprintf(stderr,"usb-pad: data token out len=0x%X %X,%X,%X,%X,%X,%X,%X,%X\n",len,
|
||||
/*Console.Warning("usb-pad: data token out len=0x%X %X,%X,%X,%X,%X,%X,%X,%X\n",len,
|
||||
data[0],data[1],data[2],data[3],data[4],data[5],data[6],data[7]);*/
|
||||
//fprintf(stderr,"usb-pad: data token out len=0x%X\n",len);
|
||||
//Console.Warning("usb-pad: data token out len=0x%X\n",len);
|
||||
ret = s->pad->TokenOut(data, p->iov.size);
|
||||
break;
|
||||
default:
|
||||
|
@ -244,11 +243,9 @@ namespace usb_pad
|
|||
|
||||
break;
|
||||
case InterfaceRequest | USB_REQ_GET_DESCRIPTOR: //GT3
|
||||
OSDebugOut(TEXT("InterfaceRequest | USB_REQ_GET_DESCRIPTOR 0x%04X\n"), value);
|
||||
switch (value >> 8)
|
||||
{
|
||||
case USB_DT_REPORT:
|
||||
OSDebugOut(TEXT("Sending hid report desc.\n"));
|
||||
if (t == WT_DRIVING_FORCE_PRO || t == WT_DRIVING_FORCE_PRO_1102)
|
||||
{
|
||||
ret = sizeof(pad_driving_force_pro_hid_report_descriptor);
|
||||
|
@ -275,7 +272,6 @@ namespace usb_pad
|
|||
// no idea, Rock Band 2 keeps spamming this
|
||||
if (length > 0)
|
||||
{
|
||||
OSDebugOut(TEXT("SET_REPORT: 0x%02X \n"), data[0]);
|
||||
/* 0x01: Num Lock LED
|
||||
* 0x02: Caps Lock LED
|
||||
* 0x04: Scroll Lock LED
|
||||
|
@ -286,7 +282,6 @@ namespace usb_pad
|
|||
}
|
||||
break;
|
||||
case SET_IDLE:
|
||||
OSDebugOut(TEXT("SET_IDLE\n"));
|
||||
break;
|
||||
default:
|
||||
ret = usb_desc_handle_control(dev, p, request, value, index, length, data);
|
||||
|
@ -387,7 +382,6 @@ namespace usb_pad
|
|||
w->hi |= 0x11 << 24; //enables wheel and pedals?
|
||||
|
||||
//PrintBits(w, sizeof(*w));
|
||||
//OSDebugOut(TEXT("DFP thr: %u brake: %u\n"), (w->hi >> 8) & 0xFF, (w->hi >> 16) & 0xFF);
|
||||
|
||||
break;
|
||||
case WT_DRIVING_FORCE_PRO_1102:
|
||||
|
@ -439,7 +433,7 @@ namespace usb_pad
|
|||
|
||||
u_wheel_data_t* w = (u_wheel_data_t*)buf;
|
||||
|
||||
//fprintf(stderr,"usb-pad: axis x %d\n", data.axis_x);
|
||||
//Console.Warning("usb-pad: axis x %d\n", data.axis_x);
|
||||
switch (type)
|
||||
{
|
||||
case WT_GENERIC:
|
||||
|
@ -491,7 +485,6 @@ namespace usb_pad
|
|||
w->u.dfp_data.axis_x = data.steering;
|
||||
w->u.dfp_data.axis_z = 1 | (data.throttle * 0x3F) / 0xFF; //TODO Always > 0 or everything stops working, wut.
|
||||
w->u.dfp_data.axis_rz = 0x3F - (data.brake * 0x3F) / 0xFF;
|
||||
//OSDebugOut(TEXT("dfp: axis_z=0x%02x, axis_rz=0x%02x\n"), w->u.dfp_data.axis_z, w->u.dfp_data.axis_rz);
|
||||
|
||||
w->u.dfp_data.magic1 = 1;
|
||||
w->u.dfp_data.magic2 = 1;
|
||||
|
@ -548,11 +541,9 @@ namespace usb_pad
|
|||
if (!proxy)
|
||||
{
|
||||
Console.WriteLn("USB: PAD: Invalid input API.\n");
|
||||
USB_LOG("usb-pad: %s: Invalid input API.\n", TypeName());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
USB_LOG("usb-pad: creating device '%s' on port %d with %s\n", TypeName(), port, varApi.c_str());
|
||||
Pad* pad = proxy->CreateObject(port, TypeName());
|
||||
|
||||
if (!pad)
|
||||
|
@ -676,11 +667,9 @@ namespace usb_pad
|
|||
if (!proxy)
|
||||
{
|
||||
Console.WriteLn("RBDK: Invalid input API.\n");
|
||||
USB_LOG("usb-pad: %s: Invalid input API.\n", TypeName());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
USB_LOG("usb-pad: creating device '%s' on port %d with %s\n", TypeName(), port, varApi.c_str());
|
||||
Pad* pad = proxy->CreateObject(port, TypeName());
|
||||
|
||||
if (!pad)
|
||||
|
@ -749,11 +738,9 @@ namespace usb_pad
|
|||
if (!proxy)
|
||||
{
|
||||
Console.WriteLn("Buzz: Invalid input API.\n");
|
||||
USB_LOG("usb-pad: %s: Invalid input API.\n", TypeName());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
USB_LOG("usb-pad: creating device '%s' on port %d with %s\n", TypeName(), port, varApi.c_str());
|
||||
Pad* pad = proxy->CreateObject(port, TypeName());
|
||||
|
||||
if (!pad)
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace usb_pad
|
|||
class PadDevice
|
||||
{
|
||||
public:
|
||||
virtual ~PadDevice() { OSDebugOut("%p\n", this); }
|
||||
virtual ~PadDevice() { }
|
||||
static USBDevice* CreateDevice(int port);
|
||||
static const TCHAR* Name()
|
||||
{
|
||||
|
|
|
@ -323,11 +323,9 @@ namespace usb_pad
|
|||
|
||||
break;
|
||||
case InterfaceRequest | USB_REQ_GET_DESCRIPTOR:
|
||||
OSDebugOut(TEXT("InterfaceRequest | USB_REQ_GET_DESCRIPTOR 0x%04X\n"), value);
|
||||
switch (value >> 8)
|
||||
{
|
||||
case USB_DT_REPORT:
|
||||
OSDebugOut(TEXT("Sending hid report desc.\n"));
|
||||
ret = sizeof(hid_report_descriptor);
|
||||
memcpy(data, hid_report_descriptor, ret);
|
||||
p->actual_length = ret;
|
||||
|
@ -340,13 +338,11 @@ namespace usb_pad
|
|||
case SET_REPORT:
|
||||
if (length > 0)
|
||||
{
|
||||
OSDebugOut(TEXT("SET_REPORT: 0x%02X \n"), data[0]);
|
||||
p->actual_length = 0;
|
||||
//p->status = USB_RET_SUCCESS;
|
||||
}
|
||||
break;
|
||||
case SET_IDLE:
|
||||
OSDebugOut(TEXT("SET_IDLE\n"));
|
||||
break;
|
||||
default:
|
||||
ret = usb_desc_handle_control(dev, p, request, value, index, length, data);
|
||||
|
@ -401,7 +397,6 @@ namespace usb_pad
|
|||
if (!proxy)
|
||||
{
|
||||
Console.WriteLn("USB: PAD: Invalid input API.\n");
|
||||
USB_LOG("usb-pad: %s: Invalid input API.\n", TypeName());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -409,10 +404,8 @@ namespace usb_pad
|
|||
|
||||
|
||||
#ifdef _WIN32
|
||||
USB_LOG("usb-pad: creating device '%s' on port %d with %s\n", TypeName(), port, str_to_wstr(varApi));
|
||||
if (!LoadSetting(nullptr, port, usb_mic::SingstarDevice::TypeName(), N_DEVICE_API, str_to_wstr(api)))
|
||||
#else
|
||||
USB_LOG("usb-pad: creating device '%s' on port %d with %s\n", TypeName(), port, varApi.c_str());
|
||||
if (!LoadSetting(nullptr, port, usb_mic::SingstarDevice::TypeName(), N_DEVICE_API, api))
|
||||
#endif
|
||||
return nullptr;
|
||||
|
|
|
@ -352,7 +352,6 @@
|
|||
<ClCompile Include="..\..\USB\configuration.cpp" />
|
||||
<ClCompile Include="..\..\USB\deviceproxy.cpp" />
|
||||
<ClCompile Include="..\..\USB\device_init.cpp" />
|
||||
<ClCompile Include="..\..\USB\osdebugout.cpp" />
|
||||
<ClCompile Include="..\..\USB\qemu-usb\bus.cpp" />
|
||||
<ClCompile Include="..\..\USB\qemu-usb\core.cpp" />
|
||||
<ClCompile Include="..\..\USB\qemu-usb\desc.cpp" />
|
||||
|
@ -665,7 +664,6 @@
|
|||
<ClInclude Include="..\..\USB\configuration.h" />
|
||||
<ClInclude Include="..\..\USB\deviceproxy.h" />
|
||||
<ClInclude Include="..\..\USB\helpers.h" />
|
||||
<ClInclude Include="..\..\USB\osdebugout.h" />
|
||||
<ClInclude Include="..\..\USB\platcompat.h" />
|
||||
<ClInclude Include="..\..\USB\proxybase.h" />
|
||||
<ClInclude Include="..\..\USB\qemu-usb\desc.h" />
|
||||
|
@ -907,4 +905,4 @@
|
|||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets" />
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -1081,9 +1081,6 @@
|
|||
<ClCompile Include="..\..\USB\deviceproxy.cpp">
|
||||
<Filter>System\Ps2\USB</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\USB\osdebugout.cpp">
|
||||
<Filter>System\Ps2\USB</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\USB\USB.cpp">
|
||||
<Filter>System\Ps2\USB</Filter>
|
||||
</ClCompile>
|
||||
|
@ -1764,9 +1761,6 @@
|
|||
<ClInclude Include="..\..\USB\helpers.h">
|
||||
<Filter>System\Ps2\USB</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\USB\osdebugout.h">
|
||||
<Filter>System\Ps2\USB</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\USB\platcompat.h">
|
||||
<Filter>System\Ps2\USB</Filter>
|
||||
</ClInclude>
|
||||
|
|
Loading…
Reference in New Issue