🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
10 messages
10 total messages Started by Nicholas Gessler Fri, 07 Apr 2006 01:38
Moving Cursor under Program Control?
#3953
Author: Nicholas Gessler
Date: Fri, 07 Apr 2006 01:38
15 lines
1344 bytes
Is there a way to move the cursor under program control?  
Basically, I want to use the mouse as a real-world data
collection device.  I want to intercept the XY data from the roller ball interruptors or laser? LEDs and process it under
program control WITHOUT moving the cursor on the screen. Can 
I disconnect the two?

Why do this?  Simply to create a new physical data input device
that won't stop inputting data when the cursor would OTHERWISE
stop at the edge of the screen.

Any ideas?

Thanks, 
Nick Gessler, Ph.D.
Re: Moving Cursor under Program Control?
#3954
Author: Roel Schroeven
Date: Fri, 07 Apr 2006 07:16
18 lines
1910 bytes
Nicholas Gessler schreef:
> Is there a way to move the cursor under program control?  
> Basically, I want to use the mouse as a real-world data
> collection device.  I want to intercept the XY data from the roller ball interruptors or laser? LEDs and process it under
> program control WITHOUT moving the cursor on the screen. Can 
> I disconnect the two?
> 
> Why do this?  Simply to create a new physical data input device
> that won't stop inputting data when the cursor would OTHERWISE
> stop at the edge of the screen.

I think you can do stuff like that using DirectInput from DirectX.

-- 
If I have been able to see further, it was only because I stood
on the shoulders of giants.  -- Isaac Newton

Roel Schroeven
Re: Moving Cursor under Program Control?
#3957
Author: Remy Lebeau (TeamB)
Date: Fri, 07 Apr 2006 17:42
17 lines
1529 bytes
"Nicholas Gessler" <gessler@ucla.edu> wrote in message
news:4435c27b$1@newsgroups.borland.com...

> Basically, I want to use the mouse as a real-world data
> collection device.  I want to intercept the XY data from the
> roller ball interruptors or laser? LEDs and process it under
> program control WITHOUT moving the cursor on the screen.
> Can I disconnect the two?

The cursor is under the control of the OS.  s far as I know, you can't stop
it from moving the cursor around when it receives input from the mouse
hardware, unless you write your own device driver to process the hardware
signals directly.


Gambit
Re: Moving Cursor under Program Control?
#3959
Author: Nick Gessler
Date: Fri, 07 Apr 2006 22:23
12 lines
1343 bytes
Remy,

OK, thanks.  I was afraid of that...
I'm sure I could "bend" the usual use of the mouse with a
MouseMove event handler for the Form, but then there will
be a data-collection problem every time the cursor hits the edge of the form.  I was hoping there might be some way to tell the cursor to go back to the center of the screen.  Oh 
well...  I think I'll have to leave writing a new device driver
to some time in the future.

Thanks again,
Nick
Re: Moving Cursor under Program Control?
#3961
Author: Remy Lebeau (TeamB)
Date: Sat, 08 Apr 2006 00:45
21 lines
1709 bytes
"Nick Gessler" <gessler@ucla.edu> wrote in message
news:4436e650$1@newsgroups.borland.com...

> I'm sure I could "bend" the usual use of the mouse with a
> MouseMove event handler for the Form, but then there will
> be a data-collection problem every time the cursor hits the
> edge of the form.  I was hoping there might be some way to
> tell the cursor to go back to the center of the screen.

You can move the mouse cursor anywhere you want, using the VCL's
TMouse::CursorPos property or the Win32 API SetCursorPos() function.

> Oh well...  I think I'll have to leave writing a new device driver
> to some time in the future.

I am still unsure of what exactly you are trying to accomplish.  Can you
provide a more detailed example?


Gambit
Re: Moving Cursor under Program Control?
#3962
Author: Nick Gessler
Date: Sat, 08 Apr 2006 18:02
48 lines
3002 bytes
Hello Remy,

I will try your suggestions over the weekend...

You asked why I would want to do this.  I'm afraid it is a 
rather lengthy answer...

I teach several courses at UCLA in computer simulation, for
students who mostly have had no previous programming
experience. The flagship course is "ALiCE - Artificial Life,
Culture and Evolution." These courses are part of our new
Human Complex Systems program, and I recently won a teaching
award for the flagship course - my "innovation" was "teaching
students how to REASON with technology." For more, please
visit my website: http://gessler.bol.ucla.edu

When I teach to Arts students, we use an EZIO AD/DA board 
and interface our software with the real world. Because that
board is cumbersome to demonstrate in a classroom setting,
I'd like to experiment with other alternatives for simple AD
converters.  

The mouse is one such device, and I was hoping to sacrifice
a few of them by taking them apart, and in the case of roller
ball mice, physically connecting the rollers to processes in
the real world.  In that case I'd control the software from 
the keyboard and use the mouse in a way it was not intended
to be used: as a movement sensor, or pair of movement sensors.
With the optical mice, I'm sure I could do something similar.

So I would want to be able to input an endless and seamless 
stream of data from the re-purposed mouse.  I would use the 
mouse-move event to collect the data. However, the data stream
would be interrupted when the cursor hit the edge of the 
window.  If I can reset the position of the cursor under
program control, I could then reset the cursor when this
happens and with code I could reconstruct a steady stream of
data.

I would love to buy ready-to-use plug-in USB AD/DA devices for
everyone in my class, but as a Lecturer, I cannot afford to
do that. So I was hoping to be able to repurpose a bunch of 
mice to do this.

Thanks, Nick
Nick Gessler, Ph.D.
UCLA Human Complex Systems Program
Re: Moving Cursor under Program Control?
#3964
Author: JD
Date: Sat, 08 Apr 2006 19:05
28 lines
2184 bytes
"Nick Gessler" <gessler@ucla.edu> wrote:
>
> [...] So I would want to be able to input an endless and
> seamless stream of data from the re-purposed mouse.  I would
> use the mouse-move event to collect the data. However, the
> data stream would be interrupted when the cursor hit the
> edge of the window.

This can be easily accomplished if you change your concept of
data collection. Instead of collecting the absolute TPoint( X,Y ),
Assume that the starting position is the center of the screen
and then collect points relative to the previouse point. For
example, if the previouse point was 10,10 and the new point
is 8,12, the data point would be -2,2 and the previouse point
would become 8,12.

Now all you have to do is add logic to your code to handle
when the mouse hits the limits of the window. Just reposition
it back to the center of the screen and set the previouse point
to the center of the screen as well.

As for mouse movement in terms of GUI, you could paint
a simulated mouse at the center of the screen and set the
Screen::Cursor to crNone so that it appears that the mouse
isn't moving at all.

~ JD
Re: Moving Cursor under Program Control?
#3965
Author: Nick Gessler
Date: Sat, 08 Apr 2006 21:03
41 lines
2301 bytes
JD,

Yes, this is exactly what I had in mind. As a quick test,
I coded the following:

void __fastcall TForm1::FormMouseMove(TObject *Sender, TShiftState Shift,
      int X, int Y)
{
   Form1->Canvas->Pixels[X][Y] = clBlack;
   if (X <= 10) {
      SetCursorPos(Form1->Left + Form1->Width,
      Y + Form1->Top);
   }
   if (Y <= 10) {
      SetCursorPos(X + Form1->Left,
      Form1->Top + Form1->Height);
   }
   // yes, more "if"s are needed for bottom and right...
}

I know it's not quite what you suggested. I will have to keep
the cursor in the center of the Form as you wrote.  But this
does show that it will work.

Interesting that the cursor position is in global screen
coordinates while the mouse move is in Form coordinates.  So
one has to compensate for the position of the form.  And for 
the height of the top banner (which I have not done yet).  And
interesting that to get to the close icon one must "sneak" off
of the Form window...

Is there any way I can speed up the mouse sample rate or keep 
it constant?  That is, I don't want to let it accelerate.  It 
would also be useful to associate the mouse move events with
the system clock, which I assume I can do in the standard way.

Yes, this has possibilities...

Many thanks,
Nick
Re: Moving Cursor under Program Control?
#3966
Author: Bob Gonder
Date: Sun, 09 Apr 2006 03:45
22 lines
1954 bytes
Nick Gessler wrote:

>void __fastcall TForm1::FormMouseMove(TObject *Sender, TShiftState Shift,
>      int X, int Y)
>{
>   Form1->Canvas->Pixels[X][Y] = clBlack;
>   if (X <= 10) {

Why test the X and Y, why not just reset to the middle every time?

>the height of the top banner (which I have not done yet).  And
>interesting that to get to the close icon one must "sneak" off
>of the Form window...

You might also add a test for Right+Left click to disable the
centering and alow proper mouse usage.

>Is there any way I can speed up the mouse sample rate or keep 
>it constant? 

Take a look at SystemParametersInfo() and particularly the
SPI_SETMOUSE setting.
Re: Moving Cursor under Program Control?
#3967
Author: JD
Date: Sun, 09 Apr 2006 10:53
13 lines
1410 bytes
Bob Gonder <notbg@notmindspring.invalid> wrote:
>
> [...] why not just reset to the middle every time?

That's a good idea. It certainly does simplify the logic.

>You might also add a test for Right+Left click to disable the
>centering and alow proper mouse usage.

I was thinking of using WM_KEYDOWN but I like your idea better.

~ JD
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads