Address feedback
This commit is contained in:
parent
6f49c5f137
commit
7cf2170846
|
@ -11,7 +11,7 @@
|
|||
|
||||
#include "json/json.hpp"
|
||||
|
||||
namespace zelda64 {
|
||||
namespace recomp {
|
||||
// x-macros to build input enums and arrays.
|
||||
// First parameter is the enum name, second parameter is the bit field for the input (or 0 if there is no associated one), third is the readable name.
|
||||
// TODO refactor this to allow projects to rename these, or get rid of the readable name and leave that up to individual projects to map.
|
||||
|
@ -67,9 +67,9 @@ namespace zelda64 {
|
|||
|
||||
void poll_inputs();
|
||||
float get_input_analog(const InputField& field);
|
||||
float get_input_analog(const std::span<const zelda64::InputField> fields);
|
||||
float get_input_analog(const std::span<const recomp::InputField> fields);
|
||||
bool get_input_digital(const InputField& field);
|
||||
bool get_input_digital(const std::span<const zelda64::InputField> fields);
|
||||
bool get_input_digital(const std::span<const recomp::InputField> fields);
|
||||
void get_gyro_deltas(float* x, float* y);
|
||||
void get_mouse_deltas(float* x, float* y);
|
||||
void get_right_analog(float* x, float* y);
|
||||
|
@ -169,63 +169,22 @@ namespace zelda64 {
|
|||
void apply_joystick_deadzone(float x_in, float y_in, float* x_out, float* y_out);
|
||||
void set_right_analog_suppressed(bool suppressed);
|
||||
|
||||
enum class TargetingMode {
|
||||
Switch,
|
||||
Hold,
|
||||
OptionCount
|
||||
};
|
||||
|
||||
NLOHMANN_JSON_SERIALIZE_ENUM(zelda64::TargetingMode, {
|
||||
{zelda64::TargetingMode::Switch, "Switch"},
|
||||
{zelda64::TargetingMode::Hold, "Hold"}
|
||||
});
|
||||
|
||||
TargetingMode get_targeting_mode();
|
||||
void set_targeting_mode(TargetingMode mode);
|
||||
|
||||
enum class BackgroundInputMode {
|
||||
On,
|
||||
Off,
|
||||
OptionCount
|
||||
};
|
||||
|
||||
NLOHMANN_JSON_SERIALIZE_ENUM(zelda64::BackgroundInputMode, {
|
||||
{zelda64::BackgroundInputMode::On, "On"},
|
||||
{zelda64::BackgroundInputMode::Off, "Off"}
|
||||
NLOHMANN_JSON_SERIALIZE_ENUM(recomp::BackgroundInputMode, {
|
||||
{recomp::BackgroundInputMode::On, "On"},
|
||||
{recomp::BackgroundInputMode::Off, "Off"}
|
||||
});
|
||||
|
||||
BackgroundInputMode get_background_input_mode();
|
||||
void set_background_input_mode(BackgroundInputMode mode);
|
||||
|
||||
enum class CameraInvertMode {
|
||||
InvertNone,
|
||||
InvertX,
|
||||
InvertY,
|
||||
InvertBoth,
|
||||
OptionCount
|
||||
};
|
||||
|
||||
NLOHMANN_JSON_SERIALIZE_ENUM(zelda64::CameraInvertMode, {
|
||||
{zelda64::CameraInvertMode::InvertNone, "InvertNone"},
|
||||
{zelda64::CameraInvertMode::InvertX, "InvertX"},
|
||||
{zelda64::CameraInvertMode::InvertY, "InvertY"},
|
||||
{zelda64::CameraInvertMode::InvertBoth, "InvertBoth"}
|
||||
});
|
||||
|
||||
CameraInvertMode get_camera_invert_mode();
|
||||
void set_camera_invert_mode(CameraInvertMode mode);
|
||||
|
||||
CameraInvertMode get_analog_camera_invert_mode();
|
||||
void set_analog_camera_invert_mode(CameraInvertMode mode);
|
||||
|
||||
bool game_input_disabled();
|
||||
bool all_input_disabled();
|
||||
|
||||
// TODO move these somewhere else.
|
||||
void quicksave_save();
|
||||
void quicksave_load();
|
||||
|
||||
void open_quit_game_prompt();
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef __RECOMP_CONFIG_H__
|
||||
#define __RECOMP_CONFIG_H__
|
||||
#ifndef __ZELDA_CONFIG_H__
|
||||
#define __ZELDA_CONFIG_H__
|
||||
|
||||
#include <filesystem>
|
||||
#include <string_view>
|
||||
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace zelda64 {
|
||||
constexpr std::u8string_view program_id = u8"Zelda64Recompiled";
|
||||
constexpr std::u8string_view mm_game_id = u8"mm.n64.us.1.0";
|
||||
constexpr std::string_view program_name = "Zelda 64: Recompiled";
|
||||
|
||||
void load_config();
|
||||
|
@ -33,6 +32,41 @@ namespace zelda64 {
|
|||
{zelda64::AutosaveMode::Off, "Off"}
|
||||
});
|
||||
|
||||
enum class TargetingMode {
|
||||
Switch,
|
||||
Hold,
|
||||
OptionCount
|
||||
};
|
||||
|
||||
NLOHMANN_JSON_SERIALIZE_ENUM(zelda64::TargetingMode, {
|
||||
{zelda64::TargetingMode::Switch, "Switch"},
|
||||
{zelda64::TargetingMode::Hold, "Hold"}
|
||||
});
|
||||
|
||||
TargetingMode get_targeting_mode();
|
||||
void set_targeting_mode(TargetingMode mode);
|
||||
|
||||
enum class CameraInvertMode {
|
||||
InvertNone,
|
||||
InvertX,
|
||||
InvertY,
|
||||
InvertBoth,
|
||||
OptionCount
|
||||
};
|
||||
|
||||
NLOHMANN_JSON_SERIALIZE_ENUM(zelda64::CameraInvertMode, {
|
||||
{zelda64::CameraInvertMode::InvertNone, "InvertNone"},
|
||||
{zelda64::CameraInvertMode::InvertX, "InvertX"},
|
||||
{zelda64::CameraInvertMode::InvertY, "InvertY"},
|
||||
{zelda64::CameraInvertMode::InvertBoth, "InvertBoth"}
|
||||
});
|
||||
|
||||
CameraInvertMode get_camera_invert_mode();
|
||||
void set_camera_invert_mode(CameraInvertMode mode);
|
||||
|
||||
CameraInvertMode get_analog_camera_invert_mode();
|
||||
void set_analog_camera_invert_mode(CameraInvertMode mode);
|
||||
|
||||
enum class AnalogCamMode {
|
||||
On,
|
||||
Off,
|
||||
|
@ -49,6 +83,8 @@ namespace zelda64 {
|
|||
|
||||
AnalogCamMode get_analog_cam_mode();
|
||||
void set_analog_cam_mode(AnalogCamMode mode);
|
||||
|
||||
void open_quit_game_prompt();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef __RECOMP_DEBUG_H__
|
||||
#define __RECOMP_DEBUG_H__
|
||||
#ifndef __ZELDA_DEBUG_H__
|
||||
#define __ZELDA_DEBUG_H__
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
#ifndef __ZELDA_GAME_H__
|
||||
#define __ZELDA_GAME_H__
|
||||
|
||||
namespace zelda64 {
|
||||
void quicksave_save();
|
||||
void quicksave_load();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef __RECOMP_SOUND_H__
|
||||
#define __RECOMP_SOUND_H__
|
||||
#ifndef __ZELDA_SOUND_H__
|
||||
#define __ZELDA_SOUND_H__
|
||||
|
||||
namespace zelda64 {
|
||||
void reset_sound_settings();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "zelda_config.h"
|
||||
#include "zelda_input.h"
|
||||
#include "recomp_input.h"
|
||||
#include "zelda_sound.h"
|
||||
#include "ultramodern/config.hpp"
|
||||
#include "librecomp/files.hpp"
|
||||
|
@ -117,7 +117,7 @@ namespace ultramodern {
|
|||
}
|
||||
}
|
||||
|
||||
namespace zelda64 {
|
||||
namespace recomp {
|
||||
void to_json(json& j, const InputField& field) {
|
||||
j = json{ {"input_type", field.input_type}, {"input_id", field.input_id} };
|
||||
}
|
||||
|
@ -200,11 +200,11 @@ bool save_general_config(const std::filesystem::path& path) {
|
|||
nlohmann::json config_json{};
|
||||
|
||||
zelda64::to_json(config_json["targeting_mode"], zelda64::get_targeting_mode());
|
||||
zelda64::to_json(config_json["background_input_mode"], zelda64::get_background_input_mode());
|
||||
config_json["rumble_strength"] = zelda64::get_rumble_strength();
|
||||
config_json["gyro_sensitivity"] = zelda64::get_gyro_sensitivity();
|
||||
config_json["mouse_sensitivity"] = zelda64::get_mouse_sensitivity();
|
||||
config_json["joystick_deadzone"] = zelda64::get_joystick_deadzone();
|
||||
recomp::to_json(config_json["background_input_mode"], recomp::get_background_input_mode());
|
||||
config_json["rumble_strength"] = recomp::get_rumble_strength();
|
||||
config_json["gyro_sensitivity"] = recomp::get_gyro_sensitivity();
|
||||
config_json["mouse_sensitivity"] = recomp::get_mouse_sensitivity();
|
||||
config_json["joystick_deadzone"] = recomp::get_joystick_deadzone();
|
||||
config_json["autosave_mode"] = zelda64::get_autosave_mode();
|
||||
config_json["camera_invert_mode"] = zelda64::get_camera_invert_mode();
|
||||
config_json["analog_cam_mode"] = zelda64::get_analog_cam_mode();
|
||||
|
@ -216,11 +216,11 @@ bool save_general_config(const std::filesystem::path& path) {
|
|||
|
||||
void set_general_settings_from_json(const nlohmann::json& config_json) {
|
||||
zelda64::set_targeting_mode(from_or_default(config_json, "targeting_mode", zelda64::TargetingMode::Switch));
|
||||
zelda64::set_background_input_mode(from_or_default(config_json, "background_input_mode", zelda64::BackgroundInputMode::On));
|
||||
zelda64::set_rumble_strength(from_or_default(config_json, "rumble_strength", 25));
|
||||
zelda64::set_gyro_sensitivity(from_or_default(config_json, "gyro_sensitivity", 50));
|
||||
zelda64::set_mouse_sensitivity(from_or_default(config_json, "mouse_sensitivity", is_steam_deck ? 50 : 0));
|
||||
zelda64::set_joystick_deadzone(from_or_default(config_json, "joystick_deadzone", 5));
|
||||
recomp::set_background_input_mode(from_or_default(config_json, "background_input_mode", recomp::BackgroundInputMode::On));
|
||||
recomp::set_rumble_strength(from_or_default(config_json, "rumble_strength", 25));
|
||||
recomp::set_gyro_sensitivity(from_or_default(config_json, "gyro_sensitivity", 50));
|
||||
recomp::set_mouse_sensitivity(from_or_default(config_json, "mouse_sensitivity", is_steam_deck ? 50 : 0));
|
||||
recomp::set_joystick_deadzone(from_or_default(config_json, "joystick_deadzone", 5));
|
||||
zelda64::set_autosave_mode(from_or_default(config_json, "autosave_mode", zelda64::AutosaveMode::On));
|
||||
zelda64::set_camera_invert_mode(from_or_default(config_json, "camera_invert_mode", zelda64::CameraInvertMode::InvertY));
|
||||
zelda64::set_analog_cam_mode(from_or_default(config_json, "analog_cam_mode", zelda64::AnalogCamMode::Off));
|
||||
|
@ -238,57 +238,57 @@ bool load_general_config(const std::filesystem::path& path) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void assign_mapping(zelda64::InputDevice device, zelda64::GameInput input, const std::vector<zelda64::InputField>& value) {
|
||||
for (size_t binding_index = 0; binding_index < std::min(value.size(), zelda64::bindings_per_input); binding_index++) {
|
||||
zelda64::set_input_binding(input, binding_index, device, value[binding_index]);
|
||||
void assign_mapping(recomp::InputDevice device, recomp::GameInput input, const std::vector<recomp::InputField>& value) {
|
||||
for (size_t binding_index = 0; binding_index < std::min(value.size(), recomp::bindings_per_input); binding_index++) {
|
||||
recomp::set_input_binding(input, binding_index, device, value[binding_index]);
|
||||
}
|
||||
};
|
||||
|
||||
// same as assign_mapping, except will clear unassigned bindings if not in value
|
||||
void assign_mapping_complete(zelda64::InputDevice device, zelda64::GameInput input, const std::vector<zelda64::InputField>& value) {
|
||||
for (size_t binding_index = 0; binding_index < zelda64::bindings_per_input; binding_index++) {
|
||||
void assign_mapping_complete(recomp::InputDevice device, recomp::GameInput input, const std::vector<recomp::InputField>& value) {
|
||||
for (size_t binding_index = 0; binding_index < recomp::bindings_per_input; binding_index++) {
|
||||
if (binding_index >= value.size()) {
|
||||
zelda64::set_input_binding(input, binding_index, device, zelda64::InputField{});
|
||||
recomp::set_input_binding(input, binding_index, device, recomp::InputField{});
|
||||
} else {
|
||||
zelda64::set_input_binding(input, binding_index, device, value[binding_index]);
|
||||
recomp::set_input_binding(input, binding_index, device, value[binding_index]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void assign_all_mappings(zelda64::InputDevice device, const zelda64::DefaultN64Mappings& values) {
|
||||
assign_mapping_complete(device, zelda64::GameInput::A, values.a);
|
||||
assign_mapping_complete(device, zelda64::GameInput::B, values.b);
|
||||
assign_mapping_complete(device, zelda64::GameInput::Z, values.z);
|
||||
assign_mapping_complete(device, zelda64::GameInput::START, values.start);
|
||||
assign_mapping_complete(device, zelda64::GameInput::DPAD_UP, values.dpad_up);
|
||||
assign_mapping_complete(device, zelda64::GameInput::DPAD_DOWN, values.dpad_down);
|
||||
assign_mapping_complete(device, zelda64::GameInput::DPAD_LEFT, values.dpad_left);
|
||||
assign_mapping_complete(device, zelda64::GameInput::DPAD_RIGHT, values.dpad_right);
|
||||
assign_mapping_complete(device, zelda64::GameInput::L, values.l);
|
||||
assign_mapping_complete(device, zelda64::GameInput::R, values.r);
|
||||
assign_mapping_complete(device, zelda64::GameInput::C_UP, values.c_up);
|
||||
assign_mapping_complete(device, zelda64::GameInput::C_DOWN, values.c_down);
|
||||
assign_mapping_complete(device, zelda64::GameInput::C_LEFT, values.c_left);
|
||||
assign_mapping_complete(device, zelda64::GameInput::C_RIGHT, values.c_right);
|
||||
void assign_all_mappings(recomp::InputDevice device, const recomp::DefaultN64Mappings& values) {
|
||||
assign_mapping_complete(device, recomp::GameInput::A, values.a);
|
||||
assign_mapping_complete(device, recomp::GameInput::B, values.b);
|
||||
assign_mapping_complete(device, recomp::GameInput::Z, values.z);
|
||||
assign_mapping_complete(device, recomp::GameInput::START, values.start);
|
||||
assign_mapping_complete(device, recomp::GameInput::DPAD_UP, values.dpad_up);
|
||||
assign_mapping_complete(device, recomp::GameInput::DPAD_DOWN, values.dpad_down);
|
||||
assign_mapping_complete(device, recomp::GameInput::DPAD_LEFT, values.dpad_left);
|
||||
assign_mapping_complete(device, recomp::GameInput::DPAD_RIGHT, values.dpad_right);
|
||||
assign_mapping_complete(device, recomp::GameInput::L, values.l);
|
||||
assign_mapping_complete(device, recomp::GameInput::R, values.r);
|
||||
assign_mapping_complete(device, recomp::GameInput::C_UP, values.c_up);
|
||||
assign_mapping_complete(device, recomp::GameInput::C_DOWN, values.c_down);
|
||||
assign_mapping_complete(device, recomp::GameInput::C_LEFT, values.c_left);
|
||||
assign_mapping_complete(device, recomp::GameInput::C_RIGHT, values.c_right);
|
||||
|
||||
assign_mapping_complete(device, zelda64::GameInput::X_AXIS_NEG, values.analog_left);
|
||||
assign_mapping_complete(device, zelda64::GameInput::X_AXIS_POS, values.analog_right);
|
||||
assign_mapping_complete(device, zelda64::GameInput::Y_AXIS_NEG, values.analog_down);
|
||||
assign_mapping_complete(device, zelda64::GameInput::Y_AXIS_POS, values.analog_up);
|
||||
assign_mapping_complete(device, zelda64::GameInput::TOGGLE_MENU, values.toggle_menu);
|
||||
assign_mapping_complete(device, recomp::GameInput::X_AXIS_NEG, values.analog_left);
|
||||
assign_mapping_complete(device, recomp::GameInput::X_AXIS_POS, values.analog_right);
|
||||
assign_mapping_complete(device, recomp::GameInput::Y_AXIS_NEG, values.analog_down);
|
||||
assign_mapping_complete(device, recomp::GameInput::Y_AXIS_POS, values.analog_up);
|
||||
assign_mapping_complete(device, recomp::GameInput::TOGGLE_MENU, values.toggle_menu);
|
||||
};
|
||||
|
||||
void zelda64::reset_input_bindings() {
|
||||
assign_all_mappings(zelda64::InputDevice::Keyboard, zelda64::default_n64_keyboard_mappings);
|
||||
assign_all_mappings(zelda64::InputDevice::Controller, zelda64::default_n64_controller_mappings);
|
||||
assign_all_mappings(recomp::InputDevice::Keyboard, recomp::default_n64_keyboard_mappings);
|
||||
assign_all_mappings(recomp::InputDevice::Controller, recomp::default_n64_controller_mappings);
|
||||
}
|
||||
|
||||
void zelda64::reset_cont_input_bindings() {
|
||||
assign_all_mappings(zelda64::InputDevice::Controller, zelda64::default_n64_controller_mappings);
|
||||
assign_all_mappings(recomp::InputDevice::Controller, recomp::default_n64_controller_mappings);
|
||||
}
|
||||
|
||||
void zelda64::reset_kb_input_bindings() {
|
||||
assign_all_mappings(zelda64::InputDevice::Keyboard, zelda64::default_n64_keyboard_mappings);
|
||||
assign_all_mappings(recomp::InputDevice::Keyboard, recomp::default_n64_keyboard_mappings);
|
||||
}
|
||||
|
||||
void reset_graphics_options() {
|
||||
|
@ -324,12 +324,12 @@ bool load_graphics_config(const std::filesystem::path& path) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void add_input_bindings(nlohmann::json& out, zelda64::GameInput input, zelda64::InputDevice device) {
|
||||
const std::string& input_name = zelda64::get_input_enum_name(input);
|
||||
void add_input_bindings(nlohmann::json& out, recomp::GameInput input, recomp::InputDevice device) {
|
||||
const std::string& input_name = recomp::get_input_enum_name(input);
|
||||
nlohmann::json& out_array = out[input_name];
|
||||
out_array = nlohmann::json::array();
|
||||
for (size_t binding_index = 0; binding_index < zelda64::bindings_per_input; binding_index++) {
|
||||
out_array[binding_index] = zelda64::get_input_binding(input, binding_index, device);
|
||||
for (size_t binding_index = 0; binding_index < recomp::bindings_per_input; binding_index++) {
|
||||
out_array[binding_index] = recomp::get_input_binding(input, binding_index, device);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -339,17 +339,17 @@ bool save_controls_config(const std::filesystem::path& path) {
|
|||
config_json["keyboard"] = {};
|
||||
config_json["controller"] = {};
|
||||
|
||||
for (size_t i = 0; i < zelda64::get_num_inputs(); i++) {
|
||||
zelda64::GameInput cur_input = static_cast<zelda64::GameInput>(i);
|
||||
for (size_t i = 0; i < recomp::get_num_inputs(); i++) {
|
||||
recomp::GameInput cur_input = static_cast<recomp::GameInput>(i);
|
||||
|
||||
add_input_bindings(config_json["keyboard"], cur_input, zelda64::InputDevice::Keyboard);
|
||||
add_input_bindings(config_json["controller"], cur_input, zelda64::InputDevice::Controller);
|
||||
add_input_bindings(config_json["keyboard"], cur_input, recomp::InputDevice::Keyboard);
|
||||
add_input_bindings(config_json["controller"], cur_input, recomp::InputDevice::Controller);
|
||||
}
|
||||
|
||||
return save_json_with_backups(path, config_json);
|
||||
}
|
||||
|
||||
bool load_input_device_from_json(const nlohmann::json& config_json, zelda64::InputDevice device, const std::string& key) {
|
||||
bool load_input_device_from_json(const nlohmann::json& config_json, recomp::InputDevice device, const std::string& key) {
|
||||
// Check if the json object for the given key exists.
|
||||
auto find_it = config_json.find(key);
|
||||
if (find_it == config_json.end()) {
|
||||
|
@ -358,9 +358,9 @@ bool load_input_device_from_json(const nlohmann::json& config_json, zelda64::Inp
|
|||
|
||||
const nlohmann::json& mappings_json = *find_it;
|
||||
|
||||
for (size_t i = 0; i < zelda64::get_num_inputs(); i++) {
|
||||
zelda64::GameInput cur_input = static_cast<zelda64::GameInput>(i);
|
||||
const std::string& input_name = zelda64::get_input_enum_name(cur_input);
|
||||
for (size_t i = 0; i < recomp::get_num_inputs(); i++) {
|
||||
recomp::GameInput cur_input = static_cast<recomp::GameInput>(i);
|
||||
const std::string& input_name = recomp::get_input_enum_name(cur_input);
|
||||
|
||||
// Check if the json object for the given input exists and that it's an array.
|
||||
auto find_input_it = mappings_json.find(input_name);
|
||||
|
@ -368,10 +368,10 @@ bool load_input_device_from_json(const nlohmann::json& config_json, zelda64::Inp
|
|||
assign_mapping(
|
||||
device,
|
||||
cur_input,
|
||||
zelda64::get_default_mapping_for_input(
|
||||
device == zelda64::InputDevice::Keyboard ?
|
||||
zelda64::default_n64_keyboard_mappings :
|
||||
zelda64::default_n64_controller_mappings,
|
||||
recomp::get_default_mapping_for_input(
|
||||
device == recomp::InputDevice::Keyboard ?
|
||||
recomp::default_n64_keyboard_mappings :
|
||||
recomp::default_n64_controller_mappings,
|
||||
cur_input
|
||||
)
|
||||
);
|
||||
|
@ -380,10 +380,10 @@ bool load_input_device_from_json(const nlohmann::json& config_json, zelda64::Inp
|
|||
const nlohmann::json& input_json = *find_input_it;
|
||||
|
||||
// Deserialize all the bindings from the json array (up to the max number of bindings per input).
|
||||
for (size_t binding_index = 0; binding_index < std::min(zelda64::bindings_per_input, input_json.size()); binding_index++) {
|
||||
zelda64::InputField cur_field{};
|
||||
zelda64::from_json(input_json[binding_index], cur_field);
|
||||
zelda64::set_input_binding(cur_input, binding_index, device, cur_field);
|
||||
for (size_t binding_index = 0; binding_index < std::min(recomp::bindings_per_input, input_json.size()); binding_index++) {
|
||||
recomp::InputField cur_field{};
|
||||
recomp::from_json(input_json[binding_index], cur_field);
|
||||
recomp::set_input_binding(cur_input, binding_index, device, cur_field);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -396,12 +396,12 @@ bool load_controls_config(const std::filesystem::path& path) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!load_input_device_from_json(config_json, zelda64::InputDevice::Keyboard, "keyboard")) {
|
||||
assign_all_mappings(zelda64::InputDevice::Keyboard, zelda64::default_n64_keyboard_mappings);
|
||||
if (!load_input_device_from_json(config_json, recomp::InputDevice::Keyboard, "keyboard")) {
|
||||
assign_all_mappings(recomp::InputDevice::Keyboard, recomp::default_n64_keyboard_mappings);
|
||||
}
|
||||
|
||||
if (!load_input_device_from_json(config_json, zelda64::InputDevice::Controller, "controller")) {
|
||||
assign_all_mappings(zelda64::InputDevice::Controller, zelda64::default_n64_controller_mappings);
|
||||
if (!load_input_device_from_json(config_json, recomp::InputDevice::Controller, "controller")) {
|
||||
assign_all_mappings(recomp::InputDevice::Controller, recomp::default_n64_controller_mappings);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#include <array>
|
||||
|
||||
#include "librecomp/helpers.hpp"
|
||||
#include "zelda_input.h"
|
||||
#include "recomp_input.h"
|
||||
#include "ultramodern/ultramodern.hpp"
|
||||
|
||||
// Arrays that hold the mappings for every input for keyboard and controller respectively.
|
||||
using input_mapping = std::array<zelda64::InputField, zelda64::bindings_per_input>;
|
||||
using input_mapping_array = std::array<input_mapping, static_cast<size_t>(zelda64::GameInput::COUNT)>;
|
||||
using input_mapping = std::array<recomp::InputField, recomp::bindings_per_input>;
|
||||
using input_mapping_array = std::array<input_mapping, static_cast<size_t>(recomp::GameInput::COUNT)>;
|
||||
static input_mapping_array keyboard_input_mappings{};
|
||||
static input_mapping_array controller_input_mappings{};
|
||||
|
||||
|
@ -31,43 +31,43 @@ static const std::vector<std::string> input_enum_names = {
|
|||
};
|
||||
#undef DEFINE_INPUT
|
||||
|
||||
size_t zelda64::get_num_inputs() {
|
||||
size_t recomp::get_num_inputs() {
|
||||
return (size_t)GameInput::COUNT;
|
||||
}
|
||||
|
||||
const std::string& zelda64::get_input_name(GameInput input) {
|
||||
const std::string& recomp::get_input_name(GameInput input) {
|
||||
return input_names.at(static_cast<size_t>(input));
|
||||
}
|
||||
|
||||
const std::string& zelda64::get_input_enum_name(GameInput input) {
|
||||
const std::string& recomp::get_input_enum_name(GameInput input) {
|
||||
return input_enum_names.at(static_cast<size_t>(input));
|
||||
}
|
||||
|
||||
zelda64::GameInput zelda64::get_input_from_enum_name(const std::string_view enum_name) {
|
||||
recomp::GameInput recomp::get_input_from_enum_name(const std::string_view enum_name) {
|
||||
auto find_it = std::find(input_enum_names.begin(), input_enum_names.end(), enum_name);
|
||||
if (find_it == input_enum_names.end()) {
|
||||
return zelda64::GameInput::COUNT;
|
||||
return recomp::GameInput::COUNT;
|
||||
}
|
||||
|
||||
return static_cast<zelda64::GameInput>(find_it - input_enum_names.begin());
|
||||
return static_cast<recomp::GameInput>(find_it - input_enum_names.begin());
|
||||
}
|
||||
|
||||
// Due to an RmlUi limitation this can't be const. Ideally it would return a const reference or even just a straight up copy.
|
||||
zelda64::InputField& zelda64::get_input_binding(GameInput input, size_t binding_index, zelda64::InputDevice device) {
|
||||
input_mapping_array& device_mappings = (device == zelda64::InputDevice::Controller) ? controller_input_mappings : keyboard_input_mappings;
|
||||
recomp::InputField& recomp::get_input_binding(GameInput input, size_t binding_index, recomp::InputDevice device) {
|
||||
input_mapping_array& device_mappings = (device == recomp::InputDevice::Controller) ? controller_input_mappings : keyboard_input_mappings;
|
||||
input_mapping& cur_input_mapping = device_mappings.at(static_cast<size_t>(input));
|
||||
|
||||
if (binding_index < cur_input_mapping.size()) {
|
||||
return cur_input_mapping[binding_index];
|
||||
}
|
||||
else {
|
||||
static zelda64::InputField dummy_field = {};
|
||||
static recomp::InputField dummy_field = {};
|
||||
return dummy_field;
|
||||
}
|
||||
}
|
||||
|
||||
void zelda64::set_input_binding(zelda64::GameInput input, size_t binding_index, zelda64::InputDevice device, zelda64::InputField value) {
|
||||
input_mapping_array& device_mappings = (device == zelda64::InputDevice::Controller) ? controller_input_mappings : keyboard_input_mappings;
|
||||
void recomp::set_input_binding(recomp::GameInput input, size_t binding_index, recomp::InputDevice device, recomp::InputField value) {
|
||||
input_mapping_array& device_mappings = (device == recomp::InputDevice::Controller) ? controller_input_mappings : keyboard_input_mappings;
|
||||
input_mapping& cur_input_mapping = device_mappings.at(static_cast<size_t>(input));
|
||||
|
||||
if (binding_index < cur_input_mapping.size()) {
|
||||
|
@ -75,33 +75,33 @@ void zelda64::set_input_binding(zelda64::GameInput input, size_t binding_index,
|
|||
}
|
||||
}
|
||||
|
||||
void zelda64::get_n64_input(uint16_t* buttons_out, float* x_out, float* y_out) {
|
||||
void recomp::get_n64_input(uint16_t* buttons_out, float* x_out, float* y_out) {
|
||||
uint16_t cur_buttons = 0;
|
||||
float cur_x = 0.0f;
|
||||
float cur_y = 0.0f;
|
||||
|
||||
if (!zelda64::game_input_disabled()) {
|
||||
if (!recomp::game_input_disabled()) {
|
||||
for (size_t i = 0; i < n64_button_values.size(); i++) {
|
||||
size_t input_index = (size_t)GameInput::N64_BUTTON_START + i;
|
||||
cur_buttons |= zelda64::get_input_digital(keyboard_input_mappings[input_index]) ? n64_button_values[i] : 0;
|
||||
cur_buttons |= zelda64::get_input_digital(controller_input_mappings[input_index]) ? n64_button_values[i] : 0;
|
||||
cur_buttons |= recomp::get_input_digital(keyboard_input_mappings[input_index]) ? n64_button_values[i] : 0;
|
||||
cur_buttons |= recomp::get_input_digital(controller_input_mappings[input_index]) ? n64_button_values[i] : 0;
|
||||
}
|
||||
|
||||
float joystick_deadzone = zelda64::get_joystick_deadzone() / 100.0f;
|
||||
float joystick_deadzone = recomp::get_joystick_deadzone() / 100.0f;
|
||||
|
||||
float joystick_x = zelda64::get_input_analog(controller_input_mappings[(size_t)GameInput::X_AXIS_POS])
|
||||
- zelda64::get_input_analog(controller_input_mappings[(size_t)GameInput::X_AXIS_NEG]);
|
||||
float joystick_x = recomp::get_input_analog(controller_input_mappings[(size_t)GameInput::X_AXIS_POS])
|
||||
- recomp::get_input_analog(controller_input_mappings[(size_t)GameInput::X_AXIS_NEG]);
|
||||
|
||||
float joystick_y = zelda64::get_input_analog(controller_input_mappings[(size_t)GameInput::Y_AXIS_POS])
|
||||
- zelda64::get_input_analog(controller_input_mappings[(size_t)GameInput::Y_AXIS_NEG]);
|
||||
float joystick_y = recomp::get_input_analog(controller_input_mappings[(size_t)GameInput::Y_AXIS_POS])
|
||||
- recomp::get_input_analog(controller_input_mappings[(size_t)GameInput::Y_AXIS_NEG]);
|
||||
|
||||
zelda64::apply_joystick_deadzone(joystick_x, joystick_y, &joystick_x, &joystick_y);
|
||||
recomp::apply_joystick_deadzone(joystick_x, joystick_y, &joystick_x, &joystick_y);
|
||||
|
||||
cur_x = zelda64::get_input_analog(keyboard_input_mappings[(size_t)GameInput::X_AXIS_POS])
|
||||
- zelda64::get_input_analog(keyboard_input_mappings[(size_t)GameInput::X_AXIS_NEG]) + joystick_x;
|
||||
cur_x = recomp::get_input_analog(keyboard_input_mappings[(size_t)GameInput::X_AXIS_POS])
|
||||
- recomp::get_input_analog(keyboard_input_mappings[(size_t)GameInput::X_AXIS_NEG]) + joystick_x;
|
||||
|
||||
cur_y = zelda64::get_input_analog(keyboard_input_mappings[(size_t)GameInput::Y_AXIS_POS])
|
||||
- zelda64::get_input_analog(keyboard_input_mappings[(size_t)GameInput::Y_AXIS_NEG]) + joystick_y;
|
||||
cur_y = recomp::get_input_analog(keyboard_input_mappings[(size_t)GameInput::Y_AXIS_POS])
|
||||
- recomp::get_input_analog(keyboard_input_mappings[(size_t)GameInput::Y_AXIS_NEG]) + joystick_y;
|
||||
}
|
||||
|
||||
*buttons_out = cur_buttons;
|
||||
|
|
|
@ -3,8 +3,9 @@
|
|||
|
||||
#include "ultramodern/ultramodern.hpp"
|
||||
#include "librecomp/recomp.h"
|
||||
#include "zelda_input.h"
|
||||
#include "zelda_ui.h"
|
||||
#include "recomp_input.h"
|
||||
#include "zelda_config.h"
|
||||
#include "recomp_ui.h"
|
||||
#include "SDL.h"
|
||||
#include "promptfont.h"
|
||||
#include "GamepadMotion.hpp"
|
||||
|
@ -41,8 +42,8 @@ static struct {
|
|||
bool rumble_active;
|
||||
} InputState;
|
||||
|
||||
std::atomic<zelda64::InputDevice> scanning_device = zelda64::InputDevice::COUNT;
|
||||
std::atomic<zelda64::InputField> scanned_input;
|
||||
std::atomic<recomp::InputDevice> scanning_device = recomp::InputDevice::COUNT;
|
||||
std::atomic<recomp::InputField> scanned_input;
|
||||
|
||||
enum class InputType {
|
||||
None = 0, // Using zero for None ensures that default initialized InputFields are unbound.
|
||||
|
@ -52,28 +53,28 @@ enum class InputType {
|
|||
ControllerAnalog // Axis input_id values are the SDL value + 1
|
||||
};
|
||||
|
||||
void set_scanned_input(zelda64::InputField value) {
|
||||
scanning_device.store(zelda64::InputDevice::COUNT);
|
||||
void set_scanned_input(recomp::InputField value) {
|
||||
scanning_device.store(recomp::InputDevice::COUNT);
|
||||
scanned_input.store(value);
|
||||
}
|
||||
|
||||
zelda64::InputField zelda64::get_scanned_input() {
|
||||
zelda64::InputField ret = scanned_input.load();
|
||||
recomp::InputField recomp::get_scanned_input() {
|
||||
recomp::InputField ret = scanned_input.load();
|
||||
scanned_input.store({});
|
||||
return ret;
|
||||
}
|
||||
|
||||
void zelda64::start_scanning_input(zelda64::InputDevice device) {
|
||||
void recomp::start_scanning_input(recomp::InputDevice device) {
|
||||
scanned_input.store({});
|
||||
scanning_device.store(device);
|
||||
}
|
||||
|
||||
void zelda64::stop_scanning_input() {
|
||||
scanning_device.store(zelda64::InputDevice::COUNT);
|
||||
void recomp::stop_scanning_input() {
|
||||
scanning_device.store(recomp::InputDevice::COUNT);
|
||||
}
|
||||
|
||||
void queue_if_enabled(SDL_Event* event) {
|
||||
if (!zelda64::all_input_disabled()) {
|
||||
if (!recomp::all_input_disabled()) {
|
||||
recompui::queue_event(*event);
|
||||
}
|
||||
}
|
||||
|
@ -111,10 +112,10 @@ bool sdl_event_filter(void* userdata, SDL_Event* event) {
|
|||
) {
|
||||
recompui::toggle_fullscreen();
|
||||
}
|
||||
if (scanning_device != zelda64::InputDevice::COUNT) {
|
||||
if (scanning_device != recomp::InputDevice::COUNT) {
|
||||
if (keyevent->keysym.scancode == SDL_Scancode::SDL_SCANCODE_ESCAPE) {
|
||||
zelda64::cancel_scanning_input();
|
||||
} else if (scanning_device == zelda64::InputDevice::Keyboard) {
|
||||
recomp::cancel_scanning_input();
|
||||
} else if (scanning_device == recomp::InputDevice::Keyboard) {
|
||||
set_scanned_input({(uint32_t)InputType::Keyboard, keyevent->keysym.scancode});
|
||||
}
|
||||
} else {
|
||||
|
@ -170,14 +171,14 @@ bool sdl_event_filter(void* userdata, SDL_Event* event) {
|
|||
queue_if_enabled(event);
|
||||
break;
|
||||
case SDL_EventType::SDL_CONTROLLERBUTTONDOWN:
|
||||
if (scanning_device != zelda64::InputDevice::COUNT) {
|
||||
auto menuToggleBinding0 = zelda64::get_input_binding(zelda64::GameInput::TOGGLE_MENU, 0, zelda64::InputDevice::Controller);
|
||||
auto menuToggleBinding1 = zelda64::get_input_binding(zelda64::GameInput::TOGGLE_MENU, 1, zelda64::InputDevice::Controller);
|
||||
if (scanning_device != recomp::InputDevice::COUNT) {
|
||||
auto menuToggleBinding0 = recomp::get_input_binding(recomp::GameInput::TOGGLE_MENU, 0, recomp::InputDevice::Controller);
|
||||
auto menuToggleBinding1 = recomp::get_input_binding(recomp::GameInput::TOGGLE_MENU, 1, recomp::InputDevice::Controller);
|
||||
// note - magic number: 0 is InputType::None
|
||||
if ((menuToggleBinding0.input_type != 0 && event->cbutton.button == menuToggleBinding0.input_id) ||
|
||||
(menuToggleBinding1.input_type != 0 && event->cbutton.button == menuToggleBinding1.input_id)) {
|
||||
zelda64::cancel_scanning_input();
|
||||
} else if (scanning_device == zelda64::InputDevice::Controller) {
|
||||
recomp::cancel_scanning_input();
|
||||
} else if (scanning_device == recomp::InputDevice::Controller) {
|
||||
SDL_ControllerButtonEvent* button_event = &event->cbutton;
|
||||
set_scanned_input({(uint32_t)InputType::ControllerDigital, button_event->button});
|
||||
}
|
||||
|
@ -186,7 +187,7 @@ bool sdl_event_filter(void* userdata, SDL_Event* event) {
|
|||
}
|
||||
break;
|
||||
case SDL_EventType::SDL_CONTROLLERAXISMOTION:
|
||||
if (scanning_device == zelda64::InputDevice::Controller) {
|
||||
if (scanning_device == recomp::InputDevice::Controller) {
|
||||
SDL_ControllerAxisEvent* axis_event = &event->caxis;
|
||||
float axis_value = axis_event->value * (1/32768.0f);
|
||||
if (axis_value > axis_threshold) {
|
||||
|
@ -235,7 +236,7 @@ bool sdl_event_filter(void* userdata, SDL_Event* event) {
|
|||
}
|
||||
break;
|
||||
case SDL_EventType::SDL_MOUSEMOTION:
|
||||
if (!zelda64::game_input_disabled()) {
|
||||
if (!recomp::game_input_disabled()) {
|
||||
SDL_MouseMotionEvent* motion_event = &event->motion;
|
||||
std::lock_guard lock{ InputState.pending_input_mutex };
|
||||
InputState.pending_mouse_delta[0] += motion_event->xrel;
|
||||
|
@ -248,14 +249,14 @@ bool sdl_event_filter(void* userdata, SDL_Event* event) {
|
|||
return false;
|
||||
}
|
||||
|
||||
void zelda64::handle_events() {
|
||||
void recomp::handle_events() {
|
||||
SDL_Event cur_event;
|
||||
static bool exited = false;
|
||||
while (SDL_PollEvent(&cur_event) && !exited) {
|
||||
exited = sdl_event_filter(nullptr, &cur_event);
|
||||
|
||||
// Lock the cursor if all three conditions are true: mouse aiming is enabled, game input is not disabled, and the game has been started.
|
||||
bool cursor_locked = (zelda64::get_mouse_sensitivity() != 0) && !zelda64::game_input_disabled() && ultramodern::is_game_started();
|
||||
bool cursor_locked = (recomp::get_mouse_sensitivity() != 0) && !recomp::game_input_disabled() && ultramodern::is_game_started();
|
||||
|
||||
// Hide the cursor based on its enable state, but override visibility to false if the cursor is locked.
|
||||
bool cursor_visible = cursor_enabled;
|
||||
|
@ -273,7 +274,7 @@ constexpr SDL_GameControllerButton SDL_CONTROLLER_BUTTON_EAST = SDL_CONTROLLER_B
|
|||
constexpr SDL_GameControllerButton SDL_CONTROLLER_BUTTON_WEST = SDL_CONTROLLER_BUTTON_X;
|
||||
constexpr SDL_GameControllerButton SDL_CONTROLLER_BUTTON_NORTH = SDL_CONTROLLER_BUTTON_Y;
|
||||
|
||||
const zelda64::DefaultN64Mappings zelda64::default_n64_keyboard_mappings = {
|
||||
const recomp::DefaultN64Mappings recomp::default_n64_keyboard_mappings = {
|
||||
.a = {
|
||||
{.input_type = (uint32_t)InputType::Keyboard, .input_id = SDL_SCANCODE_SPACE}
|
||||
},
|
||||
|
@ -333,7 +334,7 @@ const zelda64::DefaultN64Mappings zelda64::default_n64_keyboard_mappings = {
|
|||
},
|
||||
};
|
||||
|
||||
const zelda64::DefaultN64Mappings zelda64::default_n64_controller_mappings = {
|
||||
const recomp::DefaultN64Mappings recomp::default_n64_controller_mappings = {
|
||||
.a = {
|
||||
{.input_type = (uint32_t)InputType::ControllerDigital, .input_id = SDL_CONTROLLER_BUTTON_SOUTH},
|
||||
},
|
||||
|
@ -397,7 +398,7 @@ const zelda64::DefaultN64Mappings zelda64::default_n64_controller_mappings = {
|
|||
},
|
||||
};
|
||||
|
||||
void zelda64::poll_inputs() {
|
||||
void recomp::poll_inputs() {
|
||||
InputState.keys = SDL_GetKeyboardState(&InputState.numkeys);
|
||||
InputState.keymod = SDL_GetModState();
|
||||
|
||||
|
@ -444,7 +445,7 @@ void zelda64::poll_inputs() {
|
|||
#endif
|
||||
}
|
||||
|
||||
void zelda64::set_rumble(bool on) {
|
||||
void recomp::set_rumble(bool on) {
|
||||
InputState.rumble_active = on;
|
||||
}
|
||||
|
||||
|
@ -454,7 +455,7 @@ static float smoothstep(float from, float to, float amount) {
|
|||
}
|
||||
|
||||
// Update rumble to attempt to mimic the way n64 rumble ramps up and falls off
|
||||
void zelda64::update_rumble() {
|
||||
void recomp::update_rumble() {
|
||||
// Note: values are not accurate! just approximations based on feel
|
||||
if (InputState.rumble_active) {
|
||||
InputState.cur_rumble += 0.17f;
|
||||
|
@ -466,7 +467,7 @@ void zelda64::update_rumble() {
|
|||
}
|
||||
float smooth_rumble = smoothstep(0, 1, InputState.cur_rumble);
|
||||
|
||||
uint16_t rumble_strength = smooth_rumble * (zelda64::get_rumble_strength() * 0xFFFF / 100);
|
||||
uint16_t rumble_strength = smooth_rumble * (recomp::get_rumble_strength() * 0xFFFF / 100);
|
||||
uint32_t duration = 1000000; // Dummy duration value that lasts long enough to matter as the game will reset rumble on its own.
|
||||
{
|
||||
std::lock_guard lock{ InputState.cur_controllers_mutex };
|
||||
|
@ -522,7 +523,7 @@ float controller_axis_state(int32_t input_id, bool allow_suppression) {
|
|||
return false;
|
||||
}
|
||||
|
||||
float zelda64::get_input_analog(const zelda64::InputField& field) {
|
||||
float recomp::get_input_analog(const recomp::InputField& field) {
|
||||
switch ((InputType)field.input_type) {
|
||||
case InputType::Keyboard:
|
||||
if (InputState.keys && field.input_id >= 0 && field.input_id < InputState.numkeys) {
|
||||
|
@ -544,7 +545,7 @@ float zelda64::get_input_analog(const zelda64::InputField& field) {
|
|||
}
|
||||
}
|
||||
|
||||
float zelda64::get_input_analog(const std::span<const zelda64::InputField> fields) {
|
||||
float recomp::get_input_analog(const std::span<const recomp::InputField> fields) {
|
||||
float ret = 0.0f;
|
||||
for (const auto& field : fields) {
|
||||
ret += get_input_analog(field);
|
||||
|
@ -552,7 +553,7 @@ float zelda64::get_input_analog(const std::span<const zelda64::InputField> field
|
|||
return std::clamp(ret, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
bool zelda64::get_input_digital(const zelda64::InputField& field) {
|
||||
bool recomp::get_input_digital(const recomp::InputField& field) {
|
||||
switch ((InputType)field.input_type) {
|
||||
case InputType::Keyboard:
|
||||
if (InputState.keys && field.input_id >= 0 && field.input_id < InputState.numkeys) {
|
||||
|
@ -575,7 +576,7 @@ bool zelda64::get_input_digital(const zelda64::InputField& field) {
|
|||
}
|
||||
}
|
||||
|
||||
bool zelda64::get_input_digital(const std::span<const zelda64::InputField> fields) {
|
||||
bool recomp::get_input_digital(const std::span<const recomp::InputField> fields) {
|
||||
bool ret = 0;
|
||||
for (const auto& field : fields) {
|
||||
ret |= get_input_digital(field);
|
||||
|
@ -583,22 +584,22 @@ bool zelda64::get_input_digital(const std::span<const zelda64::InputField> field
|
|||
return ret;
|
||||
}
|
||||
|
||||
void zelda64::get_gyro_deltas(float* x, float* y) {
|
||||
void recomp::get_gyro_deltas(float* x, float* y) {
|
||||
std::array<float, 2> cur_rotation_delta = InputState.rotation_delta;
|
||||
float sensitivity = (float)zelda64::get_gyro_sensitivity() / 100.0f;
|
||||
float sensitivity = (float)recomp::get_gyro_sensitivity() / 100.0f;
|
||||
*x = cur_rotation_delta[0] * sensitivity;
|
||||
*y = cur_rotation_delta[1] * sensitivity;
|
||||
}
|
||||
|
||||
void zelda64::get_mouse_deltas(float* x, float* y) {
|
||||
void recomp::get_mouse_deltas(float* x, float* y) {
|
||||
std::array<float, 2> cur_mouse_delta = InputState.mouse_delta;
|
||||
float sensitivity = (float)zelda64::get_mouse_sensitivity() / 100.0f;
|
||||
float sensitivity = (float)recomp::get_mouse_sensitivity() / 100.0f;
|
||||
*x = cur_mouse_delta[0] * sensitivity;
|
||||
*y = cur_mouse_delta[1] * sensitivity;
|
||||
}
|
||||
|
||||
void zelda64::apply_joystick_deadzone(float x_in, float y_in, float* x_out, float* y_out) {
|
||||
float joystick_deadzone = (float)zelda64::get_joystick_deadzone() / 100.0f;
|
||||
void recomp::apply_joystick_deadzone(float x_in, float y_in, float* x_out, float* y_out) {
|
||||
float joystick_deadzone = (float)recomp::get_joystick_deadzone() / 100.0f;
|
||||
|
||||
if(fabsf(x_in) < joystick_deadzone) {
|
||||
x_in = 0.0f;
|
||||
|
@ -632,28 +633,28 @@ void zelda64::apply_joystick_deadzone(float x_in, float y_in, float* x_out, floa
|
|||
*y_out = y_in;
|
||||
}
|
||||
|
||||
void zelda64::get_right_analog(float* x, float* y) {
|
||||
void recomp::get_right_analog(float* x, float* y) {
|
||||
float x_val =
|
||||
controller_axis_state((SDL_GameControllerAxis::SDL_CONTROLLER_AXIS_RIGHTX + 1), false) -
|
||||
controller_axis_state(-(SDL_GameControllerAxis::SDL_CONTROLLER_AXIS_RIGHTX + 1), false);
|
||||
float y_val =
|
||||
controller_axis_state((SDL_GameControllerAxis::SDL_CONTROLLER_AXIS_RIGHTY + 1), false) -
|
||||
controller_axis_state(-(SDL_GameControllerAxis::SDL_CONTROLLER_AXIS_RIGHTY + 1), false);
|
||||
zelda64::apply_joystick_deadzone(x_val, y_val, x, y);
|
||||
recomp::apply_joystick_deadzone(x_val, y_val, x, y);
|
||||
}
|
||||
|
||||
void zelda64::set_right_analog_suppressed(bool suppressed) {
|
||||
void recomp::set_right_analog_suppressed(bool suppressed) {
|
||||
right_analog_suppressed.store(suppressed);
|
||||
}
|
||||
|
||||
bool zelda64::game_input_disabled() {
|
||||
bool recomp::game_input_disabled() {
|
||||
// Disable input if any menu is open.
|
||||
return recompui::get_current_menu() != recompui::Menu::None;
|
||||
}
|
||||
|
||||
bool zelda64::all_input_disabled() {
|
||||
bool recomp::all_input_disabled() {
|
||||
// Disable all input if an input is being polled.
|
||||
return scanning_device != zelda64::InputDevice::COUNT;
|
||||
return scanning_device != recomp::InputDevice::COUNT;
|
||||
}
|
||||
|
||||
std::string controller_button_to_string(SDL_GameControllerButton button) {
|
||||
|
@ -805,7 +806,7 @@ std::string controller_axis_to_string(int axis) {
|
|||
}
|
||||
}
|
||||
|
||||
std::string zelda64::InputField::to_string() const {
|
||||
std::string recomp::InputField::to_string() const {
|
||||
switch ((InputType)input_type) {
|
||||
case InputType::None:
|
||||
return "";
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
#include "librecomp/recomp.h"
|
||||
#include "librecomp/overlays.hpp"
|
||||
#include "zelda_config.h"
|
||||
#include "zelda_input.h"
|
||||
#include "zelda_ui.h"
|
||||
#include "recomp_input.h"
|
||||
#include "recomp_ui.h"
|
||||
#include "zelda_sound.h"
|
||||
#include "librecomp/helpers.hpp"
|
||||
#include "../patches/input.h"
|
||||
|
@ -15,7 +15,7 @@
|
|||
#include "ultramodern/rt64_layer.hpp"
|
||||
|
||||
extern "C" void recomp_update_inputs(uint8_t* rdram, recomp_context* ctx) {
|
||||
zelda64::poll_inputs();
|
||||
recomp::poll_inputs();
|
||||
}
|
||||
|
||||
extern "C" void recomp_puts(uint8_t* rdram, recomp_context* ctx) {
|
||||
|
@ -35,14 +35,14 @@ extern "C" void recomp_get_gyro_deltas(uint8_t* rdram, recomp_context* ctx) {
|
|||
float* x_out = _arg<0, float*>(rdram, ctx);
|
||||
float* y_out = _arg<1, float*>(rdram, ctx);
|
||||
|
||||
zelda64::get_gyro_deltas(x_out, y_out);
|
||||
recomp::get_gyro_deltas(x_out, y_out);
|
||||
}
|
||||
|
||||
extern "C" void recomp_get_mouse_deltas(uint8_t* rdram, recomp_context* ctx) {
|
||||
float* x_out = _arg<0, float*>(rdram, ctx);
|
||||
float* y_out = _arg<1, float*>(rdram, ctx);
|
||||
|
||||
zelda64::get_mouse_deltas(x_out, y_out);
|
||||
recomp::get_mouse_deltas(x_out, y_out);
|
||||
}
|
||||
|
||||
extern "C" void recomp_powf(uint8_t* rdram, recomp_context* ctx) {
|
||||
|
@ -144,7 +144,7 @@ extern "C" void recomp_get_camera_inputs(uint8_t* rdram, recomp_context* ctx) {
|
|||
|
||||
float x, y;
|
||||
|
||||
zelda64::get_right_analog(&x, &y);
|
||||
recomp::get_right_analog(&x, &y);
|
||||
|
||||
float magnitude = sqrtf(x * x + y * y);
|
||||
|
||||
|
@ -164,5 +164,5 @@ extern "C" void recomp_get_camera_inputs(uint8_t* rdram, recomp_context* ctx) {
|
|||
extern "C" void recomp_set_right_analog_suppressed(uint8_t* rdram, recomp_context* ctx) {
|
||||
s32 suppressed = _arg<0, s32>(rdram, ctx);
|
||||
|
||||
zelda64::set_right_analog_suppressed(suppressed);
|
||||
recomp::set_right_analog_suppressed(suppressed);
|
||||
}
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
#include "SDL2/SDL_syswm.h"
|
||||
#endif
|
||||
|
||||
#include "zelda_ui.h"
|
||||
#include "zelda_input.h"
|
||||
#include "recomp_ui.h"
|
||||
#include "recomp_input.h"
|
||||
#include "zelda_config.h"
|
||||
#include "zelda_sound.h"
|
||||
#include "ovl_patches.hpp"
|
||||
|
@ -156,7 +156,7 @@ ultramodern::WindowHandle create_window(ultramodern::gfx_callbacks_t::gfx_data_t
|
|||
}
|
||||
|
||||
void update_gfx(void*) {
|
||||
zelda64::handle_events();
|
||||
recomp::handle_events();
|
||||
}
|
||||
|
||||
static SDL_AudioCVT audio_convert;
|
||||
|
@ -403,13 +403,13 @@ int main(int argc, char** argv) {
|
|||
};
|
||||
|
||||
const static ultramodern::input_callbacks_t input_callbacks{
|
||||
.poll_input = zelda64::poll_inputs,
|
||||
.get_input = zelda64::get_n64_input,
|
||||
.set_rumble = zelda64::set_rumble,
|
||||
.poll_input = recomp::poll_inputs,
|
||||
.get_input = recomp::get_n64_input,
|
||||
.set_rumble = recomp::set_rumble,
|
||||
};
|
||||
|
||||
const static ultramodern::events::callbacks_t thread_callbacks{
|
||||
.vi_callback = zelda64::update_rumble,
|
||||
.vi_callback = recomp::update_rumble,
|
||||
.gfx_init_callback = recompui::update_supported_options,
|
||||
};
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
#include "RmlUi/Core.h"
|
||||
#include "RmlUi/../../Source/Core/PropertyParserColour.h"
|
||||
#include "zelda_ui.h"
|
||||
#include "recomp_ui.h"
|
||||
#include <string.h>
|
||||
|
||||
using ColourMap = Rml::UnorderedMap<Rml::String, Rml::Colourb>;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "zelda_ui.h"
|
||||
#include "zelda_input.h"
|
||||
#include "recomp_ui.h"
|
||||
#include "recomp_input.h"
|
||||
#include "zelda_sound.h"
|
||||
#include "zelda_config.h"
|
||||
#include "zelda_debug.h"
|
||||
|
@ -161,10 +161,10 @@ static bool sample_positions_supported = false;
|
|||
|
||||
static bool cont_active = true;
|
||||
|
||||
static zelda64::InputDevice cur_device = zelda64::InputDevice::Controller;
|
||||
static recomp::InputDevice cur_device = recomp::InputDevice::Controller;
|
||||
|
||||
void zelda64::finish_scanning_input(zelda64::InputField scanned_field) {
|
||||
zelda64::set_input_binding(static_cast<zelda64::GameInput>(scanned_input_index), scanned_binding_index, cur_device, scanned_field);
|
||||
void recomp::finish_scanning_input(recomp::InputField scanned_field) {
|
||||
recomp::set_input_binding(static_cast<recomp::GameInput>(scanned_input_index), scanned_binding_index, cur_device, scanned_field);
|
||||
scanned_input_index = -1;
|
||||
scanned_binding_index = -1;
|
||||
controls_model_handle.DirtyVariable("inputs");
|
||||
|
@ -172,8 +172,8 @@ void zelda64::finish_scanning_input(zelda64::InputField scanned_field) {
|
|||
controls_model_handle.DirtyVariable("active_binding_slot");
|
||||
}
|
||||
|
||||
void zelda64::cancel_scanning_input() {
|
||||
zelda64::stop_scanning_input();
|
||||
void recomp::cancel_scanning_input() {
|
||||
recomp::stop_scanning_input();
|
||||
scanned_input_index = -1;
|
||||
scanned_binding_index = -1;
|
||||
controls_model_handle.DirtyVariable("inputs");
|
||||
|
@ -181,7 +181,7 @@ void zelda64::cancel_scanning_input() {
|
|||
controls_model_handle.DirtyVariable("active_binding_slot");
|
||||
}
|
||||
|
||||
void zelda64::config_menu_set_cont_or_kb(bool cont_interacted) {
|
||||
void recomp::config_menu_set_cont_or_kb(bool cont_interacted) {
|
||||
if (cont_active != cont_interacted) {
|
||||
cont_active = cont_interacted;
|
||||
|
||||
|
@ -275,54 +275,54 @@ struct ControlOptionsContext {
|
|||
int gyro_sensitivity; // 0 to 100
|
||||
int mouse_sensitivity; // 0 to 100
|
||||
int joystick_deadzone; // 0 to 100
|
||||
zelda64::TargetingMode targeting_mode;
|
||||
zelda64::BackgroundInputMode background_input_mode;
|
||||
zelda64::TargetingMode targeting_mode;
|
||||
recomp::BackgroundInputMode background_input_mode;
|
||||
zelda64::AutosaveMode autosave_mode;
|
||||
zelda64::CameraInvertMode camera_invert_mode;
|
||||
zelda64::CameraInvertMode camera_invert_mode;
|
||||
zelda64::AnalogCamMode analog_cam_mode;
|
||||
zelda64::CameraInvertMode analog_camera_invert_mode;
|
||||
zelda64::CameraInvertMode analog_camera_invert_mode;
|
||||
};
|
||||
|
||||
ControlOptionsContext control_options_context;
|
||||
|
||||
int zelda64::get_rumble_strength() {
|
||||
int recomp::get_rumble_strength() {
|
||||
return control_options_context.rumble_strength;
|
||||
}
|
||||
|
||||
void zelda64::set_rumble_strength(int strength) {
|
||||
void recomp::set_rumble_strength(int strength) {
|
||||
control_options_context.rumble_strength = strength;
|
||||
if (general_model_handle) {
|
||||
general_model_handle.DirtyVariable("rumble_strength");
|
||||
}
|
||||
}
|
||||
|
||||
int zelda64::get_gyro_sensitivity() {
|
||||
int recomp::get_gyro_sensitivity() {
|
||||
return control_options_context.gyro_sensitivity;
|
||||
}
|
||||
|
||||
int zelda64::get_mouse_sensitivity() {
|
||||
int recomp::get_mouse_sensitivity() {
|
||||
return control_options_context.mouse_sensitivity;
|
||||
}
|
||||
|
||||
int zelda64::get_joystick_deadzone() {
|
||||
int recomp::get_joystick_deadzone() {
|
||||
return control_options_context.joystick_deadzone;
|
||||
}
|
||||
|
||||
void zelda64::set_gyro_sensitivity(int sensitivity) {
|
||||
void recomp::set_gyro_sensitivity(int sensitivity) {
|
||||
control_options_context.gyro_sensitivity = sensitivity;
|
||||
if (general_model_handle) {
|
||||
general_model_handle.DirtyVariable("gyro_sensitivity");
|
||||
}
|
||||
}
|
||||
|
||||
void zelda64::set_mouse_sensitivity(int sensitivity) {
|
||||
void recomp::set_mouse_sensitivity(int sensitivity) {
|
||||
control_options_context.mouse_sensitivity = sensitivity;
|
||||
if (general_model_handle) {
|
||||
general_model_handle.DirtyVariable("mouse_sensitivity");
|
||||
}
|
||||
}
|
||||
|
||||
void zelda64::set_joystick_deadzone(int deadzone) {
|
||||
void recomp::set_joystick_deadzone(int deadzone) {
|
||||
control_options_context.joystick_deadzone = deadzone;
|
||||
if (general_model_handle) {
|
||||
general_model_handle.DirtyVariable("joystick_deadzone");
|
||||
|
@ -340,18 +340,18 @@ void zelda64::set_targeting_mode(zelda64::TargetingMode mode) {
|
|||
}
|
||||
}
|
||||
|
||||
zelda64::BackgroundInputMode zelda64::get_background_input_mode() {
|
||||
recomp::BackgroundInputMode recomp::get_background_input_mode() {
|
||||
return control_options_context.background_input_mode;
|
||||
}
|
||||
|
||||
void zelda64::set_background_input_mode(zelda64::BackgroundInputMode mode) {
|
||||
void recomp::set_background_input_mode(recomp::BackgroundInputMode mode) {
|
||||
control_options_context.background_input_mode = mode;
|
||||
if (general_model_handle) {
|
||||
general_model_handle.DirtyVariable("background_input_mode");
|
||||
}
|
||||
SDL_SetHint(
|
||||
SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS,
|
||||
mode == zelda64::BackgroundInputMode::On
|
||||
mode == recomp::BackgroundInputMode::On
|
||||
? "1"
|
||||
: "0"
|
||||
);
|
||||
|
@ -551,9 +551,9 @@ public:
|
|||
|
||||
recompui::register_event(listener, "toggle_input_device",
|
||||
[](const std::string& param, Rml::Event& event) {
|
||||
cur_device = cur_device == zelda64::InputDevice::Controller
|
||||
? zelda64::InputDevice::Keyboard
|
||||
: zelda64::InputDevice::Controller;
|
||||
cur_device = cur_device == recomp::InputDevice::Controller
|
||||
? recomp::InputDevice::Keyboard
|
||||
: recomp::InputDevice::Controller;
|
||||
controls_model_handle.DirtyVariable("input_device_is_keyboard");
|
||||
controls_model_handle.DirtyVariable("inputs");
|
||||
});
|
||||
|
@ -707,29 +707,29 @@ public:
|
|||
throw std::runtime_error("Failed to make RmlUi data model for the controls config menu");
|
||||
}
|
||||
|
||||
constructor.BindFunc("input_count", [](Rml::Variant& out) { out = zelda64::get_num_inputs(); } );
|
||||
constructor.BindFunc("input_device_is_keyboard", [](Rml::Variant& out) { out = cur_device == zelda64::InputDevice::Keyboard; } );
|
||||
constructor.BindFunc("input_count", [](Rml::Variant& out) { out = recomp::get_num_inputs(); } );
|
||||
constructor.BindFunc("input_device_is_keyboard", [](Rml::Variant& out) { out = cur_device == recomp::InputDevice::Keyboard; } );
|
||||
|
||||
constructor.RegisterTransformFunc("get_input_name", [](const Rml::VariantList& inputs) {
|
||||
return Rml::Variant{zelda64::get_input_name(static_cast<zelda64::GameInput>(inputs.at(0).Get<size_t>()))};
|
||||
return Rml::Variant{recomp::get_input_name(static_cast<recomp::GameInput>(inputs.at(0).Get<size_t>()))};
|
||||
});
|
||||
|
||||
constructor.RegisterTransformFunc("get_input_enum_name", [](const Rml::VariantList& inputs) {
|
||||
return Rml::Variant{zelda64::get_input_enum_name(static_cast<zelda64::GameInput>(inputs.at(0).Get<size_t>()))};
|
||||
return Rml::Variant{recomp::get_input_enum_name(static_cast<recomp::GameInput>(inputs.at(0).Get<size_t>()))};
|
||||
});
|
||||
|
||||
constructor.BindEventCallback("set_input_binding",
|
||||
[](Rml::DataModelHandle model_handle, Rml::Event& event, const Rml::VariantList& inputs) {
|
||||
scanned_input_index = inputs.at(0).Get<size_t>();
|
||||
scanned_binding_index = inputs.at(1).Get<size_t>();
|
||||
zelda64::start_scanning_input(cur_device);
|
||||
recomp::start_scanning_input(cur_device);
|
||||
model_handle.DirtyVariable("active_binding_input");
|
||||
model_handle.DirtyVariable("active_binding_slot");
|
||||
});
|
||||
|
||||
constructor.BindEventCallback("reset_input_bindings_to_defaults",
|
||||
[](Rml::DataModelHandle model_handle, Rml::Event& event, const Rml::VariantList& inputs) {
|
||||
if (cur_device == zelda64::InputDevice::Controller) {
|
||||
if (cur_device == recomp::InputDevice::Controller) {
|
||||
zelda64::reset_cont_input_bindings();
|
||||
} else {
|
||||
zelda64::reset_kb_input_bindings();
|
||||
|
@ -739,9 +739,9 @@ public:
|
|||
|
||||
constructor.BindEventCallback("clear_input_bindings",
|
||||
[](Rml::DataModelHandle model_handle, Rml::Event& event, const Rml::VariantList& inputs) {
|
||||
zelda64::GameInput input = static_cast<zelda64::GameInput>(inputs.at(0).Get<size_t>());
|
||||
for (size_t binding_index = 0; binding_index < zelda64::bindings_per_input; binding_index++) {
|
||||
zelda64::set_input_binding(input, binding_index, cur_device, zelda64::InputField{});
|
||||
recomp::GameInput input = static_cast<recomp::GameInput>(inputs.at(0).Get<size_t>());
|
||||
for (size_t binding_index = 0; binding_index < recomp::bindings_per_input; binding_index++) {
|
||||
recomp::set_input_binding(input, binding_index, cur_device, recomp::InputField{});
|
||||
}
|
||||
model_handle.DirtyVariable("inputs");
|
||||
});
|
||||
|
@ -761,7 +761,7 @@ public:
|
|||
struct InputFieldVariableDefinition : public Rml::VariableDefinition {
|
||||
InputFieldVariableDefinition() : Rml::VariableDefinition(Rml::DataVariableType::Scalar) {}
|
||||
|
||||
virtual bool Get(void* ptr, Rml::Variant& variant) override { variant = reinterpret_cast<zelda64::InputField*>(ptr)->to_string(); return true; }
|
||||
virtual bool Get(void* ptr, Rml::Variant& variant) override { variant = reinterpret_cast<recomp::InputField*>(ptr)->to_string(); return true; }
|
||||
virtual bool Set(void* ptr, const Rml::Variant& variant) override { return false; }
|
||||
};
|
||||
// Static instance of the InputField variable definition to have a pointer to return to RmlUi.
|
||||
|
@ -774,10 +774,10 @@ public:
|
|||
virtual bool Get(void* ptr, Rml::Variant& variant) override { return false; }
|
||||
virtual bool Set(void* ptr, const Rml::Variant& variant) override { return false; }
|
||||
|
||||
virtual int Size(void* ptr) override { return zelda64::bindings_per_input; }
|
||||
virtual int Size(void* ptr) override { return recomp::bindings_per_input; }
|
||||
virtual Rml::DataVariable Child(void* ptr, const Rml::DataAddressEntry& address) override {
|
||||
zelda64::GameInput input = static_cast<zelda64::GameInput>((uintptr_t)ptr);
|
||||
return Rml::DataVariable{&input_field_definition_instance, &zelda64::get_input_binding(input, address.index, cur_device)};
|
||||
recomp::GameInput input = static_cast<recomp::GameInput>((uintptr_t)ptr);
|
||||
return Rml::DataVariable{&input_field_definition_instance, &recomp::get_input_binding(input, address.index, cur_device)};
|
||||
}
|
||||
};
|
||||
// Static instance of the InputField array variable definition to have a fixed pointer to return to RmlUi.
|
||||
|
@ -790,7 +790,7 @@ public:
|
|||
virtual bool Get(void* ptr, Rml::Variant& variant) override { return false; }
|
||||
virtual bool Set(void* ptr, const Rml::Variant& variant) override { return false; }
|
||||
|
||||
virtual int Size(void* ptr) override { return zelda64::get_num_inputs(); }
|
||||
virtual int Size(void* ptr) override { return recomp::get_num_inputs(); }
|
||||
virtual Rml::DataVariable Child(void* ptr, const Rml::DataAddressEntry& address) override {
|
||||
// Encode the input index as the pointer to avoid needing to do any allocations.
|
||||
return Rml::DataVariable(&binding_container_var_instance, (void*)(uintptr_t)address.index);
|
||||
|
@ -806,14 +806,14 @@ public:
|
|||
virtual bool Get(void* ptr, Rml::Variant& variant) override { return true; }
|
||||
virtual bool Set(void* ptr, const Rml::Variant& variant) override { return false; }
|
||||
|
||||
virtual int Size(void* ptr) override { return zelda64::get_num_inputs(); }
|
||||
virtual int Size(void* ptr) override { return recomp::get_num_inputs(); }
|
||||
virtual Rml::DataVariable Child(void* ptr, const Rml::DataAddressEntry& address) override {
|
||||
if (address.name == "array") {
|
||||
return Rml::DataVariable(&binding_array_var_instance, nullptr);
|
||||
}
|
||||
else {
|
||||
zelda64::GameInput input = zelda64::get_input_from_enum_name(address.name);
|
||||
if (input != zelda64::GameInput::COUNT) {
|
||||
recomp::GameInput input = recomp::get_input_from_enum_name(address.name);
|
||||
if (input != recomp::GameInput::COUNT) {
|
||||
return Rml::DataVariable(&binding_container_var_instance, (void*)(uintptr_t)input);
|
||||
}
|
||||
}
|
||||
|
@ -834,7 +834,7 @@ public:
|
|||
out = "NONE";
|
||||
}
|
||||
else {
|
||||
out = zelda64::get_input_enum_name(static_cast<zelda64::GameInput>(focused_input_index));
|
||||
out = recomp::get_input_enum_name(static_cast<recomp::GameInput>(focused_input_index));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -843,7 +843,7 @@ public:
|
|||
out = "NONE";
|
||||
}
|
||||
else {
|
||||
out = zelda64::get_input_enum_name(static_cast<zelda64::GameInput>(scanned_input_index));
|
||||
out = recomp::get_input_enum_name(static_cast<recomp::GameInput>(scanned_input_index));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -973,7 +973,7 @@ public:
|
|||
|
||||
void make_bindings(Rml::Context* context) override {
|
||||
// initially set cont state for ui help
|
||||
zelda64::config_menu_set_cont_or_kb(recompui::get_cont_active());
|
||||
recomp::config_menu_set_cont_or_kb(recompui::get_cont_active());
|
||||
make_nav_help_bindings(context);
|
||||
make_general_bindings(context);
|
||||
make_controls_bindings(context);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "zelda_ui.h"
|
||||
#include "recomp_ui.h"
|
||||
#include "zelda_config.h"
|
||||
#include "librecomp/game.hpp"
|
||||
#include "ultramodern/ultramodern.hpp"
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
#endif
|
||||
|
||||
|
||||
#include "zelda_ui.h"
|
||||
#include "zelda_input.h"
|
||||
#include "recomp_ui.h"
|
||||
#include "recomp_input.h"
|
||||
#include "librecomp/game.hpp"
|
||||
#include "zelda_config.h"
|
||||
#include "ui_rml_hacks.hpp"
|
||||
|
@ -1201,8 +1201,8 @@ int cont_button_to_key(SDL_ControllerButtonEvent& button) {
|
|||
}
|
||||
|
||||
// Allows closing the menu
|
||||
auto menuToggleBinding0 = zelda64::get_input_binding(zelda64::GameInput::TOGGLE_MENU, 0, zelda64::InputDevice::Controller);
|
||||
auto menuToggleBinding1 = zelda64::get_input_binding(zelda64::GameInput::TOGGLE_MENU, 1, zelda64::InputDevice::Controller);
|
||||
auto menuToggleBinding0 = recomp::get_input_binding(recomp::GameInput::TOGGLE_MENU, 0, recomp::InputDevice::Controller);
|
||||
auto menuToggleBinding1 = recomp::get_input_binding(recomp::GameInput::TOGGLE_MENU, 1, recomp::InputDevice::Controller);
|
||||
// note - magic number: 0 is InputType::None
|
||||
if ((menuToggleBinding0.input_type != 0 && button.button == menuToggleBinding0.input_id) ||
|
||||
(menuToggleBinding1.input_type != 0 && button.button == menuToggleBinding1.input_id)) {
|
||||
|
@ -1226,14 +1226,14 @@ int cont_axis_to_key(SDL_ControllerAxisEvent& axis, float value) {
|
|||
}
|
||||
|
||||
void apply_background_input_mode() {
|
||||
static zelda64::BackgroundInputMode last_input_mode = zelda64::BackgroundInputMode::OptionCount;
|
||||
static recomp::BackgroundInputMode last_input_mode = recomp::BackgroundInputMode::OptionCount;
|
||||
|
||||
zelda64::BackgroundInputMode cur_input_mode = zelda64::get_background_input_mode();
|
||||
recomp::BackgroundInputMode cur_input_mode = recomp::get_background_input_mode();
|
||||
|
||||
if (last_input_mode != cur_input_mode) {
|
||||
SDL_SetHint(
|
||||
SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS,
|
||||
cur_input_mode == zelda64::BackgroundInputMode::On
|
||||
cur_input_mode == recomp::BackgroundInputMode::On
|
||||
? "1"
|
||||
: "0"
|
||||
);
|
||||
|
@ -1311,7 +1311,7 @@ void draw_hook(RT64::RenderCommandList* command_list, RT64::RenderFramebuffer* s
|
|||
while (recompui::try_deque_event(cur_event)) {
|
||||
bool menu_is_open = cur_menu != recompui::Menu::None;
|
||||
|
||||
if (!zelda64::all_input_disabled()) {
|
||||
if (!recomp::all_input_disabled()) {
|
||||
// Implement some additional behavior for specific events on top of what RmlUi normally does with them.
|
||||
switch (cur_event.type) {
|
||||
case SDL_EventType::SDL_MOUSEMOTION: {
|
||||
|
@ -1395,8 +1395,8 @@ void draw_hook(RT64::RenderCommandList* command_list, RT64::RenderFramebuffer* s
|
|||
}
|
||||
break;
|
||||
case SDL_EventType::SDL_CONTROLLERBUTTONDOWN:
|
||||
auto menuToggleBinding0 = zelda64::get_input_binding(zelda64::GameInput::TOGGLE_MENU, 0, zelda64::InputDevice::Controller);
|
||||
auto menuToggleBinding1 = zelda64::get_input_binding(zelda64::GameInput::TOGGLE_MENU, 1, zelda64::InputDevice::Controller);
|
||||
auto menuToggleBinding0 = recomp::get_input_binding(recomp::GameInput::TOGGLE_MENU, 0, recomp::InputDevice::Controller);
|
||||
auto menuToggleBinding1 = recomp::get_input_binding(recomp::GameInput::TOGGLE_MENU, 1, recomp::InputDevice::Controller);
|
||||
// note - magic number: 0 is InputType::None
|
||||
if ((menuToggleBinding0.input_type != 0 && cur_event.cbutton.button == menuToggleBinding0.input_id) ||
|
||||
(menuToggleBinding1.input_type != 0 && cur_event.cbutton.button == menuToggleBinding1.input_id)) {
|
||||
|
@ -1416,11 +1416,11 @@ void draw_hook(RT64::RenderCommandList* command_list, RT64::RenderFramebuffer* s
|
|||
if (cont_interacted || kb_interacted || mouse_clicked) {
|
||||
recompui::set_cont_active(cont_interacted);
|
||||
}
|
||||
zelda64::config_menu_set_cont_or_kb(ui_context->rml.cont_is_active);
|
||||
recomp::config_menu_set_cont_or_kb(ui_context->rml.cont_is_active);
|
||||
|
||||
zelda64::InputField scanned_field = zelda64::get_scanned_input();
|
||||
if (scanned_field != zelda64::InputField{}) {
|
||||
zelda64::finish_scanning_input(scanned_field);
|
||||
recomp::InputField scanned_field = recomp::get_scanned_input();
|
||||
if (scanned_field != recomp::InputField{}) {
|
||||
recomp::finish_scanning_input(scanned_field);
|
||||
}
|
||||
|
||||
ui_context->rml.update_primary_input(mouse_moved, non_mouse_interacted);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "zelda_ui.h"
|
||||
#include "recomp_ui.h"
|
||||
#include "RmlUi/Core.h"
|
||||
#include "ui_rml_hacks.hpp"
|
||||
|
||||
|
|
Loading…
Reference in New Issue