Input Functions

From Danmakufu Wiki
Jump to: navigation, search


Key State List

  • KEY_FREE: the key is not pressed.
  • KEY_PUSH: the key has been pressed.
  • KEY_HOLD: the key is being held.
  • KEY_PULL: the key has been released.

Virtual Key List

  • VK_LEFT (ID: 0) - Move left
  • VK_RIGHT (ID: 1) - Move right
  • VK_UP (ID: 2) - Move up
  • VK_DOWN (ID: 3) - Move down
  • VK_OK (ID: 4) - Confirm
  • VK_CANCEL (ID: 5) - Cancel
  • VK_SHOT (ID: 6) - Player Shot
  • VK_BOMB (ID: 7) - Player Spell/Bomb
  • VK_SPELL (ID: 7) (Alias for VK_BOMB)
  • VK_SLOWMOVE (ID: 8) - Focus
  • VK_USER1 (ID: 9) - User Key 1
  • VK_USER2 (ID: 10) - User Key 2
  • VK_PAUSE (ID: 11) - Pause

(Keys ordered by VK ID, starting from 0)

Key List

  • KEY_0 ... KEY_9: 0-9 Keys
  • KEY_A ... KEY_Z: A-Z Keys
  • KEY_F1 ... KEY_F10: F1-F10 Keys
  • KEY_MINUS: -
  • KEY_EQUALS: =
  • KEY_SLASH: /
  • KEY_BACK: Backspace
  • KEY_TAB: Tab
  • KEY_SPACE: Space
  • KEY_LBRACKET: [
  • KEY_RBRACKET: ]
  • KEY_SEMICOLON: ;
  • KEY_APOSTROPHE: '
  • KEY_GRAVE: `
  • KEY_BACKSLASH: \
  • KEY_YEN: \ Note: the former keycode refers to the key on Western keyboards, and the latter to the key on Japanese keyboards. Be sure to test both if you don't want surprises.
  • KEY_AT: @
  • KEY_COLON: :
  • KEY_UNDERLINE: _
  • KEY_CIRCUMFLEX: ^
  • KEY_COMMA: ,
  • KEY_PERIOD: .
  • KEY_INSERT: Insert
  • KEY_DELETE: Delete
  • KEY_RETURN: Enter
  • KEY_LCONTROL: Left Ctrl key
  • KEY_RCONTROL: Right Ctrl key
  • KEY_LSHIFT: Left Shift
  • KEY_RSHIFT: Right Shift
  • KEY_LEFT: Left Arrow Key
  • KEY_RIGHT: Right Arrow Key
  • KEY_UP: Up Arrow Key
  • KEY_DOWN: Down Arrow Key
  • KEY_NUMPAD0 ... KEY_NUMPAD9: 0-9 on the Number Pad
  • KEY_ADD: Number Pad +
  • KEY_SUBTRACT: Number Pad -
  • KEY_MULTIPLY: Number Pad *
  • KEY_DIVIDE: Number Pad /
  • KEY_DECIMAL: Number Pad .
  • KEY_NUMPADEQUALS: Number Pad =
  • KEY_ESCAPE: Escape

GetVirtualKeyState

Arguments:
    1) virtual key name
Returns:
    1) key state

Returns the state of the specified virtual key.

Refer to the list at the top for list of Virtual Keys and Key States.


SetVirtualKeyState

Arguments:
    1) virtual key name
    2) key state

Sets the given virtual key to the given state.

The virtual key will be restored to its true state a frame after you stop calling this function.

Keep in mind that if you set it to KEY_HOLD it will not go to KEY_PULL or KEY_PUSH.

Refer to the list at the top for list of Virtual Keys and Key States.

AddVirtualKey

Arguments:
    1) virtual key name
    2) key name
    3) pad key
         (If you do not want pad input, put KEY_INVALID)

Registers the given virtual key with the given key.

You may map any number of virtual keys to a single key, but virtual keys may only be mapped to a single key.

For an example, if you were to use AddVirtualKey(VK_SHOT, KEY_UP, KEY_INVALID);, whenever you press the up arrow key, the virtual shot key will be pressed.

Take note that you will not be able to move up. To fix this, you add AddVirtualKey(VK_UP, KEY_UP, KEY_INVALID);. You will now shoot and move up at the same time.

However, if you were to add AddVirtualKey(VK_UP, KEY_LEFT, KEY_INVALID); with the above two examples, you will not move up when you press up, because VK_UP has been remapped to KEY_LEFT.

Refer to the list at the top for list of Keys and Virtual Keys.


AddReplayTargetVirtualKey

Arguments:
    1) key name

Registers the given key id to the replay file.

This key id should be one that you have already registered with AddVirtualKey.

Refer to the list at the top for list of Virtual Keys.


GetKeyState

Arguments:
    1) key name
Returns:
    Key State

Returns the given key id's current state.

Refer to the list at the top for list of Keys and Key States.


GetMouseState

Arguments:
    1) mouse button
         - MOUSE_LEFT: Left Mouse Button
         - MOUSE_MIDDLE: Middle Mouse Button 
         - MOUSE_RIGHT: RightMouse Button
Returns:
    Mouse State

Returns the given mouse button's current state.

Refer to the list at the top for list of Key States


GetMouseX

Returns the mouse's X coordinate. The origin for the mouse coordinates is the upper left of the Danmakufu window (0, 0).

Mouse coordinates will be properly adjusted according to the resizing of Danmakufu's window.


GetMouseY

Returns the mouse's Y coordinate. The origin for the mouse coordinates is the upper left of the Danmakufu window (0, 0).

Mouse coordinates will be properly adjusted according to the resizing of Danmakufu's window.


GetMouseMoveZ

Returns the amount of change that has occurred to the mouse's Z axis.

The Z axis is normally the middle mouse wheel. If there is no mouse wheel, the value will be 0.

The value returned will be negative if the wheel was moved back, and positive if the wheel moved forward.


SetSkipModeKey

Arguments:
    1) key to specify for fast playback mode (specify KEY_INVALID if you do not wish to enable fast playback)

Specifies the key to use for fast playback mode.

The default key is KEY_LCONTROL.