Hi,
If we need to check if a particular key was pressed, is this the
correct way of doing it?:
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_O) {
alert("you pressed the 'o' key!");
}
else if (keyCode == KeyEvent.KEYCODE_R) {
alert("you pressed the 'r' key!");
}
}
Thanks
On Nov 13, 1:03 pm, Dianne Hackborn <[email protected]> wrote:
> The mapping tables are device-specific.
>
>
>
>
>
> On Fri, Nov 13, 2009 at 7:36 AM, Android_n00b <[email protected]> wrote:
> > Hi Yi,
>
> > I am looking for the KeycodeLabels.h files in /android/frameworks/base/
> > libs/ui because that is where it is supposed to be, but I cannot find
> > it. I see the KeyLayoutMap.h file but do not see the KeycodeLabels
> > file. I am looking at online versions of the source code file
> > structure and do not see it there either. What am I missing?
>
> > On Nov 11, 2:46 pm, Yi Sun <[email protected]> wrote:
> > > The EventHub.cpp calls the KeyLayoutMap.cpp to cover the real scan code
> > to
> > > the Android internal keycode mapping. The internal key code mapping can
> > be
> > > found in KeycodeLabels.h and KeyEvent.java.
>
> > > On Wed, Nov 11, 2009 at 11:34 AM, Android_n00b <[email protected]>
> > wrote:
> > > > I would really appreciate a reply from someone at Google if nobody can
> > > > answer this. I really need to know this to move ahead with my
> > > > project.
> > > > Thanks.
>
> > > > On Nov 11, 2:12 pm, Android_n00b <[email protected]> wrote:
> > > > > Hi
> > > > > I am writing a program which captures the keys pressed by user in
> > > > > android and displays it in Ubuntu. According to what I read,
> > Android's
> > > > > input event device is structured around an interrupt or polling
> > > > > routine that captures the device-specific scancode and converts it to
> > > > > a standard form acceptable to Linux (as defined in input.h) before
> > > > > passing it to the kernel with input_event(). There are the steps
> > which
> > > > > describe the translation from keyboard input to application action:
> > > > > 1. Window manager reads key event from Linux keyboard driver.
> > > > > 2. Window manager maps scancode to keycode.
> > > > > 3. Window manager sends both the scancode and the keycode to the
> > > > > application.
>
> > > > > Now in my application I have an EditText which returns the keycode of
> > > > > any key which is pressed. So basically this is what I have:
> > > > > public boolean onKey(View v, int keyCode,
> > > > KeyEvent event) {
> > > > > // TODO Auto-generated method stub
> > > > > String a ="";a+=keyCode;
> > > > > txt.setText(a);
>
> > > > > return false;
> > > > > }
>
> > > > > Now I get this keycode value but it does not correspond to the
> > > > > scancode value. For example, the keycode value for 'A' is 29 but the
> > > > > scancode is 30. There is no correlation I can see between the input.h
> > > > > scancodes and these keycodes either. My question is, I want to know
> > > > > how step 2 (the mapping) above takes place. My applications aim is to
> > > > > echo whatever I type on my android keyboard on my Ubuntu desktop (I
> > > > > can connect between the 2 without a problem, so you don't have to
> > > > > worry about that). Any help would be appreciated, as I have looked
> > > > > online for quite a bit.
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > > > Groups "Android Developers" group.
> > > > To post to this group, send email to
> > [email protected]
> > > > To unsubscribe from this group, send email to
> > > > [email protected]<android-developers%2Bunsubs
> > > > [email protected]>
> > <android-developers%[email protected]<android-developers%252Bu
> > [email protected]>
>
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/android-developers?hl=en
>
> > > --
> > > Android-x86http://www.android-x86.org
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]<android-developers%2Bunsubs
> > [email protected]>
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en
>
> --
> Dianne Hackborn
> Android framework engineer
> [email protected]
>
> Note: please don't send private questions to me, as I don't have time to
> provide private support, and so won't reply to such e-mails. All such
> questions should be posted on public forums, where I and others can see and
> answer them.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en