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?
-
3have you considered enabling use of the arrow keys to fine tune the position of your object (like in Word, Photoshop, etc..)? – Tobias Cohen Jan 06 '10 at 09:45
-
Yes, that's how its done at the moment, but of course there is no 'fine' action when you get close. – Brian Frost Jan 06 '10 at 16:36
5 Answers
Afaik Jedi (jedi apilib?) had a joystick header too. It is winapi, not COM, so no TLB involved

- 25,628
- 5
- 56
- 89
Try NLDJoystick, an open-source component written by me and based on pure WinAPI (MMSystem.pas). It is downloadable from GitHub.
The interface:
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property AbsCenter;
property AbsMax;
property AbsMin;
property Active default False;
property Advanced default False;
property AxisCount;
property Axises;
property ButtonCount;
property HasPOV;
property ID;
property OnButtonDown;
property OnButtonUp;
property OnMove;
property OnPOVChanged;
property PollingInterval default 40;
property RepeatButtonDelay default 350;
property RepeatMoveDelay default 350;
property SuspendScreensaver default False;
property ThresholdFactor;

- 43,011
- 8
- 105
- 200
Maybe you can make something like that yourself.
- Take a panel, and register on Mouse up, down and move events
- On MouseDown, set a boolean (fButtonDown) so you know that the mousebutton is pressed and save the X and Y coordinates of the mousepointer.
- 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.
- On MouseUp, set fButtonDown to false
The above is very primitive, but should work.

- 6,992
- 2
- 43
- 69
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.

- 66,391
- 18
- 125
- 167
-
-
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 Jan 06 '10 at 13:28
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.

- 6,932
- 10
- 65
- 105