Skip to content

Commit

Permalink
do a buncha things! (also gamepad support is now optional)
Browse files Browse the repository at this point in the history
  • Loading branch information
callmeclover authored May 15, 2024
1 parent 8bd92bc commit aa37906
Show file tree
Hide file tree
Showing 18 changed files with 129 additions and 56 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: cargo-clippy
run-name: cargo clippy
on: [push]
jobs:
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo clippy
17 changes: 15 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
[package]
name = "jerry"
version = "0.3.4"
edition = "2021"
description = "stupid robot nuisance"
version = "0.4.0"
authors = ["Clover Johnson <[email protected]>"]
license = "MIT"
repository = "https://github.com/callmeclover/jerry"
build = "build.rs"

[package.metadata.winres]
LegalCopyright = "Copyright © 2024"
FileDescription = "stupid robot nuisance"

[dependencies]
enigo = "0.2.0"
Expand All @@ -24,11 +32,16 @@ ping = "0.5.2"

[dependencies.windows]
version = "0.56.0"
optional = true
features = [
"Gaming_Input",
"UI_Input_Preview_Injection",
]

[build-dependencies]
winres = "0.1"

[features]
invisibility = []
advanced = ["dep:windows"]
#microphone = []
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Clover Johnson

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
33 changes: 0 additions & 33 deletions appx/AppxManifest.xml

This file was deleted.

Empty file removed appx/SplashScreen.png
Empty file.
Binary file removed appx/Square150x150Logo.png
Binary file not shown.
Binary file removed appx/Square44x44Logo.png
Binary file not shown.
Binary file removed appx/StoreLogo.png
Binary file not shown.
22 changes: 22 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
extern crate winres;

fn main() {
if std::env::var("CARGO_CFG_TARGET_OS").unwrap() != "windows" {
return;
}

if std::env::var("PROFILE").unwrap() == "release" {
let mut res = winres::WindowsResource::new();

res.set_icon("icon.ico")
.set_language(0x0409)

if cfg!(feature = "advanced") { res.set_manifest_file("manifest_adv.xml"); }
else { res.set_manifest_file("manifest.xml"); }

if let Err(e) = res.compile() {
eprintln!("{}", e);
std::process::exit(1);
}
}
}
Binary file added icon.ico
Binary file not shown.
16 changes: 16 additions & 0 deletions manifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!-- Windows 8.0 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Windows 10.0 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
</application>
</compatibility>
</assembly>
23 changes: 23 additions & 0 deletions manifest_adv.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!-- Windows 8.0 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Windows 10.0 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
</application>
</compatibility>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
6 changes: 0 additions & 6 deletions registerDbg.cmd

This file was deleted.

6 changes: 0 additions & 6 deletions registerRel.cmd

This file was deleted.

6 changes: 5 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ struct Basic {
#[allow(dead_code)]
use_controller: bool,
#[allow(dead_code)]
use_pen: bool,
#[allow(dead_code)]
use_touch: bool,
#[allow(dead_code)]
do_screenshots: bool,
#[allow(dead_code)]
do_tts: bool,
Expand Down Expand Up @@ -139,7 +143,7 @@ pub async fn get_options(config: Config) -> Vec<(&'static str, usize)> {
if config.basic.use_keyboard {
options.push(("keyboard", 50));
}
if config.basic.use_controller {
if config.basic.use_controller && cfg!(feature = "advanced") {
options.push(("gamepad", 50));
}
if config.basic.do_screenshots {
Expand Down
4 changes: 2 additions & 2 deletions src/func.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,14 @@ fn screenshot(tts: &mut Tts) {
}
}

pub async fn main_logic(options: &[(&str, usize)], tts: &mut Tts, enigo: &mut Enigo, gamepadobj: &mut GamepadInjector) {
pub async fn main_logic(options: &[(&str, usize)], tts: &mut Tts, enigo: &mut Enigo, gamepadobj: &mut Option<GamepadInjector>) {
let mut rng: rand::prelude::ThreadRng = thread_rng();

let index: WeightedIndex<usize> =
WeightedIndex::new(options.iter().map(|item| item.1)).unwrap();
match options[index.sample(&mut rng)].0 {
"keyboard" => keyboard(enigo, &mut rng),
"gamepad" => gamepad(gamepadobj, &mut rng),
"gamepad" => gamepad(gamepadobj.unwrap(), &mut rng),
"mouse" => mouse(enigo, &mut rng),
"quote" => quote(tts, &mut rng),
"screenshot" => screenshot(tts),
Expand Down
12 changes: 9 additions & 3 deletions src/lists.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub static ALPHANUMERIC_KEYS: [(Key, usize); 47] = [
(Key::K, 4),
(Key::L, 4),
(Key::M, 4),
(Key::N, 4),
(Key::N, 8),
(Key::O, 4),
(Key::P, 4),
(Key::Q, 4),
Expand Down Expand Up @@ -187,7 +187,7 @@ pub static QUOTES_QUESTION: [(&str, usize); 7] = [
("did you know that in terms of male human and female pokémon breeding, vaporeon is the most compatible Pokémon for humans?", 1)
];

pub static QUOTES_STATEMENT: [(&str, usize); 8] = [
pub static QUOTES_STATEMENT: [(&str, usize); 9] = [
("i'm bored", 1),
("i am chaos", 1),
("what a mess", 1),
Expand All @@ -196,6 +196,7 @@ pub static QUOTES_STATEMENT: [(&str, usize); 8] = [
("butter dog", 1),
("damn shawty", 1),
("WE'RE GONNA CRAAAAAAAAASH", 1),
("do a flip!", 1)
];

/* Gamepad action lists */
Expand All @@ -215,7 +216,7 @@ pub static GAMEPAD_BUTTONS: [(&str, usize); 12] = [
];

pub static GAMEPAD_MOVE: [(&str, usize); 2] = [
("LeftThumbstickMove", 1),
("LeftThumbstickMove", 2),
("RightThumbstickMove", 1)
];

Expand All @@ -225,3 +226,8 @@ pub static GAMEPAD_SPECIAL: [(&str, usize); 4] = [
("RightThumbstick", 1),
("View", 1),
];

/* Pen action lists */


/* Touch action lists */
9 changes: 6 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ use tts::*;
async fn main() {
let options: Vec<(&str, usize)> = get_options(get_config().await).await;

println!("\n{} Starting Jerry...", Color::Blue.paint("[INFO]:"));
println!("{} Jerry has been started!\n", Color::Green.paint("[OK]:"));
println!("\n Starting Jerry...");
println!("Jerry has been started!\n");

if metadata("screenshots").is_err() {
let _ = create_dir("screenshots");
Expand All @@ -30,7 +30,10 @@ async fn main() {
};

let mut enigo: Enigo = Enigo::new(&Settings::default()).unwrap();
let mut gamepad = GamepadInjector::new();
let mut gamepad = None;
if cfg!(feature = "advanced") {
gamepad = Some(GamepadInjector::new());
}

loop {
main_logic(&options, &mut tts, &mut enigo, &mut gamepad).await;
Expand Down

0 comments on commit aa37906

Please sign in to comment.