started working on recording

This commit is contained in:
Schrottkatze 2022-06-27 22:29:22 +02:00
parent 3e178deb63
commit 0b1cbcea0e

View file

@ -1,9 +1,10 @@
use std::os::raw::c_uint;
use std::os::raw::{c_char, c_uint};
use std::process::{exit, ExitCode};
use clap::Parser;
use x11::keysym::XK_Escape;
use x11::xinput2::XIGrabModeSync;
use x11::xlib::{CurrentTime, GrabModeAsync, GrabModeSync, GrabSuccess, KeyCode, KeyPress, KeyPressMask, SyncPointer, XEvent};
use x11::xlib::{CurrentTime, GrabModeAsync, GrabModeSync, GrabSuccess, KeyCode, KeyPress, KeyPressMask, SyncPointer, XEvent, XPointer};
use x11::xrecord::{XRecordEndOfData, XRecordInterceptData, XRecordStartOfData};
use easymacros::x11_safe_wrapper::{Keycode, XDisplay};
/// Macro recording module for easymacros. Outputs are partially compatible with xmacro.
@ -11,8 +12,8 @@ use easymacros::x11_safe_wrapper::{Keycode, XDisplay};
#[clap(author, version, about, long_about = None)]
struct Args {
/// The file that contains the macro to run.
#[clap(value_parser, value_name = "input_file", value_hint = clap::ValueHint::FilePath)]
output_file: std::path::PathBuf,
#[clap(value_parser, value_name = "output_file", value_hint = clap::ValueHint::FilePath)]
output_file: Option<std::path::PathBuf>,
/// Display to run the macro on. This uses the $DISPLAY environment variable by default.
#[clap(short, long)]
display: Option<String>,
@ -24,7 +25,7 @@ fn main() {
let stop_key = get_stop_key(display);
dbg!(stop_key);
}
fn get_stop_key(display: XDisplay) -> Keycode {
@ -40,7 +41,7 @@ fn get_stop_key(display: XDisplay) -> Keycode {
println!("Press the key you want to use to stop recording the macro.");
let mut stop_key = XK_Escape;
let mut stop_key: Keycode = XK_Escape;
loop {
display.allow_events(SyncPointer, CurrentTime);
@ -60,6 +61,22 @@ fn get_stop_key(display: XDisplay) -> Keycode {
stop_key
}
unsafe extern "C" fn ev_callback() {
fn ev_loop(display: XDisplay, screen: i32, stop_key: Keycode) {
let root = display.get_root_window(screen);
}
struct EvCallbackData {
stop_key: Keycode,
x: i32,
y: i32,
}
unsafe extern "C" fn ev_callback(closure: *mut c_char, intercept_data: *mut XRecordInterceptData) {
let data = &mut *(closure as *mut EvCallbackData);
let intercept_data = &mut *intercept_data;
if intercept_data.category == XRecordStartOfData { println!("Got start of data!"); }
else if intercept_data.category == XRecordEndOfData { println!("Got end of data!");}
}