RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[Request] Script Add-on for Blizzard's Enhanced module Input

0 Members and 1 Guest are viewing this topic.

*
Rep: +0/-0Level 81
Script Add-on for Blizzard's Enhanced Module input
04/01/2010



Summary

I am Currently Using a Version of Blizzard's Module Input
Spoiler for:
Code: [Select]
#==============================================================================
# Blizzard's Enhanced module Input
#------------------------------------------------------------------------------
#  This module handles input.
#==============================================================================

module Input
  #----------------------------------------------------------------------------
  # Setup of Controls (ASCII)
  #----------------------------------------------------------------------------
  LMB, RMB, MMB, Backspace, Tab, Enter, Shift, Ctrl, Alt, Esc, D_Down, D_Left,
  D_Right, D_Up, Space = 1, 2, 4, 8, 9, 13, 16, 17, 18, 27, 40, 37, 39, 38, 32
  NumKeys = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57]
  NumPad = [45, 35, 40, 34, 37, 12, 39, 36, 38, 33]
  Let = {'A' => 65, 'B' => 66, 'C' => 67, 'D' => 68, 'E' => 69, 'F' => 70,
         'G' => 71, 'H' => 72, 'I' => 73, 'J' => 74, 'K' => 75, 'L' => 76,
         'M' => 77, 'N' => 78, 'O' => 79, 'P' => 80, 'Q' => 81, 'R' => 82,
         'S' => 83, 'T' => 84, 'U' => 85, 'V' => 86, 'W' => 87, 'X' => 88,
         'Y' => 89, 'Z' => 90}
  Fkeys = [-1, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123]
  Colon, Equal, Comma, Underscore, Dot, Backslash, Lb, Rb, Quote = 186, 187,
  188, 189, 190, 191, 219, 221, 222
  # dll call
  State = Win32API.new('user32', 'GetKeyState', ['i'], 'i')
  Key = Win32API.new('user32', 'GetAsyncKeyState', ['i'], 'i')
  # All ASCII keys
  All_keys = 0..255
  @repeating = []
  256.times{@repeating.push(-1)}
  # default controls
  Up       = [Let['W'], D_Up, Joy1['D_Up']]
  Left     = [Let['A'], D_Left, Joy1['D_Left'] ]
  Down     = [Let['S'], D_Down, Joy1['D_Right'] ]
  Right    = [Let['D'], D_Right, Joy1['D_Down'] ]
  Confirm  = [Let['J'], Enter, Joy1['X']]
  Cancel   = [Let['K'], Backspace, Joy1['T']]
  Prevpage = [Let['Q'], LMB, Joy1['L1']]
  Nextpage = [Let['O'], RMB, Joy1['R1']]
  #--------------------------------------------------------------------------
  # get_current_state
  #  key - the ASCII number of the key
  #  This method checks if the key is being pressed.
  #--------------------------------------------------------------------------
  def Input.get_current_state(key)
    return State.call(key).between?(0, 1)
  end
  #--------------------------------------------------------------------------
  # test_key
  #  key - the ASCII number of the key
  #  This method checks if the key was pressed.
  #--------------------------------------------------------------------------
  def Input.test_key(key)
    Key.call(key) & 0x01 == 1
  end
  #--------------------------------------------------------------------------
  # get_symbol
  #  sym - the given symbol
  #  Transforms given number into ASCII character.
  #--------------------------------------------------------------------------
  def Input.get_symbol(sym)
    return ((sym != 0 && sym != nil) ? sym.chr : '')
  end
  #--------------------------------------------------------------------------
  # update
  #  Updates input.
  #--------------------------------------------------------------------------
  def Input.update
    # storing old keys
    @_keys = (@_keys == nil ? [] : @_keys) | (@keys == nil ? [] : @keys.clone)
    # empty current keys
    @keys, @pressed = [], []
    # checking through all possible keys
    All_keys.each {|key|
        # key is triggered if not triggered before
        @keys.push(key) if Input.test_key(key) && !@_keys.include?(key)
        # if key is not being hold
        if Input.get_current_state(key)
          # remove from helping array
          @_keys.delete(key)
          # remove repeat? flag
          @repeating[key] = 0
        else
          # push into pressed array
          @pressed.push(key)
          # needed for repeat? and repeated?
          if @repeating[key] > 0
            @repeating[key] < 17 ? @repeating[key] += 1 : @repeating[key] = 14
          else
            @repeating[key] = 1
          end
        end}
  end
  #--------------------------------------------------------------------------
  # triggered?
  #  Internal method to check the trigger state.
  #--------------------------------------------------------------------------
  def Input.triggered?(key)
    return (@keys.include?(key) && !@_keys.include?(key))
  end
  #--------------------------------------------------------------------------
  # pressed?
  #  Internal method to check the pressed state.
  #--------------------------------------------------------------------------
  def Input.pressed?(key)
    return (@pressed.include?(key))
  end
  #--------------------------------------------------------------------------
  # repeated?
  #  Internal method to check the pressed state for repeat?.
  #--------------------------------------------------------------------------
  def Input.repeated?(key)
    return ([1, 16].include?(@repeating[key]))
  end
  #--------------------------------------------------------------------------
  # dir4
  #  4 direction check.
  #--------------------------------------------------------------------------
  def Input.dir4
    return 2 if Input.press?(Down)
    return 4 if Input.press?(Left)
    return 6 if Input.press?(Right)
    return 8 if Input.press?(Up)
    return 0
  end
  #--------------------------------------------------------------------------
  # dir8
  #  8 direction check.
  #--------------------------------------------------------------------------
  def Input.dir8
    return 1 if Input.press?(Down) && Input.press?(Left)
    return 3 if Input.press?(Down) && Input.press?(Right)
    return 7 if Input.press?(Up) && Input.press?(Left)
    return 9 if Input.press?(Up) && Input.press?(Right)
    return 2 if Input.press?(Down)
    return 4 if Input.press?(Left)
    return 6 if Input.press?(Right)
    return 8 if Input.press?(Up)
    return 0
  end
  #--------------------------------------------------------------------------
  # trigger?
  #  Test if key was triggered once.
  #--------------------------------------------------------------------------
  def Input.trigger?(keys)
    if keys.is_a?(Array)
      keys.each {|key| Input.check_old_keys(key).each {|k|
          return true if Input.triggered?(k)}}
    else
      Input.check_old_keys(keys).each {|k| return true if Input.triggered?(k)}
    end
    return false
  end
  #--------------------------------------------------------------------------
  # press?
  #  Test if key is being pressed.
  #--------------------------------------------------------------------------
  def Input.press?(keys)
    if keys.is_a?(Array)
      keys.each {|key| Input.check_old_keys(key).each {|k|
          return true if Input.pressed?(k)}}
    else
      Input.check_old_keys(keys).each {|k| return true if Input.pressed?(k)}
    end
    return false
  end     
  #--------------------------------------------------------------------------
  # repeat?
  #  Test if key is being pressed for repeating.
  #--------------------------------------------------------------------------
  def Input.repeat?(keys)
    if keys.is_a?(Array)
      keys.each {|key| Input.check_old_keys(key).each {|k|
          return true if Input.repeated?(k)}}
    else
      Input.check_old_keys(keys).each {|k| return true if Input.repeated?(k)}
    end
    return false
  end
  #--------------------------------------------------------------------------
  # check_old_keys
  #  Converts all the old keys into the new format if not overriding RMXP's
  #  controls.
  #--------------------------------------------------------------------------
  def Input.check_old_keys(key)
    case key
    when UP then return Up
    when LEFT then return Left
    when DOWN then return Down
    when RIGHT then return Right
    when A then return [Shift]
    when B then return ([Esc, NumPad[0]] | Cancel)
    when C then return ([Space, Enter] | Confirm)
    when X then return [Let['X']]
    when Y then return [Let['A']]
    when Z then return [Let['Z']]
    when L then return ([Let['Q']] | Prevpage)
#    when R then return ([Let['W']] | Nextpage)
    when F5 then return [Fkeys[5]]
    when F6 then return [Fkeys[6]]
    when F7 then return [Fkeys[7]]
    when F8 then return [Fkeys[8]]
    when F9 then return [Fkeys[9]]
    when SHIFT then return [Shift]
    when CTRL then return [Ctrl]
    when ALT then return [Alt]
    end
    return (key.is_a?(Array) ? key : [key])
  end
  #--------------------------------------------------------------------------
  # Anykey
  #  Checks if ANY key was pressed.
  #--------------------------------------------------------------------------
  def Input.Anykey
    return (@keys != [])
  end
 
end


Features Desired
  • All This Really Needs is a Way to Add Usb Controller Input


Games its been in
  • There are none that i Know of that Have this Feature in RMXP



Did you search?
<Yes>

Where did you search?
  • Google
  • RMRK (here)
  • RMXPUnlimited.com
  • RPGRevolution.net
  • CreationAsylum.net

What did you search for?
  • RMXP Controller
  • RMXP Controller Input
  • Custom Controller Input


Ending Notes
(i know this is not part of the Template)

I have been using RPG Maker XP, for a little over a month now.
and I Will Admit i am Still a Noob when it comes to most of this
I am Just here to Learn, so that I will be Able to Help others
when the time comes...
thank you for at least hearing me out,

Nordom