views:

203

answers:

4

I'd like to align an object in X and Y by eye using the mouse to move it into position. I can roll a solution by using various spin controls (or buttons) but it's messy and I got to wondering whether there is a control - like a joystick - that provides 2-axis control using the mouse and fires events at rates which vary depending on its position?

A: 

I Googled for "joystick dll" and found countless. You can probably throw one of these into your project and then access its C API from Delphi by simply writing a TLIB header (or whatever it's called, haven't done this in a while) for it.

Carl Smotricz
TLB is for COM, not plain procedural winapi.
Marco van de Voort
Right you are, I'm sure. I remember there are Pascal header files that one uses to declare procedures in C code, but I've forgotten the correct name for them.
Carl Smotricz
A: 

You may use a DelphiX components. They are wrappers for DirectX and one of them wraps around DirectX joystick interface as far as I remember. It wraps in a Delphi-style so it is easy to use.

Wodzu
+2  A: 

Afaik Jedi (jedi apilib?) had a joystick header too. It is winapi, not COM, so no TLB involved

Marco van de Voort
This is what I was looking for thanks.
Brian Frost
+1  A: 

Maybe you can make something like that yourself.

  1. Take a panel, and register on Mouse up, down and move events
  2. On MouseDown, set a boolean (fButtonDown) so you know that the mousebutton is pressed and save the X and Y coordinates of the mousepointer.
  3. On MouseMove, check if a button is down (fButtonDown) and move your object. The more your mousecursor is moved from its saved position, the faster you move.
  4. On MouseUp, set fButtonDown to false

The above is very primitive, but should work.

The_Fox
Yes, its tempting, thanks.
Brian Frost

related questions