Take a look on the USBMOUSE example in PicBasic Pro.