use const for unknown name (#962)

This commit is contained in:
Logan McNaughton
2026-05-27 14:23:43 +02:00
committed by GitHub
parent a9f7285c0f
commit dc6138076f
2 changed files with 5 additions and 3 deletions
+1 -1
View File
@@ -392,7 +392,7 @@ fn list_controllers_on_jvm(env: &mut Env<'_>) -> jni::errors::Result<Vec<Control
{
name
} else {
"Unknown controller".to_string()
ui::input::UNKNOWN_CONTROLLER_NAME.to_string()
};
let descriptor = if let Ok(product_id) = device.get_product_id(env)
&& let Ok(vendor_id) = device.get_vendor_id(env)
+4 -2
View File
@@ -30,6 +30,8 @@ const MAX_AXIS_VALUE: f64 = 85.0;
pub const DEADZONE_DEFAULT: i32 = 5;
pub const UNKNOWN_CONTROLLER_NAME: &str = "Unknown controller";
pub struct Controllers {
pub rumble: bool,
pub game_controller: *mut sdl3_sys::gamepad::SDL_Gamepad,
@@ -354,7 +356,7 @@ pub fn get_controller_names() -> Vec<String> {
for joystick in get_joysticks().iter() {
let name = unsafe { sdl3_sys::joystick::SDL_GetJoystickNameForID(*joystick) };
controllers.push(if name.is_null() {
"Unknown controller".to_string()
UNKNOWN_CONTROLLER_NAME.to_string()
} else {
unsafe { std::ffi::CStr::from_ptr(name).to_str().unwrap() }.to_string()
});
@@ -1184,7 +1186,7 @@ pub fn init(ui: &mut ui::Ui) {
{
unsafe { std::ffi::CStr::from_ptr(name).to_str().unwrap() }.to_string()
} else {
"Unknown controller".to_string()
UNKNOWN_CONTROLLER_NAME.to_string()
};
let vendor_id =