Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cellOskDialog: Implement keyboard input support #11834

Merged
merged 16 commits into from Apr 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 15 additions & 5 deletions rpcs3/Emu/Cell/Modules/cellKb.cpp
Expand Up @@ -98,7 +98,7 @@ error_code cellKbClearBuf(u32 port_no)

for (int i = 0; i < CELL_KB_MAX_KEYCODES; i++)
{
current_data.keycode[i] = { 0, 0 };
current_data.buttons[i] = KbButton(CELL_KEYC_NO_EVENT, 0, false);
}

return CELL_OK;
Expand Down Expand Up @@ -304,15 +304,25 @@ error_code cellKbRead(u32 port_no, vm::ptr<CellKbData> data)
return CELL_KB_ERROR_NO_DEVICE;

KbData& current_data = handler.GetData(port_no);
data->led = current_data.led;
data->mkey = current_data.mkey;
data->len = std::min<s32>(CELL_KB_MAX_KEYCODES, current_data.len);

if (current_info.is_null_handler || (current_info.info & CELL_KB_INFO_INTERCEPTED))
{
data->led = 0;
data->mkey = 0;
data->len = 0;
}
else
{
data->led = current_data.led;
data->mkey = current_data.mkey;
data->len = std::min<s32>(CELL_KB_MAX_KEYCODES, current_data.len);
}

if (current_data.len > 0)
{
for (s32 i = 0; i < current_data.len; i++)
{
data->keycode[i] = current_data.keycode[i].first;
data->keycode[i] = current_data.buttons[i].m_keyCode;
}

KbConfig& current_config = handler.GetConfig(port_no);
Expand Down
2 changes: 2 additions & 0 deletions rpcs3/Emu/Cell/Modules/cellKb.h
Expand Up @@ -56,3 +56,5 @@ struct CellKbConfig
be_t<u32> read_mode;
be_t<u32> code_type;
};

u16 cellKbCnvRawCode(u32 arrange, u32 mkey, u32 led, u16 rawcode);
32 changes: 31 additions & 1 deletion rpcs3/Emu/Cell/Modules/cellMouse.cpp
Expand Up @@ -209,8 +209,9 @@ error_code cellMouseGetData(u32 port_no, vm::ptr<CellMouseData> data)

MouseDataList& data_list = handler.GetDataList(port_no);

if (data_list.empty())
if (data_list.empty() || current_info.is_null_handler || (current_info.info & CELL_MOUSE_INFO_INTERCEPTED))
{
data_list.clear();
return CELL_OK;
}

Expand Down Expand Up @@ -252,9 +253,18 @@ error_code cellMouseGetDataList(u32 port_no, vm::ptr<CellMouseDataList> data)
return CELL_MOUSE_ERROR_NO_DEVICE;
}

std::memset(data.get_ptr(), 0, data.size());

// TODO: check if (current_info.mode[port_no] != CELL_MOUSE_INFO_TABLET_MOUSE_MODE) has any impact

auto& list = handler.GetDataList(port_no);

if (list.empty() || current_info.is_null_handler || (current_info.info & CELL_MOUSE_INFO_INTERCEPTED))
{
list.clear();
return CELL_OK;
}

data->list_num = std::min<u32>(CELL_MOUSE_MAX_DATA_LIST_NUM, static_cast<u32>(list.size()));

int i = 0;
Expand Down Expand Up @@ -332,10 +342,19 @@ error_code cellMouseGetTabletDataList(u32 port_no, vm::ptr<CellMouseTabletDataLi
return CELL_MOUSE_ERROR_NO_DEVICE;
}

std::memset(data.get_ptr(), 0, data.size());

// TODO: decr tests show that CELL_MOUSE_ERROR_DATA_READ_FAILED is returned when a mouse is connected
// TODO: check if (current_info.mode[port_no] != CELL_MOUSE_INFO_TABLET_TABLET_MODE) has any impact

auto& list = handler.GetTabletDataList(port_no);

if (list.empty() || current_info.is_null_handler || (current_info.info & CELL_MOUSE_INFO_INTERCEPTED))
{
list.clear();
return CELL_OK;
}

data->list_num = std::min<u32>(CELL_MOUSE_MAX_DATA_LIST_NUM, static_cast<u32>(list.size()));

int i = 0;
Expand All @@ -351,6 +370,8 @@ error_code cellMouseGetTabletDataList(u32 port_no, vm::ptr<CellMouseTabletDataLi
}
}

list.clear();

return CELL_OK;
}

Expand All @@ -377,10 +398,19 @@ error_code cellMouseGetRawData(u32 port_no, vm::ptr<CellMouseRawData> data)
return CELL_MOUSE_ERROR_NO_DEVICE;
}

std::memset(data.get_ptr(), 0, data.size());

// TODO: decr tests show that CELL_MOUSE_ERROR_DATA_READ_FAILED is returned when a mouse is connected
// TODO: check if (current_info.mode[port_no] != CELL_MOUSE_INFO_TABLET_MOUSE_MODE) has any impact

MouseRawData& current_data = handler.GetRawData(port_no);

if (current_info.is_null_handler || (current_info.info & CELL_MOUSE_INFO_INTERCEPTED))
{
current_data = {};
return CELL_OK;
}

data->len = current_data.len;
current_data.len = 0;

Expand Down
12 changes: 6 additions & 6 deletions rpcs3/Emu/Cell/Modules/cellMusic.cpp
Expand Up @@ -168,7 +168,7 @@ error_code cellMusicSetSelectionContext2(vm::ptr<CellMusicSelectionContext> cont

error_code cellMusicSetVolume2(f32 level)
{
cellMusic.todo("cellMusicSetVolume2(level=%f)", level);
cellMusic.warning("cellMusicSetVolume2(level=%f)", level);

level = std::clamp(level, 0.0f, 1.0f);

Expand Down Expand Up @@ -260,7 +260,7 @@ error_code cellMusicInitialize2SystemWorkload(s32 mode, vm::ptr<CellMusic2Callba

error_code cellMusicGetPlaybackStatus2(vm::ptr<s32> status)
{
cellMusic.todo("cellMusicGetPlaybackStatus2(status=*0x%x)", status);
cellMusic.warning("cellMusicGetPlaybackStatus2(status=*0x%x)", status);

if (!status)
return CELL_MUSIC2_ERROR_PARAM;
Expand Down Expand Up @@ -389,7 +389,7 @@ error_code cellMusicGetSelectionContext2(vm::ptr<CellMusicSelectionContext> cont

error_code cellMusicGetVolume(vm::ptr<f32> level)
{
cellMusic.todo("cellMusicGetVolume(level=*0x%x)", level);
cellMusic.warning("cellMusicGetVolume(level=*0x%x)", level);

if (!level)
return CELL_MUSIC_ERROR_PARAM;
Expand All @@ -402,7 +402,7 @@ error_code cellMusicGetVolume(vm::ptr<f32> level)

error_code cellMusicGetPlaybackStatus(vm::ptr<s32> status)
{
cellMusic.todo("cellMusicGetPlaybackStatus(status=*0x%x)", status);
cellMusic.warning("cellMusicGetPlaybackStatus(status=*0x%x)", status);

if (!status)
return CELL_MUSIC_ERROR_PARAM;
Expand Down Expand Up @@ -567,7 +567,7 @@ error_code cellMusicInitialize2(s32 mode, s32 spuPriority, vm::ptr<CellMusic2Cal

error_code cellMusicSetVolume(f32 level)
{
cellMusic.todo("cellMusicSetVolume(level=%f)", level);
cellMusic.warning("cellMusicSetVolume(level=%f)", level);

level = std::clamp(level, 0.0f, 1.0f);

Expand All @@ -589,7 +589,7 @@ error_code cellMusicSetVolume(f32 level)

error_code cellMusicGetVolume2(vm::ptr<f32> level)
{
cellMusic.todo("cellMusicGetVolume2(level=*0x%x)", level);
cellMusic.warning("cellMusicGetVolume2(level=*0x%x)", level);

if (!level)
return CELL_MUSIC2_ERROR_PARAM;
Expand Down