德尔福有“操纵杆”吗?控制?

发布于 2024-08-17 03:09:56 字数 117 浏览 6 评论 0原文

我想使用鼠标将对象在 X 和 Y 方向上对齐,将其移动到位。我可以通过使用各种旋转控件(或按钮)来滚动解决方案,但它很混乱,我想知道是否有一个控件(例如操纵杆)可以使用鼠标提供 2 轴控制并以不同的速率触发事件它的地位?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

懒猫 2024-08-24 03:09:56

Afaik Jedi(jedi apilib?)也有一个操纵杆头。它是winapi,不是COM,所以不涉及TLB

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

幸福%小乖 2024-08-24 03:09:56

尝试 NLDJoystick,这是我编写的基于纯 WinAPI (MMSystem.pas)。它可以从 GitHub 下载。

界面:

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;

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;
彩虹直至黑白 2024-08-24 03:09:56

也许你可以自己做类似的东西。

  1. 拿一个面板,注册鼠标向上、向下和移动事件。
  2. 在鼠标按下时,设置一个布尔值(fButtonDown),以便您知道鼠标按钮被按下并保存鼠标指针的 X 和 Y 坐标。
  3. 在 MouseMove 上,检查按钮是否按下 (fButtonDown) 并移动对象。鼠标光标从保存的位置移动得越多,移动的速度就越快。
  4. 在 MouseUp 上,将 fButtonDown 设置为 false

上面的内容非常原始,但应该可以工作。

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.

痕至 2024-08-24 03:09:56

我用谷歌搜索“joystick dll”并找到了无数。您可能可以将其中一个放入您的项目中,然后通过简单地为其编写一个 TLIB 标头(或无论它被称为什么,有一段时间没有这样做)来从 Delphi 访问其 C API。

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.

凯凯我们等你回来 2024-08-24 03:09:56

您可以使用DelphiX 组件。据我所知,它们是 DirectX 的包装器,其中之一包装了 DirectX 操纵杆接口。它采用 Delphi 风格包装,因此易于使用。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文