How can I obtain cursor position continuosly while executing in external mode?

2 views (last 30 days)
Hi,
I have a simulink model which I need to execute in external mode. Inside the model, I need to obtain the cursor position continuously and then use this data to produce some signals. I tried two methods for it. First I put a Matlab function block inside the modal and used the "get(0,'PointerLocation')" command of Matlab. It worked well in normal mode when I defined get as "coder.extrinsic('get')" inside the code. But it didn't worked in external mode. Then I tried to use S-function (C++) but since I get the cursor position using GetCursorPos command which is defined in header windows.h it also did not worked in external mode since I can't use Windows API in real-time code. Is there any other method that I can use to obtain the cursor position on the screen continuosly which is compatible with executing in external mode?
Thanks for your help.
  1 Comment
Borano
Borano on 17 Jan 2014
I also tried Matlab Level 2 S-functions but still it does not work. Are there any alternative to "get(0,'PointerLocation')" in Matlab that I can use in external mode for code generation?

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 17 Jan 2014
Provided that your external computer has a mouse device (and a display would help) you would probably have to use a mouse driver and query it for the current position. Depending on how the mouse works, the mouse driver might need to keep track of every movement to know where the cursor should be; I have also seen some mice that report absolute positions back, with the mouse interface hardware keeping track of the movement.
PointerLocation and GetCursoPos are much higher level functions; you will need to talk more directly to the hardware.

Categories

Find more on Simulink Real-Time in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!