Input latency timer w/ Mouse.h

I made a project to count input latency between mouse input and output on PC monitor by using Arduino Micro and photo transistor. So I tried two approaches: 1. Mouse.click(), 2. Mouse.move(). Both works, but I get different results, with move command I get average latency 19,75ms, with click command it’s 40ms. My question would be: is it games fault of different results on input, or is it my project handling move and click commands differently?

Code w/ move:

#include <Mouse.h>
#include <SevSeg.h>
SevSeg sevseg; //Instantiate a seven segment object

unsigned long previousMicros = 0;
const int ledPin = 13;
const int buttonPin = 0;
const long interval = 5000000;
int analogPin = 0;
int val = 0;
int buttonState = 0;
unsigned long lag = 0;
unsigned long lag2;
int state = 0;
unsigned long var2 = 0;

void setup(){ 
  Mouse.begin();
  byte numDigits = 4;   
  byte digitPins[] = {8, 11, 3, 12};
  byte segmentPins[] = {7, 6, 4, 2, 1, 9, 10, 5};
  bool resistorsOnSegments = true; // 'false' means resistors are on digit pins
  byte hardwareConfig = COMMON_CATHODE; // See README.md for options
  sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments);
  
  pinMode(ledPin, OUTPUT);
  pinMode(buttonPin, INPUT_PULLUP);
 
}
void loop(){
  unsigned long currentMicros = micros();
  val = analogRead(analogPin);
  buttonState = digitalRead(buttonPin);
  if (buttonState == LOW){
    previousMicros = currentMicros;
    state = 1;
  }
  if (currentMicros - previousMicros >= interval && state == 1){
    Mouse.move(50, 0, 0);
    digitalWrite(ledPin, HIGH);
    previousMicros = currentMicros;
    state = 2;
  }
  if (val <= 980 && state == 2){
    lag = currentMicros - previousMicros;
    state = 3;
    digitalWrite(ledPin, LOW);
    Mouse.move(-50, 0, 0);
    
  }
  if (state == 3){
    if (lag >=1000000){
      lag2 = lag /1000;
      sevseg.setNumber(lag2);
      
    }
    if (lag < 1000000){
      lag2 = lag / 100; 
      sevseg.setNumber(lag2, 1);
     
    }
    
  }
  sevseg.refreshDisplay();
}

Code w/ click:

#include <Mouse.h>
#include <SevSeg.h>
SevSeg sevseg; //Instantiate a seven segment object

unsigned long previousMicros = 0;
const int ledPin = 13;
const int buttonPin = 0;
const long interval = 5000000;
int analogPin = 0;
int val = 0;
int buttonState = 0;
unsigned long lag = 0;
unsigned long lag2;
int state = 0;
unsigned long var2 = 0;

void setup(){ 
  Mouse.begin();
  byte numDigits = 4;   
  byte digitPins[] = {8, 11, 3, 12};
  byte segmentPins[] = {7, 6, 4, 2, 1, 9, 10, 5};
  bool resistorsOnSegments = true; // 'false' means resistors are on digit pins
  byte hardwareConfig = COMMON_CATHODE; // See README.md for options
  sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments);
  
  pinMode(ledPin, OUTPUT);
  pinMode(buttonPin, INPUT_PULLUP);

}
void loop(){
  unsigned long currentMicros = micros();
  val = analogRead(analogPin);
  buttonState = digitalRead(buttonPin);
  if (buttonState == LOW){
    previousMicros = currentMicros;
    state = 1;
  }
  if (currentMicros - previousMicros >= interval && state == 1){
    Mouse.click();
    digitalWrite(ledPin, HIGH);
    previousMicros = currentMicros;
    state = 2;
  }
  if (val <= 980 && state == 2){
    lag = currentMicros - previousMicros;
    state = 3;
    digitalWrite(ledPin, LOW);
    
  }
  if (state == 3){
    if (lag >=1000000){
      lag2 = lag /1000;
      sevseg.setNumber(lag2);
      
    }
    if (lag < 1000000){
      lag2 = lag / 100; 
      sevseg.setNumber(lag2, 1);
     
    }
    
  }

A mouse driver has to wait for mouse down then mouse up for a single click. Eventually a debounce feature delays the recognition of a single click, and/or waits to distinguish between single and double clicks.

How did you write the reaction on the PC monitor? Which OS?

DrDiettrich:
A mouse driver has to wait for mouse down then mouse up for a single click. Eventually a debounce feature delays the recognition of a single click, and/or waits to distinguish between single and double clicks.

How did you write the reaction on the PC monitor? Which OS?

Oh thanks that explains a lot. Windows 10. I attached photo transistor onto monitor screen, which reacts to brightness. In case of mouse move I just place it on black spot, but very near bright spot, then it moves and photo transistor reacts. In case of mouse click I place photo transistor at end of a gun where fire happens. So I suppose better use move command as it doesn't have any waiting for debounce and etc.

Mouse click:

Mouse move:

For the click you can react on WM_LBUTTONDOWN or on WM_LBUTTONUP, with different timing.

Also note that screen update has lowest priority, occurs only if everything else has been handled.