Mem leaks in input mapping/jvs/x11. Fix crash when latin-1 char is input
Fix warnings
This commit is contained in:
parent
aff2b9e1af
commit
4e73af0f94
|
@ -1,3 +1,4 @@
|
|||
#include <memory>
|
||||
#include "types.h"
|
||||
#include "maple_if.h"
|
||||
#include "maple_helper.h"
|
||||
|
@ -1807,7 +1808,7 @@ struct maple_naomi_jamma : maple_sega_controller
|
|||
{
|
||||
const u8 ALL_NODES = 0xff;
|
||||
|
||||
std::vector<jvs_io_board *> io_boards;
|
||||
std::vector<std::unique_ptr<jvs_io_board>> io_boards;
|
||||
bool crazy_mode = false;
|
||||
|
||||
u8 jvs_repeat_request[32][256];
|
||||
|
@ -1819,43 +1820,43 @@ struct maple_naomi_jamma : maple_sega_controller
|
|||
switch (settings.input.JammaSetup)
|
||||
{
|
||||
case 0:
|
||||
io_boards.push_back(new jvs_837_13551(1, this));
|
||||
io_boards.emplace_back(new jvs_837_13551(1, this));
|
||||
break;
|
||||
case 1:
|
||||
io_boards.push_back(new jvs_837_13551_4P(1, this));
|
||||
io_boards.emplace_back(new jvs_837_13551_4P(1, this));
|
||||
break;
|
||||
case 2:
|
||||
io_boards.push_back(new jvs_837_13938(1, this));
|
||||
io_boards.push_back(new jvs_837_13551(2, this));
|
||||
io_boards.emplace_back(new jvs_837_13938(1, this));
|
||||
io_boards.emplace_back(new jvs_837_13551(2, this));
|
||||
break;
|
||||
case 3: // Sega Marine Fishing
|
||||
io_boards.push_back(new jvs_837_13844(1, this));
|
||||
io_boards.emplace_back(new jvs_837_13844(1, this));
|
||||
break;
|
||||
case 4:
|
||||
io_boards.push_back(new jvs_837_13551(1, this));
|
||||
io_boards.push_back(new jvs_837_13551(2, this, 2));
|
||||
io_boards.emplace_back(new jvs_837_13551(1, this));
|
||||
io_boards.emplace_back(new jvs_837_13551(2, this, 2));
|
||||
break;
|
||||
case 5: // Ninja Assault
|
||||
io_boards.push_back(new jvs_namco_jyu(1, this));
|
||||
io_boards.emplace_back(new jvs_namco_jyu(1, this));
|
||||
break;
|
||||
case 6: // Mazan
|
||||
io_boards.push_back(new jvs_namco_fcb(1, this));
|
||||
io_boards.push_back(new jvs_namco_fcb(2, this));
|
||||
io_boards.emplace_back(new jvs_namco_fcb(1, this));
|
||||
io_boards.emplace_back(new jvs_namco_fcb(2, this));
|
||||
break;
|
||||
case 7: // Gun Survivor
|
||||
io_boards.push_back(new jvs_namco_fca(1, this));
|
||||
io_boards.emplace_back(new jvs_namco_fca(1, this));
|
||||
break;
|
||||
case 8: // Dog Walking
|
||||
io_boards.push_back(new jvs_837_13844_encoders(1, this));
|
||||
io_boards.emplace_back(new jvs_837_13844_encoders(1, this));
|
||||
break;
|
||||
case 9: // Touch de Uno
|
||||
io_boards.push_back(new jvs_837_13844_touch(1, this));
|
||||
io_boards.emplace_back(new jvs_837_13844_touch(1, this));
|
||||
break;
|
||||
case 10: // World Kicks
|
||||
io_boards.push_back(new jvs_namco_v226(1, this));
|
||||
io_boards.emplace_back(new jvs_namco_v226(1, this));
|
||||
break;
|
||||
case 11: // World Kicks PCB
|
||||
io_boards.push_back(new jvs_namco_v226_pcb(1, this));
|
||||
io_boards.emplace_back(new jvs_namco_v226_pcb(1, this));
|
||||
break;
|
||||
}
|
||||
if (settings.input.JammaSetup != 6)
|
||||
|
|
|
@ -48,7 +48,7 @@ bool GamepadDevice::gamepad_btn_input(u32 code, bool pressed)
|
|||
_input_detected(code);
|
||||
_input_detected = NULL;
|
||||
}
|
||||
if (input_mapper == NULL || _maple_port < 0 || _maple_port >= ARRAY_SIZE(kcode))
|
||||
if (!input_mapper || _maple_port < 0 || _maple_port >= ARRAY_SIZE(kcode))
|
||||
return false;
|
||||
DreamcastKey key = input_mapper->get_button_id(code);
|
||||
if (key == EMU_BTN_NONE)
|
||||
|
@ -141,7 +141,7 @@ bool GamepadDevice::gamepad_axis_input(u32 code, int value)
|
|||
_input_detected(code);
|
||||
_input_detected = NULL;
|
||||
}
|
||||
if (input_mapper == NULL || _maple_port < 0 || _maple_port >= ARRAY_SIZE(kcode))
|
||||
if (!input_mapper || _maple_port < 0 || _maple_port >= ARRAY_SIZE(kcode))
|
||||
return false;
|
||||
DreamcastKey key = input_mapper->get_axis_id(code);
|
||||
|
||||
|
@ -247,7 +247,7 @@ bool GamepadDevice::find_mapping(const char *custom_mapping /* = NULL */)
|
|||
mapping_file = make_mapping_filename();
|
||||
|
||||
input_mapper = InputMapping::LoadMapping(mapping_file.c_str());
|
||||
return input_mapper != NULL;
|
||||
return !!input_mapper;
|
||||
}
|
||||
|
||||
int GamepadDevice::GetGamepadCount()
|
||||
|
@ -272,9 +272,10 @@ std::shared_ptr<GamepadDevice> GamepadDevice::GetGamepad(int index)
|
|||
|
||||
void GamepadDevice::save_mapping()
|
||||
{
|
||||
if (input_mapper == NULL)
|
||||
if (!input_mapper)
|
||||
return;
|
||||
input_mapper->save(make_mapping_filename().c_str());
|
||||
std::string filename = make_mapping_filename();
|
||||
InputMapping::SaveMapping(filename.c_str(), input_mapper);
|
||||
}
|
||||
|
||||
void UpdateVibration(u32 port, float power, float inclination, u32 duration_ms)
|
||||
|
|
|
@ -42,9 +42,9 @@ public:
|
|||
{
|
||||
_input_detected = NULL;
|
||||
}
|
||||
InputMapping *get_input_mapping() { return input_mapper; }
|
||||
std::shared_ptr<InputMapping> get_input_mapping() { return input_mapper; }
|
||||
void save_mapping();
|
||||
bool remappable() { return _remappable && input_mapper != NULL; }
|
||||
bool remappable() { return _remappable && input_mapper; }
|
||||
virtual bool is_virtual_gamepad() { return false; }
|
||||
|
||||
virtual void rumble(float power, float inclination, u32 duration_ms) {}
|
||||
|
@ -61,7 +61,7 @@ public:
|
|||
|
||||
protected:
|
||||
GamepadDevice(int maple_port, const char *api_name, bool remappable = true)
|
||||
: _api_name(api_name), _maple_port(maple_port), input_mapper(NULL), _input_detected(NULL), _remappable(remappable)
|
||||
: _api_name(api_name), _maple_port(maple_port), _input_detected(nullptr), _remappable(remappable)
|
||||
{
|
||||
}
|
||||
bool find_mapping(const char *custom_mapping = NULL);
|
||||
|
@ -70,7 +70,7 @@ protected:
|
|||
|
||||
std::string _name;
|
||||
std::string _unique_id = "";
|
||||
InputMapping *input_mapper;
|
||||
std::shared_ptr<InputMapping> input_mapper;
|
||||
std::map<u32, int> axis_min_values;
|
||||
std::map<u32, unsigned int> axis_ranges;
|
||||
bool _rumble_enabled = true;
|
||||
|
@ -83,7 +83,7 @@ private:
|
|||
std::string _api_name;
|
||||
int _maple_port;
|
||||
bool _detecting_button = false;
|
||||
double _detection_start_time;
|
||||
double _detection_start_time = 0.0;
|
||||
input_detected_cb _input_detected;
|
||||
bool _remappable;
|
||||
float _dead_zone = 0.1f;
|
||||
|
|
|
@ -48,12 +48,12 @@ public:
|
|||
virtual void keyboard_input(Keycode keycode, bool pressed, int modifier_keys = 0);
|
||||
|
||||
protected:
|
||||
KeyboardDeviceTemplate(int maple_port) : KeyboardDevice(maple_port), _kb_used(0), _modifier_keys(0) {}
|
||||
KeyboardDeviceTemplate(int maple_port) : KeyboardDevice(maple_port), _modifier_keys(0), _kb_used(0) {}
|
||||
virtual u8 convert_keycode(Keycode keycode) = 0;
|
||||
|
||||
private:
|
||||
int _modifier_keys;
|
||||
int _kb_used;
|
||||
u32 _kb_used;
|
||||
};
|
||||
|
||||
extern u8 kb_key[6]; // normal keys pressed
|
||||
|
@ -84,7 +84,7 @@ void KeyboardDeviceTemplate<Keycode>::keyboard_input(Keycode keycode, bool press
|
|||
if (_kb_used < ARRAY_SIZE(kb_key))
|
||||
{
|
||||
bool found = false;
|
||||
for (int i = 0; !found && i < _kb_used; i++)
|
||||
for (u32 i = 0; !found && i < _kb_used; i++)
|
||||
{
|
||||
if (kb_key[i] == dc_keycode)
|
||||
found = true;
|
||||
|
@ -95,12 +95,12 @@ void KeyboardDeviceTemplate<Keycode>::keyboard_input(Keycode keycode, bool press
|
|||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < _kb_used; i++)
|
||||
for (u32 i = 0; i < _kb_used; i++)
|
||||
{
|
||||
if (kb_key[i] == dc_keycode)
|
||||
{
|
||||
_kb_used--;
|
||||
for (int j = i; j < ARRAY_SIZE(kb_key) - 1; j++)
|
||||
for (u32 j = i; j < ARRAY_SIZE(kb_key) - 1; j++)
|
||||
kb_key[j] = kb_key[j + 1];
|
||||
kb_key[ARRAY_SIZE(kb_key) - 1] = 0;
|
||||
break;
|
||||
|
|
|
@ -70,7 +70,7 @@ axis_list[] =
|
|||
{ EMU_AXIS_DPAD2_Y, "compat", "axis_dpad2_y", "compat", "axis_dpad2_y_inverted" }
|
||||
};
|
||||
|
||||
std::map<std::string, InputMapping *> InputMapping::loaded_mappings;
|
||||
std::map<std::string, std::shared_ptr<InputMapping>> InputMapping::loaded_mappings;
|
||||
|
||||
void InputMapping::set_button(DreamcastKey id, u32 code)
|
||||
{
|
||||
|
@ -154,7 +154,7 @@ u32 InputMapping::get_axis_code(DreamcastKey key)
|
|||
return -1;
|
||||
}
|
||||
|
||||
InputMapping *InputMapping::LoadMapping(const char *name)
|
||||
std::shared_ptr<InputMapping> InputMapping::LoadMapping(const char *name)
|
||||
{
|
||||
auto it = loaded_mappings.find(name);
|
||||
if (it != loaded_mappings.end())
|
||||
|
@ -164,7 +164,7 @@ InputMapping *InputMapping::LoadMapping(const char *name)
|
|||
FILE *fp = fopen(path.c_str(), "r");
|
||||
if (fp == NULL)
|
||||
return NULL;
|
||||
InputMapping *mapping = new InputMapping();
|
||||
std::shared_ptr<InputMapping> mapping = std::make_shared<InputMapping>();
|
||||
mapping->load(fp);
|
||||
fclose(fp);
|
||||
loaded_mappings[name] = mapping;
|
||||
|
@ -174,7 +174,6 @@ InputMapping *InputMapping::LoadMapping(const char *name)
|
|||
|
||||
bool InputMapping::save(const char *name)
|
||||
{
|
||||
loaded_mappings[name] = this;
|
||||
if (!dirty)
|
||||
return true;
|
||||
|
||||
|
@ -217,3 +216,9 @@ bool InputMapping::save(const char *name)
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
void InputMapping::SaveMapping(const char *name, std::shared_ptr<InputMapping> mapping)
|
||||
{
|
||||
mapping->save(name);
|
||||
InputMapping::loaded_mappings[name] = mapping;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
#pragma once
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <cstdio>
|
||||
#include "types.h"
|
||||
#include "gamepad.h"
|
||||
|
@ -70,7 +71,8 @@ public:
|
|||
|
||||
bool is_dirty() { return dirty; }
|
||||
|
||||
static InputMapping *LoadMapping(const char *name);
|
||||
static std::shared_ptr<InputMapping> LoadMapping(const char *name);
|
||||
static void SaveMapping(const char *name, std::shared_ptr<InputMapping> mapping);
|
||||
|
||||
protected:
|
||||
bool dirty = false;
|
||||
|
@ -80,7 +82,7 @@ private:
|
|||
std::map<u32, DreamcastKey> axes;
|
||||
std::map<u32, bool> axes_inverted;
|
||||
|
||||
static std::map<std::string, InputMapping *> loaded_mappings;
|
||||
static std::map<std::string, std::shared_ptr<InputMapping>> loaded_mappings;
|
||||
};
|
||||
|
||||
class IdentityInputMapping : public InputMapping
|
||||
|
|
|
@ -68,7 +68,7 @@ void dispmanx_window_create()
|
|||
dispman_element = vc_dispmanx_element_add(dispman_update, dispman_display,
|
||||
0 /*layer*/, &dst_rect, 0 /*src*/,
|
||||
&src_rect, DISPMANX_PROTECTION_NONE,
|
||||
&dispman_alpha /*alpha*/, 0 /*clamp*/, 0 /*transform*/);
|
||||
&dispman_alpha /*alpha*/, 0 /*clamp*/, (DISPMANX_TRANSFORM_T)0 /*transform*/);
|
||||
|
||||
static EGL_DISPMANX_WINDOW_T native_window;
|
||||
native_window.element = dispman_element;
|
||||
|
|
|
@ -51,10 +51,10 @@ public:
|
|||
if (find_mapping(mapping_file))
|
||||
{
|
||||
INFO_LOG(INPUT, "using default mapping '%s'", input_mapper->name.c_str());
|
||||
input_mapper = new InputMapping(*input_mapper);
|
||||
input_mapper = std::make_shared<InputMapping>(*input_mapper);
|
||||
}
|
||||
else
|
||||
input_mapper = new IdentityInputMapping();
|
||||
input_mapper = std::make_shared<IdentityInputMapping>();
|
||||
input_mapper->name = _name + " mapping";
|
||||
save_mapping();
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public:
|
|||
_name = "Mouse";
|
||||
_unique_id = "x11_mouse";
|
||||
if (!find_mapping())
|
||||
input_mapper = new MouseInputMapping();
|
||||
input_mapper = std::make_shared<MouseInputMapping>();
|
||||
}
|
||||
bool gamepad_btn_input(u32 code, bool pressed) override
|
||||
{
|
||||
|
@ -113,7 +113,7 @@ void event_x11_handle()
|
|||
XNextEvent(x11_disp, &event);
|
||||
|
||||
if (event.type == ClientMessage &&
|
||||
event.xclient.data.l[0] == wmDeleteMessage)
|
||||
(unsigned long)event.xclient.data.l[0] == wmDeleteMessage)
|
||||
dc_exit();
|
||||
else if (event.type == ConfigureNotify)
|
||||
{
|
||||
|
@ -365,9 +365,6 @@ void x11_window_create()
|
|||
float ydpi = (float)DisplayHeight(x11_disp, x11Screen) / DisplayHeightMM(x11_disp, x11Screen) * 25.4;
|
||||
screen_dpi = max(xdpi, ydpi);
|
||||
|
||||
// Gets the window parameters
|
||||
Window sRootWindow = RootWindow(x11_disp, x11Screen);
|
||||
|
||||
int depth = CopyFromParent;
|
||||
|
||||
XVisualInfo* x11Visual = nullptr;
|
||||
|
@ -386,6 +383,8 @@ void x11_window_create()
|
|||
delete x11Visual;
|
||||
return;
|
||||
}
|
||||
// Gets the window parameters
|
||||
Window sRootWindow = RootWindow(x11_disp, x11Screen);
|
||||
x11Colormap = XCreateColormap(x11_disp, sRootWindow, x11Visual->visual, AllocNone);
|
||||
#endif
|
||||
XSetWindowAttributes sWA;
|
||||
|
@ -409,6 +408,11 @@ void x11_window_create()
|
|||
// Creates the X11 window
|
||||
x11_win = XCreateWindow(x11_disp, RootWindow(x11_disp, x11Screen), 0, 0, x11_width, x11_height,
|
||||
0, depth, InputOutput, x11Visual->visual, ui32Mask, &sWA);
|
||||
#if !defined(GLES)
|
||||
XFree(x11Visual);
|
||||
#else
|
||||
delete x11Visual;
|
||||
#endif
|
||||
|
||||
XSetWindowBackground(x11_disp, x11_win, 0);
|
||||
|
||||
|
|
|
@ -184,6 +184,6 @@ public:
|
|||
_name = "Keyboard";
|
||||
_unique_id = "x11_keyboard";
|
||||
if (!find_mapping())
|
||||
input_mapper = new KbInputMapping();
|
||||
input_mapper = std::make_shared<KbInputMapping>();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -235,9 +235,16 @@ void ImGui_Impl_NewFrame()
|
|||
|
||||
if (KeyboardDevice::GetInstance() != NULL)
|
||||
{
|
||||
std::string input_text = KeyboardDevice::GetInstance()->get_character_input();
|
||||
const std::string input_text = KeyboardDevice::GetInstance()->get_character_input();
|
||||
if (io.WantCaptureKeyboard)
|
||||
io.AddInputCharactersUTF8(input_text.c_str());
|
||||
{
|
||||
for (const u8 b : input_text)
|
||||
// Cheap ISO Latin-1 to UTF-8 conversion
|
||||
if (b < 0x80)
|
||||
io.AddInputCharacter(b);
|
||||
else
|
||||
io.AddInputCharacter((0xc2 + (b > 0xbf)) | ((b & 0x3f) + 0x80) << 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -490,16 +497,16 @@ static void detect_input_popup(int index, bool analog)
|
|||
: arcade_button_mode ? arcade_button_names[index] : button_names[index]);
|
||||
double now = os_GetSeconds();
|
||||
ImGui::Text("Time out in %d s", (int)(5 - (now - map_start_time)));
|
||||
if (mapped_code != -1)
|
||||
if (mapped_code != (u32)-1)
|
||||
{
|
||||
InputMapping *input_mapping = mapped_device->get_input_mapping();
|
||||
std::shared_ptr<InputMapping> input_mapping = mapped_device->get_input_mapping();
|
||||
if (input_mapping != NULL)
|
||||
{
|
||||
if (analog)
|
||||
{
|
||||
u32 previous_mapping = input_mapping->get_axis_code(axis_keys[index]);
|
||||
bool inverted = false;
|
||||
if (previous_mapping != -1)
|
||||
if (previous_mapping != (u32)-1)
|
||||
inverted = input_mapping->get_axis_inverted(previous_mapping);
|
||||
// FIXME Allow inverted to be set
|
||||
input_mapping->set_axis(axis_keys[index], mapped_code, inverted);
|
||||
|
@ -534,7 +541,7 @@ static void controller_mapping_popup(std::shared_ptr<GamepadDevice> gamepad)
|
|||
- (col0_width + ImGui::GetStyle().ItemSpacing.x)
|
||||
- (ImGui::CalcTextSize("Map").x + ImGui::GetStyle().FramePadding.x * 2.0f + ImGui::GetStyle().ItemSpacing.x);
|
||||
|
||||
InputMapping *input_mapping = gamepad->get_input_mapping();
|
||||
std::shared_ptr<InputMapping> input_mapping = gamepad->get_input_mapping();
|
||||
if (input_mapping == NULL || ImGui::Button("Done", ImVec2(100 * scaling, 30 * scaling)))
|
||||
{
|
||||
ImGui::CloseCurrentPopup();
|
||||
|
@ -553,14 +560,14 @@ static void controller_mapping_popup(std::shared_ptr<GamepadDevice> gamepad)
|
|||
ImGui::Columns(3, "bindings", false);
|
||||
ImGui::SetColumnWidth(0, col0_width);
|
||||
ImGui::SetColumnWidth(1, col1_width);
|
||||
for (int j = 0; j < ARRAY_SIZE(button_keys); j++)
|
||||
for (u32 j = 0; j < ARRAY_SIZE(button_keys); j++)
|
||||
{
|
||||
sprintf(key_id, "key_id%d", j);
|
||||
ImGui::PushID(key_id);
|
||||
ImGui::Text("%s", arcade_button_mode ? arcade_button_names[j] : button_names[j]);
|
||||
ImGui::NextColumn();
|
||||
u32 code = input_mapping->get_button_code(button_keys[j]);
|
||||
if (code != -1)
|
||||
if (code != (u32)-1)
|
||||
ImGui::Text("%d", code);
|
||||
ImGui::NextColumn();
|
||||
if (ImGui::Button("Map"))
|
||||
|
@ -587,14 +594,14 @@ static void controller_mapping_popup(std::shared_ptr<GamepadDevice> gamepad)
|
|||
ImGui::SetColumnWidth(0, col0_width);
|
||||
ImGui::SetColumnWidth(1, col1_width);
|
||||
|
||||
for (int j = 0; j < ARRAY_SIZE(axis_keys); j++)
|
||||
for (u32 j = 0; j < ARRAY_SIZE(axis_keys); j++)
|
||||
{
|
||||
sprintf(key_id, "axis_id%d", j);
|
||||
ImGui::PushID(key_id);
|
||||
ImGui::Text("%s", axis_names[j]);
|
||||
ImGui::NextColumn();
|
||||
u32 code = input_mapping->get_axis_code(axis_keys[j]);
|
||||
if (code != -1)
|
||||
if (code != (u32)-1)
|
||||
ImGui::Text("%d", code);
|
||||
ImGui::NextColumn();
|
||||
if (ImGui::Button("Map"))
|
||||
|
@ -718,7 +725,7 @@ static void gui_display_settings()
|
|||
{
|
||||
for (int i = 0; i < IM_ARRAYSIZE(languages); i++)
|
||||
{
|
||||
bool is_selected = settings.dreamcast.language == i;
|
||||
bool is_selected = (int)settings.dreamcast.language == i;
|
||||
if (ImGui::Selectable(languages[i], &is_selected))
|
||||
settings.dreamcast.language = i;
|
||||
if (is_selected)
|
||||
|
@ -734,7 +741,7 @@ static void gui_display_settings()
|
|||
{
|
||||
for (int i = 0; i < IM_ARRAYSIZE(broadcast); i++)
|
||||
{
|
||||
bool is_selected = settings.dreamcast.broadcast == i;
|
||||
bool is_selected = (int)settings.dreamcast.broadcast == i;
|
||||
if (ImGui::Selectable(broadcast[i], &is_selected))
|
||||
settings.dreamcast.broadcast = i;
|
||||
if (is_selected)
|
||||
|
@ -750,7 +757,7 @@ static void gui_display_settings()
|
|||
{
|
||||
for (int i = 0; i < IM_ARRAYSIZE(region); i++)
|
||||
{
|
||||
bool is_selected = settings.dreamcast.region == i;
|
||||
bool is_selected = (int)settings.dreamcast.region == i;
|
||||
if (ImGui::Selectable(region[i], &is_selected))
|
||||
settings.dreamcast.region = i;
|
||||
if (is_selected)
|
||||
|
@ -766,7 +773,7 @@ static void gui_display_settings()
|
|||
{
|
||||
for (int i = 0; i < IM_ARRAYSIZE(cable); i++)
|
||||
{
|
||||
bool is_selected = i == 0 ? settings.dreamcast.cable <= 1 : settings.dreamcast.cable - 1 == i;
|
||||
bool is_selected = i == 0 ? (int)settings.dreamcast.cable <= 1 : (int)settings.dreamcast.cable - 1 == i;
|
||||
if (ImGui::Selectable(cable[i], &is_selected))
|
||||
settings.dreamcast.cable = i == 0 ? 0 : i + 1;
|
||||
if (is_selected)
|
||||
|
@ -777,7 +784,6 @@ static void gui_display_settings()
|
|||
ImGui::SameLine();
|
||||
ShowHelpMarker("Video connection type");
|
||||
|
||||
static int current_item;
|
||||
std::vector<const char *> paths;
|
||||
for (auto& path : settings.dreamcast.ContentPath)
|
||||
paths.push_back(path.c_str());
|
||||
|
@ -790,7 +796,7 @@ static void gui_display_settings()
|
|||
if (ImGui::ListBoxHeader("Content Location", size))
|
||||
{
|
||||
int to_delete = -1;
|
||||
for (int i = 0; i < settings.dreamcast.ContentPath.size(); i++)
|
||||
for (u32 i = 0; i < settings.dreamcast.ContentPath.size(); i++)
|
||||
{
|
||||
ImGui::PushID(settings.dreamcast.ContentPath[i].c_str());
|
||||
ImGui::AlignTextToFramePadding();
|
||||
|
@ -801,10 +807,10 @@ static void gui_display_settings()
|
|||
ImGui::PopID();
|
||||
}
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(24 * scaling, 3 * scaling));
|
||||
if (ImGui::Button("Add"))
|
||||
ImGui::OpenPopup("Select Directory");
|
||||
select_directory_popup("Select Directory", scaling, &directory_selected_callback);
|
||||
ImGui::PopStyleVar();
|
||||
if (ImGui::Button("Add"))
|
||||
ImGui::OpenPopup("Select Directory");
|
||||
select_directory_popup("Select Directory", scaling, &directory_selected_callback);
|
||||
ImGui::PopStyleVar();
|
||||
|
||||
ImGui::ListBoxFooter();
|
||||
if (to_delete >= 0)
|
||||
|
@ -1170,7 +1176,7 @@ static void gui_display_settings()
|
|||
if (ImGui::Selectable("none - No audio driver", &is_selected))
|
||||
settings.audio.backend = "none";
|
||||
|
||||
for (int i = 0; i < GetAudioBackendCount(); i++)
|
||||
for (u32 i = 0; i < GetAudioBackendCount(); i++)
|
||||
{
|
||||
backend = GetAudioBackend(i);
|
||||
is_selected = (settings.audio.backend == backend->slug);
|
||||
|
@ -1399,8 +1405,8 @@ static void gui_display_settings()
|
|||
ImGui_impl_RenderDrawData(ImGui::GetDrawData(), false);
|
||||
|
||||
if (vulkan ^ (settings.pvr.rend == 4 || settings.pvr.rend == 5))
|
||||
pvr_rend = !vulkan ? 0 : settings.pvr.rend == 3 ? 5 : 4;
|
||||
renderer_changed = pvr_rend;
|
||||
pvr_rend = !vulkan ? 0 : settings.pvr.rend == 3 ? 5 : 4;
|
||||
renderer_changed = pvr_rend;
|
||||
settings.dynarec.Enable = (bool)dynarec_enabled;
|
||||
}
|
||||
|
||||
|
@ -1793,10 +1799,10 @@ static ImTextureID vmu_lcd_tex_ids[8];
|
|||
void push_vmu_screen(int bus_id, int bus_port, u8* buffer)
|
||||
{
|
||||
int vmu_id = bus_id * 2 + bus_port;
|
||||
if (vmu_id < 0 || vmu_id >= ARRAY_SIZE(vmu_lcd_data))
|
||||
if (vmu_id < 0 || vmu_id >= (int)ARRAY_SIZE(vmu_lcd_data))
|
||||
return;
|
||||
u32 *p = &vmu_lcd_data[vmu_id][0];
|
||||
for (int i = 0; i < ARRAY_SIZE(vmu_lcd_data[vmu_id]); i++, buffer++)
|
||||
for (int i = 0; i < (int)ARRAY_SIZE(vmu_lcd_data[vmu_id]); i++, buffer++)
|
||||
*p++ = *buffer != 0 ? 0xFFFFFFFFu : 0xFF000000u;
|
||||
vmu_lcd_status[vmu_id] = true;
|
||||
vmu_lcd_changed[vmu_id] = true;
|
||||
|
@ -1861,7 +1867,7 @@ static void display_vmus()
|
|||
|
||||
static void reset_vmus()
|
||||
{
|
||||
for (int i = 0; i < ARRAY_SIZE(vmu_lcd_status); i++)
|
||||
for (u32 i = 0; i < ARRAY_SIZE(vmu_lcd_status); i++)
|
||||
vmu_lcd_status[i] = false;
|
||||
}
|
||||
|
||||
|
@ -1869,7 +1875,7 @@ static void term_vmus()
|
|||
{
|
||||
if (!settings.pvr.IsOpenGL())
|
||||
return;
|
||||
for (int i = 0; i < ARRAY_SIZE(vmu_lcd_status); i++)
|
||||
for (u32 i = 0; i < ARRAY_SIZE(vmu_lcd_status); i++)
|
||||
{
|
||||
if (vmu_lcd_tex_ids[i] != (ImTextureID)0)
|
||||
{
|
||||
|
|
|
@ -62,12 +62,12 @@ public:
|
|||
{
|
||||
if (_name == "Microsoft X-Box 360 pad")
|
||||
{
|
||||
input_mapper = new Xbox360InputMapping();
|
||||
input_mapper = std::make_shared<Xbox360InputMapping>();
|
||||
INFO_LOG(INPUT, "using Xbox 360 mapping");
|
||||
}
|
||||
else
|
||||
{
|
||||
input_mapper = new DefaultInputMapping();
|
||||
input_mapper = std::make_shared<DefaultInputMapping>();
|
||||
INFO_LOG(INPUT, "using default mapping");
|
||||
}
|
||||
save_mapping();
|
||||
|
@ -186,7 +186,7 @@ public:
|
|||
_name = "Keyboard";
|
||||
_unique_id = "sdl_keyboard";
|
||||
if (!find_mapping())
|
||||
input_mapper = new KbInputMapping();
|
||||
input_mapper = std::make_shared<KbInputMapping>();
|
||||
}
|
||||
virtual ~SDLKbGamepadDevice() {}
|
||||
};
|
||||
|
@ -213,7 +213,7 @@ public:
|
|||
_name = "Mouse";
|
||||
_unique_id = "sdl_mouse";
|
||||
if (!find_mapping())
|
||||
input_mapper = new MouseInputMapping();
|
||||
input_mapper = std::make_shared<MouseInputMapping>();
|
||||
}
|
||||
virtual ~SDLMouseGamepadDevice() {}
|
||||
bool gamepad_btn_input(u32 code, bool pressed) override
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
|
||||
if (XInputGetState(_xinput_port, &state) == 0)
|
||||
{
|
||||
if (input_mapper == NULL)
|
||||
if (!input_mapper)
|
||||
Open();
|
||||
u32 xbutton = state.Gamepad.wButtons;
|
||||
u32 changes = xbutton ^ last_buttons_state;
|
||||
|
@ -90,11 +90,11 @@ public:
|
|||
last_right_thumb_y = state.Gamepad.sThumbRY;
|
||||
}
|
||||
}
|
||||
else if (input_mapper != NULL)
|
||||
else if (input_mapper)
|
||||
{
|
||||
INFO_LOG(INPUT, "xinput: Controller '%s' on port %d disconnected", _name.c_str(), _xinput_port);
|
||||
GamepadDevice::Unregister(xinput_gamepads[_xinput_port]);
|
||||
input_mapper = NULL;
|
||||
input_mapper.reset();
|
||||
last_buttons_state = 0;
|
||||
last_left_trigger = 0;
|
||||
last_right_trigger = 0;
|
||||
|
@ -137,7 +137,7 @@ public:
|
|||
INFO_LOG(INPUT, "xinput: Opened controller '%s' on port %d", _name.c_str(), _xinput_port);
|
||||
if (!find_mapping())
|
||||
{
|
||||
input_mapper = new XInputMapping();
|
||||
input_mapper = std::make_shared<XInputMapping>();
|
||||
input_mapper->name = _name + " mapping";
|
||||
save_mapping();
|
||||
INFO_LOG(INPUT, "using default mapping");
|
||||
|
@ -236,7 +236,7 @@ public:
|
|||
_name = "Keyboard";
|
||||
_unique_id = "win_keyboard";
|
||||
if (!find_mapping())
|
||||
input_mapper = new KbInputMapping();
|
||||
input_mapper = std::make_shared<KbInputMapping>();
|
||||
}
|
||||
virtual ~WinKbGamepadDevice() {}
|
||||
};
|
||||
|
@ -263,7 +263,7 @@ public:
|
|||
_name = "Mouse";
|
||||
_unique_id = "win_mouse";
|
||||
if (!find_mapping())
|
||||
input_mapper = new MouseInputMapping();
|
||||
input_mapper = std::make_shared<MouseInputMapping>();
|
||||
}
|
||||
virtual ~WinMouseGamepadDevice() {}
|
||||
bool gamepad_btn_input(u32 code, bool pressed) override
|
||||
|
|
|
@ -95,7 +95,7 @@ public:
|
|||
INFO_LOG(INPUT, "Android: Opened joystick %d on port %d: '%s' descriptor '%s'", id, maple_port, _name.c_str(), _unique_id.c_str());
|
||||
if (id == VIRTUAL_GAMEPAD_ID)
|
||||
{
|
||||
input_mapper = new IdentityInputMapping();
|
||||
input_mapper = std::make_shared<IdentityInputMapping>();
|
||||
axis_min_values[DC_AXIS_X] = -128;
|
||||
axis_ranges[DC_AXIS_X] = 255;
|
||||
axis_min_values[DC_AXIS_Y] = -128;
|
||||
|
@ -108,9 +108,9 @@ public:
|
|||
else if (!find_mapping())
|
||||
{
|
||||
if (_name == "SHIELD Remote")
|
||||
input_mapper = new ShieldRemoteInputMapping();
|
||||
input_mapper = std::make_shared<ShieldRemoteInputMapping>();
|
||||
else
|
||||
input_mapper = new DefaultInputMapping();
|
||||
input_mapper = std::make_shared<DefaultInputMapping>();
|
||||
save_mapping();
|
||||
INFO_LOG(INPUT, "using default mapping");
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ public:
|
|||
_name = "Mouse";
|
||||
_unique_id = "android_mouse";
|
||||
if (!find_mapping())
|
||||
input_mapper = new MouseInputMapping();
|
||||
input_mapper = std::make_shared<MouseInputMapping>();
|
||||
}
|
||||
|
||||
bool gamepad_btn_input(u32 code, bool pressed) override
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
_name = "Keyboard";
|
||||
_unique_id = "osx_keyboard";
|
||||
if (!find_mapping())
|
||||
input_mapper = new KbInputMapping();
|
||||
input_mapper = std::make_shared<KbInputMapping>();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -65,7 +65,7 @@ public:
|
|||
_name = "Mouse";
|
||||
_unique_id = "osx_mouse";
|
||||
if (!find_mapping())
|
||||
input_mapper = new MouseInputMapping();
|
||||
input_mapper = std::make_shared<MouseInputMapping>();
|
||||
}
|
||||
bool gamepad_btn_input(u32 code, bool pressed) override
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue