Jump to content
  • Advertisement
Sign in to follow this  

Gameplay A good key list for User Rebindability

Recommended Posts

(Note to Mods: Could "Input" or "Peripherals" be a good Tag to add to the tag list? Just a thought.)

Hey, I'm currently working on which keys on a keyboard that a user can rebind their actions to. The trick is that I use a Norwegian keyboard, so it's not obvious which keys correspond to the actual C#/XNA Keys enum values.

Are there any keys from the XNA Keys enum that, in your opinion, I've neglected to add? I don't need all Keys to be bindable, only the "most commonly used keys on a keyboard". Thanks.
https://pastebin.com/n1cz8Y0u

Edited by Madolite

Share this post


Link to post
Share on other sites
Advertisement

Just FYI, in my code I allow every single key to be assigned.  This includes the famous media keys and things like that, as long as they are found as part of the 256(technically less) possible keycodes.  Now, I of course don't have actual descriptions for all those keys, and I won't ever be able to because I'm sure the more rare ones are going to be different for different keyboards.  The solution is to have a sort of "default" text that works for any undefined descriptions.  The words "Unknown Key" work for me.  This way, the player can still bind any key they want.  I don't think any players are going to care if you don't have a proper description for that really rare key they want to use for whatever reason.

Share this post


Link to post
Share on other sites

Windows actually provides an API for retrieving the names of keys - GetKeyNameText().

A quick search found some old C++ example code at: http://www.setnode.com/blog/mapvirtualkey-getkeynametext-and-a-story-of-how-to/ - you probably don't need to worry about XP compatibility any more.

To use it from C# you'll probably want something like the example code at: https://stackoverflow.com/questions/38584015/using-getkeynametext-with-special-keys

Share this post


Link to post
Share on other sites
On 11/19/2017 at 5:38 AM, kburkhart84 said:

I allow every single key to be assigned.

Thanks. Now that I think of it, I'm somewhat conflating what would be smart to default my keys to, with whatever the user might want to rebind them to, which is their responsibility and not my own. So I think I'll just include every key in the rebindable list, and instead just setup the defaults to the more common keys. I'm certainly going to have a "Revert to Default" option anyways.
 

On 11/20/2017 at 10:51 PM, Adam_42 said:

Windows actually provides an API for retrieving the names of keys - GetKeyNameText().

I'm trying to stick with XNA's Keys enum which is (afaik) is higher level and culture independent, but I'll keep your tip in mind and play around with it if needed. Thanks. :)

Edited by Madolite

Share this post


Link to post
Share on other sites

This is my thoughts on it...I have a default which should be somewhat usable, though not perfect.  I then allow any available keys on the keyboard to be used, whether I have proper names for them or not.  I allow the default to be loaded at any time too.  So what you have described in that last post is basically exactly what I would do.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Advertisement
  • Advertisement
  • Popular Tags

  • Popular Now

  • Advertisement
  • Similar Content

    • By ethancodes
      I've got a bug with my brick breaker style game. The bricks move down one line at a time ever 1.5 seconds. What appears to be happening is occasionally the ball will be just about to hit the brick when the brick moves down a line, and now the ball is behind it. I'm not sure how to fix this. I have two ideas but I'm not sure of implementation. 1 solution would be to check where they were and where they are going to be before rendering the frame. Then if they crossed paths, then register the brick as hit. Solution 2 would be change how the bricks move. I could maybe slide them down line by line, instead of a jump down. I'm not sure of this will fix the issue or not. Any ideas?
    • By Scouting Ninja
      Once again Unity is frustrating me to the point of insanity.
      What I am looking for is a way to find a ray intersect with the edges of the mesh, using Unity's already made collision system. I want to point out that I know how to do a line intersect, what I want to know is if Unity supports this already.

      The image above shows how I sweep a ray,intersecting the mesh. The top green image shows what I want and the red shows what Unity is giving me.
      I want to know if there is some way, to find the edges in Unity without creating a custom line intersection tool.
      Most engines I know don't use rays for this but instead use a plane like this:

      I checked the Unity "Plane intersection" but it is just a ray cast. It will still need me to find the vertices on the collision mesh to cast the ray from; if I am doing that then making my own line intersection tool is better.
       
      I looked online and can find anything on this. Also I don't want to cut the mesh, so I don't need a way to know what side is what.
      Does Unity even have collisions that support edge only detection?
    • By Shtabbbe
      I've had a game idea for a while, and I wanted to finally try to create it.
      Its a 2D open-world tile-based MMO. The concept is it is one world and multiplayer only, so everyone shares one world no matter region, platform, etc.
      I am having problems finding out what to use to start development, I tried Unity but saw some of the negatives and refrained and now im stuck, could anyone recommend some intermediate friendly 2D engines that can support what I am looking for? Preferably in languages that are or are somewhat like Java, C#, Python, JavaScript, Lua.
      Thanks for your help, im very new at this if you cant tell
    • By JuliaAxt
      Please help me with this code, this error is currently stopping my project 
      using System.Collections;
      using System.Collections.Generic;
      using UnityEngine;
      [RequireComponent(typeof(Rigidbody2D))]
      public class TapController : MonoBehaviour {
          public float tapForence = 10;
          public float tiltSmooth = 5;
          public Vector3 startPos;
          Rigidbody2D Rigidbody;
          Quaternion downRotation;
          Quaternion forwardRotation;
          private void Start() {
              Rigidbody = GetComponent<Rigidbody2D>();
              downRotation = Quaternion.Euler(0, 0, -90);
              forwardRotation = Quaternion.Euler(0, 0, 35);
        
          }
          private void Update() {
              if (Input.GetMouseButtonDown(0))
              {
                  transform.rotation = forwardRotation;
                  Rigidbody.AddForce(Vector2.up * tapForce, ForceMode2D.Force);   (The name `tapForce`does not exist in current context)
              }
              transform.rotation = Quaternion.Lerp(transform.rotation, downRotation, tiltSmooth * Time.deltaTime);
          }
      }
          void OnTriggerEnter2D(Collider2D col){
          if (col.gameObject.tag == "scoreZone")
          {
              // register a score event
              // play a sound
          }
          if (col.gameObject.tag == "deadZone")
          {
              Rigidbody.simulated = false;   (`Rigidbody` does not contain a definition for `simulated´) 
              //register a dead event
              //play a sound
          }
           }

      }
       
    • By syedali233
      Hi, I want to pass message back and forth on client and server which are on different scenes, how can I do that in Unity?**
      Following is my Scenario:-
      I have 5 scenes- 
       1. BaseScene (2) OfflineScene (3) OnlineScene (4) ClientOnline (5)
          ServerOnline.
      All these scenes have button having text of the names of the scenes.
      On Base Scene, I have add empty game object on which i have placed "customNetworkScript" which extends from "NetworkManager" script and also placed "Network Manager HUD" on it. Following is the code which i have placed in "customNetworkScript":-
         
      public class customNetworkScript : NetworkManager {                              public override void OnClientSceneChanged(NetworkConnection conn)                 {                     SceneManager.LoadScene("ClientOnline", LoadSceneMode.Single);                     ClientScene.Ready(conn);                     ClientScene.AddPlayer(conn, 0);                 }                              public override void OnServerSceneChanged(string sceneName)                 {                     SceneManager.LoadScene("ServerOnline", LoadSceneMode.Single);                 }         } I have placed "OfflineScene" and "OnlineScene" in the fields, named "Offline Scene" and "Online Scene" in "Network Manager" component. Also have placed an empty prefab in "Spawn Info" in "customNetworkScript" and it has component "Network Identity" on it. Now when i run project, on one instance, I click on "LAN Server only" and on another instance, I click on "LAN Client". And I get my respective scenes on both the instances -> "ServerOnline" appear on instance where I click "LAN Server only" and "ClientOnline" appear on other instance.
      What I want is, when i click on "ServerOnline" button, a message string will pass on to "ClientOnline" scene and same happens in backward direction when i click on "ClientOnline" button. 
      I have tried "Rpc" and "Command" but they only work when I click on "LAN Host" instead of "LAN Server Only".
      I have tried very hard but couldn't find anything useful. It will be a great pleasure if someone explain to me in detail along with the code, how can I achieve this.
      ThankYou Very Much for Your Time.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!