Skip to content

Commit

Permalink
Distinguish emulated input and user input (Bug #110)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwhat committed Jul 12, 2023
1 parent 7afe1a6 commit 4cd9c3d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
16 changes: 8 additions & 8 deletions src/windows/dispatch_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ bool dispatch_key_press(KBDLLHOOKSTRUCT *kbhook) {

// Populate key pressed event.
uio_event.time = timestamp;
uio_event.reserved = 0x00;
uio_event.reserved = kbhook->flags & LLKHF_INJECTED ? 0x02 : 0x00;

uio_event.type = EVENT_KEY_PRESSED;
uio_event.mask = get_modifiers();
Expand All @@ -177,7 +177,7 @@ bool dispatch_key_press(KBDLLHOOKSTRUCT *kbhook) {
for (unsigned int i = 0; i < count; i++) {
// Populate key typed event.
uio_event.time = timestamp;
uio_event.reserved = 0x00;
uio_event.reserved = kbhook->flags & LLKHF_INJECTED ? 0x02 : 0x00;

uio_event.type = EVENT_KEY_TYPED;
uio_event.mask = get_modifiers();
Expand Down Expand Up @@ -222,7 +222,7 @@ bool dispatch_key_release(KBDLLHOOKSTRUCT *kbhook) {

// Populate key pressed event.
uio_event.time = timestamp;
uio_event.reserved = 0x00;
uio_event.reserved = kbhook->flags & LLKHF_INJECTED ? 0x02 : 0x00;

uio_event.type = EVENT_KEY_RELEASED;
uio_event.mask = get_modifiers();
Expand Down Expand Up @@ -275,7 +275,7 @@ bool dispatch_button_press(MSLLHOOKSTRUCT *mshook, uint16_t button) {

// Populate mouse pressed event.
uio_event.time = timestamp;
uio_event.reserved = 0x00;
uio_event.reserved = mshook->flags & LLKHF_INJECTED ? 0x02 : 0x00;

uio_event.type = EVENT_MOUSE_PRESSED;
uio_event.mask = get_modifiers();
Expand Down Expand Up @@ -308,7 +308,7 @@ bool dispatch_button_release(MSLLHOOKSTRUCT *mshook, uint16_t button) {

// Populate mouse released event.
uio_event.time = timestamp;
uio_event.reserved = 0x00;
uio_event.reserved = kbhook->flags & LLKHF_INJECTED ? 0x02 : 0x00;

uio_event.type = EVENT_MOUSE_RELEASED;
uio_event.mask = get_modifiers();
Expand All @@ -332,7 +332,7 @@ bool dispatch_button_release(MSLLHOOKSTRUCT *mshook, uint16_t button) {
if (!consumed && last_click.x == mshook->pt.x && last_click.y == mshook->pt.y) {
// Populate mouse clicked event.
uio_event.time = timestamp;
uio_event.reserved = 0x00;
uio_event.reserved = mshook->flags & LLKHF_INJECTED ? 0x02 : 0x00;

uio_event.type = EVENT_MOUSE_CLICKED;
uio_event.mask = get_modifiers();
Expand Down Expand Up @@ -380,7 +380,7 @@ bool dispatch_mouse_move(MSLLHOOKSTRUCT *mshook) {

// Populate mouse move event.
uio_event.time = timestamp;
uio_event.reserved = 0x00;
uio_event.reserved = mshook->flags & LLKHF_INJECTED ? 0x02 : 0x00;

uio_event.mask = get_modifiers();

Expand Down Expand Up @@ -427,7 +427,7 @@ bool dispatch_mouse_wheel(MSLLHOOKSTRUCT *mshook, uint8_t direction) {

// Populate mouse wheel event.
uio_event.time = timestamp;
uio_event.reserved = 0x00;
uio_event.reserved = mshook->flags & LLKHF_INJECTED ? 0x02 : 0x00;

uio_event.type = EVENT_MOUSE_WHEEL;
uio_event.mask = get_modifiers();
Expand Down
20 changes: 10 additions & 10 deletions src/x11/dispatch_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void dispatch_hook_enabled(XAnyEvent * const x_event) {

// Populate the hook start event.
uio_event.time = x_event->serial;
uio_event.reserved = 0x00;
uio_event.reserved = x_event->send_event ? 0x02 : 0x00;

uio_event.type = EVENT_HOOK_ENABLED;
uio_event.mask = 0x00;
Expand All @@ -84,7 +84,7 @@ void dispatch_hook_enabled(XAnyEvent * const x_event) {
void dispatch_hook_disabled(XAnyEvent * const x_event) {
// Populate the hook stop event.
uio_event.time = x_event->serial;
uio_event.reserved = 0x00;
uio_event.reserved = x_event->send_event ? 0x02 : 0x00;

uio_event.type = EVENT_HOOK_DISABLED;
uio_event.mask = 0x00;
Expand Down Expand Up @@ -124,7 +124,7 @@ void dispatch_key_press(XKeyPressedEvent * const x_event) {

// Populate key pressed event.
uio_event.time = x_event->serial;
uio_event.reserved = 0x00;
uio_event.reserved = x_event->send_event ? 0x02 : 0x00;

uio_event.type = EVENT_KEY_PRESSED;
uio_event.mask = get_modifiers();
Expand All @@ -145,7 +145,7 @@ void dispatch_key_press(XKeyPressedEvent * const x_event) {
for (unsigned int i = 0; i < count; i++) {
// Populate key typed event.
uio_event.time = x_event->serial;
uio_event.reserved = 0x00;
uio_event.reserved = x_event->send_event ? 0x02 : 0x00;

uio_event.type = EVENT_KEY_TYPED;
uio_event.mask = get_modifiers();
Expand Down Expand Up @@ -189,7 +189,7 @@ void dispatch_key_release(XKeyReleasedEvent * const x_event) {

// Populate key released event.
uio_event.time = x_event->serial;
uio_event.reserved = 0x00;
uio_event.reserved = x_event->send_event ? 0x02 : 0x00;

uio_event.type = EVENT_KEY_RELEASED;
uio_event.mask = get_modifiers();
Expand All @@ -213,7 +213,7 @@ static void dispatch_mouse_wheel_rotated(XButtonEvent * const x_event) {

// Populate mouse wheel event.
uio_event.time = x_event->serial;
uio_event.reserved = 0x00;
uio_event.reserved = x_event->send_event ? 0x02 : 0x00;

uio_event.type = EVENT_MOUSE_WHEEL;
uio_event.mask = get_modifiers();
Expand Down Expand Up @@ -327,7 +327,7 @@ static void dispatch_mouse_button_pressed(XButtonPressedEvent * const x_event) {

// Populate mouse pressed event.
uio_event.time = x_event->serial;
uio_event.reserved = 0x00;
uio_event.reserved = x_event->send_event ? 0x02 : 0x00;

uio_event.type = EVENT_MOUSE_PRESSED;
uio_event.mask = get_modifiers();
Expand Down Expand Up @@ -416,7 +416,7 @@ static void dispatch_mouse_button_released(XButtonReleasedEvent * const x_event)

// Populate mouse released event.
uio_event.time = x_event->serial;
uio_event.reserved = 0x00;
uio_event.reserved = x_event->send_event ? 0x02 : 0x00;

uio_event.type = EVENT_MOUSE_RELEASED;
uio_event.mask = get_modifiers();
Expand Down Expand Up @@ -451,7 +451,7 @@ static void dispatch_mouse_button_released(XButtonReleasedEvent * const x_event)
static void dispatch_mouse_button_clicked(XButtonEvent * const x_event) {
// Populate mouse clicked event.
uio_event.time = x_event->serial;
uio_event.reserved = 0x00;
uio_event.reserved = x_event->send_event ? 0x02 : 0x00;

uio_event.type = EVENT_MOUSE_CLICKED;
uio_event.mask = get_modifiers();
Expand Down Expand Up @@ -518,7 +518,7 @@ void dispatch_mouse_move(XMotionEvent * const x_event) {

// Populate mouse move event.
uio_event.time = x_event->serial;
uio_event.reserved = 0x00;
uio_event.reserved = x_event->send_event ? 0x02 : 0x00;

uio_event.mask = get_modifiers();

Expand Down

0 comments on commit 4cd9c3d

Please sign in to comment.