Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cursor movement API #6162

Closed
wants to merge 4 commits into from
Closed

Conversation

LorenLuke
Copy link
Contributor

When merged this pull request will:

  • Add extensions capable of mimicking player mouse input.
  • Adds a function to 'common' to call the extension easily.

Notes:

  • Cursor movement in loops persists in dialog and pause menu.
    Be sure to have safeguards in place before using in loops.

ip.mi.time = 0;

int x, y;
if (strncmp(function, "x", 1)) {
Copy link
Contributor

@dedmen dedmen Feb 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the advanced ballistics extension like format x:y so you can just send both.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe just use callExtensionArgs.


// "bluefcs" callExtension "x100"; "bluefcs" callExtension "y-100"
// Yes, they're backwards. No, I can't fix it because I don't know how to DLL. -Luke
call compile format ['"ace_cursor_movement" callExtension "y%1"',_x];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

call compile format? really?
"ace_cursor_movement" callExtension format ["%1:%2",_x,_y]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

April, April. Yes, really.
I do stuff the way I know how that it works. If there's a better way, tell instead of condescending for not knowing the better way.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there's a better way, tell instead of condescending for not knowing the better way.

Uhm...

"ace_cursor_movement" callExtension format ["%1:%2",_x,_y]

And my other comment about the format in the extension?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't write the extension. I don't know how to .DLL.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And? Does that mean problems in your PR don't need to be fixed and can just be ignored?

Copy link
Contributor

@dedmen dedmen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no protection to make sure that someone can't just move your cursor on your Desktop. At minimum this should check if Arma is in foreground and currently has focus.

@@ -0,0 +1,30 @@
/*
* Author: LorenLuke (function), BaerMitUmlaut (Extension)
* Simulates mouse input by number of pixels (not consistent/smooth)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional animated movement? linear or even specific curves?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rotating a foot-mobile is all in one go, but vehicles had some sort of acceleration and cap on how fast you can traverse, meaning it has to be inputting for more than one frame to do much of anything.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is a foot-mobile?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A person. Don't you play proper Arma, that's standard callout. :p

Copy link
Contributor

@dedmen dedmen Mar 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I intended this to mean adding animation handled in a second thread.
Which also solves:

meaning it has to be inputting for more than one frame to do much of anything.

Because you just tell it "Move that much over that much time"

Second thread also needs the "Arma in focus" check so we can't accidentally move the mouse outside of Arma. And it needs a limit. Bad guy could just launch a 10 hour animation...

IMO this feature could use Intercept. Intercept_CBA already has "Arma in focus" checks for the keybinding stuff. It could internally take care of dialog-open check and others. Instead of basing them on scripts which a bad-guy could just ignore by using callExtension directly.

ip.mi.dy = atoi(&function[1]);
ip.mi.dx = 0;
}
else {
Copy link
Contributor

@dedmen dedmen Feb 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All other extensions use } else {.
else on same line.

return;
}

SendInput(1, &ip, sizeof(INPUT));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it also return "error" if SendInput fails?

@dedmen
Copy link
Contributor

dedmen commented Feb 22, 2018

Could also call this mouse extension and use it to click. But that needs even better protection so that it can't be missused.

Would also be nice to get MOUSEEVENTF_ABSOLUTE and a way to use Arma display coordinates. Aka float from 0-1 to move the mouse and have it automatically translate to the game window position/size.
I'd say that would be more usable. Because with just pixel offsets you cannot move the mouse precisely in ingame UI's as you don't know what resolution the player is running.

Also

Relative mouse motion is subject to the effects of the mouse speed and the two-mouse threshold values. A user sets these three values with the Pointer Speed slider of the Control Panel's Mouse Properties sheet.

Makes it even more imprecise.

I guess baer want's this for the flashbang stuff? It would break if the player happens to be in whatever state where his mouse doesn't control camera movement.

Yeees. I know I should've done one review with comments inside it instead of seperate comments. I always make that mistake 🗡️

EDIT: To the flashbang stuff. What I quoted above also means the flashbang effect is different depending on the Players mouse acceleration setting in Windows.

/*
* Author: LorenLuke (function), BaerMitUmlaut (Extension)
* Simulates mouse input by number of pixels (not consistent/smooth)
* Note- using with open dialogs may cause issues when in loops.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What kind of issues? Moving out of game window?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And pinning your cursor to the corner of the desktop/monitor like it's a professional wrestler waiting for a three-count.

ip.mi.dx = atoi(&function[1]);
ip.mi.dy = 0;
}
else if (strncmp(function, "y", 1)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strncmp for just one character is a little overkill..
function[0] == 'y'

@LorenLuke
Copy link
Contributor Author

not precise motion.

The intended use is to call it within a PFH. Check that the game isn't paused and a dialogue isn't open, then use a constant angle check in to tandem with a PID controller to direct a correspondence towards an orientation.

@dedmen
Copy link
Contributor

dedmen commented Feb 22, 2018

then use a constant angle check in to tandem with a PID controller to direct a correspondence towards an orientation.

Ehhh.... What?

@Cuel
Copy link
Contributor

Cuel commented Feb 22, 2018

what's the purpose after merge? just wondering

@LorenLuke
Copy link
Contributor Author

@dedmen

angle check in to tandem with a

Should have been 'in tandem with'. Also not proofread semi-pseudocode, because I'm on my phone.

Player setVariable ["autotrack", [0,0]];
onEachFrame { 
(player getVarable "autotrack") call func(move_cursor);
};

and just check angles between it and a desired aimpoint from there and feed them into the unit variable.

@Cuel I recall in the slack regarding #6034 that someone said they wouldn't mind if a vertical component could be added somehow. This could do just that. However original plans were for this to be used with a to-be-written Shtora defensive system framework, one of the components of which involves rotating the entire turret automatically to face an incoming rocket. With an AI or even nobody in the turret, that's doable; with a player in this, less so. Additional capabilities of this can include laying off some automatic artillery pieces and the creation of auto-tracking, radar-guided guns like the Shilka would be.

@commy2
Copy link
Contributor

commy2 commented Feb 22, 2018

Hunter-Killer for tanks.

@jonpas jonpas changed the title Adds cursor movement. Add cursor movement API Feb 22, 2018
@Dystopian
Copy link
Contributor

Some time ago I was thinking about systems like Shilka: maybe it could be done with temporary moving player from main gunner to some other vehicle seat and creating UAV-like AI at gunner seat. AI could be ordered not fire till player orders.

@commy2
Copy link
Contributor

commy2 commented Mar 15, 2018

State?

@dedmen
Copy link
Contributor

dedmen commented Mar 15, 2018

See all comments. Currently Stale it seems because author is unable to change stuff on the extension.
Unless you are just fine with ignoring all comments and just merging it.
Even the SQF only comments weren't addressed. Aka call compile format

@PabstMirror
Copy link
Contributor

I think we should wait until we have an actual use for this

@PabstMirror PabstMirror added this to the Ongoing milestone Mar 15, 2018
Copy link
Contributor

@commy2 commy2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • only one extension call should be used to change both X (0=left) and Y (0=top) (callExtensionArgs)
  • absolute change, pixels are useless
  • syntax for "move by X,Y from where you are now" and "move to X,Y regardless of where you are now"

Someone please explain to me why Windows has X as the ordinate. I am used to it being inverted by Arma too, but this just baffles me.

Ref.: https://community.bistudio.com/wiki/getMousePosition

For dialogs this function should probably just fall back to: https://community.bistudio.com/wiki/setMousePosition

I want this for Hunter-Killer :~)

@LorenLuke
Copy link
Contributor Author

@dedmen
@commy2
As someone of variable and limited free time (why are there only 24 hours in a day?!), fluctuating mental health, and biting off more than I can chew with many other projects (missile guidance rework, MANPADS realistic functionality, Javelin realistic functionality introduction, MiniSpike television guidance, UAV vanilla module replacement/improvement) this PR has indeed gone somewhat stale, but it's not gone from my memory.

@PabstMirror
Uses for it would include commy's Hunter-Killer/slew-to-cue system, as well as auto tracking radar guided guns for the Tigris/Bardelas AA as well as 3rd party AA (ZSU Shilka), and Shtora active protection systems (intended to be compatible with the missile guidance rewrite).

@jonpas jonpas added kind/feature Release Notes: **ADDED:** status/WIP labels Dec 17, 2019
@jonpas jonpas removed this from the Ongoing milestone Apr 20, 2021
@jonpas jonpas added this to the Backlog milestone Apr 20, 2021
@LorenLuke LorenLuke closed this Nov 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Release Notes: **ADDED:** status/WIP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants