mirror of https://github.com/PCSX2/pcsx2.git
parent
7d2209860e
commit
dd6f9c5ad3
|
@ -54,10 +54,11 @@ static void populateApiWidget(SettingsCB* settingsCB, const std::string& device)
|
|||
gtk_list_store_clear(GTK_LIST_STORE(gtk_combo_box_get_model(settingsCB->combo)));
|
||||
|
||||
auto dev = RegisterDevice::instance().Device(device);
|
||||
int port = 1 - settingsCB->player;
|
||||
GtkComboBox* widget = settingsCB->combo;
|
||||
if (dev)
|
||||
{
|
||||
int port = 1 - settingsCB->player;
|
||||
|
||||
std::string api;
|
||||
|
||||
auto it = changedAPIs.find(std::make_pair(port, device));
|
||||
|
@ -90,10 +91,10 @@ static void populateSubtypeWidget(SettingsCB* settingsCB, const std::string& dev
|
|||
gtk_list_store_clear(GTK_LIST_STORE(gtk_combo_box_get_model(settingsCB->subtype)));
|
||||
|
||||
auto dev = RegisterDevice::instance().Device(device);
|
||||
int port = 1 - settingsCB->player;
|
||||
GtkComboBox* widget = settingsCB->subtype;
|
||||
if (dev)
|
||||
{
|
||||
int port = 1 - settingsCB->player;
|
||||
int sel = 0;
|
||||
if (!LoadSetting(nullptr, port, device, N_DEV_SUBTYPE, sel))
|
||||
{
|
||||
|
@ -134,7 +135,6 @@ static void apiChanged(GtkComboBox* widget, gpointer data)
|
|||
SettingsCB* settingsCB = (SettingsCB*)data;
|
||||
int player = settingsCB->player;
|
||||
gint active = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
|
||||
int port = 1 - player;
|
||||
|
||||
auto& name = settingsCB->device;
|
||||
auto dev = RegisterDevice::instance().Device(name);
|
||||
|
@ -145,6 +145,7 @@ static void apiChanged(GtkComboBox* widget, gpointer data)
|
|||
std::advance(it, active);
|
||||
if (it != apis.end())
|
||||
{
|
||||
int port = 1 - player;
|
||||
auto pair = std::make_pair(port, name);
|
||||
auto itAPI = changedAPIs.find(pair);
|
||||
|
||||
|
@ -162,12 +163,12 @@ static void subtypeChanged(GtkComboBox* widget, gpointer data)
|
|||
SettingsCB* settingsCB = (SettingsCB*)data;
|
||||
int player = settingsCB->player;
|
||||
gint active = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
|
||||
int port = 1 - player;
|
||||
|
||||
auto& name = settingsCB->device;
|
||||
auto dev = RegisterDevice::instance().Device(name);
|
||||
if (dev)
|
||||
{
|
||||
int port = 1 - player;
|
||||
changedSubtype[std::make_pair(port, name)] = active;
|
||||
}
|
||||
}
|
||||
|
@ -176,14 +177,15 @@ static void configureApi(GtkWidget* widget, gpointer data)
|
|||
{
|
||||
SettingsCB* settingsCB = (SettingsCB*)data;
|
||||
int player = settingsCB->player;
|
||||
int port = 1 - player;
|
||||
|
||||
auto& name = settingsCB->device;
|
||||
auto& api = settingsCB->api;
|
||||
auto dev = RegisterDevice::instance().Device(name);
|
||||
|
||||
if (dev)
|
||||
{
|
||||
int port = 1 - player;
|
||||
auto& api = settingsCB->api;
|
||||
|
||||
GtkWidget* dlg = GTK_WIDGET(g_object_get_data(G_OBJECT(widget), "dlg"));
|
||||
[[maybe_unused]]int res = dev->Configure(port, api, dlg);
|
||||
}
|
||||
|
|
|
@ -83,19 +83,13 @@ void INIAddOutExt(char *tempname, int temppos) {
|
|||
|
||||
// Returns number of bytes read to get line (0 means end-of-file)
|
||||
int INIReadLine(ACTUALHANDLE infile, char *buffer) {
|
||||
int charcount;
|
||||
int i;
|
||||
char tempin[2];
|
||||
int retflag;
|
||||
int retval;
|
||||
|
||||
charcount = 0;
|
||||
i = 0;
|
||||
tempin[1] = 0;
|
||||
retflag = 0;
|
||||
int charcount = 0;
|
||||
int i = 0;
|
||||
char tempin[2] = {0};
|
||||
int retflag = 0;
|
||||
|
||||
while((i < INIMAXLEN) && (retflag < 2)) {
|
||||
retval = ActualFileRead(infile, 1, tempin);
|
||||
const int retval = ActualFileRead(infile, 1, tempin);
|
||||
charcount++;
|
||||
if(retval != 1) {
|
||||
retflag = 2;
|
||||
|
@ -118,22 +112,17 @@ int INIReadLine(ACTUALHANDLE infile, char *buffer) {
|
|||
|
||||
// Returns: number of bytes to get to start of section (or -1)
|
||||
int INIFindSection(ACTUALHANDLE infile, const char *section) {
|
||||
int charcount;
|
||||
int i;
|
||||
int retflag;
|
||||
int charcount = 0;
|
||||
int retflag = 0;
|
||||
int retval;
|
||||
char scanbuffer[INIMAXLEN+1];
|
||||
|
||||
|
||||
charcount = 0;
|
||||
retflag = 0;
|
||||
|
||||
while(retflag == 0) {
|
||||
retval = INIReadLine(infile, scanbuffer);
|
||||
if(retval == 0) return(-1); // EOF? Stop here.
|
||||
|
||||
if(scanbuffer[0] == '[') {
|
||||
i = 0;
|
||||
int i = 0;
|
||||
while((i < INIMAXLEN) &&
|
||||
(*(section + i) != 0) &&
|
||||
(*(section + i) == scanbuffer[i + 1])) i++;
|
||||
|
@ -152,22 +141,16 @@ int INIFindSection(ACTUALHANDLE infile, const char *section) {
|
|||
|
||||
// Returns: number of bytes to get to start of keyword (or -1)
|
||||
int INIFindKeyword(ACTUALHANDLE infile, const char *keyword, char *buffer) {
|
||||
int charcount;
|
||||
int i;
|
||||
int j;
|
||||
int retflag;
|
||||
int retval;
|
||||
int charcount = 0;
|
||||
int retflag = 0;
|
||||
char scanbuffer[INIMAXLEN+1];
|
||||
|
||||
charcount = 0;
|
||||
retflag = 0;
|
||||
|
||||
while(retflag == 0) {
|
||||
retval = INIReadLine(infile, scanbuffer);
|
||||
int retval = INIReadLine(infile, scanbuffer);
|
||||
if(retval == 0) return(-1); // EOF? Stop here.
|
||||
if(scanbuffer[0] == '[') return(-1); // New section? Stop here.
|
||||
|
||||
i = 0;
|
||||
int i = 0;
|
||||
while((i < INIMAXLEN) &&
|
||||
(*(keyword + i) != 0) &&
|
||||
(*(keyword + i) == scanbuffer[i])) i++;
|
||||
|
@ -176,7 +159,7 @@ int INIFindKeyword(ACTUALHANDLE infile, const char *keyword, char *buffer) {
|
|||
retflag = 1;
|
||||
if(buffer != NULL) {
|
||||
i++;
|
||||
j = 0;
|
||||
int j = 0;
|
||||
while((i < INIMAXLEN) && (scanbuffer[i] != 0)) {
|
||||
*(buffer + j) = scanbuffer[i];
|
||||
i++;
|
||||
|
@ -197,15 +180,13 @@ int INIFindKeyword(ACTUALHANDLE infile, const char *keyword, char *buffer) {
|
|||
// Returns: number of bytes left to write... (from charcount back)
|
||||
int INICopy(ACTUALHANDLE infile, ACTUALHANDLE outfile, int charcount) {
|
||||
char buffer[4096];
|
||||
int i;
|
||||
int chunk;
|
||||
int retval;
|
||||
int chunk = 4096;
|
||||
|
||||
i = charcount;
|
||||
int i = charcount;
|
||||
chunk = 4096;
|
||||
if(i < chunk) chunk = i;
|
||||
while(chunk > 0) {
|
||||
retval = ActualFileRead(infile, chunk, buffer);
|
||||
int retval = ActualFileRead(infile, chunk, buffer);
|
||||
if(retval <= 0) return(i); // Trouble? Stop here.
|
||||
if(retval < chunk) chunk = retval; // Short block? Note it.
|
||||
|
||||
|
|
|
@ -742,14 +742,13 @@ void usb_ep_dump(USBDevice* dev)
|
|||
/* [USB_ENDPOINT_XFER_BULK] = */ "bulk",
|
||||
/* [USB_ENDPOINT_XFER_INT] = */ "int",
|
||||
};
|
||||
int ifnum, ep, first;
|
||||
|
||||
Console.Warning("Device \"%s\", config %d\n",
|
||||
dev->product_desc, dev->configuration);
|
||||
for (ifnum = 0; ifnum < 16; ifnum++)
|
||||
for (int ifnum = 0; ifnum < 16; ifnum++)
|
||||
{
|
||||
first = 1;
|
||||
for (ep = 0; ep < USB_MAX_ENDPOINTS; ep++)
|
||||
int first = 1;
|
||||
for (int ep = 0; ep < USB_MAX_ENDPOINTS; ep++)
|
||||
{
|
||||
if (dev->ep_in[ep].type != USB_ENDPOINT_XFER_INVALID &&
|
||||
dev->ep_in[ep].ifnum == ifnum)
|
||||
|
|
|
@ -115,11 +115,9 @@ void* my_g_malloc_n(size_t n_blocks,
|
|||
void* my_g_realloc(void* mem,
|
||||
size_t n_bytes)
|
||||
{
|
||||
void* newmem;
|
||||
|
||||
if (G_LIKELY(n_bytes))
|
||||
{
|
||||
newmem = realloc(mem, n_bytes);
|
||||
void* newmem = realloc(mem, n_bytes);
|
||||
//TRACE (GLIB_MEM_REALLOC((void*) newmem, (void*)mem, (unsigned int) n_bytes, 0));
|
||||
if (newmem)
|
||||
return newmem;
|
||||
|
|
|
@ -469,11 +469,9 @@ static void hid_pointer_sync(HIDState* hs)
|
|||
|
||||
static void hid_keyboard_event(HIDState* hs, InputEvent* evt)
|
||||
{
|
||||
int scancodes[3], i, count;
|
||||
int slot;
|
||||
int scancodes[3];
|
||||
InputKeyEvent* key = &evt->u.key;
|
||||
|
||||
count = qemu_input_key_value_to_scancode(&key->key,
|
||||
const int count = qemu_input_key_value_to_scancode(&key->key,
|
||||
key->down,
|
||||
scancodes);
|
||||
if (hs->n + count > QUEUE_LENGTH)
|
||||
|
@ -481,9 +479,9 @@ static void hid_keyboard_event(HIDState* hs, InputEvent* evt)
|
|||
//trace_hid_kbd_queue_full();
|
||||
return;
|
||||
}
|
||||
for (i = 0; i < count; i++)
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
slot = (hs->head + hs->n) & QUEUE_MASK;
|
||||
const int slot = (hs->head + hs->n) & QUEUE_MASK;
|
||||
hs->n++;
|
||||
hs->kbd.keycodes[slot] = scancodes[i];
|
||||
}
|
||||
|
|
|
@ -462,15 +462,13 @@ static int usb_hub_handle_control(USBDevice* dev, int request, int value,
|
|||
static int usb_hub_handle_data(USBDevice* dev, int pid,
|
||||
uint8_t devep, uint8_t* data, int len)
|
||||
{
|
||||
USBHubState* s = (USBHubState*)dev;
|
||||
int ret;
|
||||
|
||||
int ret = 0;
|
||||
switch (pid)
|
||||
{
|
||||
case USB_TOKEN_IN:
|
||||
if (devep == 1)
|
||||
{
|
||||
USBHubPort* port;
|
||||
USBHubState* s = (USBHubState*)dev;
|
||||
unsigned int status;
|
||||
int i, n;
|
||||
n = (s->nb_ports + 1 + 7) / 8;
|
||||
|
@ -485,7 +483,7 @@ static int usb_hub_handle_data(USBDevice* dev, int pid,
|
|||
status = 0;
|
||||
for (i = 0; i < s->nb_ports; i++)
|
||||
{
|
||||
port = &s->ports[i];
|
||||
USBHubPort* port = &s->ports[i];
|
||||
if (port->wPortChange)
|
||||
status |= (1 << (i + 1));
|
||||
}
|
||||
|
@ -520,17 +518,13 @@ static int usb_hub_broadcast_packet(USBHubState* s, int pid,
|
|||
uint8_t devaddr, uint8_t devep,
|
||||
uint8_t* data, int len)
|
||||
{
|
||||
USBHubPort* port;
|
||||
USBDevice* dev;
|
||||
int i, ret;
|
||||
|
||||
for (i = 0; i < s->nb_ports; i++)
|
||||
for (int i = 0; i < s->nb_ports; i++)
|
||||
{
|
||||
port = &s->ports[i];
|
||||
dev = port->port.dev;
|
||||
USBHubPort* port = &s->ports[i];
|
||||
USBDevice* dev = port->port.dev;
|
||||
if (dev && (port->wPortStatus & PORT_STAT_ENABLE))
|
||||
{
|
||||
ret = dev->handle_packet(dev, pid,
|
||||
int ret = dev->handle_packet(dev, pid,
|
||||
devaddr, devep,
|
||||
data, len);
|
||||
if (ret != USB_RET_NODEV)
|
||||
|
@ -570,13 +564,9 @@ static void usb_hub_handle_destroy(USBDevice* dev)
|
|||
|
||||
USBDevice* usb_hub_init(int nb_ports)
|
||||
{
|
||||
USBHubState* s;
|
||||
USBHubPort* port;
|
||||
int i;
|
||||
|
||||
if (nb_ports > MAX_PORTS)
|
||||
return NULL;
|
||||
s = (USBHubState*)qemu_mallocz(sizeof(USBHubState));
|
||||
USBHubState* s = (USBHubState*)qemu_mallocz(sizeof(USBHubState));
|
||||
if (!s)
|
||||
return NULL;
|
||||
s->dev.speed = USB_SPEED_FULL;
|
||||
|
@ -591,9 +581,9 @@ USBDevice* usb_hub_init(int nb_ports)
|
|||
strncpy(s->dev.devname, "QEMU USB Hub", sizeof(s->dev.devname));
|
||||
|
||||
s->nb_ports = nb_ports;
|
||||
for (i = 0; i < s->nb_ports; i++)
|
||||
for (int i = 0; i < s->nb_ports; i++)
|
||||
{
|
||||
port = &s->ports[i];
|
||||
USBHubPort* port = &s->ports[i];
|
||||
port->port.opaque = s;
|
||||
port->port.index = i;
|
||||
port->port.attach = usb_hub_attach;
|
||||
|
|
|
@ -81,10 +81,9 @@ size_t RingBuffer::read(uint8_t* dst, size_t nbytes)
|
|||
|
||||
void RingBuffer::write(uint8_t* src, size_t nbytes)
|
||||
{
|
||||
size_t bytes;
|
||||
while (nbytes > 0)
|
||||
{
|
||||
bytes = std::min(nbytes, m_capacity - m_end);
|
||||
size_t bytes = std::min(nbytes, m_capacity - m_end);
|
||||
memcpy(back(), src, bytes);
|
||||
write(bytes);
|
||||
src += bytes;
|
||||
|
|
|
@ -248,7 +248,6 @@ namespace usb_eyetoy
|
|||
{
|
||||
EYETOYState* s = (EYETOYState*)dev;
|
||||
static const int max_ep_size = 896;
|
||||
uint8_t data[max_ep_size];
|
||||
uint8_t devep = p->ep->nr;
|
||||
|
||||
if (!s->hw_camera_running)
|
||||
|
@ -261,6 +260,7 @@ namespace usb_eyetoy
|
|||
switch (p->pid)
|
||||
{
|
||||
case USB_TOKEN_IN:
|
||||
uint8_t data[max_ep_size];
|
||||
if (devep == 1)
|
||||
{
|
||||
memset(data, 0xff, sizeof(data));
|
||||
|
|
|
@ -895,7 +895,6 @@ namespace usb_mic
|
|||
|
||||
static BOOL CALLBACK WASAPIDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
int tmp = 0;
|
||||
WASAPISettings* s;
|
||||
|
||||
switch (uMsg)
|
||||
|
@ -954,6 +953,7 @@ namespace usb_mic
|
|||
{
|
||||
case EN_CHANGE:
|
||||
{
|
||||
int tmp = 0;
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDC_BUFFER1_USB:
|
||||
|
|
|
@ -580,20 +580,18 @@ namespace usb_pad
|
|||
HBITMAP hAABitmap = (HBITMAP)GetCurrentObject(hAADC, OBJ_BITMAP);
|
||||
GetBitmapBits(hAABitmap, dstSize, lpDstBits);
|
||||
|
||||
int gridSize = scale * scale;
|
||||
const int gridSize = scale * scale;
|
||||
int resultRed, resultGreen, resultBlue;
|
||||
int dstX, dstY = 0, dstOffset;
|
||||
int srcX, srcY, srcOffset;
|
||||
int dstY = 0;
|
||||
int tmpX, tmpY, tmpOffset;
|
||||
for (int y = 1; y < dstHeight - 2; y++)
|
||||
{
|
||||
dstX = 0;
|
||||
srcX = 0;
|
||||
srcY = (y * scale) * srcPitch;
|
||||
int dstX = 0;
|
||||
const int srcY = (y * scale) * srcPitch;
|
||||
for (int x = 1; x < dstWidth - 2; x++)
|
||||
{
|
||||
srcX = (x * scale) * 4;
|
||||
srcOffset = srcY + srcX;
|
||||
const int srcX = (x * scale) * 4;
|
||||
const int srcOffset = srcY + srcX;
|
||||
|
||||
resultRed = resultGreen = resultBlue = 0;
|
||||
tmpY = -srcPitch;
|
||||
|
@ -613,7 +611,7 @@ namespace usb_pad
|
|||
tmpY += srcPitch;
|
||||
}
|
||||
|
||||
dstOffset = dstY + dstX;
|
||||
const int dstOffset = dstY + dstX;
|
||||
lpDstBits[dstOffset + 2] = (BYTE)(resultRed / gridSize);
|
||||
lpDstBits[dstOffset + 1] = (BYTE)(resultGreen / gridSize);
|
||||
lpDstBits[dstOffset] = (BYTE)(resultBlue / gridSize);
|
||||
|
|
|
@ -525,7 +525,6 @@ namespace usb_pad
|
|||
|
||||
int GtkPadConfigure(int port, const char* dev_type, const char* apititle, const char* apiname, GtkWindow* parent, ApiCallbacks& apicbs)
|
||||
{
|
||||
GtkWidget *ro_frame, *rs_cb;
|
||||
GtkWidget *right_vbox, *left_vbox;
|
||||
|
||||
ConfigData cfg{};
|
||||
|
@ -633,7 +632,7 @@ namespace usb_pad
|
|||
|
||||
gtk_box_pack_start(GTK_BOX(right_vbox), cfg.label, TRUE, TRUE, 5);
|
||||
}
|
||||
ro_frame = gtk_frame_new("Force feedback");
|
||||
GtkWidget* ro_frame = gtk_frame_new("Force feedback");
|
||||
gtk_box_pack_start(GTK_BOX(right_vbox), ro_frame, TRUE, FALSE, 5);
|
||||
|
||||
//GtkWidget *frame_vbox = gtk_vbox_new (FALSE, 5);
|
||||
|
@ -704,7 +703,7 @@ namespace usb_pad
|
|||
g_signal_connect(G_OBJECT(chk_btn), "toggled", G_CALLBACK(checkbox_toggled), reinterpret_cast<gboolean*>(&cfg.use_hidraw_ff_pt));
|
||||
gtk_box_pack_start(GTK_BOX(frame_vbox), chk_btn, FALSE, FALSE, 5);
|
||||
|
||||
rs_cb = new_combobox("Device:", frame_vbox, true);
|
||||
GtkWidget* rs_cb = new_combobox("Device:", frame_vbox, true);
|
||||
|
||||
const std::vector<uint16_t> whitelist{PAD_LG_FFB_WHITELIST};
|
||||
int idx = 0, sel_idx = 0;
|
||||
|
|
|
@ -831,13 +831,12 @@ namespace usb_pad
|
|||
cfg->pt[plyCapturing] = IsDlgButtonChecked(hW, IDC_DFP_PASS) > 0;
|
||||
break;
|
||||
case IDC_UNBIND:
|
||||
int sel;
|
||||
HWND lhW;
|
||||
lhW = GetDlgItem(hW, IDC_LIST1);
|
||||
while (1)
|
||||
{
|
||||
ZeroMemory(&lv, sizeof(LVITEM));
|
||||
sel = ListView_GetNextItem(lhW, -1, LVNI_SELECTED);
|
||||
int sel = ListView_GetNextItem(lhW, -1, LVNI_SELECTED);
|
||||
if (sel < 0)
|
||||
break;
|
||||
lv.iItem = sel;
|
||||
|
|
|
@ -101,14 +101,13 @@ namespace usb_pad
|
|||
return;
|
||||
|
||||
static int warned = 0;
|
||||
int caps = 0;
|
||||
DevCon.WriteLn("FFB %02X, %02X, %02X, %02X : %02X, %02X, %02X, %02X",
|
||||
ffdata->cmdslot, ffdata->type, ffdata->u.params[0], ffdata->u.params[1],
|
||||
ffdata->u.params[2], ffdata->u.params[3], ffdata->u.params[4], ffdata->padd0);
|
||||
|
||||
if (ffdata->cmdslot != CMD_EXTENDED_CMD)
|
||||
{
|
||||
|
||||
int caps = 0;
|
||||
uint8_t slots = (ffdata->cmdslot & 0xF0) >> 4;
|
||||
uint8_t cmd = ffdata->cmdslot & 0x0F;
|
||||
|
||||
|
|
Loading…
Reference in New Issue