Menu

#95 Sphere Controls – keyboards/Joysticks

open
nobody
engine (98)
1
2014-07-11
2003-01-25
No

regarding:
-AttachInput(person_entity)
-BindKey(key, onkeydown, onkeyup)
-IsKeyPressed(key)
-IsMouseButtonPressed(button)
-IsJoystickButtonPressed(joy, button)

Joystick Support has been added to sphere 1.0beta but
I have a few suggestions for it and key handling in
general.

1st the way input is attached is very limited. There is no
option to edit the keys used for moving the player. This
means that alternate key configurations can’t be used
and for the same reason the Joystick can’t be used to
move an attached player. Its very inconvenient – you’d
have to hand-code your own movement system.

Likewise Bindkey() only supports keyboard presses. So
the map-engine and the keyboard are basically
incompatible without writing special movement/button
systems.

Currently there are there are 3 “is pressed” functions - -
IsKeyPressed(key), IsMouseButtonPressed(button),
and IsJoystickButtonPressed(joy, button).
I think these should be consolidated into One function -
IsKeyPressed( key),
Which could accept KEY_LEFT, MOUSE_LEFT, or Joy
[1]. BUTTON_1 as a parameter. (or something similar to
this system) This way, the input source could be
changed very easily (on the fly?) without having to add
extra code things 3 times every time you check for
input. Likewise Bindkey should accept keyboard, mice,
or joystick buttons.
And we should be able to edit the keys used for
AttachInput. Maybe SetInputUpkey(key) or a function
like that. The function should accept either a key, or a
joystick direction as a parameter.

I think these ideas would simplify the way input is
handled in sphere, and also make it more flexible.

What do other people think about this?

Discussion

  • August Bigelow

    August Bigelow - 2003-01-28

    Logged In: YES
    user_id=614751

    I feel the same way, DRosen. Sphere input is quite limiting.
    People complain about the way my games' control is setup,
    but the way Sphere does input now limits the configuration
    abilities of my games.

     
  • Chad Austin

    Chad Austin - 2003-02-04
    • labels: --> engine
    • priority: 5 --> 1
     
  • Chad Austin

    Chad Austin - 2003-02-04

    Logged In: YES
    user_id=7212

    I agree that your ideas are good. Maybe after 1.0 though.

     
  • Brian Robb

    Brian Robb - 2003-07-03

    Logged In: YES
    user_id=387078

    Hmm...

    Perhaps we could write a script like:

    function Key(value) {
    this.valueOf = function() { return value; }
    this.isPressed = function() {
    return IsKeyPressed(value);
    }
    }

    function MouseButton(value) {
    this.valueOf = function() { return value; }
    this.isPressed = function() {
    return IsMouseButtonPressed(value);
    }
    }

    function JoystickButton(joystick, value) {
    this.valueOf = function() { return value; }
    this.isPressed = function() {
    return IsJoystickButtonPressed(joystick, value);
    }
    }

    KEY_A = new Key(KEY_A);
    KEY_Z = new Key(KEY_Z);
    MOUSE_LEFT = new MouseButton(MOUSE_LEFT);
    JOYSTICK_0_BUTTON_1 = new JoystickButton(0, 0);

    function IsPressed(key) {
    return key.isPressed();
    }

     

Log in to post a comment.