mirror of https://github.com/wayvr-org/wayvr.git
clippy, minor refactoring
This commit is contained in:
parent
860ae92edf
commit
92b9cb8d30
|
|
@ -56,6 +56,8 @@ fn vdf_parse_libraryfolders<'a>(vdf_root: &'a Vdf<'a>) -> Option<Vec<AppEntry>>
|
|||
let mut res = Vec::<AppEntry>::new();
|
||||
|
||||
let mut num = 0;
|
||||
|
||||
#[allow(clippy::while_let_loop)]
|
||||
loop {
|
||||
let Some(library_folder) = get_obj_first(obj_libraryfolders, format!("{}", num).as_str()) else {
|
||||
// no more libraries to find
|
||||
|
|
@ -293,7 +295,7 @@ impl SteamUtils {
|
|||
games.sort_by(|a, b| b.name.cmp(&a.name));
|
||||
}
|
||||
GameSortMethod::PlayDateDesc => {
|
||||
games.sort_by(|a, b| b.last_played.cmp(&a.last_played));
|
||||
games.sort_by_key(|b| std::cmp::Reverse(b.last_played));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -125,10 +125,8 @@ impl InputState {
|
|||
hand.interaction.mode = PointerMode::Left;
|
||||
}
|
||||
}
|
||||
PointerMode::Right => {
|
||||
if !right_click_orientation {
|
||||
hand.interaction.mode = PointerMode::Left;
|
||||
}
|
||||
PointerMode::Right if !right_click_orientation => {
|
||||
hand.interaction.mode = PointerMode::Left;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -216,63 +216,51 @@ impl OpenVrInputSource {
|
|||
|
||||
app_hand.now.click = input
|
||||
.get_digital_action_data(self.click_hnd, hand.input_hnd)
|
||||
.map(|x| x.0.bState)
|
||||
.unwrap_or(false);
|
||||
.is_ok_and(|x| x.0.bState);
|
||||
|
||||
app_hand.now.grab = input
|
||||
.get_digital_action_data(self.grab_hnd, hand.input_hnd)
|
||||
.map(|x| x.0.bState)
|
||||
.unwrap_or(false);
|
||||
.is_ok_and(|x| x.0.bState);
|
||||
|
||||
app_hand.now.alt_click = input
|
||||
.get_digital_action_data(self.alt_click_hnd, hand.input_hnd)
|
||||
.map(|x| x.0.bState)
|
||||
.unwrap_or(false);
|
||||
.is_ok_and(|x| x.0.bState);
|
||||
|
||||
app_hand.now.show_hide = input
|
||||
.get_digital_action_data(self.show_hide_hnd, hand.input_hnd)
|
||||
.map(|x| x.0.bState)
|
||||
.unwrap_or(false);
|
||||
.is_ok_and(|x| x.0.bState);
|
||||
|
||||
app_hand.now.toggle_dashboard = input
|
||||
.get_digital_action_data(self.toggle_dashboard_hnd, hand.input_hnd)
|
||||
.map(|x| x.0.bState)
|
||||
.unwrap_or(false);
|
||||
.is_ok_and(|x| x.0.bState);
|
||||
|
||||
app_hand.now.space_drag = input
|
||||
.get_digital_action_data(self.space_drag_hnd, hand.input_hnd)
|
||||
.map(|x| x.0.bState)
|
||||
.unwrap_or(false);
|
||||
.is_ok_and(|x| x.0.bState);
|
||||
|
||||
app_hand.now.space_rotate = input
|
||||
.get_digital_action_data(self.space_rotate_hnd, hand.input_hnd)
|
||||
.map(|x| x.0.bState)
|
||||
.unwrap_or(false);
|
||||
.is_ok_and(|x| x.0.bState);
|
||||
|
||||
app_hand.now.space_reset = input
|
||||
.get_digital_action_data(self.space_reset_hnd, hand.input_hnd)
|
||||
.map(|x| x.0.bState)
|
||||
.unwrap_or(false);
|
||||
.is_ok_and(|x| x.0.bState);
|
||||
|
||||
app_hand.now.click_modifier_right = input
|
||||
.get_digital_action_data(self.click_modifier_right_hnd, hand.input_hnd)
|
||||
.map(|x| x.0.bState)
|
||||
.unwrap_or(false);
|
||||
.is_ok_and(|x| x.0.bState);
|
||||
|
||||
app_hand.now.click_modifier_middle = input
|
||||
.get_digital_action_data(self.click_modifier_middle_hnd, hand.input_hnd)
|
||||
.map(|x| x.0.bState)
|
||||
.unwrap_or(false);
|
||||
.is_ok_and(|x| x.0.bState);
|
||||
|
||||
app_hand.now.move_mouse = input
|
||||
.get_digital_action_data(self.move_mouse_hnd, hand.input_hnd)
|
||||
.map(|x| x.0.bState)
|
||||
.unwrap_or(false);
|
||||
.is_ok_and(|x| x.0.bState);
|
||||
|
||||
let scroll = input
|
||||
.get_analog_action_data(self.scroll_hnd, hand.input_hnd)
|
||||
.map(|x| (x.0.x, x.0.y))
|
||||
.unwrap_or((0.0, 0.0));
|
||||
.map_or((0.0, 0.0), |x| (x.0.x, x.0.y));
|
||||
app_hand.now.scroll_x = scroll.0;
|
||||
app_hand.now.scroll_y = scroll.1;
|
||||
}
|
||||
|
|
@ -364,8 +352,7 @@ fn get_tracked_device(
|
|||
index,
|
||||
ETrackedDeviceProperty::Prop_TrackingSystemName_String,
|
||||
)
|
||||
.map(|x: String| x.contains("ALVR"))
|
||||
.unwrap_or(false);
|
||||
.is_ok_and(|x: String| x.contains("ALVR"));
|
||||
|
||||
if is_alvr {
|
||||
// don't show ALVR's fake trackers on battery panel
|
||||
|
|
|
|||
|
|
@ -519,7 +519,7 @@ pub fn openxr_run(
|
|||
let watch = overlays.mut_by_id(watch_id).unwrap(); // want panic
|
||||
|
||||
if let Some(state) = watch.config.active_state.as_mut() {
|
||||
state.transform = watch_transform
|
||||
state.transform = watch_transform;
|
||||
}
|
||||
if !app.session.config.enable_watch {
|
||||
watch.config.deactivate();
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ impl WGfxExtras {
|
|||
| MemoryTypeFilter::HOST_SEQUENTIAL_WRITE,
|
||||
..Default::default()
|
||||
},
|
||||
vertices.into_iter(),
|
||||
vertices,
|
||||
)?;
|
||||
|
||||
let mut cmd_xfer = gfx.create_xfer_command_buffer(CommandBufferUsage::OneTimeSubmit)?;
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ impl DbusConnector {
|
|||
let proxy = connection.with_proxy(
|
||||
"org.freedesktop.DBus",
|
||||
"/org/freedesktop/DBus",
|
||||
Duration::from_millis(5000),
|
||||
Duration::from_secs(5),
|
||||
);
|
||||
let result: Result<(), dbus::Error> = proxy.method_call(
|
||||
"org.freedesktop.DBus.Monitoring",
|
||||
|
|
|
|||
|
|
@ -288,13 +288,13 @@ where
|
|||
self.sets_changed(app);
|
||||
}
|
||||
OverlayTask::SettingsChanged => {
|
||||
if let Some(watch) = self.mut_by_id(self.watch_id) {
|
||||
if app.session.config.enable_watch != watch.config.active_state.is_some() {
|
||||
if watch.config.active_state.is_some() {
|
||||
watch.config.deactivate();
|
||||
} else {
|
||||
watch.config.activate(app);
|
||||
}
|
||||
if let Some(watch) = self.mut_by_id(self.watch_id)
|
||||
&& app.session.config.enable_watch != watch.config.active_state.is_some()
|
||||
{
|
||||
if watch.config.active_state.is_some() {
|
||||
watch.config.deactivate();
|
||||
} else {
|
||||
watch.config.activate(app);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,9 +61,7 @@ impl TextRenderer {
|
|||
|
||||
let resolution = viewport.resolution();
|
||||
let mut glyphs_to_render = Vec::new();
|
||||
let mut pending_glyph_uploads = Vec::new();
|
||||
let mut missing_glyphs = HashSet::new();
|
||||
let mut unavailable_glyphs = HashSet::new();
|
||||
let mut glyphs_todo = GlyphsTodo::default();
|
||||
|
||||
for text_area in text_areas {
|
||||
let bounds_min_x = text_area.bounds.left.max(0);
|
||||
|
|
@ -101,13 +99,13 @@ impl TextRenderer {
|
|||
.unwrap_or(text_area.default_color);
|
||||
|
||||
if queue_missing_glyph_upload(
|
||||
atlas,
|
||||
font_system,
|
||||
cache,
|
||||
cache_key,
|
||||
&mut missing_glyphs,
|
||||
&mut unavailable_glyphs,
|
||||
&mut pending_glyph_uploads,
|
||||
&mut QueueMissingGlyphUploadParams {
|
||||
atlas,
|
||||
font_system,
|
||||
cache,
|
||||
cache_key,
|
||||
glyphs_todo: &mut glyphs_todo,
|
||||
},
|
||||
|_cache, _font_system| -> Option<GetGlyphImageResult> {
|
||||
if cached_width == 0 || cached_height == 0 {
|
||||
return None;
|
||||
|
|
@ -180,13 +178,13 @@ impl TextRenderer {
|
|||
let cache_key = GlyphonCacheKey::Text(physical_glyph.cache_key);
|
||||
|
||||
if queue_missing_glyph_upload(
|
||||
atlas,
|
||||
font_system,
|
||||
cache,
|
||||
cache_key,
|
||||
&mut missing_glyphs,
|
||||
&mut unavailable_glyphs,
|
||||
&mut pending_glyph_uploads,
|
||||
&mut QueueMissingGlyphUploadParams {
|
||||
atlas,
|
||||
font_system,
|
||||
cache,
|
||||
cache_key,
|
||||
glyphs_todo: &mut glyphs_todo,
|
||||
},
|
||||
|cache, font_system| -> Option<GetGlyphImageResult> {
|
||||
let image = cache.get_image_uncached(font_system, physical_glyph.cache_key)?;
|
||||
|
||||
|
|
@ -229,7 +227,7 @@ impl TextRenderer {
|
|||
}
|
||||
}
|
||||
|
||||
upload_missing_glyphs(atlas, font_system, cache, pending_glyph_uploads)?;
|
||||
upload_missing_glyphs(atlas, font_system, cache, glyphs_todo.pending_uploads)?;
|
||||
|
||||
for glyph in &glyphs_to_render {
|
||||
if let Some(glyph_to_render) = prepare_glyph(&mut PrepareGlyphParams {
|
||||
|
|
@ -349,31 +347,43 @@ struct PrepareGlyphParams<'a> {
|
|||
model_buffer: &'a mut ModelBuffer,
|
||||
}
|
||||
|
||||
fn queue_missing_glyph_upload(
|
||||
atlas: &mut TextAtlas,
|
||||
font_system: &mut FontSystem,
|
||||
cache: &mut SwashCache,
|
||||
#[derive(Default)]
|
||||
struct GlyphsTodo {
|
||||
pending_uploads: Vec<PendingGlyphUpload>,
|
||||
missing: HashSet<GlyphonCacheKey>,
|
||||
unavailable: HashSet<GlyphonCacheKey>,
|
||||
}
|
||||
|
||||
struct QueueMissingGlyphUploadParams<'a> {
|
||||
atlas: &'a mut TextAtlas,
|
||||
font_system: &'a mut FontSystem,
|
||||
cache: &'a mut SwashCache,
|
||||
cache_key: GlyphonCacheKey,
|
||||
missing_glyphs: &mut HashSet<GlyphonCacheKey>,
|
||||
unavailable_glyphs: &mut HashSet<GlyphonCacheKey>,
|
||||
pending_glyph_uploads: &mut Vec<PendingGlyphUpload>,
|
||||
glyphs_todo: &'a mut GlyphsTodo,
|
||||
}
|
||||
|
||||
fn queue_missing_glyph_upload(
|
||||
par: &mut QueueMissingGlyphUploadParams,
|
||||
get_glyph_image: impl FnOnce(&mut SwashCache, &mut FontSystem) -> Option<GetGlyphImageResult>,
|
||||
) -> bool {
|
||||
if mark_glyph_in_use_if_cached(atlas, cache_key) {
|
||||
if mark_glyph_in_use_if_cached(par.atlas, par.cache_key) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if unavailable_glyphs.contains(&cache_key) {
|
||||
if par.glyphs_todo.unavailable.contains(&par.cache_key) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if missing_glyphs.insert(cache_key) {
|
||||
let Some(image) = get_glyph_image(cache, font_system) else {
|
||||
unavailable_glyphs.insert(cache_key);
|
||||
if par.glyphs_todo.missing.insert(par.cache_key) {
|
||||
let Some(image) = get_glyph_image(par.cache, par.font_system) else {
|
||||
par.glyphs_todo.unavailable.insert(par.cache_key);
|
||||
return false;
|
||||
};
|
||||
|
||||
pending_glyph_uploads.push(PendingGlyphUpload { cache_key, image });
|
||||
par.glyphs_todo.pending_uploads.push(PendingGlyphUpload {
|
||||
cache_key: par.cache_key,
|
||||
image,
|
||||
});
|
||||
}
|
||||
|
||||
true
|
||||
|
|
@ -422,6 +432,7 @@ fn upload_missing_glyphs(
|
|||
for (upload_index, upload) in rasterized_uploads.iter().enumerate() {
|
||||
let content_type = upload.image.content_type;
|
||||
|
||||
#[allow(clippy::never_loop)]
|
||||
let allocation = loop {
|
||||
if let Some(allocation) = {
|
||||
let inner = atlas.inner_for_content_mut(content_type);
|
||||
|
|
|
|||
Loading…
Reference in New Issue