From 71bf7c2277aab64e7486939362607005a467f1c0 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Fri, 20 Dec 2024 00:23:14 +0100 Subject: [PATCH] cellGem: add setting to let the game actually set the device hues This is not very useful at the moment since the tracker can't really handle random hues yet. --- rpcs3/Emu/Cell/Modules/cellGem.cpp | 28 ++++++++++++++++------------ rpcs3/Emu/system_config.h | 1 + 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellGem.cpp b/rpcs3/Emu/Cell/Modules/cellGem.cpp index 06095c67a0..cb26b5d4b9 100644 --- a/rpcs3/Emu/Cell/Modules/cellGem.cpp +++ b/rpcs3/Emu/Cell/Modules/cellGem.cpp @@ -899,12 +899,22 @@ public: if (gem_num < 0 || gem_num >= CELL_GEM_MAX_NUM) continue; - const cfg_ps_move* config = ::at32(g_cfg_move.move, gem_num); - binding.device->color_override_active = true; - binding.device->color_override.r = config->r.get(); - binding.device->color_override.g = config->g.get(); - binding.device->color_override.b = config->b.get(); + + if (g_cfg.io.allow_move_hue_set_by_game) + { + const auto& controller = gem.controllers[gem_num]; + binding.device->color_override.r = static_cast(std::clamp(controller.sphere_rgb.r * 255.0f, 0.0f, 255.0f)); + binding.device->color_override.g = static_cast(std::clamp(controller.sphere_rgb.g * 255.0f, 0.0f, 255.0f)); + binding.device->color_override.b = static_cast(std::clamp(controller.sphere_rgb.b * 255.0f, 0.0f, 255.0f)); + } + else + { + const cfg_ps_move* config = ::at32(g_cfg_move.move, gem_num); + binding.device->color_override.r = config->r.get(); + binding.device->color_override.g = config->g.get(); + binding.device->color_override.b = config->b.get(); + } } } } @@ -916,7 +926,7 @@ public: const cfg_ps_move* config = g_cfg_move.move[gem_num]; m_tracker.set_active(gem_num, controller.enabled_tracking && controller.status == CELL_GEM_STATUS_READY); - m_tracker.set_hue(gem_num, config->hue); + m_tracker.set_hue(gem_num, g_cfg.io.allow_move_hue_set_by_game ? controller.hue : config->hue); m_tracker.set_hue_threshold(gem_num, config->hue_threshold); m_tracker.set_saturation_threshold(gem_num, config->saturation_threshold); } @@ -1822,8 +1832,6 @@ error_code cellGemForceRGB(u32 gem_num, f32 r, f32 g, f32 b) const auto [h, s, v] = ps_move_tracker::rgb_to_hsv(r, g, b); gem.controllers[gem_num].hue = h; - // TODO: set hue of tracker - return CELL_OK; } @@ -2833,8 +2841,6 @@ error_code cellGemTrackHues(vm::cptr req_hues, vm::ptr res_hues) gem.controllers[i].enabled_LED = true; gem.controllers[i].hue_set = true; - // TODO: set hue based on tracker data - switch (i) { default: @@ -2886,8 +2892,6 @@ error_code cellGemTrackHues(vm::cptr req_hues, vm::ptr res_hues) const auto [r, g, b] = ps_move_tracker::hsv_to_rgb(gem.controllers[i].hue, 1.0f, 1.0f); gem.controllers[i].sphere_rgb = gem_config::gem_color(r / 255.0f, g / 255.0f, b / 255.0f); - // TODO: set hue of tracker - if (res_hues) { res_hues[i] = gem.controllers[i].hue; diff --git a/rpcs3/Emu/system_config.h b/rpcs3/Emu/system_config.h index 289f4c2ae3..3cb3e39851 100644 --- a/rpcs3/Emu/system_config.h +++ b/rpcs3/Emu/system_config.h @@ -280,6 +280,7 @@ struct cfg_root : cfg::node cfg::_bool background_input_enabled{this, "Background input enabled", true, true}; cfg::_bool show_move_cursor{this, "Show move cursor", false, true}; cfg::_bool paint_move_spheres{this, "Paint move spheres", false, true}; + cfg::_bool allow_move_hue_set_by_game{this, "Allow move hue set by game", false, true}; cfg::_bool lock_overlay_input_to_player_one{this, "Lock overlay input to player one", false, true}; cfg::string midi_devices{this, "Emulated Midi devices", "ßßß@@@ßßß@@@ßßß@@@"}; cfg::_bool load_sdl_mappings{ this, "Load SDL GameController Mappings", true };