From 53605b27441a9dfae8b3d7a98c33a77495029e67 Mon Sep 17 00:00:00 2001 From: Linus Date: Fri, 26 Jan 2024 13:35:36 +0100 Subject: [PATCH 1/3] Check env when using Framebuffer::new() or Default trait to auto-select old way This should ensure that binaries built using this version are fixable without recompiling should issues with our current rm2fb client arise. --- src/framebuffer/core.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/framebuffer/core.rs b/src/framebuffer/core.rs index deaabc7..515aaa8 100644 --- a/src/framebuffer/core.rs +++ b/src/framebuffer/core.rs @@ -50,7 +50,16 @@ impl Framebuffer { let device = &*device::CURRENT_DEVICE; match device.model { Model::Gen1 => Framebuffer::device(device.get_framebuffer_path()), - Model::Gen2 => Framebuffer::rm2fb(device.get_framebuffer_path()), + Model::Gen2 => { + // Auto-select old method still if env LIBREMARKABLE_FB_DISFAVOR_INTERNAL_RM2FB is set affirmatively + if let Ok(env_answer) = std::env::var("LIBREMARKABLE_FB_DISFAVOR_INTERNAL_RM2FB") { + let env_answer = env_answer.to_lowercase(); + if env_answer == "1" || env_answer == "true" || env_answer == "yes" { + Framebuffer::device(device.get_framebuffer_path()) + } + } + Framebuffer::rm2fb(device.get_framebuffer_path()) + } } } From a666f29af1d0d539f72b110239b2dd5e96c2770a Mon Sep 17 00:00:00 2001 From: Linus Date: Fri, 26 Jan 2024 13:45:53 +0100 Subject: [PATCH 2/3] Fix compilation issue Sorry, but my pc has a billion toolchains and I'm not sure which one right now compiles correctly --- src/framebuffer/core.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/framebuffer/core.rs b/src/framebuffer/core.rs index 515aaa8..7a581a6 100644 --- a/src/framebuffer/core.rs +++ b/src/framebuffer/core.rs @@ -56,9 +56,12 @@ impl Framebuffer { let env_answer = env_answer.to_lowercase(); if env_answer == "1" || env_answer == "true" || env_answer == "yes" { Framebuffer::device(device.get_framebuffer_path()) + } else { + Framebuffer::rm2fb(device.get_framebuffer_path()) } + } else { + Framebuffer::rm2fb(device.get_framebuffer_path()) } - Framebuffer::rm2fb(device.get_framebuffer_path()) } } } From 3933c022492e0a140f505f1fd846d6e42d9732c0 Mon Sep 17 00:00:00 2001 From: Pierre Fenoll Date: Fri, 26 Jul 2024 17:23:41 +0200 Subject: [PATCH 3/3] Update src/framebuffer/core.rs --- src/framebuffer/core.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/framebuffer/core.rs b/src/framebuffer/core.rs index 7a581a6..ac9bfd2 100644 --- a/src/framebuffer/core.rs +++ b/src/framebuffer/core.rs @@ -52,15 +52,9 @@ impl Framebuffer { Model::Gen1 => Framebuffer::device(device.get_framebuffer_path()), Model::Gen2 => { // Auto-select old method still if env LIBREMARKABLE_FB_DISFAVOR_INTERNAL_RM2FB is set affirmatively - if let Ok(env_answer) = std::env::var("LIBREMARKABLE_FB_DISFAVOR_INTERNAL_RM2FB") { - let env_answer = env_answer.to_lowercase(); - if env_answer == "1" || env_answer == "true" || env_answer == "yes" { - Framebuffer::device(device.get_framebuffer_path()) - } else { - Framebuffer::rm2fb(device.get_framebuffer_path()) - } - } else { - Framebuffer::rm2fb(device.get_framebuffer_path()) + match std::env::var("LIBREMARKABLE_FB_DISFAVOR_INTERNAL_RM2FB").ok() { + Some("1") => Framebuffer::device(device.get_framebuffer_path()), + _ => Framebuffer::rm2fb(device.get_framebuffer_path()), } } }