11import { useEffect , useRef } from 'react' ;
22import { message } from 'antd' ;
3- import { useAtomValue , useSetAtom } from 'jotai' ;
3+ import { useAtomValue } from 'jotai' ;
44import { useTranslation } from 'react-i18next' ;
55
66import { resolutionAtom } from '@/jotai/device.ts' ;
7- import {
8- mouseJigglerModeAtom ,
9- mouseLastMoveTimeAtom ,
10- scrollDirectionAtom ,
11- scrollIntervalAtom
12- } from '@/jotai/mouse.ts' ;
7+ import { scrollDirectionAtom , scrollIntervalAtom } from '@/jotai/mouse.ts' ;
138import { device } from '@/libs/device' ;
149import { Key } from '@/libs/device/mouse.ts' ;
10+ import { mouseJiggler } from '@/libs/mouse-jiggler' ;
1511
1612export const Relative = ( ) => {
1713 const { t } = useTranslation ( ) ;
@@ -20,8 +16,6 @@ export const Relative = () => {
2016 const resolution = useAtomValue ( resolutionAtom ) ;
2117 const scrollDirection = useAtomValue ( scrollDirectionAtom ) ;
2218 const scrollInterval = useAtomValue ( scrollIntervalAtom ) ;
23- const mouseJigglerMode = useAtomValue ( mouseJigglerModeAtom ) ;
24- const setMouseLastMoveTime = useSetAtom ( mouseLastMoveTimeAtom ) ;
2519
2620 const isLockedRef = useRef ( false ) ;
2721 const keyRef = useRef < Key > ( new Key ( ) ) ;
@@ -118,10 +112,7 @@ export const Relative = () => {
118112
119113 await send ( Math . abs ( x ) < 10 ? x * 2 : x , Math . abs ( y ) < 10 ? y * 2 : y , 0 ) ;
120114
121- // mouse jiggler record last move time
122- if ( mouseJigglerMode === 'enable' ) {
123- setMouseLastMoveTime ( Date . now ( ) ) ;
124- }
115+ mouseJiggler . moveEventCallback ( ) ;
125116 }
126117
127118 // mouse scroll
@@ -150,7 +141,7 @@ export const Relative = () => {
150141 canvas . removeEventListener ( 'wheel' , handleWheel ) ;
151142 canvas . removeEventListener ( 'contextmenu' , disableEvent ) ;
152143 } ;
153- } , [ resolution , scrollDirection , scrollInterval , mouseJigglerMode , setMouseLastMoveTime ] ) ;
144+ } , [ resolution , scrollDirection , scrollInterval ] ) ;
154145
155146 async function send ( x : number , y : number , scroll : number ) {
156147 await device . sendMouseRelativeData ( keyRef . current , x , y , scroll ) ;
0 commit comments