'Smoothest way to connect @neurosity/notion with puppeteer to move mouse on chrome
In puppeteer I'm currently trying to move the mouse of a google chrome browser using my brain with the Neurosity Crown EEG brain computer. I'm using the library @neurosity/notion to get the input from the device. Getting the data from my brain is asynchronous and they use the libary rxjs to subscribe to changes. Moving the mouse on puppeteer is also asynchronous. So I was wondering if there was an optimal way of connecting these two libraries for the smoothest experience?
So this is my code for puppeteer to move the mouse.
import { Notion } from "@neurosity/notion";
import puppeteer from 'puppeteer';
import installMouseHelper from './Helpers/install-mouse-helper'; // shows mouse
const LEFT = "LEFT";
const RIGHT = "RIGHT";
const UP = "UP";
const DOWN = "DOWN";
// Class method by the way
async move(direction){
if (direction===LEFT){
this._x-=100;
} else if (direction===RIGHT){
this._x+=100;
} else if (direction===UP){
this._y-=100;
} else if (direction===DOWN){
this._y+=100;
}
await this._page.mouse.move(this._x,this._y); // Use puppeteer to move mouse
}
This is my code for notion to get when I think of moving my arm left.
notion.kinesis("leftArm").subscribe((intent) => {
if (intent.confidence>.9){
this.move(LEFT); // Move mouse
}
})
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
