2018-09-22 09:51:48 +02:00
|
|
|
|
#include "stdafx.h"
|
2018-01-17 17:14:00 +01:00
|
|
|
|
#include "overlays.h"
|
2018-05-20 22:05:00 +02:00
|
|
|
|
#include "../GSRender.h"
|
2018-01-17 17:14:00 +01:00
|
|
|
|
|
|
|
|
|
|
namespace rsx
|
|
|
|
|
|
{
|
|
|
|
|
|
namespace overlays
|
|
|
|
|
|
{
|
2018-10-02 20:27:13 +02:00
|
|
|
|
// Singleton instance declaration
|
2018-01-17 17:14:00 +01:00
|
|
|
|
fontmgr* fontmgr::m_instance = nullptr;
|
|
|
|
|
|
|
2018-12-30 02:34:15 +01:00
|
|
|
|
s32 user_interface::run_input_loop()
|
|
|
|
|
|
{
|
|
|
|
|
|
std::array<std::chrono::steady_clock::time_point, CELL_PAD_MAX_PORT_NUM> timestamp;
|
|
|
|
|
|
timestamp.fill(std::chrono::steady_clock::now());
|
|
|
|
|
|
|
|
|
|
|
|
std::array<std::array<bool, 8>, CELL_PAD_MAX_PORT_NUM> button_state;
|
|
|
|
|
|
for (auto& state : button_state)
|
|
|
|
|
|
{
|
|
|
|
|
|
state.fill(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
input_timer.Start();
|
|
|
|
|
|
|
2019-01-08 22:10:07 +01:00
|
|
|
|
pad::SetIntercepted(true);
|
2018-12-30 02:34:15 +01:00
|
|
|
|
|
|
|
|
|
|
while (!exit)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (Emu.IsStopped())
|
|
|
|
|
|
return selection_code::canceled;
|
|
|
|
|
|
|
|
|
|
|
|
std::this_thread::sleep_for(1ms);
|
|
|
|
|
|
|
|
|
|
|
|
std::lock_guard lock(pad::g_pad_mutex);
|
|
|
|
|
|
|
|
|
|
|
|
const auto handler = pad::get_current_handler();
|
|
|
|
|
|
|
|
|
|
|
|
const PadInfo& rinfo = handler->GetInfo();
|
|
|
|
|
|
|
|
|
|
|
|
if (Emu.IsPaused() || !rinfo.now_connect)
|
|
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int pad_index = -1;
|
|
|
|
|
|
for (const auto &pad : handler->GetPads())
|
|
|
|
|
|
{
|
|
|
|
|
|
if (++pad_index >= CELL_PAD_MAX_PORT_NUM)
|
|
|
|
|
|
{
|
|
|
|
|
|
LOG_FATAL(RSX, "The native overlay cannot handle more than 7 pads! Current number of pads: %d", pad_index + 1);
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (auto &button : pad->m_buttons)
|
|
|
|
|
|
{
|
|
|
|
|
|
u8 button_id = 255;
|
|
|
|
|
|
if (button.m_offset == CELL_PAD_BTN_OFFSET_DIGITAL1)
|
|
|
|
|
|
{
|
|
|
|
|
|
switch (button.m_outKeyCode)
|
|
|
|
|
|
{
|
|
|
|
|
|
case CELL_PAD_CTRL_LEFT:
|
|
|
|
|
|
button_id = pad_button::dpad_left;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case CELL_PAD_CTRL_RIGHT:
|
|
|
|
|
|
button_id = pad_button::dpad_right;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case CELL_PAD_CTRL_DOWN:
|
|
|
|
|
|
button_id = pad_button::dpad_down;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case CELL_PAD_CTRL_UP:
|
|
|
|
|
|
button_id = pad_button::dpad_up;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (button.m_offset == CELL_PAD_BTN_OFFSET_DIGITAL2)
|
|
|
|
|
|
{
|
|
|
|
|
|
switch (button.m_outKeyCode)
|
|
|
|
|
|
{
|
|
|
|
|
|
case CELL_PAD_CTRL_TRIANGLE:
|
|
|
|
|
|
button_id = pad_button::triangle;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case CELL_PAD_CTRL_CIRCLE:
|
|
|
|
|
|
button_id = g_cfg.sys.enter_button_assignment == enter_button_assign::circle ? pad_button::cross : pad_button::circle;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case CELL_PAD_CTRL_SQUARE:
|
|
|
|
|
|
button_id = pad_button::square;
|
|
|
|
|
|
break;
|
|
|
|
|
|
case CELL_PAD_CTRL_CROSS:
|
|
|
|
|
|
button_id = g_cfg.sys.enter_button_assignment == enter_button_assign::circle ? pad_button::circle : pad_button::cross;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (button_id < 255)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (button.m_pressed)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (button_id < 4) // d-pad button
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!button_state[pad_index][button_id] || input_timer.GetMsSince(timestamp[pad_index]) > 400)
|
|
|
|
|
|
{
|
|
|
|
|
|
// d-pad button was not pressed, or was pressed more than 400ms ago
|
|
|
|
|
|
timestamp[pad_index] = std::chrono::steady_clock::now();
|
|
|
|
|
|
on_button_pressed(static_cast<pad_button>(button_id));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (!button_state[pad_index][button_id])
|
|
|
|
|
|
{
|
|
|
|
|
|
// button was not pressed
|
|
|
|
|
|
on_button_pressed(static_cast<pad_button>(button_id));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
button_state[pad_index][button_id] = button.m_pressed;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (button.m_flush)
|
|
|
|
|
|
{
|
|
|
|
|
|
button.m_pressed = false;
|
|
|
|
|
|
button.m_flush = false;
|
|
|
|
|
|
button.m_value = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (exit)
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
refresh();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Unreachable
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-01-17 17:14:00 +01:00
|
|
|
|
void user_interface::close()
|
|
|
|
|
|
{
|
2018-10-02 20:27:13 +02:00
|
|
|
|
// Force unload
|
2018-01-17 17:14:00 +01:00
|
|
|
|
exit = true;
|
2018-05-20 22:05:00 +02:00
|
|
|
|
if (auto manager = fxm::get<display_manager>())
|
2018-06-08 15:20:38 +02:00
|
|
|
|
{
|
|
|
|
|
|
if (auto dlg = manager->get<rsx::overlays::message_dialog>())
|
|
|
|
|
|
{
|
|
|
|
|
|
if (dlg->progress_bar_count())
|
2018-06-19 09:15:47 +02:00
|
|
|
|
Emu.GetCallbacks().handle_taskbar_progress(0, 1);
|
2018-06-08 15:20:38 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-05-20 22:05:00 +02:00
|
|
|
|
manager->remove(uid);
|
2018-06-08 15:20:38 +02:00
|
|
|
|
}
|
2018-01-17 17:14:00 +01:00
|
|
|
|
|
2019-01-08 22:10:07 +01:00
|
|
|
|
pad::SetIntercepted(false);
|
2018-12-30 02:34:15 +01:00
|
|
|
|
|
2018-01-17 17:14:00 +01:00
|
|
|
|
if (on_close)
|
|
|
|
|
|
on_close(return_code);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-05-29 23:37:59 +02:00
|
|
|
|
void overlay::refresh()
|
2018-01-17 17:14:00 +01:00
|
|
|
|
{
|
2018-05-10 13:50:32 +02:00
|
|
|
|
if (auto rsxthr = rsx::get_current_renderer())
|
2018-01-17 17:14:00 +01:00
|
|
|
|
{
|
2018-07-11 22:51:29 +02:00
|
|
|
|
const auto now = get_system_time() - 1000000;
|
|
|
|
|
|
if ((now - rsxthr->last_flip_time) > min_refresh_duration_us)
|
|
|
|
|
|
{
|
2018-09-22 09:51:48 +02:00
|
|
|
|
rsxthr->async_flip_requested |= rsx::thread::flip_request::native_ui;
|
2018-07-11 22:51:29 +02:00
|
|
|
|
}
|
2018-01-17 17:14:00 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-05-29 23:37:59 +02:00
|
|
|
|
} // namespace overlays
|
|
|
|
|
|
} // namespace rsx
|