src: Move control to input directory
This commit is contained in:
parent
5e2ac6c72b
commit
0a94899c86
|
@ -274,8 +274,8 @@ set(VIDEO_CORE src/core/PS4/HLE/Graphics/video_out.cpp
|
||||||
src/vulkan_util.h
|
src/vulkan_util.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(HOST_SOURCES src/Emulator/Host/controller.cpp
|
set(INPUT src/input/controller.cpp
|
||||||
src/Emulator/Host/controller.h
|
src/input/controller.h
|
||||||
)
|
)
|
||||||
|
|
||||||
# the above is shared in sdl and qt version (TODO share them all)
|
# the above is shared in sdl and qt version (TODO share them all)
|
||||||
|
@ -312,14 +312,19 @@ endif()
|
||||||
|
|
||||||
if(ENABLE_QT_GUI)
|
if(ENABLE_QT_GUI)
|
||||||
qt_add_executable(shadps4
|
qt_add_executable(shadps4
|
||||||
|
${AUDIO_CORE}
|
||||||
|
${INPUT}
|
||||||
${QT_GUI}
|
${QT_GUI}
|
||||||
${COMMON}
|
${COMMON}
|
||||||
${CORE}
|
${CORE}
|
||||||
|
${VIDEO_CORE}
|
||||||
|
src/emulator.cpp
|
||||||
|
src/emulator.h
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
add_executable(shadps4
|
add_executable(shadps4
|
||||||
${AUDIO_CORE}
|
${AUDIO_CORE}
|
||||||
${HOST_SOURCES}
|
${INPUT}
|
||||||
${COMMON}
|
${COMMON}
|
||||||
${CORE}
|
${CORE}
|
||||||
${VIDEO_CORE}
|
${VIDEO_CORE}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include "Emulator/Host/controller.h"
|
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/singleton.h"
|
#include "common/singleton.h"
|
||||||
#include "core/libraries/error_codes.h"
|
#include "core/libraries/error_codes.h"
|
||||||
#include "core/libraries/libs.h"
|
#include "core/libraries/libs.h"
|
||||||
#include "core/libraries/pad/pad.h"
|
#include "core/libraries/pad/pad.h"
|
||||||
|
#include "input/controller.h"
|
||||||
|
|
||||||
namespace Libraries::LibPad {
|
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) {
|
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;
|
int connectedCount = 0;
|
||||||
bool isConnected = false;
|
bool isConnected = false;
|
||||||
Emulator::Host::Controller::State state;
|
Input::State state;
|
||||||
|
|
||||||
controller->readState(&state, &isConnected, &connectedCount);
|
controller->readState(&state, &isConnected, &connectedCount);
|
||||||
pData->buttons = state.buttonsState;
|
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 PS4_SYSV_ABI scePadRead(int handle, ScePadData* pData, int num) {
|
||||||
int connected_count = 0;
|
int connected_count = 0;
|
||||||
bool connected = false;
|
bool connected = false;
|
||||||
Emulator::Host::Controller::State states[64];
|
Input::State states[64];
|
||||||
auto* controller = Common::Singleton<Emulator::Host::Controller::GameController>::Instance();
|
auto* controller = Common::Singleton<Input::GameController>::Instance();
|
||||||
int ret_num = controller->ReadStates(states, num, &connected, &connected_count);
|
int ret_num = controller->ReadStates(states, num, &connected, &connected_count);
|
||||||
|
|
||||||
if (!connected) {
|
if (!connected) {
|
||||||
|
|
|
@ -2,14 +2,14 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include <fmt/core.h>
|
#include <fmt/core.h>
|
||||||
#include <vulkan_util.h>
|
|
||||||
#include "Emulator/Host/controller.h"
|
|
||||||
#include "common/singleton.h"
|
#include "common/singleton.h"
|
||||||
#include "common/version.h"
|
#include "common/version.h"
|
||||||
#include "core/PS4/HLE/Graphics/graphics_render.h"
|
#include "core/PS4/HLE/Graphics/graphics_render.h"
|
||||||
#include "core/PS4/HLE/Graphics/video_out.h"
|
#include "core/PS4/HLE/Graphics/video_out.h"
|
||||||
#include "core/libraries/pad/pad.h"
|
#include "core/libraries/pad/pad.h"
|
||||||
#include "emulator.h"
|
#include "emulator.h"
|
||||||
|
#include "input/controller.h"
|
||||||
|
#include "vulkan_util.h"
|
||||||
|
|
||||||
namespace Emu {
|
namespace Emu {
|
||||||
|
|
||||||
|
@ -344,8 +344,7 @@ void keyboardEvent(SDL_Event* event) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (button != 0) {
|
if (button != 0) {
|
||||||
auto* controller =
|
auto* controller = Common::Singleton<Input::GameController>::Instance();
|
||||||
Common::Singleton<Emulator::Host::Controller::GameController>::Instance();
|
|
||||||
controller->checKButton(0, button, event->type == SDL_EVENT_KEY_DOWN);
|
controller->checKButton(0, button, event->type == SDL_EVENT_KEY_DOWN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include "Emulator/Host/controller.h"
|
|
||||||
#include "core/libraries/kernel/time_management.h"
|
#include "core/libraries/kernel/time_management.h"
|
||||||
|
#include "input/controller.h"
|
||||||
|
|
||||||
namespace Emulator::Host::Controller {
|
namespace Input {
|
||||||
|
|
||||||
GameController::GameController() {
|
GameController::GameController() {
|
||||||
m_states_num = 0;
|
m_states_num = 0;
|
||||||
|
@ -87,4 +87,4 @@ void GameController::checKButton(int id, u32 button, bool isPressed) {
|
||||||
addState(state);
|
addState(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Emulator::Host::Controller
|
} // namespace Input
|
|
@ -6,7 +6,8 @@
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include "common/types.h"
|
#include "common/types.h"
|
||||||
|
|
||||||
namespace Emulator::Host::Controller {
|
namespace Input {
|
||||||
|
|
||||||
struct State {
|
struct State {
|
||||||
u32 buttonsState = 0;
|
u32 buttonsState = 0;
|
||||||
u64 time = 0;
|
u64 time = 0;
|
||||||
|
@ -36,8 +37,8 @@ private:
|
||||||
int m_connected_count = 0;
|
int m_connected_count = 0;
|
||||||
u32 m_states_num = 0;
|
u32 m_states_num = 0;
|
||||||
u32 m_first_state = 0;
|
u32 m_first_state = 0;
|
||||||
State m_states[MAX_STATES];
|
std::array<State, MAX_STATES> m_states;
|
||||||
StateInternal m_private[MAX_STATES];
|
std::array<StateInternal, MAX_STATES> m_private;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Emulator::Host::Controller
|
} // namespace Input
|
Loading…
Reference in New Issue