Code Monkey home page Code Monkey logo

gyromouse's People

Contributors

yamakaky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

nanoexplorer

gyromouse's Issues

factor this code with run

Line: 78

gyromouse//src/main.rs

Lines 75 to 85 in 2f32632

match opts.cmd {
Some(opts::Cmd::Validate(v)) => {
// TODO: factor this code with run
let mut content_file = File::open(&v.mapping_file)
.with_context(|| format!("opening config file {:?}", v.mapping_file))?;
let content = {
let mut buf = String::new();
content_file.read_to_string(&mut buf)?;
buf
};

Conditional virtual gamepad creation

Only create if option is enabled

Line: 49

gyromouse//src/engine.rs

Lines 46 to 56 in 19c6b3b

gyro: Gyro::new(&settings, calibration),
settings,
#[cfg(feature = "vgamepad")]
// TODO: Conditional virtual gamepad creation
// Only create if option is enabled
gamepad: virtual_gamepad::new(virtual_gamepad::GamepadType::DS4)
.map(|vg| -> Box<dyn virtual_gamepad::Backend> { Box::new(vg) })
.map_err(|e| {
eprintln!("Error initializing the virtual gamepad: {}", e);
e
})

fix https://github.com/enigo-rs/enigo/issues/110

Line: 539

key_parse(Left, "LMouse"),
key_parse(Middle, "MMouse"),
key_parse(Right, "RMouse"),
// TODO: fix https://github.com/enigo-rs/enigo/issues/110
key_parse(Left, "BMouse"),
key_parse(Left, "FMouse"),
key_parse(ScrollUp, "scrollup"),
key_parse(ScrollDown, "scrolldown"),
key_parse(ScrollLeft, "scrollleft"),
key_parse(ScrollRight, "scrollright"),
))(input)

Handle every special key.

Line: 49

ActionType::Special(SpecialKey::GyroOn) => ExtAction::GyroOn(b),
ActionType::Special(SpecialKey::GyroOff) => ExtAction::GyroOff(b),
ActionType::Special(s) => {
// TODO: Handle every special key.
eprintln!("Warning: special key {:?} is unimplemented", s);
ExtAction::None
}
#[cfg(feature = "vgamepad")]
ActionType::Gamepad(k) => ExtAction::GamepadKeyPress(k, b),
}
}

Correctly handle modifiers for double click

Line: 23

Cmd::Map(Key::Simple(key), ref actions) => map_key(mapping.get(key, 0), actions),
Cmd::Map(Key::Chorded(k1, k2), ref actions) if k1 == k2 => {
// TODO: Correctly handle modifiers for double click
for action in actions {
assert_eq!(
action.event_mod, None,
"event modificators not supported on double click"
);
push(
&mut mapping.get(k1, 0).on_double_click,

Implement mouse click toggle

Line: 116

gyromouse//src/engine.rs

Lines 113 to 123 in f61e801

ExtAction::MousePress(c, ClickType::Press) => self.mouse.enigo().mouse_down(c),
ExtAction::MousePress(c, ClickType::Release) => self.mouse.enigo().mouse_up(c),
ExtAction::MousePress(_, ClickType::Toggle) => {
// TODO: Implement mouse click toggle
eprintln!("Warning: mouse click toggle is not implemented");
}
#[cfg(feature = "vgamepad")]
ExtAction::GamepadKeyPress(key, ClickType::Press) => {
if let Some(gamepad) = &mut self.gamepad {
gamepad.key(key, true)?;
gamepad_pressed = true;

proper lalt and ralt

Line: 488

alt((
alt((
key_parse(Alt, "alt"),
//TODO: proper lalt and ralt
key_parse(Alt, "lalt"),
key_parse(Alt, "ralt"),
key_parse(Backspace, "backspace"),
key_parse(CapsLock, "capslock"),
key_parse(Control, "Control"),
key_parse(Delete, "Delete"),
key_parse(DownArrow, "down"),

Parse every command from JSM

Every command in https://github.com/Electronicks/JoyShockMapper#commands should at least be parsed so that every config file can be used even if the feature in not implemented here.

Needed:

  • Modify src/config/types.rs
  • Modify src/config/parse.rs
  • Modify src/config/config.rs
  • Add warnings when a unimplemented command is used then ignore it

Basically, uncomment stuff at https://github.com/Yamakaky/gyromouse/blob/master/src/config/all-settings-example, run cargo test and make it pass the test.

Support simultaneous key presses

Line: 122

map_key(mapping.get(k2, k1.to_layer()), actions);
}
Cmd::Map(Key::Simul(_k1, _k2), ref _actions) => {
// TODO: Support simultaneous key presses
eprintln!("Warning: simultaneous keys are unsupported for now");
}
Cmd::Setting(setting) => settings.apply(setting),
Cmd::Reset => {
settings.reset();
mapping.reset()
}

check normalize() with magnitude 0.

Line: 70

impl SensorFusion for AdaptativeFusion {
// TODO: check http://gyrowiki.jibbsmart.com/blog:finding-gravity-with-sensor-fusion
// TODO: check normalize() with magnitude 0.
fn compute_up_vector(&mut self, motion: &Motion, dt: Duration) -> Vector3<f64> {
// settings
let smoothing_half_time = 0.25;
let shakiness_min_threshold = 0.4;
let shakiness_max_threshold = 0.01;
let still_rate = 1.;
let shaky_rate = 0.1;

Reference missing features from JSM

Every missing feature from JSM should be documented and have an open issue. This includes:

  • missing config file commands
  • difference in behaviour

frame rate independent

Line: 43

fn compute_up_vector(&mut self, motion: &Motion, dt: Duration) -> Vector3<f64> {
let rotation = Quaternion::from(motion.rotation_speed * dt).invert();
self.up_vector = rotation.rotate_vector(self.up_vector);
// TODO: frame rate independent
self.up_vector += (motion.acceleration.as_vec() - self.up_vector) * self.correction_factor;
self.up_vector
}
}
#[derive(Debug, Copy, Clone)]
pub struct AdaptativeFusion {

Fix ugly clone

Line: 346

gyromouse//src/mapping.rs

Lines 343 to 353 in 9a79e56

for i in self.current_layers.iter().rev() {
if let Some(layer) = layers.get(i) {
if layer.is_good() {
// TODO: Fix ugly clone
return layer.clone();
}
}
}
Layer::default()
}

Make the correction rate depend on dt instead of fixed per tick.

Line: 43

fn compute_up_vector(&mut self, motion: &Motion, dt: Duration) -> Vector3<f64> {
let rotation = Quaternion::from(motion.rotation_speed * dt).invert();
self.up_vector = rotation.rotate_vector(self.up_vector);
// TODO: Make the correction rate depend on dt instead of fixed per tick.
self.up_vector += (motion.acceleration.as_vec() - self.up_vector) * self.correction_factor;
self.up_vector
}
}
#[derive(Debug, Copy, Clone)]
pub struct AdaptativeFusion {

check http://gyrowiki.jibbsmart.com/blog:finding-gravity-with-sensor-fusion

Line: 69

}
impl SensorFusion for AdaptativeFusion {
// TODO: check http://gyrowiki.jibbsmart.com/blog:finding-gravity-with-sensor-fusion
// TODO: check normalize() with magnitude 0.
fn compute_up_vector(&mut self, motion: &Motion, dt: Duration) -> Vector3<f64> {
// settings
let smoothing_half_time = 0.25;
let shakiness_min_threshold = 0.4;
let shakiness_max_threshold = 0.01;
let still_rate = 1.;

Test with lower xdo delay

enigo uses xdo which pauses for 12ms after each keypress, presumably for it to be taken into account? Test with low or no delay.

See e97f7d5

Support alternative trigger modes

Line: 18

pub left_ring_mode: RingMode,
pub right_ring_mode: RingMode,
pub trigger_threshold: f64,
// TODO: Support alternative trigger modes
pub zl_mode: TriggerMode,
pub zr_mode: TriggerMode,
pub mouse: MouseSettings,
}
impl Default for Settings {
fn default() -> Self {

Investigate if this is the right way.

Line: 127

//In egui 0.10.0 we seem to be losing the value to pixels_per_point,
//so setting it every frame now.
//TODO: Investigate if this is the right way.
self.egui_input_state.input.pixels_per_point = Some(self.native_pixels_per_point);
//An example of how OpenGL can be used to draw custom stuff with egui
//overlaying it:
//First clear the background to something nice.
unsafe {
// Clear the screen to black

Implement key press toggle

Line: 109

gyromouse//src/engine.rs

Lines 106 to 116 in f61e801

ExtAction::KeyPress(c, ClickType::Press) => self.mouse.enigo().key_down(c),
ExtAction::KeyPress(c, ClickType::Release) => self.mouse.enigo().key_up(c),
ExtAction::KeyPress(_, ClickType::Toggle) => {
// TODO: Implement key press toggle
eprintln!("Warning: key press toggle is not implemented");
}
ExtAction::MousePress(c, ClickType::Click) => self.mouse.enigo().mouse_click(c),
ExtAction::MousePress(c, ClickType::Press) => self.mouse.enigo().mouse_down(c),
ExtAction::MousePress(c, ClickType::Release) => self.mouse.enigo().mouse_up(c),
ExtAction::MousePress(_, ClickType::Toggle) => {
// TODO: Implement mouse click toggle

Add missing variants to JoyKey

Line: 354

Button::DPadDown => JoyKey::Down,
Button::DPadLeft => JoyKey::Left,
Button::DPadRight => JoyKey::Right,
// TODO: Add missing variants to JoyKey
Button::Misc1 => JoyKey::Capture,
Button::Paddle1 => JoyKey::Capture,
Button::Paddle2 => JoyKey::Capture,
Button::Paddle3 => JoyKey::Capture,
Button::Paddle4 => JoyKey::Capture,
Button::Touchpad => JoyKey::Capture,
}

JoyCon --- some buttons don't work

Hello,
I found this project to do exactly what I was looking for! It almost works, but when I press the ZR button on my 'right joycon' nothing happens. My configuration file is relatively simple, just for testing. Also I am on Mac M1 and I only have the right Joycon connected.

RESET_MAPPINGS
GYRO_SENS=32
S = e
W = f
N = g
E = h
R3 = c
R = GYRO_ON
ZR = k
RIGHT_STICK_MODE = NO_MOUSE

I expect that when I press ZR I should see it type a k, which doesn't happen. All the other options work.

Perhaps related, when I press either SL or SR I get the following crash:

name = 'gyromouse'
operating_system = 'unix:OSX'
crate_version = '0.1.0'
explanation = '''
Panic occurred in file '/Users/runner/.cargo/git/checkouts/rust-sdl2-52ead21fa771c331/27d164d/src/sdl2/controller.rs' at line 336
'''
cause = 'unhandled controller button'
method = 'Panic'
backtrace = '''

   0: 0x100a4d6a9 - gyromouse::main::ha2be660b92ece924
   1: 0x100a83dca - std::sys_common::backtrace::__rust_begin_short_backtrace::hc242b2fc2b558fd9
   2: 0x100a4b7f1 - _main'''

check settings semantic

Line: 45

_now: Instant,
dt: Duration,
) {
// TODO: check settings semantic
let s = &settings.stick_settings;
let amp = stick.magnitude();
let amp_zones = (amp - s.deadzone) / (s.fullzone - s.deadzone);
if amp_zones >= 1. {
self.current_speed = (self.current_speed
+ s.aim_stick.acceleration_rate * dt.as_secs_f64())
.min(s.aim_stick.acceleration_cap);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.