Author Topic: Default key bindings  (Read 2849 times)

Offline vonfrank

  • Posts: 447
  • Cookies: 182
Default key bindings
« on: March 05, 2009, 11:06:55 PM »
Is there any way to add a command to a keyboard shortcut?

for example, i want to add the "redistribute shields" command to a keyboard button like "CTRL-S" or something.

there are other things i would like to make shortcuts for but i need to know how first

any sudgestions would be appreciated :D

Offline MLeo

  • Retired Staff
  • Posts: 3636
  • Cookies: 833
  • Software Simian
    • the Programming Pantheon
Re: Default key bindings
« Reply #1 on: March 06, 2009, 09:44:07 AM »
The easiest way is to use my KeyFoundation, included in KM, it's old and buggy, but it does work, most of the time.
Look in WalkFX on how to use it.

Don't forget, you have to assign the actual key in the key config (options menu)!
I still can't read peoples minds, nor can I read peoples computers, even worse, I can't combine the two to read what is going wrong with your BC install...

"It was filed under 'B' for blackmail." - Morse, Inspector Morse - The dead of Jericho.

Offline vonfrank

  • Posts: 447
  • Cookies: 182
Re: Default key bindings
« Reply #2 on: March 06, 2009, 03:50:28 PM »
Thanks  :D

ill let you know if i need any more help

Offline vonfrank

  • Posts: 447
  • Cookies: 182
Re: Default key bindings
« Reply #3 on: March 09, 2009, 09:50:22 PM »
alright, i tried to understand what is in the file you sudgested, and i copiyed the approrpiate lines into the "Redistribute shields" file and changed the text to pretain to it, but it did not work, the "Redistribute shields" button dissapeared and no new key binding option appeared in the config. menu

if you can spare the time, i would appreciate a step by step procedure on what to copy into what files

thanks  :D

Offline MLeo

  • Retired Staff
  • Posts: 3636
  • Cookies: 833
  • Software Simian
    • the Programming Pantheon
Re: Default key bindings
« Reply #4 on: March 10, 2009, 10:59:49 AM »
If the button suddenly dissappeared, then an error occurred before that particular code could run, please get a console report.
I still can't read peoples minds, nor can I read peoples computers, even worse, I can't combine the two to read what is going wrong with your BC install...

"It was filed under 'B' for blackmail." - Morse, Inspector Morse - The dead of Jericho.

Offline vonfrank

  • Posts: 447
  • Cookies: 182
Re: Default key bindings
« Reply #5 on: March 22, 2009, 10:18:03 PM »
it still wont work

here is the file, if anyone knows how to fix it please try

Offline MLeo

  • Retired Staff
  • Posts: 3636
  • Cookies: 833
  • Software Simian
    • the Programming Pantheon
Re: Default key bindings
« Reply #6 on: March 23, 2009, 03:41:56 PM »
Here is a hint, where do you think "mode" comes from?
I still can't read peoples minds, nor can I read peoples computers, even worse, I can't combine the two to read what is going wrong with your BC install...

"It was filed under 'B' for blackmail." - Morse, Inspector Morse - The dead of Jericho.

Offline vonfrank

  • Posts: 447
  • Cookies: 182
Re: Default key bindings
« Reply #7 on: March 23, 2009, 05:13:21 PM »
i'm not really sure  :shock:

any tips?

Offline MLeo

  • Retired Staff
  • Posts: 3636
  • Cookies: 833
  • Software Simian
    • the Programming Pantheon
Re: Default key bindings
« Reply #8 on: March 23, 2009, 06:04:04 PM »
Remove the , { ... } part and try again, it should (if memory serves) default to a stock mutator.
I still can't read peoples minds, nor can I read peoples computers, even worse, I can't combine the two to read what is going wrong with your BC install...

"It was filed under 'B' for blackmail." - Morse, Inspector Morse - The dead of Jericho.

Offline vonfrank

  • Posts: 447
  • Cookies: 182
Re: Default key bindings
« Reply #9 on: March 23, 2009, 06:23:46 PM »
still didn't work

i changed it to:

Foundation.g_kKeyBucket.AddKeyConfig(Foundation.KeyConfig("Redistribute Shields", "RedistributeShields", ET_KEY_EVENT, App.KeyboardBinding.GET_INT_EVENT, 1, "Ship" ))


is that what you meant

Offline MLeo

  • Retired Staff
  • Posts: 3636
  • Cookies: 833
  • Software Simian
    • the Programming Pantheon
Re: Default key bindings
« Reply #10 on: March 23, 2009, 06:35:28 PM »
So you don't get a Redistribute Shields option in the Ship key options?

Try to first start a QB before heading into the key options.

Since you are using QBAutoStart it's possible that it isn't loaded untill then.
I still can't read peoples minds, nor can I read peoples computers, even worse, I can't combine the two to read what is going wrong with your BC install...

"It was filed under 'B' for blackmail." - Morse, Inspector Morse - The dead of Jericho.

Offline vonfrank

  • Posts: 447
  • Cookies: 182
Re: Default key bindings
« Reply #11 on: March 23, 2009, 07:02:48 PM »
well now i have the button in the config menu

but the binding wont work when i press it

is there some other file i need to put the binding info in to make the action work?

Offline MLeo

  • Retired Staff
  • Posts: 3636
  • Cookies: 833
  • Software Simian
    • the Programming Pantheon
Re: Default key bindings
« Reply #12 on: March 24, 2009, 12:17:08 PM »
Well, for starters, you don't bind "ET_KEY_EVENT" to anything.

First you have to create a new one (before it!) through this:
Code: [Select]
ET_KEY_EVENT = App.UtopiaModule_GetNextEventType()And then you need to bind it. In this case (mostlikely) to:
Code: [Select]
App.TopWindow_GetTopWindow().FindMainWindow(App.MWT_OPTIONS).AddPythonFuncHandlerForInstance(ET_KEY_EVENT, __name__ + ".RedistributeShields")
I still can't read peoples minds, nor can I read peoples computers, even worse, I can't combine the two to read what is going wrong with your BC install...

"It was filed under 'B' for blackmail." - Morse, Inspector Morse - The dead of Jericho.

Offline vonfrank

  • Posts: 447
  • Cookies: 182
Re: Default key bindings
« Reply #13 on: September 15, 2009, 12:51:49 PM »
sorry for bringing this up again from so long ago, but i got distracted with Galaxy Charts 2.0 and other new mods released recently.

in regards to your last post...
i am a little confused on where exactly i put those lines of code
do i place them in the Redistribute shileds file or do i put them somewhere else?

some parts of python modding are easy to get, but others are difficult for me, sorry

Offline teleguy

  • Posts: 363
  • Cookies: 53
Re: Default key bindings
« Reply #14 on: September 15, 2009, 06:53:38 PM »
sorry for bringing this up again from so long ago, but i got distracted with Galaxy Charts 2.0 and other new mods released recently.

in regards to your last post...
i am a little confused on where exactly i put those lines of code
do i place them in the Redistribute shileds file or do i put them somewhere else?

some parts of python modding are easy to get, but others are difficult for me, sorry
I've attached the relevant files so you can to take a look at them. FYI this will also add a "Redistribute Shields" mutator to the game.

I'll further look into the matter tomorrow to see if there's a less complicated way.

Offline vonfrank

  • Posts: 447
  • Cookies: 182
Re: Default key bindings
« Reply #15 on: September 15, 2009, 11:05:46 PM »
Unfortunately it still doesn't work

i get the mutator and the binding option in the config. menu and if you click the redistribute shields button from the tactical officer menu it works fine but i set the binding to work when you press the "f" key, however nothing happens when i do so.  :(

Offline teleguy

  • Posts: 363
  • Cookies: 53
Re: Default key bindings
« Reply #16 on: September 16, 2009, 02:24:06 AM »
Strange, it works for me. Does the console say anything after you pressed the button?

Offline vonfrank

  • Posts: 447
  • Cookies: 182
Re: Default key bindings
« Reply #17 on: September 16, 2009, 04:08:38 PM »
the console report doesn't mention anything about it

the shortcut simply doesn't work for me  :'(

Offline teleguy

  • Posts: 363
  • Cookies: 53
Re: Default key bindings
« Reply #18 on: September 17, 2009, 05:58:20 AM »
Do the key bindings for other mods work?

Anyway you probably have to wait for MLeo in order to fix this.

Offline vonfrank

  • Posts: 447
  • Cookies: 182
Re: Default key bindings
« Reply #19 on: September 17, 2009, 06:14:02 PM »
Yes they do

only this one (as far as i know) doesnt work