realXtend / tundra

realXtend Tundra SDK, a 3D virtual world application platform.
www.realxtend.org
Apache License 2.0
84 stars 70 forks source link

RegisterKeyEvent always return undefined in script #770

Open Arthegal opened 9 years ago

Arthegal commented 9 years ago

I'm trying the following code from documentation of InputMapper to migrate to InputContext

var moveFwd = ic.RegisterKeyEvent(new QKeySequence(Qt.Key_W)); moveFwd.SequencePressed.connect(function() { me.Exec(EntityAction.Server, "Move", "forward"); });

But moveFwd is always undefined!

Thanks in advance

Stinkfist0 commented 9 years ago

Log seems to tell us that:

Error: In run/evaluate: Error: QKeySequence::QKeySequence(): could not find a function match; candidates are:
QKeySequence()
QKeySequence(StandardKey key)
QKeySequence(QKeySequence ks)
QKeySequence(String key)
QKeySequence(String key, SequenceFormat format)
QKeySequence(int k1, int k2, int k3, int k4)

So, it would appear there is no constructor taking Qt::Key enum. Sorry about the erroneous example in the documentation. Using the QString constructor instead should help:

var moveFwd = ic.RegisterKeyEvent(new QKeySequence("W"));
// ...

I will update and fix the documentation in the near future.

Stinkfist0 commented 9 years ago

Oh, and just making sure that you're trying this with a Meshmoon Tundra/Rocket, and not a realXtend Tundra? This feature has not been merged to realXtend Tundra.

Arthegal commented 9 years ago

Thanks for updating the documentation, i just copy paste the code from documentation and forgot to mention that in my code i have declared a valid sequence (Qt.ControlModifier + Qt.Key_F). I'm using realXtend Tundra (tundra2 branch up to date), and i was thinking it was implemented since KeyEventSignal &InputContext::RegisterKeyEvent(QKeySequence keySequence) is implemented in InputContext.cpp, but everything needed has maybe not alredy merged.....

Many thanks for you feedback

jonnenauha commented 9 years ago

Ali what has not been merged? Seems to all be there, no?

https://github.com/realXtend/tundra/blob/f0b8d159870d8d6e86ec662e49fb2980409525ff/src/Core/TundraCore/Input/KeyEventSignal.h

jonnenauha commented 9 years ago

Oh seems that the register func is not returning a ptr https://github.com/realXtend/tundra/blob/f0b8d159870d8d6e86ec662e49fb2980409525ff/src/Core/TundraCore/Input/InputContext.cpp#L30 in rex Tundra. Its a public slot though, might even work? :)

Stinkfist0 commented 9 years ago

Unfortunately QtScript doesn't understand refs, only ptrs, so this has never worked in rex Tundra. I have changed it to return ptr instead in Meshmoon Tundra in order to make it work.

jonnenauha commented 9 years ago

@Arthegal Do the following changes

Change KeyEventSignal & to KeyEventSignal * in https://github.com/realXtend/tundra/blob/f0b8d159870d8d6e86ec662e49fb2980409525ff/src/Core/TundraCore/Input/InputContext.cpp#L30 and also same thing in the header (find the func declaration InputContext.h).

Change return *signal; to return signal; in https://github.com/realXtend/tundra/blob/f0b8d159870d8d6e86ec662e49fb2980409525ff/src/Core/TundraCore/Input/InputContext.cpp#L37

Those should get you going :)

Stinkfist0 commented 9 years ago

More changes are needed: ee8f676cedbb3cecb0ff975084ad934b75671846 . I would recommend simply waiting that our fixes get to upstream.

jonnenauha commented 9 years ago

Hmm does does the commit show up in realxtend/Tundra if its not merged yet? I suspect he could cherry pick the commit fine if you would find the meshmoon commit id for him. Oh well...

Arthegal commented 9 years ago

Have to admit i'm really impressed by your reactivity and support. The change ee8f676 do the trick.

Thank you so much for your help and more generally for this wonderful project. ;-)

Stinkfist0 commented 9 years ago

You're welcome!

gfxguru commented 9 years ago

just one thing I like about these guys.... ;)

jonnenauha commented 9 years ago

Hi guru, long time no see! :) I'm making 64bit linux .deb packages for Meshmoon Rocket, Ubuntu 14.04 in particular. Maybe you would be interested in doing some testing when they are done? If I remember right you were working quite a lot in linux?