use super::common::get_mouse_position;
use crate::{
DriverCallback, DriverCategory, DriverContext, DriverError, DriverResult,
types::{Driver, DriverParameter},
};
use serde_json::{Value, json};
use std::collections::HashMap;
use tracing::{debug, info};
#[derive(Debug)]
pub struct MouseControlPositionGetDriver;
#[async_trait::async_trait]
impl Driver for MouseControlPositionGetDriver {
fn name(&self) -> &str {
return "mouse_control_position_get";
}
fn description(&self) -> &str {
return "Get the current mouse cursor position";
}
fn usage_hint(&self) -> &str {
return "Use this skill to read the current coordinates of the mouse cursor on screen";
}
fn parameters(&self) -> Vec<DriverParameter> {
return vec![];
}
fn example_call(&self) -> DriverResult<Value> {
return Ok(json!({
"action": "mouse_control_position_get"
}));
}
fn example_output(&self) -> String {
return "Mouse position: x=500, y=300".to_string();
}
fn category(&self) -> DriverCategory {
return DriverCategory::Mouse;
}
async fn execute(
&self,
_parameters: &HashMap<String, Value>,
_callback: Option<&dyn DriverCallback>,
_context: Option<&DriverContext>,
) -> DriverResult<String> {
debug!("Executing mouse_control_position_get driver");
let pos = get_mouse_position()?;
let result = format!("Mouse position: x={}, y={}", pos.x, pos.y);
info!("Mouse position retrieved: ({}, {})", pos.x, pos.y);
return Ok(result);
}
fn validate(&self, _parameters: &HashMap<String, Value>) -> DriverResult<()> {
return Ok(());
}
}