mirror of
https://github.com/DeeJanuz/frametop.git
synced 2026-10-06 04:04:09 +02:00
The 3D mouse drives SteamVR's laser through the ft_pointer virtual controller, so its events reach the screens the same way a controller's do. The filter held every press, which turned the mouse's short drags (selecting a character or two, nudging a slider) into clicks. Mark button events from hand controllers and start the filter only on those. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
43 lines
2.4 KiB
C
43 lines
2.4 KiB
C
#include <assert.h>
|
|
#include "../controller-click.h"
|
|
static struct ft_event event(enum ft_event_type t, bool down, double x, double y) {
|
|
return (struct ft_event){.type=t,.screen=0,.button=BTN_LEFT,.pressed=down,.controller=true,.x=x,.y=y};
|
|
}
|
|
int main(void) {
|
|
struct ft_controller_click c={.threshold=8};
|
|
struct ft_event e=event(FT_BUTTON,true,100,100);
|
|
assert(ft_controller_click_filter(&c,&e,2));
|
|
e=event(FT_MOTION,false,112,108);
|
|
assert(!ft_controller_click_filter(&c,&e,2));
|
|
assert(c.held && !c.dragging && c.suppressed==1);
|
|
e=event(FT_BUTTON,false,116,111);
|
|
assert(ft_controller_click_filter(&c,&e,2));
|
|
assert(e.x==100 && e.y==100 && c.clicks==1 && !c.held);
|
|
e=event(FT_BUTTON,true,100,100);ft_controller_click_filter(&c,&e,1);
|
|
e=event(FT_MOTION,false,109,100);assert(ft_controller_click_filter(&c,&e,1));
|
|
assert(c.dragging && c.drags==1);
|
|
e=event(FT_MOTION,false,101,100);assert(ft_controller_click_filter(&c,&e,1));
|
|
e=event(FT_BUTTON,false,103,100);assert(ft_controller_click_filter(&c,&e,1));
|
|
assert(e.x==103 && c.clicks==1 && !c.held && !c.dragging);
|
|
e=event(FT_BUTTON,true,100,100);ft_controller_click_filter(&c,&e,1);
|
|
e=event(FT_LEAVE,false,0,0);assert(!ft_controller_click_filter(&c,&e,1));
|
|
e=event(FT_BUTTON,false,800,900);e.screen=1;ft_controller_click_filter(&c,&e,1);
|
|
assert(e.screen==0 && e.x==100 && c.clicks==2);
|
|
e=event(FT_BUTTON,true,100,100);ft_controller_click_filter(&c,&e,1);
|
|
e=event(FT_MOTION,false,101,100);e.screen=1;
|
|
assert(ft_controller_click_filter(&c,&e,1) && c.dragging);
|
|
e=event(FT_BUTTON,false,101,100);ft_controller_click_filter(&c,&e,1);
|
|
c.threshold=0;
|
|
e=event(FT_BUTTON,true,100,100);ft_controller_click_filter(&c,&e,1);
|
|
e=event(FT_MOTION,false,101,100);assert(ft_controller_click_filter(&c,&e,1) && !c.held);
|
|
c.threshold=8;
|
|
e=event(FT_BUTTON,true,100,100);ft_controller_click_filter(&c,&e,1);
|
|
e=event(FT_BUTTON,true,100,100);e.button=BTN_RIGHT;ft_controller_click_filter(&c,&e,1);
|
|
assert(!c.held);
|
|
// The 3D mouse's laser: a short drag stays a drag, and the release stays where it was.
|
|
e=event(FT_BUTTON,true,100,100);e.controller=false;assert(ft_controller_click_filter(&c,&e,1) && !c.held);
|
|
e=event(FT_MOTION,false,104,100);assert(ft_controller_click_filter(&c,&e,1));
|
|
e=event(FT_BUTTON,false,106,100);e.controller=false;
|
|
assert(ft_controller_click_filter(&c,&e,1) && e.x==106 && c.clicks==2 && c.suppressed==1);
|
|
}
|