|
|
doubt
Last post Thu, Oct 25 2007 5:22 PM by Brian Peek. 25 replies.
-
-
-
s_preethi15


- Joined on Mon, Sep 24 2007
- Posts 13
|
the new version for phidget library is present at this location:
http://www.phidgets.com/downloads.php?os_id=1 i m unable to find the new version for MSRS Services... :(
|
|
-
-
Brian Peek



- Joined on Sat, Mar 18 2006
- Niskayuna, NY
- Posts 1,116
|
I swear, the Phidgets people hate me. When I posted that msg, there was a MSRS 1.0 library. If you click on "Microsoft Robotics Studio" in the left column on that page, you go here: http://www.phidgets.com/downloads.php?example_id=14 ...which is now recompiled for MSRS v1.5. I don't think this will work with v1.0, and I'm not sure the code from my article is compatible wtih v1.5.
|
|
-
-
-
-
-
-
s_preethi15


- Joined on Mon, Sep 24 2007
- Posts 13
|
hey thanx a lot for tat link...i was able to create sumthing similar...but it looks very simple when compared to yours...jus have a look at it... namespace try2 { public partial class Form1 : Form { InterfaceKit ik = new InterfaceKit(); public int i; const int WM_KEYDOWN = 0x100; public Form1() { InitializeComponent(); Phidgets.Manager phidgetsManager = new Phidgets.Manager(); phidgetsManager.Attach+=new AttachEventHandler(phidgetsManager_Attach); phidgetsManager.open(); ik.open(i); } void phidgetsManager_Attach(object sender, AttachEventArgs e) { label1.Text=e.Device.Name + "-" + e.Device.SerialNumber; i= e.Device.SerialNumber; }
private void btn_ForwardMouseDown(object sender, MouseEventArgs e) { ik.outputs[0] = true; }
private void btn_ForwardMouseUp(object sender, MouseEventArgs e) { ik.outputs[0] = false; }
private void btn_BackwardMouseDown(object sender, MouseEventArgs e) { ik.outputs[1] = true; }
private void btn_BackwardMouseUp(object sender, MouseEventArgs e) { ik.outputs[1] = false; }
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { if (msg.Msg == WM_KEYDOWN) { switch (keyData) { case Keys.Up: ik.outputs[0] = true; break;
case Keys.Down: ik.outputs[1] = true; break;
case Keys.Left: ik.outputs[2] = true; break;
case Keys.Right: ik.outputs[3] = true; break; } return true; } return false; }
private void btn_LeftClick(object sender, EventArgs e) { if (ik.Attached) { if (ik.outputs[2] == false) ik.outputs[2] = true; else ik.outputs[2] = false; } }
private void btn_RightClick(object sender, EventArgs e) { if (ik.Attached) { if (ik.outputs[3] == false) ik.outputs[3] = true; else ik.outputs[3] = false; } }
} } i have not used mouse down and mouse up events for left and right button since my car involves turning with a forward or backward driving force...so once i toggle left/right button, i can either turn left or right after clicking on forward or reverse buttons as required....do you think i can improvise on tis...as in make it a bit more "less simpler"? i have also used keydown and keyup mapping idea from your project...however, i don't think hitting on left and forward(for example) simultaneously would move my car forward left...what should i do to implement this requirement?
|
|
-
-
Brian Peek



- Joined on Sat, Mar 18 2006
- Niskayuna, NY
- Posts 1,116
|
It is much simpler to do it in straight .NET without MSRS. The article was intended to be an intro to MSRS, but in reality, MSRS is not the best approach for a project like this. Anyway, the arrow keys should work like you want them. You will get separate keydown msgs for each arrow pressed. So if you press Up and then Left, you'll wind up toggling both outputs on. You'll need a KeyUp event as well to toggle the outputs back to false once you let go of a key (didn't see it above but you may already have it). Next to the gamepad, the arrow keys as implemented above (with the addition of KeyUp) is the easiest way to go about driving the car IMO.
|
|
-
-
|
|
|