Using joypad of phone

D

David

Hi all,

My phone is a HTC Touch.

I would like to navigate with the 'joypad' button.

I have two ToolBar buttons, first button to navigate record backwards,
second button to nav record forward. Is there anyway I can wire in the
joypad buttons to navigate as well?

I am using C#, CF 1.

Thanks for your help.
--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
 
P

Peter Foot

The direction pad (d-pad) raises standard keyboard events for left, right up
and down. You can add a handler to your form for the KeyUp/Down or KeyPress
events and act on these. e.g.

private void Form1_KeyDown(object sender, KeyEventArgs e)
{
switch(e.KeyCode)
{
case System.Windows.Forms.Keys.Left:
//left
break;
case System.Windows.Forms.Keys.Right:
//right
break;

//etc
}
}

Peter
 
C

Christopher Fairbairn

Hi,

David said:
I would like to navigate with the 'joypad' button.
I have two ToolBar buttons, first button to navigate record backwards,
second button to nav record forward. Is there anyway I can wire in the
joypad buttons to navigate as well?

You may be able to implement this by handling the key up/down events within
your form.

The joypad simply sends left/right arrow key press events to the currently
focused control. Deciding how to handle this when controls such as TextBoxes
have focus is the slightly tricky part.

Hope this helps,
Christopher Fairbairn
 
C

Christopher Fairbairn

Hi,

David said:
Thank you to both of you for the help. I will put it in.
(I am an experienced developer, just new to windows and mobile apps,
(mainly do web apps)).

Is there a reason why you are targeting .NET Compact Framework v1.0?

The device you mention you are targeting is reasonably new and has .NET
Compact Framework 2.0 in ROM, meaning even if you target the subset of APIs
available within .NET CF 1.0 your application will in fact be running on the
..NET CF 2.0 runtime.

Since you are new to .NET Compact Framework development it might pay to
check if you can use .NET CF 3.5 or atleast .NET CF 2.0.

..NET CF 2.0 was a reasonably significant step up compared to .NET CF 1.0 in
my opinion, making it a much more rounded out development platform.

Hope this helps,
Christopher Fairbairn
 
D

David

Hi,

Yes!!!

1. I don't have visual studio 5 yet (need to save my pennies to buy it) and
studio express doesn't support CF.
2. The app is for a (limited but) targetted market, but we don't yet know
what devices the target market have. (We are unable to control the device).
I want to make it work on my device and as many others. I want to build as
many features as I can to make it feel the product is worth the money being
paid for it.

There will be other questions I ask down the line as I get used to
programming it. At the moment, I think I need to program for the lowest
common denominator. The minimum device will be whichever version of windows
can be targetted.

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
 
D

David

Cool, that works. Thanks.

I noticed that there are a lot of other options within the keys. Are these
for the hard keyboards that are on many devices or will they work with the
SIP keys as well?

Which keys work with the green and red button? Is that LButton and RButton?
Is the MButton the center button of the Joypad?

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
 
D

David

Ah, it does work, but has left me with a new problem...

I have written an input pad (not SIP), that when I click in a text box, it
pops up. The input pad will then enter values into my text box.

When I have done this, I can no longer get the joypad button events. (debug,
pressing the buttons doesn't even register).

I have looked at getting the form back into focus rather than any form
fields, but the form doesn't have a focus property. How do I recover so that
my buttons can continue? (I can't even tap on the main screen to bring the
main screen back into focus.)

(Looks like the green and red buttons are not programmable using the same
method).

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
 
C

Christopher Fairbairn

Hi,

David said:
I have looked at getting the form back into focus rather than any form
fields, but the form doesn't have a focus property. How do I recover so
that my buttons can continue? (I can't even tap on the main screen to
bring the main screen back into focus.)

Yes these were the sorts of issues/rough edges I was talking about when
using the .NET CF 1.0. Many of these issues have work arounds typically
involving Platform Invoke code to access native OS APIs, but are taken care
of out of the box with .NET CF 2.0.

For example the Form class has a KeyPreview property within .NET CF 2.0
which allows the form to have a chance to process most key presses before
the currently focused controls does which helps resolve the button issue.

Would you be comfortable requiring users to install the .NET CF runtime onto
their device (if they didn't have the correct version in ROM) as part of
your application's installation process? .NET CF 2.0 and 3.5 supports
Windows Mobile 2003 or above, and for a commerical application this is
probably about as far back as you would want to go support wise. So by
developing for .NET CF 2.0 or 3.5 you are not really blocking out any area
of your potential market, you will just make the installation package
slightly larger, due to needing to install the .NET CF runtime
redistributable on devices which out of the box didn't have these later
version(s) installed.

If you are not aware of it yet, the OpenNETCF Smart Device Framework v1.4 is
a third party extension library that helps provide a lot of this missing
functionality within .NET CF 1.0. Later versions of this library require
..NET CF 2.0 or above.
(Looks like the green and red buttons are not programmable using the same
method).

Yes that is correct by default these keys serve dedicated phone functions
(such as disconnect GPRS data sessions etc), search these newsgroups, or
MSDN forums and you'll find a number of posts with possible solutions to
override these keys.

Hope this helps,
Christopher Fairbairn
 
C

Christopher Fairbairn

Hi,

David said:
I noticed that there are a lot of other options within the keys. Are these
for the hard keyboards that are on many devices or will they work with the
SIP keys as well?

The key press events will be triggered no matter what source generated them,
so they will work for both the software SIP and physical keys on devices
with QWERTY keyboards etc.

With some of the keys (such as arrow keys) there are techniques to determine
the source of the event (i.e. was it generated by a hardware keyboard, the
DPAD, or the software SIP for cases were you may want to perform slightly
different behaviour.
Is the MButton the center button of the Joypad?

The center button of the joypad actually maps to the Enter key.

Hope this helps,
Christopher Fairbairn
 
D

David

Hi Christopher,

Thanks for responding.

So, if I ensure that the min spec of the target device is WM 2003 (is there
a list of versions anywhere, and how do I tell which version is installed?),
I can run CF2 code (so long as CF2 is installed)?

If that is the case, then I will try and develop under #develop
(SharpDevelop) until I have enough cash to buy studio 2008.

--
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
 
G

Guest

So, if I ensure that the min spec of the target device is WM 2003 (is
there a list of versions anywhere, and how do I tell which version is
installed?), I can run CF2 code (so long as CF2 is installed)?
Yes

If that is the case, then I will try and develop under #develop
(SharpDevelop) until I have enough cash to buy studio 2008.

I don't know if sharpdevelop supports device development. Last I checked it
didn't.
 
C

Christopher Fairbairn

Hi,

Actually it only needs to be Standard Edition for device development.

Are you sure about this Chris?

I know that with VS2005 this was the case, but with VS2008 I think the bar
has been pushed even higher and you now need the Professional edition.

Atleast the VS2008 Standard ISO downloaded from MSDN Subscriber downloads
doesn't have smart device support.

Hope this helps,
Christopher Fairbairn
 
C

Christopher Fairbairn

Hi David,

David said:
So, if I ensure that the min spec of the target device is WM 2003 (is
there a list of versions anywhere, and how do I tell which version is
installed?), I can run CF2 code (so long as CF2 is installed)?

Yes that is correct.

There's a very handy chart available on MSDN which outlines the device
support for the various .NET CF releases, as well as the version(s) you can
expect to find in ROM (i.e. out of the box) on particular devices. This is
available at the bottom of the article at
http://msdn2.microsoft.com/en-us/library/ms172550.aspx

If you have a device in front of you, you can check which version(s) are
installed by going into the \windows directory with File Explorer and
running cgacutil.exe. For further details about this process (including how
to convert the version numbers reported to the various service packs etc)
see an entry on my blog titled "Windows Mobile Tip: Determine which versions
of the .NET Compact Framework are installed" available at
http://www.christec.co.nz/blog/archives/113
If that is the case, then I will try and develop under #develop
(SharpDevelop) until I have enough cash to buy studio 2008.

I haven't had recent experience with SharpDevelop so do not know if it
supports smart device development, or allows you to alter the compilers used
for compilation etc.

You could also resort to command line compilation if push really came to
shove.

Hope this helps,
Christopher Fairbairn
 
G

Guest

Well look at that - it's once again been pushed up to the Pro edition:
http://msdn2.microsoft.com/en-us/vs2008/products/bb980920.aspx

No idea who makes these decisions at Microsoft, but it sure doesn't seem
wise to me. Platform adoption requires software, no matter how good the OS
is (look at OS-2). Giving the tools away (like they used to do for mobile)
seems to me to make it a lot easier for lots of software to get developed.
This seems to be a move toward making it an enterprise-only platform, which
sure will ship a lot less devices.


--

Chris Tacke, eMVP
Join the Embedded Developer Community
http://community.opennetcf.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Phone number and IMEI in C# 3
Deploy files 3
Mouse selection 7
Quick survey: Multiple pages on a form 4
Deploying cab files 3
Navigate a PDF file from C# 2
Two projects, one app.config? 1
gotfocus keeps firing 4

Top