Skip to content

Commit 03f22b0

Browse files
committed
Add cli flag to disable the software arrow buttons
1 parent 3f1f2c8 commit 03f22b0

File tree

4 files changed

+22
-15
lines changed

4 files changed

+22
-15
lines changed

Cargo.lock

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ tetris_core = "0.2"
1313
downcast-rs = "1.2"
1414
fxhash = "0.2"
1515
clap = "3.0.0-beta.1"
16+
lazy_static = "1.4.0"

src/main.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/// Test ABC
2-
31
#[macro_use]
42
extern crate downcast_rs;
53

@@ -10,24 +8,29 @@ mod swipe;
108
use clap::{Clap, crate_version, crate_authors};
119
use crate::canvas::Canvas;
1210
use crate::scene::*;
11+
use lazy_static::lazy_static;
1312
use libremarkable::input::{InputDevice, InputEvent, ev::EvDevContext};
1413
use std::process::Command;
1514
use std::time::{SystemTime, Duration};
1615
use std::thread::sleep;
1716
use tetris_core::Size;
1817

19-
2018
#[derive(Clap)]
2119
#[clap(version = crate_version!(), author = crate_authors!())]
22-
struct Opts {
23-
#[clap(long, short)]
24-
spare_xochitl: bool
20+
pub struct Opts {
21+
#[clap(long, short, about = "Don't stop xochitl service when a xochitl process is found.")]
22+
spare_xochitl: bool,
23+
24+
#[clap(long, short = "A", about = "Don't display the left and right software arrow buttons.")]
25+
no_arrow_buttons: bool,
2526
}
2627

27-
fn main() {
28-
let opts: Opts = Opts::parse();
28+
lazy_static! {
29+
pub static ref CLI_OPTS: Opts = Opts::parse();
30+
}
2931

30-
let only_exit_to_xochitl = if opts.spare_xochitl {
32+
fn main() {
33+
let only_exit_to_xochitl = if CLI_OPTS.spare_xochitl {
3134
false
3235
}else if let Ok(status) = Command::new("pidof").arg("xochitl").status() {
3336
if status.code().unwrap() == 0 {

src/scene/game_scene.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -383,11 +383,13 @@ impl Scene for GameScene {
383383
let lr_vgap = 50;
384384
let lr_hgap = 50;
385385
let lr_font_size = 100.0;
386-
self.left_button_hitbox = Some(canvas.draw_button(Point2 { x: Some(lr_x_margin), y: Some(lr_y_pos) }, "«", lr_font_size, lr_vgap, lr_hgap));
387-
self.right_button_hitbox = Some(canvas.draw_button(Point2 {
388-
x: Some(DISPLAYWIDTH as i32 + lr_hgap as i32 - (self.left_button_hitbox.unwrap().left as i32 + self.left_button_hitbox.unwrap().width as i32)),
389-
y: Some(lr_y_pos)
390-
}, "»", lr_font_size, lr_vgap, lr_hgap));
386+
if ! crate::CLI_OPTS.no_arrow_buttons {
387+
self.left_button_hitbox = Some(canvas.draw_button(Point2 { x: Some(lr_x_margin), y: Some(lr_y_pos) }, "«", lr_font_size, lr_vgap, lr_hgap));
388+
self.right_button_hitbox = Some(canvas.draw_button(Point2 {
389+
x: Some(DISPLAYWIDTH as i32 + lr_hgap as i32 - (self.left_button_hitbox.unwrap().left as i32 + self.left_button_hitbox.unwrap().width as i32)),
390+
y: Some(lr_y_pos)
391+
}, "»", lr_font_size, lr_vgap, lr_hgap));
392+
}
391393

392394
canvas.update_full();
393395
self.draw_score(canvas);

0 commit comments

Comments
 (0)