Unable to pass certain IR remote key codes to Android - android

I'm trying to use an IR remote to pass certain key codes to Android. So far, I'm able to pass numeric keys (0-9) and D-pad keys (up, down, left, right, enter). Now I'm trying to extend the keys to include other characters like a-z.
The code that I'm modifying is an IR driver in the Linux kernel part of Android. It's similar to this driver. However, when I pass a value like KEY_A (maps "a" to 30: defined in Linux's include/linux/input.h), Android doesn't see it.
The section of code that passes the command up is the following:
input_report_key(cir->input, cir->last_key, 1);
input_report_key(cir->input, cir->last_key, 0);
input_sync(cir->input);
When I print cir->last_key, I can see the value 30 when I press the "a" button. However, I'm not sure how to trace the code from here to Android to see where the button press is being dropped.
In Android, I have a file called /system/usr/keylayout/qwerty.kl that maps values, e.g. 30 maps to "a". The problem is Android never gets the value of 30 when I press "a".

The keybit field of this structure has to be set to include all the key codes being passed.
For example,
set_bit(KEY_A, input_dev->keybit);

Related

Getting proper text input from physical keyboard in Android

I have a View that overrides the OnKeyDown event. I can get the Key Code and the KeyEvent, but it seems that I'm missing something.
Let me explain. For non-US keyboard layouts, the Key Code I'm getting is wrong. For example, when I press the ñ key in my Spanish keyboard, I expect to receive a "ñ" letter, but instead I get a Keycode.AltLeft as Key Code.
How do I get the real letter?
Another problematic case is with accentuated characters: When I press the ´ key and the o key, I shouldn't receive two events, but only one with the letter ó.
What are you trying to do? It is probably too low level.
A key down might not necessarily have anything to do with the final input text produced. For instance to produce on Japanese character one has to press a sequence of several keys.

Programming in Android Studio to able the user to give three numbers and save them

in android stuido I would like to code an activity, where the user can input numbers. For, example he types the number to the textfield, click 'OK' button, then the textfield gets clear, he types the second number, than the third, and after they give the third number the program goes to another activity and sayst thanks for the free number. I would like to save the three numbers for further use and have them in an ascending order. How should I do it?
I agree with Andrii, this is a very vague and general question. To get you pointed in the right direction though, you would want a layout with an number based-editText widget (for the user input). I would then add the button, and then implement OnClickListener for the button so that everytime the button is pressed, it calls a method you will define that will store the value in an array or list (which can be sorted), along with some kind of tracker to keep track of how many numbers have been entered - then clearing the editText field so that another number can be input; on the third number, the method calls the activity via intent or some other way saying "thanks for the free number".
This is all general and it is going to take quite a bit of work and API Guide/DeveloperDocs searching on the Android web site.

How can I stop editText changing my text?

I have written a program to take text entered into an editText and pass it to another system via a USB/serial link. I need to be able to enter fully arbitrary text and have it transmitted "as-is" without modification.
However, when I enter a string such as 4 2 . or SWAP OVER . . the space between the final character and the first . is removed — what is returned in these cases is 4 2. and SWAP OVER. .
Understandably, the target device doesn't recognise these and rejects the results.
I am entering the text into a textView cmdLine and returning it to my program using
cmdString = (SpannableStringBuilder) cmdLine.getText();
Is there a "feature" of getText() that tries to clean up the text entry, and, if so, how can I disable it?

how to add a new key in Android device

I have a device with Tao3530chip and there is a Android 2.3.3 system on it. I'm also having a button at gpio100 on that Tao chip. I'd like to use that button to perform some control in the high level application.
If I map this gpio 100 to a certain key value in the .kl file, lets say KEY_ESC which has the value 1, what I need more is to change the high level response to this key event.
However, obviously its not a good mapping.
On the other hand, I dont know how to map my gpio100 to an unused or user-defined key value in the .kl file. I understanding is that maybe i need to perform the following:
#define KEY_MYDEFINE 0x123
(0x123 is an unused value.)
And map my gpio100 to KEY_MYDEFINE. And then later code the high level response for KEY_MYDEFINE. Is the procedure correct?

android SearchableDictionary sample - suggesting words

i just used the searchabledictionary sample of android, which is available in samples folder of android sdk for windows. ( API level 9 )
i completed the definitions.txt file with the same format like
key - value
when i type a word in search area, the app tries to suggest words, but it doesn't find the exact word.here is an example. i searched the word test , and this is definitions.txt :
acceptance test - meaning
acid test - meaning
alpha test - meaning
benchmark tests - meaning
....
flight test - meaning
load test - meaning
....
test - meaning
it finds 15 first words of this list, ( hopefully it doesn't search words like attestaion) but it doesn't show the exact word test !
i read the DictionaryProvider and DictionaryDatabase but i could not realize the root of problem!
the question is how can i suggest the exact word test at first of the list?
Check Dictionary.java, you will see loadWords function.
That function opens definitions.txt file and iterates all lines, and splits every line with "-" and adds to a Hashmap dictionary.
And again in same file there is getMatches function, which takes your search keyword and gets result from dictionary.
Not sure but because when you are searching a suggestion, first couple of matches displays.
And because of "test" keyword exists on too many lines and ("test - meaning") is your last definition, you can't see on suggesting list.
You could try to move "test -meaning" line to the very first line on definitions.txt.

Categories

Resources