10 posts / 0 new
Last post
mattias
mattias's picture
Offline
Joined: 29 Apr 2010
Posts:
Virtual keyboard

So I have tried to implement some virtual keyboard functionality...

I have done this by implementing these two methods in my Moblet:

void OnMobile::pressKey(int keyCode)
{
    fireKeyPressEvent(keyCode, 0);
}

void OnMobile::releaseKey(int keyCode)
{
    fireKeyReleaseEvent(keyCode, 0); // line 37
}

These methods are part of a KeyEventInjector interface that the Moblet implements. An instance of this interface (I.e. the Moblet instance) is then sent to the ctor of a class called OnScreenKeyboard that translated mouse clicks to keyboard events using pressKey/releaseKey.

Is this a safe approach to implementing a virtual keyboard? What value am I supposed to use for the second argument , nativeCode, of fireKeyReleaseEvent?

I'm asking because I'm getting a panic in releaseKey():

[13] MoSync Panic 40033. "Instruction memory access out of bounds" The panic occurred in the MoSync core.
[13] IP:0xeccc: crtlib.s:1
[13] IP:0x24: C:/work/ecode3/onmobile/mosync/onMobile/src/main.cpp:16
[13] IP:0x1a702: crtlib.s:1
[13] IP:0x17b44: crtlib.s:1
[13] IP:0xcf7: C:/work/ecode3/onmobile/mosync/onMobile/src/OnScreenKeyboard.hpp:18
[13] IP:0xd9d: C:/work/ecode3/onmobile/mosync/onMobile/src/OnScreenKeyboard.cpp:152
[13] IP:0x102e: C:/work/ecode3/onmobile/mosync/onMobile/src/OnMobile.hpp:9
[13] IP:0x1061: C:/work/ecode3/onmobile/mosync/onMobile/src/OnMobile.cpp:37
[13] Exit @ IP 0x1716f  SP 0x1fef0
[13] IP:0x1716f: crtlib.s:1

This particular call to release key is when I destroy the current screen and display a new screen. I was hoping that I would be able to use the debugger to see what happened inside fireKeyReleaseEvent(), but for some reason I can't start the debugger (see: http://www.mosync.com/forum/viewtopic.php?f=18&t=215). As far as I can see something in fireKeyReleaseEvent triggers this panic.

Anyway, my basic question is this: Is my approach to implementing virtual keyboard functionality safe. Can I expect my Moblet instance be the Environment instance that I should use to fire key events?

:.:: mattias

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Mattias Frånberg
fmattias's picture
Offline
Joined: 1 Mar 2010
Posts:

Hi Mattias!

Does the problem only occur when you change the screen? Do you accidently destroy the environment singleton?

I any case I think your implementation sounds reasonable, and I cannot think of a reason why it shouldn't work. I don't fully understand, "Can I expect my Moblet instance be the Environment instance that I should use to fire key events?", is it possible to restate it? If it is possible you can send your code to me and I can take a look at it.

I will have to get back to you regarding native keycode.

I am currently working on a virtual keyboard as well, maybe we could share some ideas?

mattias
mattias's picture
Offline
Joined: 29 Apr 2010
Posts:
"fmattias" wrote:

Hi Mattias!

Does the problem only occur when you change the screen? Do you accidently destroy the environment singleton?

I any case I think your implementation sounds reasonable, and I cannot think of a reason why it shouldn't work. I don't fully understand, "Can I expect my Moblet instance be the Environment instance that I should use to fire key events?", is it possible to restate it? If it is possible you can send your code to me and I can take a look at it.

I guess that question might be a bit confusing. If I understand correctly the Environment is a singleton and the instance returned from Environment::getEnvironment() is the same as my Moblet instance. Is this correct?

Quote:

I will have to get back to you regarding native keycode.

I am currently working on a virtual keyboard as well, maybe we could share some ideas?

Of course! My current implementation is really simple and only fits my application. It's not a general solution.

:.:: mattias

overfl0w
overfl0w's picture
Offline
Mobile Conjurer
Joined: 12 Jun 2010
Posts:
"fmattias" wrote:

I am currently working on a virtual keyboard as well, maybe we could share some ideas?

Hello,

I have implemented a virtual keyboard as well. I have attached the source code to this message in case anyone is interested.

The implementation is not yet complete. I want to implement loading different keyboard layouts and languages from an xml file. Ideally, the application should look for the xml file and dynamically load all the layouts that it contains.
I have also implemented dynamic scaling so the keyboard scales evenly according to the screen size.

Any comments or ideas would be appreciated.

[attachment=0]HelloWorld.zip[/attachment]

AttachmentSize
HelloWorld.zip 212.6 KB
Mattias Frånberg
fmattias's picture
Offline
Joined: 1 Mar 2010
Posts:

Cool! I just tried it and it looks good. I will look through your code and see if I can get some inspiration :)

There is an implementation of a virtual keyboard (for MAUI) in one of our branches https://github.com/MoSync/MoSync, and I have some time to work on it again. It currently does what you have described, reading a set of layouts from an XML file. But there is much left to do, for the moment it does not support different font sizes (which I noticed that you have :)) or icons for the keys.

Anyways, very nice work.

overfl0w
overfl0w's picture
Offline
Mobile Conjurer
Joined: 12 Jun 2010
Posts:

Thanks!

I 'll look into the MAUI implementation and see if I can get any ideas for the xml layout loading!

amdane
amdane's picture
Offline
Joined: 18 Mar 2011
Posts:

Hello everyone I'm new in mosync and I wonder if someone can tell me if There's an opportunity to bring up the virtual keyboard in a editbox mosync? If so! show me a sample code please.
Thank you in advance!

amdane
amdane's picture
Offline
Joined: 18 Mar 2011
Posts:

overfl0w how to test your code as an attachment? I can not download it.
thank you

Sam Pickard
rival's picture
Offline
Mobile Archmage
Joined: 19 Mar 2009
Posts:

Hi amdane. If you are using the NativeEditBox widget then the native keyboard (even on J2ME devices) should be automatically activated. We don't support the virtual keyboard anymore as we have the native editbox. Have a look at this blog : http://www.mosync.com/blog/2011/03/using-nativeeditbox

amdane
amdane's picture
Offline
Joined: 18 Mar 2011
Posts:

Hi Sam thanks to your answer!!