src: Move control to input directory

This commit is contained in:
GPUCode 2024-04-14 00:41:51 +03:00
parent 5e2ac6c72b
commit 0a94899c86
5 changed files with 24 additions and 19 deletions

View File

@ -274,8 +274,8 @@ set(VIDEO_CORE src/core/PS4/HLE/Graphics/video_out.cpp
src/vulkan_util.h
)
set(HOST_SOURCES src/Emulator/Host/controller.cpp
src/Emulator/Host/controller.h
set(INPUT src/input/controller.cpp
src/input/controller.h
)
# the above is shared in sdl and qt version (TODO share them all)
@ -312,14 +312,19 @@ endif()
if(ENABLE_QT_GUI)
qt_add_executable(shadps4
${AUDIO_CORE}
${INPUT}
${QT_GUI}
${COMMON}
${CORE}
${VIDEO_CORE}
src/emulator.cpp
src/emulator.h
)
else()
add_executable(shadps4
${AUDIO_CORE}
${HOST_SOURCES}
${INPUT}
${COMMON}
${CORE}
${VIDEO_CORE}

View File

@ -1,12 +1,12 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "Emulator/Host/controller.h"
#include "common/logging/log.h"
#include "common/singleton.h"
#include "core/libraries/error_codes.h"
#include "core/libraries/libs.h"
#include "core/libraries/pad/pad.h"
#include "input/controller.h"
namespace Libraries::LibPad {
@ -22,11 +22,11 @@ int PS4_SYSV_ABI scePadOpen(Libraries::UserService::OrbisUserServiceUserId user_
}
int PS4_SYSV_ABI scePadReadState(int32_t handle, ScePadData* pData) {
auto* controller = Common::Singleton<Emulator::Host::Controller::GameController>::Instance();
auto* controller = Common::Singleton<Input::GameController>::Instance();
int connectedCount = 0;
bool isConnected = false;
Emulator::Host::Controller::State state;
Input::State state;
controller->readState(&state, &isConnected, &connectedCount);
pData->buttons = state.buttonsState;
@ -51,8 +51,8 @@ int PS4_SYSV_ABI scePadReadState(int32_t handle, ScePadData* pData) {
int PS4_SYSV_ABI scePadRead(int handle, ScePadData* pData, int num) {
int connected_count = 0;
bool connected = false;
Emulator::Host::Controller::State states[64];
auto* controller = Common::Singleton<Emulator::Host::Controller::GameController>::Instance();
Input::State states[64];
auto* controller = Common::Singleton<Input::GameController>::Instance();
int ret_num = controller->ReadStates(states, num, &connected, &connected_count);
if (!connected) {

View File

@ -2,14 +2,14 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include <fmt/core.h>
#include <vulkan_util.h>
#include "Emulator/Host/controller.h"
#include "common/singleton.h"
#include "common/version.h"
#include "core/PS4/HLE/Graphics/graphics_render.h"
#include "core/PS4/HLE/Graphics/video_out.h"
#include "core/libraries/pad/pad.h"
#include "emulator.h"
#include "input/controller.h"
#include "vulkan_util.h"
namespace Emu {
@ -344,8 +344,7 @@ void keyboardEvent(SDL_Event* event) {
break;
}
if (button != 0) {
auto* controller =
Common::Singleton<Emulator::Host::Controller::GameController>::Instance();
auto* controller = Common::Singleton<Input::GameController>::Instance();
controller->checKButton(0, button, event->type == SDL_EVENT_KEY_DOWN);
}
}

View File

@ -1,10 +1,10 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "Emulator/Host/controller.h"
#include "core/libraries/kernel/time_management.h"
#include "input/controller.h"
namespace Emulator::Host::Controller {
namespace Input {
GameController::GameController() {
m_states_num = 0;
@ -87,4 +87,4 @@ void GameController::checKButton(int id, u32 button, bool isPressed) {
addState(state);
}
} // namespace Emulator::Host::Controller
} // namespace Input

View File

@ -6,7 +6,8 @@
#include <mutex>
#include "common/types.h"
namespace Emulator::Host::Controller {
namespace Input {
struct State {
u32 buttonsState = 0;
u64 time = 0;
@ -36,8 +37,8 @@ private:
int m_connected_count = 0;
u32 m_states_num = 0;
u32 m_first_state = 0;
State m_states[MAX_STATES];
StateInternal m_private[MAX_STATES];
std::array<State, MAX_STATES> m_states;
std::array<StateInternal, MAX_STATES> m_private;
};
} // namespace Emulator::Host::Controller
} // namespace Input