Skip to content
This repository has been archived by the owner on Mar 5, 2021. It is now read-only.

Hotkey editor #129

Open
MarTinazzI opened this issue Apr 6, 2016 · 14 comments
Open

Hotkey editor #129

MarTinazzI opened this issue Apr 6, 2016 · 14 comments

Comments

@MarTinazzI
Copy link

I'm a DVORAK user and I having lot of troubles with the original hotkeys.

I know Dvorak user are rare, but this is a think that can help every one.

A simple hotkey editor or a easy way to edit in a file will be great.

@Getterac7
Copy link

I'm also a Dvorak user, and moving around in the scene viewer is a total pain.

@elisee
Copy link
Contributor

elisee commented Aug 28, 2016

Hi!

A hotkey editor would be nice indeed. If someone is up for it, the first step would be to come up with a design both in terms of user experience as well as an API for how plugins would interact with this hotkey editor!

@ivanixgames
Copy link

ivanixgames commented Oct 11, 2016

Hello,
I'd like to take a stab at doing some of this work. I noticed that event.keyCode is checked against hard coded values throughout several of the source files. I think I could start off on Camera2DControls.ts and Camera3DControls.ts.
Camera2DControls class has an options argument for overriding some default zoom settings.
This could be used to pass alternative hotkey values. The options param can be replicated on the Camera3DControls as well which I believe affects Scene/3D Model and perhaps Cubic Model editors.

@ivanixgames
Copy link

Looks like my first stab missed the mark as the keyCode edits in
./systems/game/plugins/common/three/main/Camera3DControls.ts
are overridden by ./systems/game/SupEngine/src/components/Camera3DControls.ts
which instead references global keyevent constants in window.KeyEvent.
These are also referenced in the other modules and plugins:
./systems/game/plugins/default/scene/editors/scene/engine.ts
./systems/game/plugins/default/scene/editors/scene/ui.ts
./systems/game/plugins/default/tileMap/editors/tileMap/ui.ts
./systems/game/plugins/default/tileMap/editors/tileMap/mapArea.ts
./systems/game/plugins/default/cubicModel/editors/cubicModel/engine.ts
./systems/game/plugins/default/cubicModel/editors/cubicModel/textureArea.ts
./systems/game/SupEngine/src/components/Camera3DControls.ts
./systems/game/SupEngine/src/components/Camera2DControls.ts
and ./systems/game/SupEngine/src/Input.ts where the constants are defined.

So my second approach would be to each plugin/module go ahead and defined custom hotkey constants that default to the original DOM_VK_ values if not previously set.

As example, assuming keyEvent = window.KeyEvent; Camera3DControls could define something like:
keyEvent.CAM3D_SETY_POS = keyEvent.CAM3D_SETY_POS|| keyEvent.DOM_VK_SPACE;
keyEvent.CAM3D_SETY_NEG = keyEvent.CAM3D_SETY_NEG || keyEvent.DOM_VK_SHIFT;

in ./systems/game/plugins/default/scene/editors/scene/ui.ts:
keyEvent.EDITOR_SCENE_UI_TRANSLATE = keyEvent.EDITOR_SCENE_UI_TRANSLATE || keyEvent.DOM_VK_E;
...
it may also be better to break out each plugin constants into their own property namespace:
window.KeyEventCustom.Cam3D.SETY_POS
window.KeyEventCustom.Cam3D.SETY_NEG
window.KeyEventCustom.EditorSceneUI.TRANSLATE

@ivanixgames
Copy link

i am seeing that each editor has its own window in a separate iframe, so there will be several instances of window.KeyEvent that exist. I would like to see about having only one instance of the KeyEvent and KeyEventCustom constants, perhaps moving them to window.parent ?

@ivanixgames
Copy link

ivanixgames commented Oct 12, 2016

On a separate issue, the current settings framework, each plugin can save its settings per project. For hotkey bindings, we may want to store these by plugin/client platform (Windows/OSX/Linux)/keyboardlayout/user

@ivanixgames
Copy link

I see that the documentation for hotkeys is generated from each plugin's jade doc.
Perhaps there is a way to get the source code to pull in the default hotkey values from jade as well?

@ivanixgames
Copy link

I am recording all the issues that I find related to hotkey on this thread, hope it's ok with everyone. Please let me know if it would be better to create separate issues, and if so, how to tag them to track them as a group.

I also created a project on my own fork of superpowers to track the work I am currently doing https://github.com/ivanixgames/superpowers-core/projects/1

@ivanixgames
Copy link

Just want to note that when using chrome browser on windows, there seems to be a few conflicts when using the Control hotkeys functions.
As example, Control-N will bring up the "NEW ASSEST" window in the Superpowers electron app.
While in Chrome, it simply brings up an new browser window or tab.

The second issue is when in the Scene editor, Control-N will bring up a dialog asking for a name of a new actor, however, it is overcome by the "NEW ASSET" window which has to be canceled. This happens in both browser and app.

Finally, the hotkey combo, Super(Windows) + N on windows also serves as a Control-N function for both popups.

@ivanixgames
Copy link

ivanixgames commented Oct 15, 2016

I would like to propose a single/global HotkeyManager object which the main app and plugins can use to register hotkey definitions, in turn it could help warn of potential conflicts.
After all the plugins have loaded, the HotkeyManager could then load up system profile overrides based on platform determined by navigator user agent on first startup.
Localstorage can be used to store a user's preferred system profile, along with any individual hotkey overrides.

At a later time, we could then have a separate class/object called HotkeyEditor, perhaps as a plugin, which provides a UI to allow end user to customize hotkey definitions. In the meantime, end users could simply bring up the javascript console via F12 and call the HotkeyManager directly to set their desired keys and profiles.

@ivanixgames
Copy link

ivanixgames commented Oct 15, 2016

On a separate thought related to hotkeys, should we enable mouse button/wheels to be remapped?

As example, I sometimes use Blender for 3D creations, so I am used to using the mouse wheel to zoom in and out of the scene. This also seems to work in SuperPowers Scene editor while in 2D mode, but not in 3D mode which requires use of defined hotkeys W and S.

Maybe can address in detail at a later phase, but think about how to prepare code for this ability.

@ivanixgames
Copy link

in ./core/systems/game/SupEngine/src/Input.ts, current key modifiers defined are:
DOM_VK_SHIFT,
DOM_VK_CONTROL,
DOM_VK_ALT

As of DOM3, we should be able to distinguish location of key pressed, so I plan to extend as follows:

DOM_VK_SHIFT_LEFT: 256,
DOM_VK_SHIFT_RIGHT: 257,
DOM_VK_CONTROL_LEFT: 258,
DOM_VK_CONTROL_RIGHT: 259,
DOM_VK_ALT_LEFT: 260,
DOM_VK_ALT_RIGHT: 261

@ivanixgames
Copy link

ivanixgames commented Oct 15, 2016

./core/SupClient/src/events.ts defines a few of the general Control hotkey sequences. It currently has hardcoded values. Would be nice if it could reference the same set of DOM_VK constants as defined in ./core/systems/game/SupEngine/src/Input.ts

Since SupClient handles loading of plugins and systems, HotKeyManager and DOM_VK constants could be defined at its level and made available for event.ts. So I was thinking something like SupClient.HotKeyManager. However ...., SupClient does not exist in a published game, instead there are SupRuntime and SupEngine. SupCore is still present.

Assuming it may be nice to allow hotkeys for games to be remapped, maybe SupCore.HotKeyManager would be better.

@ivanixgames
Copy link

@elisee Hello, I just submitted a couple of PR that demo my proposal for a HotKeyManager.
Can you have someone on your team help review?

The related PRs are

#152
superpowers/superpowers-game#157

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

No branches or pull requests

4 participants