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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added ace_cursor_movement.dll
Binary file not shown.
Binary file added ace_cursor_movement_x64.dll
Binary file not shown.
1 change: 1 addition & 0 deletions addons/common/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ PREP(loadPerson);
PREP(loadPersonLocal);
PREP(moduleCheckPBOs);
PREP(moduleLSDVehicles);
PREP(moveCursor);
PREP(muteUnit);
PREP(muteUnitHandleInitPost);
PREP(muteUnitHandleRespawn);
Expand Down
30 changes: 30 additions & 0 deletions addons/common/functions/fnc_moveCursor.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* 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.
*
* Arguments:
* 0: x direction (+right, -left) <NUMBER>
* 1: y direction (+down, -up) <NUMBER>
*
* Return Value:
* None
*
* Example:
* [100, 100] call ace_common_fnc_moveCursor
*
* Public: Yes
*/
#include "script_component.hpp"

params ["_x", "_y"];

if (!dialog) then {
"ace_cursor_movement" callExtension format ["x%1", _x];
"ace_cursor_movement" callExtension format ["y%1", _y];

TRACE_2("movecursor",_x,_y);
};

nil
1 change: 1 addition & 0 deletions extensions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ add_subdirectory(clipboard)
add_subdirectory(advanced_ballistics)
add_subdirectory(medical)
add_subdirectory(parse_imagepath)
add_subdirectory(cursor_movement)

# Test Extension for dynamically loading/unloading built extensions; does not build in release
if (DEVEL)
Expand Down
12 changes: 12 additions & 0 deletions extensions/cursor_movement/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
set(ACE_EXTENSION_NAME "ace_cursor_movement")

file(GLOB SOURCES *.h *.hpp *.c *.cpp)
add_library( ${ACE_EXTENSION_NAME} SHARED ${SOURCES} ${GLOBAL_SOURCES})
target_link_libraries(${ACE_EXTENSION_NAME} ace_common)
set_target_properties(${ACE_EXTENSION_NAME} PROPERTIES PREFIX "")
set_target_properties(${ACE_EXTENSION_NAME} PROPERTIES FOLDER Extensions)

if(CMAKE_COMPILER_IS_GNUCXX)
set_target_properties(${ACE_EXTENSION_NAME} PROPERTIES LINK_SEARCH_START_STATIC 1)
set_target_properties(${ACE_EXTENSION_NAME} PROPERTIES LINK_SEARCH_END_STATIC 1)
endif()
32 changes: 32 additions & 0 deletions extensions/cursor_movement/cursorMovement.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include "stdafx.h"
#include "windows.h"
#include "string.h"
#include <stdlib.h>

extern "C" {
__declspec (dllexport) void __stdcall RVExtension(char *output, int outputSize, const char *function);
}

void __stdcall RVExtension(char *output, int outputSize, const char *function) {
INPUT ip;
ip.type = INPUT_MOUSE;
ip.mi.mouseData = 0;
ip.mi.dwFlags = MOUSEEVENTF_MOVE;
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.

ip.mi.dx = atoi(&function[1]);
ip.mi.dy = 0;
} else if (strncmp(function, "y", 1)) {
ip.mi.dy = atoi(&function[1]);
ip.mi.dx = 0;
} else {
strncpy_s(output, outputSize, "error", _TRUNCATE);
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?


strncpy_s(output, outputSize, "ok", _TRUNCATE);
}