Results 1 to 3 of 3

Thread: User-Customized Keyboard/Mouse keys

  1. #1

    User-Customized Keyboard/Mouse keys

    Well, my problem is that I've been trying to decide how I might make a user be able to customize what keys do what in a game. I'm not 100% sure how, but I'm also not asking for specific code for libraries. All I want is maybe some pseudo code which would be adaptable to most situations. Or, if this is too difficult, I will be using the Pheonix Engine, in Free Pascal, with no extra IDE's (just plain old pure FPC).

    Can anyone help?

    Thanks!
    --MagicRPG--

  2. #2

    Re: User-Customized Keyboard/Mouse keys

    Hi DarknessX,
    I had to implement this sort of system for Hero X. Basically what you need to do is make you input logic work independent of Key and use a system based on actions.

    So code wise instead of testing for a key press you test for an action.

    It was a while ago, so if I remember correctly it went something like this.

    [pascal]
    type
    TGameAction = ( gaMoveLeft, gaMoveRight, gaMoveForward......... );
    TGameActions = set of TGameAction; // for multipleActions at the same time

    var
    GameActions : TGameActions;

    if gaMoveLeft in GameActions then
    begin
    // Move the character left
    end;

    if gaMoveRight in GameActions then
    begin
    // Move the character right
    end;

    etc
    [/pascal]

    Now the mapping part involves having an inmemory table that you can look up to see if a KeyPress/MousePress maps to an action. In HeroX we persistented this info between games by saving it out to an INI file. which looked something like this...

    [Keymapping]
    gaMoveRight=166
    gaMoveLeft=165

    I hope this gets you started.
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  3. #3

    User-Customized Keyboard/Mouse keys

    Hmmm, That does. Thanks, savage. That is really quite interesting... I was thinking along similar lines, but wasn't quite sure if it was the correct/fastest/proper way to go about it.
    --MagicRPG--

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Comodo SSL