More warning cleanups (shadowed variables.)

This commit is contained in:
waltje
2018-05-05 15:46:31 -04:00
parent 57fc9ff122
commit 12bbba12e6
40 changed files with 691 additions and 667 deletions

View File

@@ -12,7 +12,7 @@
* and builds a complete Win32 DIALOG resource block in a
* buffer in memory, and then passes that to the API handler.
*
* Version: @(#)win_devconf.c 1.0.15 2018/05/02
* Version: @(#)win_devconf.c 1.0.16 2018/05/04
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -178,7 +178,7 @@ dlg_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
const device_config_selection_t *sel;
const device_t *dev = devconf_device;
const device_config_t *cfg = dev->config;
int c, cid, changed, id, val;
int c, cid, changed, d, id, val;
HWND h;
switch (message) {
@@ -386,8 +386,7 @@ dlg_proc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lParam)
case CONFIG_FNAME:
if (cid == id+1) {
int c, d;
HWND h = GetDlgItem(hdlg, id);
h = GetDlgItem(hdlg, id);
SendMessage(h, WM_GETTEXT, 511, (LPARAM)s);
char file_filter[512];
file_filter[0] = 0;
@@ -482,15 +481,19 @@ dlg_devconf(HWND hwnd, device_t *device)
/* Font style and size to use. */
*data++ = 9; /* point size */
data += MultiByteToWideChar(CP_ACP, 0, "Segoe UI", -1, data, 120);
if (((uintptr_t)data) & 2)
data++;
/* Now add the items from the configuration. */
id = IDC_CONFIG_BASE;
while (cfg->type != -1) {
/* Align 'data' to DWORD */
if (((uint32_t)data) & 3) pclog("DEVCONF: unaligned data %08lx !\n", data);
itm = (DLGITEMTEMPLATE *)data;
switch (cfg->type) {
case CONFIG_BINARY:
itm = (DLGITEMTEMPLATE *)data;
itm->style = WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX;
itm->x = 10;
itm->y = y;
@@ -514,7 +517,6 @@ dlg_devconf(HWND hwnd, device_t *device)
case CONFIG_HEX16:
case CONFIG_HEX20:
/* combo box */
itm = (DLGITEMTEMPLATE *)data;
itm->style = WS_CHILD | WS_VISIBLE | \
CBS_DROPDOWNLIST | WS_VSCROLL;
itm->x = 70;
@@ -556,7 +558,6 @@ dlg_devconf(HWND hwnd, device_t *device)
case CONFIG_SPINNER:
/* spinner */
itm = (DLGITEMTEMPLATE *)data;
itm->style = WS_CHILD | WS_VISIBLE | \
ES_AUTOHSCROLL | ES_NUMBER;
itm->dwExtendedStyle = WS_EX_CLIENTEDGE;
@@ -600,7 +601,6 @@ dlg_devconf(HWND hwnd, device_t *device)
case CONFIG_FNAME:
/* file */
itm = (DLGITEMTEMPLATE *)data;
itm->style = WS_CHILD | WS_VISIBLE | ES_READONLY;
itm->dwExtendedStyle = WS_EX_CLIENTEDGE;
itm->x = 70;

View File

@@ -13,7 +13,7 @@
* NOTE: Hacks currently needed to compile with MSVC; DX needs to
* be updated to 11 or 12 or so. --FvK
*
* Version: @(#)win_joystick.cpp 1.0.12 2018/05/03
* Version: @(#)win_joystick.cpp 1.0.13 2018/05/05
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -41,6 +41,7 @@
* Boston, MA 02111-1307
* USA.
*/
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#define DIRECTINPUT_VERSION 0x0800
#include <dinput.h>
@@ -328,7 +329,6 @@ joystick_process(void)
for (b = 0; b < 4; b++)
plat_joystick_state[c].p[b] = joystate.rgdwPOV[b];
// pclog("joystick %i - x=%i y=%i b[0]=%i b[1]=%i %i\n", c, joystick_state[c].x, joystick_state[c].y, joystick_state[c].b[0], joystick_state[c].b[1], joysticks_present);
}
for (c = 0; c < gamedev_get_max_joysticks(joystick_type); c++) {
@@ -377,7 +377,7 @@ static uint8_t joystickconfig_changed = 0;
static void
rebuild_axis_button_selections(HWND hdlg)
rebuild_selections(HWND hdlg)
{
int id = IDC_CONFIG_BASE + 2;
int c, d, joystick;
@@ -496,6 +496,76 @@ get_pov(HWND hdlg, int id)
}
static void
dlg_init(HWND hdlg)
{
HWND h;
int joystick;
int c, id;
int mapping;
int nr_axes;
int nr_povs;
h = GetDlgItem(hdlg, IDC_CONFIG_BASE);
id = IDC_CONFIG_BASE + 2;
joystick = joystick_state[joystick_nr].plat_joystick_nr;
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"None");
for (c = 0; c < joysticks_present; c++)
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)plat_joystick_state[c].name);
SendMessage(h, CB_SETCURSEL, joystick, 0);
rebuild_selections(hdlg);
if (joystick_state[joystick_nr].plat_joystick_nr) {
nr_axes = plat_joystick_state[joystick-1].nr_axes;
nr_povs = plat_joystick_state[joystick-1].nr_povs;
for (c = 0; c < gamedev_get_axis_count(joystick_config_type); c++) {
mapping = joystick_state[joystick_nr].axis_mapping[c];
h = GetDlgItem(hdlg, id);
if (mapping & POV_X)
SendMessage(h, CB_SETCURSEL, nr_axes + (mapping & 3)*2, 0);
else if (mapping & POV_Y)
SendMessage(h, CB_SETCURSEL, nr_axes + (mapping & 3)*2 + 1, 0);
else
SendMessage(h, CB_SETCURSEL, mapping, 0);
id += 2;
}
for (c = 0; c < gamedev_get_button_count(joystick_config_type); c++) {
h = GetDlgItem(hdlg, id);
SendMessage(h, CB_SETCURSEL, joystick_state[joystick_nr].button_mapping[c], 0);
id += 2;
}
for (c = 0; c < gamedev_get_pov_count(joystick_config_type); c++) {
h = GetDlgItem(hdlg, id);
mapping = joystick_state[joystick_nr].pov_mapping[c][0];
if (mapping & POV_X)
SendMessage(h, CB_SETCURSEL, (mapping & 3)*2, 0);
else if (mapping & POV_Y)
SendMessage(h, CB_SETCURSEL, (mapping & 3)*2 + 1, 0);
else
SendMessage(h, CB_SETCURSEL, mapping + nr_povs*2, 0);
id += 2;
h = GetDlgItem(hdlg, id);
mapping = joystick_state[joystick_nr].pov_mapping[c][1];
if (mapping & POV_X)
SendMessage(h, CB_SETCURSEL, (mapping & 3)*2, 0);
else if (mapping & POV_Y)
SendMessage(h, CB_SETCURSEL, (mapping & 3)*2 + 1, 0);
else
SendMessage(h, CB_SETCURSEL, mapping + nr_povs*2, 0);
id += 2;
}
}
}
#ifdef __amd64__
static LRESULT CALLBACK
#else
@@ -504,76 +574,19 @@ static BOOL CALLBACK
dlg_proc(HWND hdlg, UINT message, WPARAM wParam, UNUSED(LPARAM lParam))
{
HWND h;
int c;
int id;
int joystick;
int nr_axes;
int nr_povs;
int mapping;
int c, id;
switch (message) {
case WM_INITDIALOG:
h = GetDlgItem(hdlg, IDC_CONFIG_BASE);
id = IDC_CONFIG_BASE + 2;
joystick = joystick_state[joystick_nr].plat_joystick_nr;
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)"None");
for (c = 0; c < joysticks_present; c++)
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)plat_joystick_state[c].name);
SendMessage(h, CB_SETCURSEL, joystick, 0);
rebuild_axis_button_selections(hdlg);
if (joystick_state[joystick_nr].plat_joystick_nr) {
nr_axes = plat_joystick_state[joystick-1].nr_axes;
nr_povs = plat_joystick_state[joystick-1].nr_povs;
for (c = 0; c < gamedev_get_axis_count(joystick_config_type); c++) {
int mapping = joystick_state[joystick_nr].axis_mapping[c];
h = GetDlgItem(hdlg, id);
if (mapping & POV_X)
SendMessage(h, CB_SETCURSEL, nr_axes + (mapping & 3)*2, 0);
else if (mapping & POV_Y)
SendMessage(h, CB_SETCURSEL, nr_axes + (mapping & 3)*2 + 1, 0);
else
SendMessage(h, CB_SETCURSEL, mapping, 0);
id += 2;
}
for (c = 0; c < gamedev_get_button_count(joystick_config_type); c++) {
h = GetDlgItem(hdlg, id);
SendMessage(h, CB_SETCURSEL, joystick_state[joystick_nr].button_mapping[c], 0);
id += 2;
}
for (c = 0; c < gamedev_get_pov_count(joystick_config_type); c++) {
h = GetDlgItem(hdlg, id);
mapping = joystick_state[joystick_nr].pov_mapping[c][0];
if (mapping & POV_X)
SendMessage(h, CB_SETCURSEL, (mapping & 3)*2, 0);
else if (mapping & POV_Y)
SendMessage(h, CB_SETCURSEL, (mapping & 3)*2 + 1, 0);
else
SendMessage(h, CB_SETCURSEL, mapping + nr_povs*2, 0);
id += 2;
h = GetDlgItem(hdlg, id);
mapping = joystick_state[joystick_nr].pov_mapping[c][1];
if (mapping & POV_X)
SendMessage(h, CB_SETCURSEL, (mapping & 3)*2, 0);
else if (mapping & POV_Y)
SendMessage(h, CB_SETCURSEL, (mapping & 3)*2 + 1, 0);
else
SendMessage(h, CB_SETCURSEL, mapping + nr_povs*2, 0);
id += 2;
}
}
dialog_center(hdlg);
dlg_init(hdlg);
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_CONFIG_BASE:
if (HIWORD(wParam) == CBN_SELCHANGE)
rebuild_axis_button_selections(hdlg);
rebuild_selections(hdlg);
break;
case IDOK:
@@ -617,6 +630,7 @@ dlg_proc(HWND hdlg, UINT message, WPARAM wParam, UNUSED(LPARAM lParam))
}
/* Create an in-memory dialog template for the Joystick Configuration. */
uint8_t
dlg_jsconf(HWND hwnd, int joy_nr, int type)
{
@@ -714,7 +728,7 @@ dlg_jsconf(HWND hwnd, int joy_nr, int type)
*data++ = 0xFFFF;
*data++ = 0x0082; /* static class */
data += MultiByteToWideChar(CP_ACP, 0,
gamedev_get_axis_name(type, c), -1, (wchar_t *)data, 256);
gamedev_get_axis_name(type, c), -1, (wchar_t *)data, 256);
*data++ = 0; /* no creation data */
if (((uintptr_t)data) & 2)
data++;
@@ -735,7 +749,7 @@ dlg_jsconf(HWND hwnd, int joy_nr, int type)
*data++ = 0xFFFF;
*data++ = 0x0085; /* combo box class */
data += MultiByteToWideChar(CP_ACP, 0,
gamedev_get_button_name(type, c), -1, (wchar_t *)data, 256);
gamedev_get_button_name(type, c), -1, (wchar_t *)data, 256);
*data++ = 0; /* no creation data */
if (((uintptr_t)data) & 2)
data++;
@@ -752,7 +766,7 @@ dlg_jsconf(HWND hwnd, int joy_nr, int type)
*data++ = 0xFFFF;
*data++ = 0x0082; /* static class */
data += MultiByteToWideChar(CP_ACP, 0,
gamedev_get_button_name(type, c), -1, (wchar_t *)data, 256);
gamedev_get_button_name(type, c), -1, (wchar_t *)data, 256);
*data++ = 0; /* no creation data */
if (((uintptr_t)data) & 2)
data++;

View File

@@ -8,7 +8,7 @@
*
* Windows raw keyboard input handler.
*
* Version: @(#)win_keyboard.c 1.0.4 2018/04/26
* Version: @(#)win_keyboard.c 1.0.5 2018/05/04
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -55,21 +55,21 @@ static uint16_t scancode_map[768];
/* This is so we can disambiguate scan codes that would otherwise conflict and get
passed on incorrectly. */
static UINT16
convert_scan_code(UINT16 scan_code)
convert_scan_code(UINT16 code)
{
if ((scan_code & 0xFF00) == 0xE000) {
scan_code &= 0x00FF;
scan_code |= 0x0100;
} else if (scan_code == 0xE11D)
scan_code = 0xE000;
if ((code & 0xFF00) == 0xE000) {
code &= 0x00FF;
code |= 0x0100;
} else if (code == 0xE11D)
code = 0xE000;
/* E0 00 is sent by some USB keyboards for their special keys, as it is an
invalid scan code (it has no untranslated set 2 equivalent), we mark it
appropriately so it does not get passed through. */
else if ((scan_code > 0x00FF) || (scan_code == 0xE000)) {
scan_code = 0xFFFF;
else if ((code > 0x00FF) || (code == 0xE000)) {
code = 0xFFFF;
}
return scan_code;
return code;
}
@@ -128,15 +128,15 @@ keyboard_getkeymap(void)
void
keyboard_handle(LPARAM lParam, int infocus)
keyboard_handle(LPARAM lParam, int focus)
{
static int recv_lalt = 0, recv_ralt = 0, recv_tab = 0;
uint32_t ri_size = 0;
UINT size;
RAWINPUT *raw;
USHORT scancode;
static int recv_lalt = 0, recv_ralt = 0, recv_tab = 0;
USHORT code;
if (! infocus) return;
if (! focus) return;
GetRawInputData((HRAWINPUT)lParam, RID_INPUT, NULL,
&size, sizeof(RAWINPUTHEADER));
@@ -152,26 +152,26 @@ keyboard_handle(LPARAM lParam, int infocus)
/* If the input is keyboard, we process it */
if (raw->header.dwType == RIM_TYPEKEYBOARD) {
RAWKEYBOARD rawKB = raw->data.keyboard;
scancode = rawKB.MakeCode;
code = rawKB.MakeCode;
/* If it's not a scan code that starts with 0xE1 */
if (!(rawKB.Flags & RI_KEY_E1)) {
if (rawKB.Flags & RI_KEY_E0)
scancode |= (0xE0 << 8);
code |= (0xE0 << 8);
/* Translate the scan code to 9-bit */
scancode = convert_scan_code(scancode);
code = convert_scan_code(code);
/* Remap it according to the list from the Registry */
/* pclog("Scan code: %04X (map: %04X)\n", scancode, scancode_map[scancode]); */
scancode = scancode_map[scancode];
/* pclog("Scan code: %04X (map: %04X)\n", code, scancode_map[code]); */
code = scancode_map[code];
/* If it's not 0xFFFF, send it to the emulated
keyboard.
We use scan code 0xFFFF to mean a mapping that
has a prefix other than E0 and that is not E1 1D,
which is, for our purposes, invalid. */
if ((scancode == 0x00F) &&
if ((code == 0x00F) &&
!(rawKB.Flags & RI_KEY_BREAK) &&
(recv_lalt || recv_ralt) &&
!mouse_capture) {
@@ -193,7 +193,7 @@ keyboard_handle(LPARAM lParam, int infocus)
keyboard_input(0, 0x138);
recv_ralt = 0;
}
} else if (((scancode == 0x038) || (scancode == 0x138)) &&
} else if (((code == 0x038) || (code == 0x138)) &&
!(rawKB.Flags & RI_KEY_BREAK) &&
recv_tab &&
!mouse_capture) {
@@ -202,7 +202,7 @@ keyboard_handle(LPARAM lParam, int infocus)
keyboard_input(0, 0x00F);
recv_tab = 0;
} else {
switch(scancode) {
switch(code) {
case 0x00F:
recv_tab = !(rawKB.Flags & RI_KEY_BREAK);
break;
@@ -216,25 +216,27 @@ keyboard_handle(LPARAM lParam, int infocus)
/* Translate right CTRL to left ALT if the user has so
chosen. */
if ((scancode == 0x11D) && rctrl_is_lalt)
scancode = 0x038;
if ((code == 0x11D) && rctrl_is_lalt)
code = 0x038;
/* Normal scan code pass through, pass it through as is if
it's not an invalid scan code. */
if (scancode != 0xFFFF)
keyboard_input(!(rawKB.Flags & RI_KEY_BREAK), scancode);
if (code != 0xFFFF)
keyboard_input(!(rawKB.Flags & RI_KEY_BREAK), code);
}
} else {
if (rawKB.MakeCode == 0x1D) {
scancode = scancode_map[0x100]; /* Translate E1 1D to 0x100 (which would
otherwise be E0 00 but that is invalid
anyway).
Also, take a potential mapping into
account. */
/* Translate E1 1D to 0x100 (which would
otherwise be E0 00 but that is invalid
anyway).
Also, take a potential mapping into
account. */
code = scancode_map[0x100];
} else
scancode = 0xFFFF;
if (scancode != 0xFFFF)
keyboard_input(!(rawKB.Flags & RI_KEY_BREAK), scancode);
code = 0xFFFF;
if (code != 0xFFFF)
keyboard_input(!(rawKB.Flags & RI_KEY_BREAK), code);
}
}

View File

@@ -8,7 +8,7 @@
*
* Implementation of the Settings dialog.
*
* Version: @(#)win_settings_periph.h 1.0.6 2018/05/02
* Version: @(#)win_settings_periph.h 1.0.7 2018/05/04
*
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com>
@@ -63,7 +63,7 @@ find_irq_in_array(int irq, int def)
static void
recalc_hdc_list(HWND hdlg, int machine, int use_selected_hdc)
recalc_hdc_list(HWND hdlg, int m, int use_selected_hdc)
{
WCHAR temp[128];
char old_name[32];
@@ -93,12 +93,12 @@ recalc_hdc_list(HWND hdlg, int machine, int use_selected_hdc)
if (stransi == NULL)
break;
if (c==1 && !(machines[temp_machine].flags&MACHINE_HDC)) {
if (c==1 && !(machines[m].flags&MACHINE_HDC)) {
/* Skip "Internal" if machine doesn't have one. */
c++;
continue;
}
if (!hdc_available(c) || !device_is_valid(hdc_get_device(c), machines[temp_machine].flags)) {
if (!hdc_available(c) || !device_is_valid(hdc_get_device(c), machines[m].flags)) {
c++;
continue;
}