Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Offline Robert Walter  
#1 Posted : Tuesday, January 17, 2012 9:18:11 AM(UTC)
Robert Walter

Joined: 8/24/2011(UTC)
Posts: 68

Thanks: 4 times
Good morning,

I have some questions regarding the InputGestures class.

I want to include the possibility of using a touchscreen in my application. So I had a look into the InputGestures class and the samples in Delta.InputSystem.Tests.

1.) When I try out the AllGestures() unit test and drag the mouse, dragging is immediately recognized (the green circle appears), although the if clause checks

Code:
if (Input.GetState(InputButton.GestureDrag) == InputState.Released)


Would have expected that it would only be recognized when I release the mouse button or take my finger of the touchscreen.

2.) IsHorizontalDrag and IsVerticalDrag don't seem to work. I never see a green circle :( Or can't these events be activated with a mouse?

3.) Multitouch - with more than 2 fingers - isn't possible right now? Or didn't I stumble over it, yet?

4.) How would I best implement something like this:

Code:

// move camera right, if mouse/touch drag at least 0.1f in x direction
if (Input.Gestures.IsDrag && ((Input.Mouse.DragStartPosition.X +0.1f) < Input.Mouse.Position.X))



The code works, but I feel as if there is a much nicer version, which I can't seem to figure out. Cool

Edited by user Tuesday, January 17, 2012 2:26:36 PM(UTC)  | Reason: Not specified

Wanna join the discussion?! Login to your forum accountregister a new account. Or Connect via Facebook Twitter Google

Offline Benjamin  
#2 Posted : Tuesday, January 17, 2012 3:23:08 PM(UTC)
Benjamin

Medals: Admin

Joined: 8/20/2011(UTC)
Posts: 1,421
Location: Hannover

Thanks: 18 times
Was thanked: 97 time(s) in 92 post(s)
Hi.

Touch capabilities can be tested best on Windows 7 with a touch screen and yes Multitouch works fine on all platforms. Another way to test is using multiple mouses or the wiimote ..

I am not sure why IsHorizontalDrag and IsVerticalDrag always return false, it is probably just not implemented (should say so in the comment ..)

Please note that while the InputSystem is working we still have many open issues and that is why the base assembly is not public yet .. we also like to add some more extensibility options (e.g. use kinect as a input controller for example, which is not really one of the 5 existing supported input device types).

About your drag example, it does not look too bad. Usually a InputCommand should be used, but I am not sure how to do that yet. It should be possible with the modifiers, but it could also be that they are not powerful enough yet. For using InputCommands you should wait until the editor is available in the ContentManager. Until then roll your own ^^

Edited by user Tuesday, January 17, 2012 3:45:48 PM(UTC)  | Reason: Not specified

Offline Robert Walter  
#3 Posted : Tuesday, January 17, 2012 3:37:03 PM(UTC)
Robert Walter

Joined: 8/24/2011(UTC)
Posts: 68

Thanks: 4 times
Thanks.

So I guess I have to use Delta.InputSystem.Devices.BaseTouch class and the filed Touches to see how many fingers are on the touchscreen? For example I want the camera only to move if there are 3 fingers on the screen.

As I don't have a touch screen, will the multi touch capable mousepad of my macbook suffice?
Offline Benjamin  
#4 Posted : Tuesday, January 17, 2012 3:47:03 PM(UTC)
Benjamin

Medals: Admin

Joined: 8/20/2011(UTC)
Posts: 1,421
Location: Hannover

Thanks: 18 times
Was thanked: 97 time(s) in 92 post(s)
Anything works that can do multitouch on Windows 7, but I guess your mac hardware won't cut it ^^ artist tablets usually don't work either (they only work as single touch devices).
Offline elasto  
#5 Posted : Sunday, February 5, 2012 3:54:42 AM(UTC)
elasto

Joined: 8/23/2011(UTC)
Posts: 245

Thanks: 6 times
Was thanked: 12 time(s) in 11 post(s)
I accept that InputSystem isn't fully fleshed out yet but I have a question about processing a pinch.

What is the neatest way to process a pinch? In particular, does "Input.Touch.GetMovement(InputButton.GesturePinch)" have any meaning? What does it represent?
Used in conjunction with "Input.Touch.Position()" (the pinch centre) is there enough info to process a pinch?

(I appreciate there's Input.Touch.Touches[index].Position available but I'm wondering if there's a neater, more abstracted way in place or planned.)
Offline Benjamin  
#6 Posted : Sunday, February 5, 2012 2:38:42 PM(UTC)
Benjamin

Medals: Admin

Joined: 8/20/2011(UTC)
Posts: 1,421
Location: Hannover

Thanks: 18 times
Was thanked: 97 time(s) in 92 post(s)
Well, there is gestures and using them via input commands.

Check out the unit tests in Delta.InputSystem.Tests. There are several ways to detect a pinch gesture:
Code:

Input.Gestures.IsPinch


Or via InputCommands (just added this test to Delta.InputSystem.Tests.CommandTests):
Code:

		#region TestCustomPinchCommand
		/// <summary>
		/// Test Custom Pinch Command Trigger (we don't have pinch commands in
		/// InputSettings.xml yet).
		/// </summary>
		[Test, Category("Visual")]
		public static void TestCustomPinchCommand()
		{
			const string PinchCommandName = "TestCustomPinchCommand";
			Input.Commands[PinchCommandName].AddTrigger(new CommandTrigger
			{
				Button = InputButton.GesturePinch,
				State = InputState.Released,
			});
			Input.Commands[PinchCommandName].Add(delegate(CommandTrigger trigger)
			{
				Application.BackgroundColor = Color.Random;
			});

			Application.Start(delegate
			{
				Font.Default.Draw("Pinch to change color", ScreenSpace.DrawArea);
			});
		}
		#endregion


Or you can check directly the InputButton.GesturePinch state (not sure if all states are supported, most gestures will only fire the Released state):
Code:

bool pinchStarted = Input.GetState(InputButton.GesturePinch) == InputState.Pressed;
bool pinching = Input.GetState(InputButton.GesturePinch) == InputState.IsPressed;
bool pinchDone = Input.GetState(InputButton.GesturePinch) == InputState.Released;
Point pinchMovement = Input.Touch.GetMovement(InputButton.GesturePinch);


And finally you can do your own checking via Input.Touch:
Code:

			for (int index = 0; index < Input.Touch.ActiveTouches; index++)
			{
				TouchData touch = Input.Touch.Touches[index];
				if (touch.State == InputState.Pressed &&
					touch.Position - touch.LastPosition > PinchOffset
etc.
Offline elasto  
#7 Posted : Sunday, February 5, 2012 3:02:08 PM(UTC)
elasto

Joined: 8/23/2011(UTC)
Posts: 245

Thanks: 6 times
Was thanked: 12 time(s) in 11 post(s)
Sorry, I guess I wasn't clear.

What I meant to ask was: How do I know how much of a pinch has occurred - have they pinched 0.01f or 0.1f? Or have they done a reverse pinch of -0.1f?

That's why I was asking if the value returned from Input.Touch.GetMovement(InputButton.GesturePinch) has any meaning or if I had to calculate the amount of pinch myself through keeping track of Input.Touch.Touches[index].Position(s)?
Offline Benjamin  
#8 Posted : Sunday, February 5, 2012 5:02:14 PM(UTC)
Benjamin

Medals: Admin

Joined: 8/20/2011(UTC)
Posts: 1,421
Location: Hannover

Thanks: 18 times
Was thanked: 97 time(s) in 92 post(s)
Your question is answered by the xml help for InputGestures.IsPinch:
Code:

		/// <summary>
		/// If two fingers are used and are currently pinching, we will fire this
		/// event, which is usually used for zooming (e.g. pictures, or zooming
		/// into 3D scenes). Note that normal GestureDrag events will not be fired
		/// if we detect that this might be a GesturePinch, GestureRotate or
		/// GestureDualDrag event (basically whenever we got 2 fingers on the
		/// screen and they are both dragging).
		/// <para />
		/// The position for GesturePinch is the center of both Gesture points,
		/// which is usually used to indicate what we want to pinch. Usually
		/// ignored because there is only one pinch-able object. Movement is used
		/// to indicate how much the fingers were moved together (negative) or
		/// apart (positive values). You can also determinate the direction of the
		/// pinch (e.g. horizontal or vertical or diagonal), but this feature is
		/// rarely need and might be too complex to understand for an end user.
		/// <para />
		/// The pinch gesture is usually only supported by touch input devices.
		/// </summary>
		public bool IsPinch


For input commands you can directly use the position and movement, for input button states you have to grab them like in your example with Input.Touch.GetMovement(InputButton.GesturePinch). Or you can calculate it yourself by checking all the touches and using the StartDragPosition - the current Position to get the movement yourself.

Hope that helps!
Offline elasto  
#9 Posted : Sunday, February 5, 2012 5:19:00 PM(UTC)
elasto

Joined: 8/23/2011(UTC)
Posts: 245

Thanks: 6 times
Was thanked: 12 time(s) in 11 post(s)
Thanks, that helps a lot!
Offline elasto  
#10 Posted : Monday, February 6, 2012 10:38:58 AM(UTC)
elasto

Joined: 8/23/2011(UTC)
Posts: 245

Thanks: 6 times
Was thanked: 12 time(s) in 11 post(s)
Possible bug?

If I do this in my Game constructor:

Code:
Input.Commands[Command.UIClick].Add(delegate { ProcessClick(Input.Mouse.Position); });
Input.Commands[Command.UIDragMove].Add(delegate { ProcessDrag(Input.Mouse.Movement); });


Both delegates seem to fire when I do a drag (the UIClick fires at the end of the drag). Is this intended behaviour?

Because I don't wish UIClick to fire at the end of a drag I've commented out the "Input.Commands[Command.UIClick].Add..." line in the constructor and replaced it with the following in the Run method:

Code:
if (Input.Gestures.IsTap) ProcessClick(Input.Mouse.Position);


And that works better: Input.Gestures.IsTap is never true during or after a drag.
Offline Benjamin  
#11 Posted : Monday, February 6, 2012 11:28:09 AM(UTC)
Benjamin

Medals: Admin

Joined: 8/20/2011(UTC)
Posts: 1,421
Location: Hannover

Thanks: 18 times
Was thanked: 97 time(s) in 92 post(s)
Hey Phil,

Thanks for the bug report, it has been entered into the bug database.

However, using UIClick and UIDragMove is indented for the Delta.Scenes.UserInterfaces classes, not for game logic. You should probably wire up your own input commands to have better control what actually happens.

Also on Friday one game team changed the behavior of UIClick for Button controls (only sucessful UIClick Pressed events are processed now, not all press states, which will mostly be noticeable for buttons that behave differently when you click them several times in the same screen). I have to check with them if the UI commands still work fine when doing any input change ..

You are probably right about the behavior that UIClick should match just a Tap gesture, but currently it is fired for every click/tap/etc. release on each of the input devices (see InputSettings.xml):
Code:

			#region UIClick
			commands[Command.UIClick].AddTrigger(new CommandTrigger
			{
				Button = InputButton.MouseLeft,
				State = InputState.Released,
			});
			commands[Command.UIClick].AddTrigger(new CommandTrigger
			{
				Button = InputButton.TouchPress,
				State = InputState.Released,
			});
			commands[Command.UIClick].AddTrigger(new CommandTrigger
			{
				Button = InputButton.Space,
				State = InputState.Released,
			});
			commands[Command.UIClick].AddTrigger(new CommandTrigger
			{
				Button = InputButton.GamePadA,
				State = InputState.Released,
			});
			#endregion
Rss Feed  Atom Feed
Users browsing this topic
OceanSpiders 2.0
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2023, Yet Another Forum.NET
This page was generated in 0.698 seconds.