http://img209.imageshack.us/img209/875/ ... putzg4.png[/img]
http://img152.imageshack.us/img152/2110 ... iontu8.png[/img]
This script is faster then the old ones because it handles the KeyState calls inside the dll.
Extra credits to poccil, thanks to him, we found out how to convert RGSS Object -> C variable
http://img71.imageshack.us/img71/8927/howtousepp8.png[/img]
Only copy the DLL RGSSInput.dll to your game folder and copy the script:
http://img293.imageshack.us/img293/9623/scriptdm3.png[/img]
Methods available:
Input.press?(key)
Input.trigger?(key)
Input.repeat?(key)
Input.release?(key)
You MUST add every additional key using Input.add_key(key), otherwise, the DLL will not read it.
To clear the added keys, use Input.clear.
You can now setup the 4 directions keys using:
Input.setup_direction_keys(key_for_up, down, left, right)
http://img361.imageshack.us/img361/3016/botaumdownload02zl4.jpg[/img]
http://img227.imageshack.us/img227/2402/prlogoqp5.png[/img]
NightWalker
PHCDO
RTH
http://i.creativecommons.org/l/by-nc-sa/2.5/br/88x31.png[/img]
PR Input DLL by PR Coders is licensed under a
Creative Commons Attribution-Noncommercial-Share Alike 2.5 Brazill License.
http://img152.imageshack.us/img152/2110 ... iontu8.png[/img]
This script is faster then the old ones because it handles the KeyState calls inside the dll.
Extra credits to poccil, thanks to him, we found out how to convert RGSS Object -> C variable
http://img71.imageshack.us/img71/8927/howtousepp8.png[/img]
Only copy the DLL RGSSInput.dll to your game folder and copy the script:
http://img293.imageshack.us/img293/9623/scriptdm3.png[/img]
Code:
#===============================================================================
# Input module
#-------------------------------------------------------------------------------
# Créditos: PRCoders
#       poccil - Thanks to him we discovered how to convert RGSS Objects into C variables
#===============================================================================
module Input
Â
 #--------------------------------------------------------------------------
 # * Váriáveis
 #--------------------------------------------------------------------------
Â
 @keys = Array.new(256)
 @pressed = Array.new(256)
 @repeated = Array.new(256)
 @released = Array.new(256)
 @dir = Array.new(2)
Â
 #--------------------------------------------------------------------------
 # * Constantes
 #--------------------------------------------------------------------------
Â
 Mouse_Left = 1
 Mouse_Right = 2
 Mouse_Middle = 4
 Back = 8
 Tab = 9
 Enter = 13
 SHIFT = Shift = 16
 CTRL = Ctrl = 17
 ALT = Alt = 18
 Pause = 0x13
 CAPS = 0x14
 Esc = 0x1B
 LEFT = 0x25
 UP = 0x26Â
 RIGHT = 0x27
 DOWN = 0x28
 Space = 32
 PageUp = 0x21
 PageDowm = 0x22
 Home = 0x23
 End = 0x24
 Numberkeys = {}
 Numberkeys[0] = 48    # => 0
 Numberkeys[1] = 49    # => 1
 Numberkeys[2] = 50    # => 2
 Numberkeys[3] = 51    # => 3
 Numberkeys[4] = 52    # => 4
 Numberkeys[5] = 53    # => 5
 Numberkeys[6] = 54    # => 6
 Numberkeys[7] = 55    # => 7
 Numberkeys[8] = 56    # => 8
 Numberkeys[9] = 57    # => 9
 Numberpad = {}
 Numberpad[0] = 96
 Numberpad[1] = 97
 Numberpad[2] = 98
 Numberpad[3] = 99
 Numberpad[4] = 100
 Numberpad[5] = 101
 Numberpad[6] = 102
 Numberpad[7] = 103
 Numberpad[8] = 104
 Numberpad[9] = 105
 Letters = {}
 Letters["A"] = 65
 Letters["B"] = 66
 Letters["C"] = 67
 Letters["D"] = 68
 Letters["E"] = 69
 Letters["F"] = 70
 Letters["G"] = 71
 Letters["H"] = 72
 Letters["I"] = 73
 Letters["J"] = 74
 Letters["K"] = 75
 Letters["L"] = 76
 Letters["M"] = 77
 Letters["N"] = 78
 Letters["O"] = 79
 Letters["P"] = 80
 Letters["Q"] = 81
 Letters["R"] = 82
 Letters["S"] = 83
 Letters["T"] = 84
 Letters["U"] = 85
 Letters["V"] = 86
 Letters["W"] = 87
 Letters["X"] = 88
 Letters["Y"] = 89
 Letters["Z"] = 90
 Fkeys = {}
 F1 = Fkeys[1] = 112
 F2 = Fkeys[2] = 113
 F3 = Fkeys[3] = 114
 F4 = Fkeys[4] = 115
 F5 = Fkeys[5] = 116
 F6 = Fkeys[6] = 117
 F7 = Fkeys[7] = 118
 F8 = Fkeys[8] = 119
 F9 = Fkeys[9] = 120
 F10 = Fkeys[10] = 121
 F11 = Fkeys[11] = 122
 F12 = Fkeys[12] = 123
 Collon = 186    # => \ |
 Equal = 187    # => = +
 Comma = 188    # => , <
 Underscore = 189  # => - _
 Dot = 190     # => . >
 Backslash = 191  # => / ?
 Lb = 219
 Rb = 221
 Quote = 222    # => '"
Â
 #--------------------------------------------------------------------------
 # * Constantes originais
 #--------------------------------------------------------------------------
Â
 A = Letters["C"]
 B = [Letters["X"], Esc]
 C = [Letters["Z"], Space, Enter]
 X = Letters["A"]
 Y = Letters["S"]
 Z = Letters["D"]
 L = Letters["Q"]
 R = Letters["W"]
Â
 #--------------------------------------------------------------------------
 # * Métodos da DLL
 #--------------------------------------------------------------------------
Â
 UPDATE = Win32API.new("PRABS.dll", "UpdateInputArray", "lllll", "")
 ADDKEY = Win32API.new("PRABS.dll", "InputAddUsedKey", "i", "")
Â
 #--------------------------------------------------------------------------
 # * Adiciona uma tecla para ser atualizada
 #--------------------------------------------------------------------------
Â
 def self.add_key(key)
  if (key.is_a?(Array))
   for k in key
    self.add_key(k)
   end
   return
  end
  ADDKEY.call(key)
 end
Â
 #--------------------------------------------------------------------------
 # * Reseta as teclas atualizadas
 #--------------------------------------------------------------------------
Â
 def self.clear
  Win32API.new("PRABS.dll", "ClearUsedKeys", "", "").call()
 end
Â
 #--------------------------------------------------------------------------
 # * Reseta as teclas atualizadas
 #--------------------------------------------------------------------------
Â
 def self.setup_direction_keys(up, down, left, right)
  self.add_key(up)
  self.add_key(down)
  self.add_key(left)
  self.add_key(right)
  Win32API.new("PRABS.dll", "SetupDirectionKeys", "iiii", "").call(up, down, left, right)
 end
Â
 #--------------------------------------------------------------------------
 # * Atualização
 #--------------------------------------------------------------------------
Â
 def self.update
  UPDATE.call(@keys.__id__, @pressed.__id__, @repeated.__id__, @released.__id__, @dir.__id__)
 end
Â
 #--------------------------------------------------------------------------
 # * Trigger?
 #--------------------------------------------------------------------------
Â
 def self.trigger?(key)
  if (key.is_a?(Array))
   return key.any? { |k| self.trigger?(k) }
  end
  return @keys[key]
 end
Â
 #--------------------------------------------------------------------------
 # * Press?
 #--------------------------------------------------------------------------
Â
 def self.press?(key)
  if (key.is_a?(Array))
   return key.any? { |k| self.press?(k) }
  end
  return @pressed[key]
 end
Â
 #--------------------------------------------------------------------------
 # * Repeat?
 #--------------------------------------------------------------------------
Â
 def self.repeat?(key)
  if (key.is_a?(Array))
   return key.any? { |k| self.repeat?(k) }
  end
  return @repeated[key]
 end
Â
 #--------------------------------------------------------------------------
 # * Release?
 #--------------------------------------------------------------------------
Â
 def self.release?(key)
  if (key.is_a?(Array))
   return key.any? { |k| self.release?(k) }
  end
  return @released[key]
 end
Â
 #--------------------------------------------------------------------------
 # * Dir4
 #--------------------------------------------------------------------------
Â
 def self.dir4
  return @dir[0]
 end
 #--------------------------------------------------------------------------
 # * Dir8
 #--------------------------------------------------------------------------
Â
 def self.dir8
  return @dir[1]
 end
Â
 self.clear
Â
end
# Adicionando as teclas mais utilizadas ao sistema
Input.add_key(Input::DOWN)
Input.add_key(Input::UP)
Input.add_key(Input::LEFT)
Input.add_key(Input::RIGHT)
Input.add_key(Input::A)
Input.add_key(Input::B)
Input.add_key(Input::C)
Input.add_key(Input::X)
Input.add_key(Input::Y)
Input.add_key(Input::Z)
Input.add_key(Input::L)
Input.add_key(Input::R)
Input.add_key(Input::CTRL)
Input.add_key(Input::SHIFT)
Input.add_key(Input::ALT)
Input.setup_direction_keys(Input::UP, Input::DOWN, Input::LEFT, Input::RIGHT)
Methods available:
Input.press?(key)
Input.trigger?(key)
Input.repeat?(key)
Input.release?(key)
You MUST add every additional key using Input.add_key(key), otherwise, the DLL will not read it.
To clear the added keys, use Input.clear.
You can now setup the 4 directions keys using:
Input.setup_direction_keys(key_for_up, down, left, right)
http://img361.imageshack.us/img361/3016/botaumdownload02zl4.jpg[/img]
http://img227.imageshack.us/img227/2402/prlogoqp5.png[/img]
NightWalker
PHCDO
RTH
http://i.creativecommons.org/l/by-nc-sa/2.5/br/88x31.png[/img]
PR Input DLL by PR Coders is licensed under a
Creative Commons Attribution-Noncommercial-Share Alike 2.5 Brazill License.