Some checks failed
Build and Deploy / build-macos (push) Failing after 7s
Build and Deploy / build-windows (CLANG64) (push) Has been cancelled
Build and Deploy / package-dist (push) Has been cancelled
Build and Deploy / deploy-itch (push) Has been cancelled
Build and Deploy / deploy-gitea (push) Has been cancelled
Build and Deploy / build-linux (push) Has been cancelled
38 lines
1.0 KiB
JavaScript
38 lines
1.0 KiB
JavaScript
// Test event watching functionality
|
|
use('input');
|
|
|
|
// Start watching events
|
|
input.watch($_);
|
|
|
|
$_.receiver(msg => {
|
|
if (msg.type) {
|
|
console.log("Received event:", msg.type);
|
|
|
|
// Log specific event details
|
|
switch(msg.type) {
|
|
case "key_down":
|
|
case "key_up":
|
|
console.log(" Key:", msg.key, "Scancode:", msg.scancode, "Down:", msg.down);
|
|
break;
|
|
case "mouse_motion":
|
|
console.log(" Mouse position:", msg.pos, "Delta:", msg.d_pos);
|
|
break;
|
|
case "mouse_button_down":
|
|
case "mouse_button_up":
|
|
console.log(" Button:", msg.button, "Position:", msg.mouse, "Down:", msg.down);
|
|
break;
|
|
}
|
|
|
|
// Stop watching after receiving 10 events
|
|
if (!$_.event_count) $_.event_count = 0;
|
|
$_.event_count++;
|
|
|
|
if ($_.event_count >= 10) {
|
|
console.log("Received 10 events, stopping watch");
|
|
input.unwatch($_);
|
|
}
|
|
}
|
|
});
|
|
|
|
console.log("Event watcher started. Press keys or move mouse to generate events.");
|
|
console.log("Will stop after 10 events."); |