|
Post by ilitirit on Jan 22, 2018 17:14:53 GMT
I'm writing a simple Feeder app using .NET Forms.
I have button controls on a Form which correspond to inputs on the Virtual Joystick. When I press the button, it should activate the corresponding input and vice versa when I release it.
The issue I have is that the "release" method does not seem to do anything unless I put in a significant Sleep time.
My PressButton method (called on the Clicked event) looks something like this:
private void PressButton(string buttonName) { switch (buttonName) { case "Up": _state.AxisY = 0; break;
case "Down": _state.AxisY = 0x8000; break;
case "Left": _state.AxisX = 0; break;
case "Right": _state.AxisX = 0x8000; break;
default: return; }
_joystick.UpdateVJD(_id, ref _state); }
The ReleaseButton method (called on MouseUp for now) does something similar except it sets the corresponding Axis to neutral. As I mentioned though it doesn't do anything unless I use a Thread.Sleep() with a high enough value.
What am I doing incorrectly?
EDIT: It seems the issue is with the app I'm testing (Mame). It works fine in other apps.
|
|
evilc
New Member
Posts: 32
|
Post by evilc on Jan 23, 2018 17:27:25 GMT
Games tend to "Poll" input rather than read them through events. If, say, the stick is updated twice between polls, the game would never see the first update. But this should only really be the case if your release code executes <~50ms after your press code.
I say 50ms as this is a value that typically works with most modern games though. The poll rate is often loosely associated with frame rate, so for something like a MAME emulator, I would not be surprised if the FrameRate was very low (say 15-20FPS) and so it may have a very slow poll rate.
|
|