PAD: Use files on disk instead of embedded resources

This commit is contained in:
TellowKrinkle 2021-11-21 04:04:44 -06:00 committed by refractionpcsx2
parent bcec38bd97
commit 0e0e23eefb
4 changed files with 6 additions and 30 deletions

View File

@ -532,18 +532,6 @@ else(WIN32)
COMMAND ${BIN2CPP} "${PADImg}/${result_file}.png" "${PADImgHeader}/${result_file}" )
endforeach()
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/pcsx2/PAD/Linux/resources_pad.h
COMMAND glib-compile-resources --sourcedir "${CMAKE_SOURCE_DIR}/pcsx2/PAD/Linux/res" --generate-header
--c-name PAD_res "${CMAKE_SOURCE_DIR}/pcsx2/PAD/Linux/res/PAD-res.xml" --target=${CMAKE_BINARY_DIR}/pcsx2/PAD/Linux/resources_pad.h
DEPENDS ${CMAKE_SOURCE_DIR}/pcsx2/PAD/Linux/res/PAD-res.xml ${CMAKE_SOURCE_DIR}/pcsx2/PAD/Linux/res/game_controller_db.txt)
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/pcsx2/PAD/Linux/resources_pad.cpp
COMMAND glib-compile-resources --sourcedir "${CMAKE_SOURCE_DIR}/pcsx2/PAD/Linux/res" --generate-source
--c-name PAD_res "${CMAKE_SOURCE_DIR}/pcsx2/PAD/Linux/res/PAD-res.xml" --target=${CMAKE_BINARY_DIR}/pcsx2/PAD/Linux/resources_pad.cpp
DEPENDS ${CMAKE_SOURCE_DIR}/pcsx2/PAD/Linux/res/PAD-res.xml ${CMAKE_SOURCE_DIR}/pcsx2/PAD/Linux/res/game_controller_db.txt)
# PAD/Linux sources
set(pcsx2PADSources
PAD/Linux/Device.cpp
@ -558,7 +546,6 @@ else(WIN32)
PAD/Linux/wx_dialog/GamepadConfiguration.cpp
PAD/Linux/wx_dialog/JoystickConfiguration.cpp
PAD/Linux/Config.cpp
${CMAKE_BINARY_DIR}/pcsx2/PAD/Linux/resources_pad.cpp
)
# PAD/Linux headers
@ -576,7 +563,6 @@ else(WIN32)
PAD/Linux/wx_dialog/opPanel.h
PAD/Linux/wx_dialog/GamepadConfiguration.h
PAD/Linux/wx_dialog/JoystickConfiguration.h
${CMAKE_BINARY_DIR}/pcsx2/PAD/Linux/resources_pad.h
# images
${PADImgHeader}/analog.h
${PADImgHeader}/circle.h

View File

@ -14,7 +14,7 @@
*/
#include "joystick.h"
#include "resources_pad.h"
#include "Host.h"
#include <signal.h> // sigaction
//////////////////////////
@ -46,15 +46,11 @@ void JoystickInfo::EnumerateJoysticks(std::vector<std::unique_ptr<Device>>& vjoy
SDL_EventState(SDL_CONTROLLERDEVICEREMOVED, SDL_ENABLE);
{ // Support as much Joystick as possible
GBytes* bytes = g_resource_lookup_data(PAD_res_get_resource(), "/PAD/res/game_controller_db.txt", G_RESOURCE_LOOKUP_FLAGS_NONE, nullptr);
size_t size = 0;
// SDL forget to add const for SDL_RWFromMem API...
void* data = const_cast<void*>(g_bytes_get_data(bytes, &size));
SDL_GameControllerAddMappingsFromRW(SDL_RWFromMem(data, size), 1);
g_bytes_unref(bytes);
auto file = Host::ReadResourceFile("game_controller_db.txt");
if (file.has_value())
SDL_GameControllerAddMappingsFromRW(SDL_RWFromMem(file->data(), file->size()), 1);
else
Console.Warning("Failed to load SDL Game Controller DB file!");
// Add user mapping too
for (auto const& map : g_conf.sdl2_mapping)

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/PAD/res/">
<file>game_controller_db.txt</file>
</gresource>
</gresources>