remote_cursor 0.0.2

SDKflutter
Platformandroidiosweb

A Flutter package that enables simulating mouse movements via WebSocket. Useful for building remote control interfaces, virtual desktops, or real-time interaction tools.

RemoteCursor

Pub Version License: MIT

A powerful Flutter package that transforms your mobile device into a wireless mouse/trackpad controller. Control your computer cursor with precision using touch gestures or device gyroscope movements via WebSocket communication.

Features

  • Dual Control Methods: Use your device as a touchpad or motion-controlled pointer
  • Precise Tracking: Advanced algorithms for smooth cursor movement
  • Customizable Sensitivity: Fine-tune controls for your preferences
  • WebSocket Communication: Low-latency connection to your computer
  • Gesture Support: Click, right-click, double-click actions
  • Configuration Options: Extensive parameters to customize behavior

Gyroscope Control Demo

RemoteCursor Demo

Trackpad Control Demo

Gyroscope Control

Supported Gestures

GestureDescriptionJSON ValueStatus
MoveBasic cursor movement"move"✅ Supported
ClickLeft mouse button click"click"✅ Supported
Double ClickDouble left mouse button click"double_click"✅ Supported
Right ClickRight mouse button click"right_click"✅ Supported
Vertical ScrollScroll up and down"scroll_vertical"🔄 Coming soon
Horizontal ScrollScroll left and right"scroll_horizontal"🔄 Coming soon
Middle ClickMiddle mouse button click"middle_click"🔄 Coming soon
Drag StartBegin drag operation"drag_start"🔄 Coming soon
Drag MoveContinue drag operation"drag_move"🔄 Coming soon
Drag EndEnd drag operation"drag_end"🔄 Coming soon
Pinch ZoomZoom in/out using pinch gesture"pinch_zoom"🔄 Coming soon
SwipeQuick directional gestures"swipe_left", "swipe_right", etc.🔄 Coming soon

Installation

Add this to your package's pubspec.yaml file:

dependencies:
  remote_cursor: ^0.0.2

Then run:

flutter pub get

Quick Start

1. Initialize the Service

import 'package:remote_cursor/remote_cursor.dart';

// Initialize with WebSocket configuration
await RemoteCursor.init(
  webSocketConfig: WebSocketConfig(
    ip: '192.168.1.100',  // Your computer's IP address
    port: 8080,           // WebSocket server port
  ),
);

2. Use Trackpad Controller

// Get the singleton instance
final trackpadController = RemoteCursor.trackpadController;

// In your GestureDetector
GestureDetector(
  onPanUpdate: (details) {
    trackpadController.onDrag(details.delta);
  },
  onTap: () {
    trackpadController.sendClick();
  },
  onDoubleTap: () {
    trackpadController.sendDoubleClick();
  },
  onLongPress: () {
    trackpadController.sendRightClick();
  },
  child: Container(
    color: Colors.grey[200],
    height: 300,
    width: double.infinity,
    child: Center(child: Text('Trackpad Area')),
  ),
);

3. Use Gyroscope Controller

// Get the singleton instance
final gyroController = RemoteCursor.gyroController;

// Activate gyroscope control
gyroController.activate();

// Deactivate when not needed
gyroController.deactivate();

// Pause when not needed
gyroController.pause();

// Listen to gyroscope data
gyroController.gyroDataStream.listen((vector) {
  // Vector contains processed gyro data if needed
  print('Gyro data: $vector');
});

Server Setup

This package requires a WebSocket server running on your computer to receive mouse commands. You can find example server implementations in:

Advanced Configuration

Trackpad Configuration

// Create custom trackpad configuration
final customTrackpadConfig = TrackpadConfig(
  horizontalSensitivity: 1.5,
  verticalSensitivity: 1.2,
  accelerationCurve: 1.8,
  // More parameters...
);

// Initialize controller with custom config
final trackpadController = TrackpadController(config: customTrackpadConfig);
//
//or
//
final trackpadController = RemoteCursor.trackpadController;
trackpadController.initConfig(config: customTrackpadConfig);

Gyroscope Configuration

// Create custom gyroscope configuration
final customGyroConfig = GyroConfig(
  deadZone: 0.05,
  smoothingFactor: 0.7,
  horizontalSensitivity: 1.3,
  verticalSensitivity: 1.0,
  // More parameters...
);

// Initialize controller with custom config
final gyroController = GyroController(config: customGyroConfig);
//
//or
//
final gyroController = RemoteCursor.gyroController;
gyroController.initConfig(config: customTrackpadConfig);

API Reference

Core Classes

ClassDescription
RemoteCursorService locator for dependency management
RemoteCursorConnectionWebSocket connection management
TrackpadControllerHandles touch input for trackpad functionality
GyroControllerProcesses gyroscope data for motion control
WebSocketConfigConfiguration for WebSocket connection
TrackpadConfigConfiguration parameters for trackpad behavior
GyroConfigConfiguration parameters for gyroscope behavior

TrackpadController

MethodDescription
onDrag(Offset delta)Processes drag movement
sendClick()Sends a left-click action
sendDoubleClick()Sends a double-click action
sendRightClick()Sends a right-click action
sendCustomData(Map<String, dynamic> data)Sends custom data to the server
setSensitivity(double value)Sets overall sensitivity multiplier

GyroController

MethodDescription
activate()Starts gyroscope tracking
deactivate()Stops gyroscope tracking
pause()Temporarily pauses tracking
calibrate()Calibrates gyroscope to adjust for drift
reset()Resets all gyroscope data and state
sendCustomData(Map<String, dynamic> data)Sends custom data to the server

RemoteCursorConnection

MethodDescription
connect(String url)Connects to WebSocket server
disconnect()Disconnects from server
sendMessage(MouseActionConfig mouseActionConfig)Sends standardized action
sendCustomMessage(Map<String, dynamic> message)Sends custom message

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.