Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RegisterKeyEvent always return undefined in script #770

Open
Arthegal opened this issue Jul 30, 2014 · 13 comments
Open

RegisterKeyEvent always return undefined in script #770

Arthegal opened this issue Jul 30, 2014 · 13 comments

Comments

@Arthegal
Copy link

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

@Arthegal Arthegal changed the title RegisterKeyEvent always return undefined RegisterKeyEvent always return undefined in script Jul 30, 2014
@Stinkfist0
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Author

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
Copy link
Member

@jonnenauha
Copy link
Member

Oh seems that the register func is not returning a ptr

KeyEventSignal &InputContext::RegisterKeyEvent(QKeySequence keySequence)
in rex Tundra. Its a public slot though, might even work? :)

@Stinkfist0
Copy link
Contributor

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
Copy link
Member

@Arthegal Do the following changes

Change KeyEventSignal & to KeyEventSignal * in

KeyEventSignal &InputContext::RegisterKeyEvent(QKeySequence keySequence)
and also same thing in the header (find the func declaration InputContext.h).

Change return *signal; to return signal; in

Those should get you going :)

Stinkfist0 added a commit to Adminotech/tundra that referenced this issue Jul 31, 2014
@Stinkfist0
Copy link
Contributor

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

@jonnenauha
Copy link
Member

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
Copy link
Author

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
Copy link
Contributor

You're welcome!

@gfxguru
Copy link

gfxguru commented Aug 1, 2014

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

@jonnenauha
Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants