Open luanpotter opened 2 months ago
Hey, thanks for this amazing library! I've used a while ago for this FPS-style camera implementation.
However, upon testing it more recently, it appears that with new Flutter versions it now only works while the mouse button is down, i.e., while dragging. While not dragging, the mouse pointer does "disappear", but I don't get mouse events via
onPointerDataPacket
. It seems by the readme that this is an "expected" issue, and that this packet is not really meant for what I thought it was (first person camera). And the events are intentionally only sent when the mouse button is down. Is that correct?
With the streaming mode, that's correct. It only works with button being down. With that other mode, it should also work with other "triggers". Are you on Windows?
And, more broadly, is FPS-camera a use case that you wish to support with this library? Or is this out-of-scope?
I think it would be a nice addition to this library and it somehow fits in, but I currently don't have the time to add it. But if someone else wants to give it a go, sure!
I also have tried this simplified version based on the example on the repo, which also does not work:
Does it work when you download this repo and start the example app as is?
Thanks for the response! I am on macos (sadly flutter_gpu only works on macos for now), but I did try both "capture modes". I will try the example app in a bit - I thought it only had the lock while dragging use case. Either way - I would be happy to try to contribute, if you are open to a PR :)
It's correct, the example app only shows the "lock while dragging" use case, but you can choose between both usage modes. You can modify the "manual" usage mode example to see whether it would work with other trigger events.
Yes, I'm open for a PR. I hope not too many code changes/additions are necessary ;) Looking forward.
Hey, thanks for this amazing library! I've used a while ago for this FPS-style camera implementation.
However, upon testing it more recently, it appears that with new Flutter versions it now only works while the mouse button is down, i.e., while dragging. While not dragging, the mouse pointer does "disappear", but I don't get mouse events via
onPointerDataPacket
. It seems by the readme that this is an "expected" issue, and that this packet is not really meant for what I thought it was (first person camera). And the events are intentionally only sent when the mouse button is down. Is that correct?And, more broadly, is FPS-camera a use case that you wish to support with this library? Or is this out-of-scope?
I also have tried this simplified version based on the example on the repo, which also does not work:
mouse.dart
``` class Mouse { static final _lock = PointerLock(); static Offset _delta = Offset.zero; static StreamSubscription? _lockStream;
static Offset getDelta() {
final delta = _delta;
_delta = Offset.zero;
return delta;
}
static Future init() async {
//
}
static Future dispose() async {
//
return await unlock();
}
static Future reset() async {
_delta = Offset.zero;
}
static Future lock() async {
if (_lockStream != null) return;
_lockStream = _lock
.startPointerLockSession(windowsMode: WindowsPointerLockMode.clip)
.listen((delta) => _delta = delta, onDone: unlock);
await _lock.lockPointer();
await _lock.hidePointer();
}
static Future unlock() async {
if (_lockStream == null) return;
await _lockStream?.cancel();
_lockStream = null;
await _lock.showPointer();
await _lock.unlockPointer();
}
}
```