mirror of
https://github.com/JanNeuendorf/SVC16.git
synced 2025-06-04 18:45:27 +00:00
Allow for fractional scaling if the filtering is set to linear
This commit is contained in:
parent
c809f5774a
commit
3f9f0a037c
@ -34,7 +34,7 @@ pub struct Cli {
|
||||
long,
|
||||
short,
|
||||
default_value_t = false,
|
||||
help = "Use linear filtering (instead of pixel-perfect)"
|
||||
help = "Use linear filtering (instead of pixel-perfect) this enables fractional scaling"
|
||||
)]
|
||||
pub linear_filtering: bool,
|
||||
}
|
||||
|
@ -73,6 +73,7 @@ async fn main() -> Result<()> {
|
||||
cli.cursor = !cli.cursor;
|
||||
}
|
||||
|
||||
let layout = Layout::generate(cli.linear_filtering);
|
||||
if !paused {
|
||||
ipf = 0;
|
||||
while !engine.wants_to_sync() && ipf <= MAX_IPF {
|
||||
@ -85,10 +86,10 @@ async fn main() -> Result<()> {
|
||||
gilrs.update(&event);
|
||||
}
|
||||
#[cfg(not(feature = "gamepad"))]
|
||||
let (mpos, keycode) = get_input_code_no_gamepad();
|
||||
let (mpos, keycode) = get_input_code_no_gamepad(&layout);
|
||||
|
||||
#[cfg(feature = "gamepad")]
|
||||
let (mpos, keycode) = get_input_code_gamepad(&gilrs);
|
||||
let (mpos, keycode) = get_input_code_gamepad(&layout, &gilrs);
|
||||
|
||||
engine.perform_sync(mpos, keycode, &mut raw_buffer);
|
||||
update_image_buffer(&mut buffer, &raw_buffer);
|
||||
@ -96,7 +97,6 @@ async fn main() -> Result<()> {
|
||||
texture.update(&image);
|
||||
}
|
||||
clear_background(BLACK);
|
||||
let layout = Layout::generate();
|
||||
|
||||
if layout.cursor_in_window() {
|
||||
show_mouse(cli.cursor);
|
||||
|
@ -10,10 +10,13 @@ pub struct Layout {
|
||||
pub font_size: f32,
|
||||
}
|
||||
impl Layout {
|
||||
pub fn generate() -> Self {
|
||||
pub fn generate(linear: bool) -> Self {
|
||||
let (width, height) = (screen_width(), screen_height());
|
||||
let minsize = width.min(height);
|
||||
let image_size = ((minsize / 256.).floor() * 256.).max(256.);
|
||||
let image_size = match linear {
|
||||
false => ((minsize / 256.).floor() * 256.).max(256.),
|
||||
true => minsize.max(256.),
|
||||
};
|
||||
let x = (0. as f32).max((width - image_size) / 2.);
|
||||
let y = (0. as f32).max((height - image_size) / 2.);
|
||||
let font_y = y + image_size / 15.;
|
||||
|
12
src/utils.rs
12
src/utils.rs
@ -52,14 +52,14 @@ pub fn update_image_buffer(imbuff: &mut [Color; RES * RES], screen: &[u16; RES *
|
||||
}
|
||||
|
||||
#[cfg(feature = "gamepad")]
|
||||
pub fn get_input_code_gamepad(gilrs: &Gilrs) -> (u16, u16) {
|
||||
pub fn get_input_code_gamepad(layout: &Layout, gilrs: &Gilrs) -> (u16, u16) {
|
||||
#[cfg(not(feature = "gamepad"))]
|
||||
return get_input_code_no_gamepad();
|
||||
let mut key_code = 0_u16;
|
||||
let mp = Layout::generate().clamp_mouse();
|
||||
let mp = layout.clamp_mouse();
|
||||
let pos_code = (mp.1 as u16 * 256) + mp.0 as u16;
|
||||
let Some(gamepad) = gilrs.gamepads().next().map(|t| t.1) else {
|
||||
return get_input_code_no_gamepad();
|
||||
return get_input_code_no_gamepad(layout);
|
||||
};
|
||||
let tol = 0.5;
|
||||
let axis_horizontal = gamepad
|
||||
@ -120,10 +120,8 @@ pub fn get_input_code_gamepad(gilrs: &Gilrs) -> (u16, u16) {
|
||||
(pos_code, key_code)
|
||||
}
|
||||
|
||||
pub fn get_input_code_no_gamepad() -> (u16, u16) {
|
||||
use crate::ui::Layout;
|
||||
|
||||
let mp = Layout::generate().clamp_mouse();
|
||||
pub fn get_input_code_no_gamepad(layout: &Layout) -> (u16, u16) {
|
||||
let mp = layout.clamp_mouse();
|
||||
|
||||
let pos_code = (mp.1 as u16 * 256) + mp.0 as u16;
|
||||
let mut key_code = 0_u16;
|
||||
|
Loading…
x
Reference in New Issue
Block a user