HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: [Resolved] Customizable hotkeys  (Read 1093 times)

Akezhar

  • General Accounts
  • *
  • Posts: 12
    • View Profile
[Resolved] Customizable hotkeys
« on: Sep 28, 12, 04:03:22 PM »

I'm willing to put a hotkey customization option in my game, what is the best way to do it?

is there a way to change the gamekeybindings.ini from the game client?

any hint will be much appreciated.
« Last Edit: Oct 03, 12, 01:19:35 PM by HE-Cooper »
Logged

JoshHalls

  • Founding Professional
  • *****
  • Posts: 335
    • View Profile
    • The Repopulation
Re: Customizable hotkeys
« Reply #1 on: Sep 29, 12, 03:27:09 PM »

They probably need to document this better, had to do a lot of digging to get it working.

SetKeyBinding

Is one of the functions you want, you create a class of keybinding and set the values (the class has a key, command, and layer value).  Key is the key command (Q, ANY+LEFT, LEFT, etc), command is the command you see in the key binding file (Forward, Jump, RotateLeft, etc) and layer is the layer also in the keybinding (Movement, Command, Camera, etc).

We then use the CaptureKeyInput command to override the input and capture the key push and then once the key goes down we get it with onCaptureKeyUp and set the key value to the binding.  These don't auto save, you then have to setup a method to save the preferences to the client and push them when the client first initializes itself.

All in all we have a GUI where all the current bindings are found with GetKeyBinding and then buttons are made for each command and broken down into layers.  They press the button and it sounds out the capture command, one a button is pressed (like Q, A, etc) it maps the button press and saves the setting.  Can also clear out the mapping as well by clickong on the big reset button.

Hope that helps some.

Logged
Co-Owner/Programmer - The Repopulation

Akezhar

  • General Accounts
  • *
  • Posts: 12
    • View Profile
Re: Customizable hotkeys
« Reply #2 on: Sep 29, 12, 04:26:09 PM »

Thanks, i'm going to look into it.
Logged