Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> [SOLVED] Vlad Input Script Bug Fix, For who know about Win32API
onidsouza
post Jun 17 2009, 05:42 PM
Post #1


image master of doom
Group Icon

Group: Revolutionary
Posts: 603
Type: None
RM Skill: Undisclosed




Hey every one,

I believe that every one knows Vlad's Input module. And some people know that it guives a lot of lag in windows vista, and i know why.
When it calls GetAsyncKeyState from user32.dll, Windows Vista Automatically blocks that command, returning 0 to the value. That's because a update of windows vista blocked almost every application from getting information from the core of the system (that's what GetAsyncKeyState do).But i don't know the solution to that problem, still shearching. If anybody want to help, you are welcome.
Vlad's Input Module is the best input module i've ever seen, and i will like to see it working on vista too!


__________________________
Gabba Gabba Hey! enjoy your life ^^
lol (by keet's brother)
some lol
more lol
even MORE lol
Serious Discussion
why all my lol's have Teh Parakeet involved?

me ^^

bacon

Spamming is always better with bacon
Go to the top of the page
 
+Quote Post
   
Speed@
post Jun 17 2009, 10:32 PM
Post #2


Level 12
Group Icon

Group: Revolutionary
Posts: 203
Type: None
RM Skill: Undisclosed




I would help, my scripting knowledge really advanced since I started making VX Phoenix, but I don't know how to do DLL calls or anything related sad.gif
Go to the top of the page
 
+Quote Post
   
onidsouza
post Jun 18 2009, 02:05 AM
Post #3


image master of doom
Group Icon

Group: Revolutionary
Posts: 603
Type: None
RM Skill: Undisclosed




Well, in ruby, you use that command in order to do api calls:

Obj = Win32API.new("dll name", "method name", [arguments], 'return type')
Obj.call(arguments)


__________________________
Gabba Gabba Hey! enjoy your life ^^
lol (by keet's brother)
some lol
more lol
even MORE lol
Serious Discussion
why all my lol's have Teh Parakeet involved?

me ^^

bacon

Spamming is always better with bacon
Go to the top of the page
 
+Quote Post
   
Speed@
post Jun 18 2009, 02:19 AM
Post #4


Level 12
Group Icon

Group: Revolutionary
Posts: 203
Type: None
RM Skill: Undisclosed




I partly get it in theory, but still don't know how to use it in real example.
Go to the top of the page
 
+Quote Post
   
AmIMeYet
post Jun 18 2009, 07:08 AM
Post #5


new av & (dynamic) sig!
Group Icon

Group: Revolutionary
Posts: 149
Type: Scripter
RM Skill: Undisclosed




QUOTE (Speed@ @ Jun 18 2009, 12:19 PM) *
I partly get it in theory, but still don't know how to use it in real example.
I might be able to help you with that later, if you wish.

Back on topic: msdn reports no other function to get the key state, other than getAsynchKeyState. It might be worth trying GetKeyState, but that can only get 'a'..'z', and 0..9.

And you say the input module returns 0.. but still works? (even though it creates a horrible lag)?
I might scan through the script later, to see how this works.


__________________________

>>Latest EventScripter news: Conditional Branches fully working! Currently working on a documentation site. Topic: EventScripter
>>Portals (yes, in RPG Maker VX!)
>>Working with Sojabird on his Scriptology; I also invented Scriptuzzle.. Try one; make one!
[Show/Hide] USEFULL script snippets:
[Show/Hide] Do require's in VX:
CODE
$LOAD_PATH << Dir.getwd #You only need to call this once
Kernel.require("includable.rb") #replace includable.rb with the name of the file you want to load
[Show/Hide] Invert Dash enabling:
CODE
#=============================================================================#
# # #                            ANTI DASH HACK                           # # #
# # #                              By AmIMeYet                            # # #
# # #                           please credit me                          # # #
#=============================================================================#
class Game_Player < Game_Character
  def dash?
    return false if @move_route_forcing
    return false if in_vehicle?
    return true if Input.press?(Input::A) and $game_map.disable_dash?
  end
end

This snippet basically inverts the dashing.. allowing you to dash only when 'disable dashing' is checked.
This way, normal maps disable dashing, but the ones you set to disable actually allow dashing..

It should be placed where you normally place the scripts ('above main', in the materials section of the scripts window)..
Go to the top of the page
 
+Quote Post
   
onidsouza
post Jun 18 2009, 02:17 PM
Post #6


image master of doom
Group Icon

Group: Revolutionary
Posts: 603
Type: None
RM Skill: Undisclosed




Well, windows vista created a level 0 block in some processes, and the input only work good in the level 0.
But the game.exe doesn't works in level 0.
The solution is:

put Game.exe into the level 0 block (system processes)

Unblock the input so it can work out of lvl 0.

So, the method will always return 0, because the method doesn't have any return from the hardware.


__________________________
Gabba Gabba Hey! enjoy your life ^^
lol (by keet's brother)
some lol
more lol
even MORE lol
Serious Discussion
why all my lol's have Teh Parakeet involved?

me ^^

bacon

Spamming is always better with bacon
Go to the top of the page
 
+Quote Post
   
onidsouza
post Jun 19 2009, 02:19 PM
Post #7


image master of doom
Group Icon

Group: Revolutionary
Posts: 603
Type: None
RM Skill: Undisclosed




Vlad solved it in his Requiem ABS 8
Here is the script:

CODE

#==============================================================================
# Input Module (Modificated by Vlad)
#==============================================================================
module Input

Mouse_Left = 1
Mouse_Right = 2
Mouse_Middle = 4

Back = 8
Tab = 9
Enter = 13
Shift = 16
Ctrl = 17
Alt = 18
CapsLock = 20
Esc = 27
Space = 32
PGUP = 33
PGDN = 34
End = 35
Home = 36
Left = 37
Up = 38
Right = 39
Down = 40
PrintScreen = 44
Insert = 45
Delete = 46

Numberkeys = {}
Numberkeys[0] = 48
Numberkeys[1] = 49
Numberkeys[2] = 50
Numberkeys[3] = 51
Numberkeys[4] = 52
Numberkeys[5] = 53
Numberkeys[6] = 54
Numberkeys[7] = 55
Numberkeys[8] = 56
Numberkeys[9] = 57

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

LWin = 91
RWin = 92
Apps = 93

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
Multiply = 106
Add = 107
Subtract = 109
Decimal = 110
Divide = 111

Fkeys = {}
Fkeys[1] = 112
Fkeys[2] = 113
Fkeys[3] = 114
Fkeys[4] = 115
Fkeys[5] = 116
Fkeys[6] = 117
Fkeys[7] = 118
Fkeys[8] = 119
Fkeys[9] = 120
Fkeys[10] = 121
Fkeys[11] = 122
Fkeys[12] = 123

NumLock = 144
ScrollLock = 145
LShift = 160
RShift = 161
LControl = 162
RControl = 163
LAlt = 164
RAlt = 165

Collon = 186
Equal = 187
Comma = 188
Underscore = 189
Dot = 190
Backslash = 191
Uncle = 192
LB = 219
Bar = 220
RB = 221
Quote = 222

@time = Array.new(256, 0)
@press = Array.new(256, false)
@trigger = Array.new(256, false)
@repeat = Array.new(256, false)
@release = Array.new(256, false)
@dirs = [0, 0]

InputInitialize = Win32API.new("Input", 'InputInitialize', 'LLLLLL', '')
InputUpdate = Win32API.new("Input", 'InputUpdate', '', '')

REG_KVALUES = {0=>32,1=>13,2=>27,3=>96,4=>16,5=>90,6=>88,7=>67,8=>86,9=>66,
10=>65,11=>83,12=>68,13=>81,14=>87}

DEFAULT_KEYS = {11=>[16,90],12=>[27,88,96],13=>[13,32],14=>[65],15=>[83],
16=>[68],17=>[81],18=>[87]}

def convert_keys(key)
begin
keys = []
rkey = 'HKEY_CURRENT_USER\\Software\\Enterbrain\\RGSS'
data = Registry.read_entry(rkey, 'ButtonAssign')[10, 25].scan(/./)
15.times {|i| keys.push(REG_KVALUES[i]) if key == data[i].unpack('C')[0]}
keys
rescue
DEFAULT_KEYS[key] rescue []
end
end

module_function :convert_keys

LEFT = 37
UP = 38
RIGHT = 39
DOWN = 40
A = convert_keys(11)
B = [45] + convert_keys(12)
C = convert_keys(13)
X = convert_keys(14)
Y = convert_keys(15)
Z = convert_keys(16)
L = [33] + convert_keys(17)
R = [34] + convert_keys(18)
SHIFT = 16
CTRL = 17
ALT = 18
F5 = 116
F6 = 117
F7 = 118
F8 = 119
F9 = 120

InputInitialize.call(@time.object_id, @press.object_id, @trigger.object_id,
@repeat.object_id, @release.object_id, @dirs.object_id)

def self.update
InputUpdate.call
end

def self.trigger?(id)
@trigger.indexes(*id.to_a).include?(true)
end

def self.press?(id)
@press.indexes(*id.to_a).include?(true)
end

def self.triggerd?(what)
if triggered.include?(what)
return true
end
end

def self.triggered
array = Array.new
@trigger.each_index {|i| array.push(i) if @trigger[i]}
array
end

def self.pressed?(what)
if pressed.include?(what)
return true
end
end

def self.pressed
array = Array.new
@press.each_index {|i| array.push(i) if @press[i]}
array
end

def self.repeat?(id)
@repeat.indexes(*id.to_a).include?(true)
end

def self.repeated
array = Array.new
@repeat.each_index {|i| array.push(i) if @repeat[i]}
array
end

def self.release?(id)
@release.indexes(*id.to_a).include?(true)
end

def self.released
array = Array.new
@release.each_index {|i| array.push(i) if @release[i]}
array
end

def self.dir4
@dirs[0]
end

def self.dir8
@dirs[1]
end

KEYS_NAMES = {1=>'Mouse Left',2=>'Mouse Right',3=>'Cancel',
4=>'Mouse Middle',5=>'Mouse 4th',6=>'Mouse 5th',8=>'Backspace',9=>'Tab',
12=>'Clear',13=>'Enter',16=>'Shift',17=>'Control',18=>'Alt',19=>'Pause',
20=>'Capitals Lock',21=>'Kana',23=>'Junja',24=>'Final',25=>'Kanji',
27=>'Escape',28=>'Convert',29=>'Non Convert',30=>'Accept',31=>'Mode Change',
32=>'Space',33=>'Page Up',34=>'Page Down',35=>'End',36=>'Home',37=>'Left',
38=>'Up',39=>'Right',40=>'Down',41=>'Select',42=>'Print',43=>'Execute',
44=>'PrintScreen',45=>'Insert',46=>'Delete',47=>'Help',48=>'0',49=>'1',50=>'2',
51=>'3',52=>'4',53=>'5',54=>'6',55=>'7',56=>'8',57=>'9',65=>'A',66=>'B',
67=>'C',68=>'D',69=>'E',70=>'F',71=>'G',72=>'H',73=>'I',74=>'J',75=>'K',
76=>'L',77=>'M',78=>'N',79=>'O',80=>'P',81=>'Q',82=>'R',83=>'S',84=>'T',
85=>'U',86=>'V',87=>'W',88=>'X',89=>'Y',90=>'Z',91=>'Left Windows',
92=>'Right Windows',93=>'Application',95=>'Sleep',96=>'PAD 0',97=>'PAD 1',
98=>'PAD 2',99=>'PAD 3',100=>'PAD 4',101=>'PAD 5',102=>'PAD 6',103=>'PAD 7',
104=>'PAD 8',105=>'PAD 9',106=>'*',107=>'+',108=>'Separator',109=>'-',110=>'.',
111=>'/',112=>'F1',113=>'F2',114=>'F3',115=>'F4',116=>'F5',117=>'F6',118=>'F7',
119=>'F8',120=>'F9',121=>'F10',122=>'F11',123=>'F12',124=>'F13',125=>'F14',
126=>'F15',127=>'F16',128=>'F17',129=>'F18',130=>'F19',131=>'F20',132=>'F21',
133=>'F22',134=>'F23',135=>'F24',144=>'Number Lock',145=>'Scroll Lock',
146=>'OEM 15',147=>'OEM 16',148=>'OEM 17',149=>'OEM 18',150=>'OEM 19',
160=>'Left Shift',161=>'Right Shift',162=>' Left Control',163=>'Right Control',
164=>' Left Alt',165=>'Right Alt',166=>'Browser Back',167=>'Browser Forward',
168=>'Browser Refresh',169=>'Browser Stop',170=>'Browser Search',
171=>'Browser Favorites',172=>'Browser Home',173=>'Volume Mute',
174=>'Volume Down',175=>'Volume Up',176=>'Media Next Track',
177=>'Media Previous Track',178=>'Media Stop',179=>'Media Play Pause',
180=>'Launch Mail',181=>'Launch Media Select',182=>'Launch Application',
183=>'Launch Application',186=>'OEM 1',187=>'OEM 2',188=>'OEM 3',189=>'OEM 4',
190=>'OEM 5',191=>'OEM 6',192=>'OEM 7',219=>'OEM 8',220=>'OEM 9',221=>'OEM 10',
222=>'OEM 11',223=>'OEM 13',225=>'OEM 20',226=>'OEM 14',227=>'OEM 21',
228=>'OEM 22',229=>'Proccess',230=>'OEM 23',232=>'OEM 24',240=>'OEM 25',
241=>'OEM 26',242=>'OEM 27',243=>'OEM 28',244=>'OEM 29',245=>'OEM 30',
246=>'ATTN',247=>'CRSEL',248=>'EXSEL',249=>'EREOF',250=>'Play',251=>'Zoom',
253=>'PA1',254=>'OEM Clear'}

def self.name?(id)
return (KEYS_NAMES[id].nil? ? '???' : KEYS_NAMES[id])
end

end

#-----------------------------------------------------------------------------
module Registry

module_function

RegCloseKey = Win32API.new('advapi32', 'RegCloseKey', 'L', 'L')
RegOpenKeyExA = Win32API.new('advapi32', 'RegOpenKeyExA', 'LPLLP', 'L')
RegQueryValueExA = Win32API.new('advapi32', 'RegQueryValueExA','LPLPPP','L')
HKEYS = {'HKEY_CLASSES_ROOT' => 0x80000000,'HKEY_CURRENT_USER' =>0x80000001,
'HKEY_LOCAL_MACHINE' => 0x80000002, 'HKEY_USERS' => 0x80000003,
'HKEY_CURRENT_CONFIG' => 0x80000005}

def read_entry(key, entry)
key.sub!(/(.*?)\\/, '')
if HKEYS[$1] != nil
hkey = HKEYS[$1]
else
return nil
end
opened, type, size = [0].pack('V'), [0].pack('V'), [0].pack('V')
RegOpenKeyExA.call(hkey, key, 0, 131097, opened)
opened = (opened + [0].pack('V')).unpack('V')[0]
RegQueryValueExA.call(opened, entry, 0, type, 0, size)
data = ' ' * (size + [0].pack('V')).unpack('V')[0]
RegQueryValueExA.call(opened, entry, 0, type, data, size)
RegCloseKey.call(opened)
data = data[0, (size + [0].pack('V')).unpack('V')[0]]
type = (type += [0].pack('V')).unpack('V')[0]
case type
when 1
data.chop
when 2
data.chop.gsub(/%([^%]+)%/) { ENV[$1] || $& }
when 3
data
when 4
(data += [0].pack('V')).unpack('V')[0]
when 5
data.unpack('N')[0]
when 7
data.split(/\0/)
when 11
(data.unpack('VV')[1] << 32) | data[0]
else
nil
end
end

end


Well, it needs Input.dll, that comes with Requiem ABS 8


__________________________
Gabba Gabba Hey! enjoy your life ^^
lol (by keet's brother)
some lol
more lol
even MORE lol
Serious Discussion
why all my lol's have Teh Parakeet involved?

me ^^

bacon

Spamming is always better with bacon
Go to the top of the page
 
+Quote Post
   
AmIMeYet
post Jun 20 2009, 01:12 PM
Post #8


new av & (dynamic) sig!
Group Icon

Group: Revolutionary
Posts: 149
Type: Scripter
RM Skill: Undisclosed




QUOTE (onidsouza @ Jun 20 2009, 12:19 AM) *
Vlad solved it in his Requiem ABS 8
Here is the script: <code/>
Well, it needs Input.dll, that comes with Requiem ABS 8

Ah.. I hate ext. dll's.
And I'm almost sure that dll uses get(Asynch)Key itself XD

Good find though


__________________________

>>Latest EventScripter news: Conditional Branches fully working! Currently working on a documentation site. Topic: EventScripter
>>Portals (yes, in RPG Maker VX!)
>>Working with Sojabird on his Scriptology; I also invented Scriptuzzle.. Try one; make one!
[Show/Hide] USEFULL script snippets:
[Show/Hide] Do require's in VX:
CODE
$LOAD_PATH << Dir.getwd #You only need to call this once
Kernel.require("includable.rb") #replace includable.rb with the name of the file you want to load
[Show/Hide] Invert Dash enabling:
CODE
#=============================================================================#
# # #                            ANTI DASH HACK                           # # #
# # #                              By AmIMeYet                            # # #
# # #                           please credit me                          # # #
#=============================================================================#
class Game_Player < Game_Character
  def dash?
    return false if @move_route_forcing
    return false if in_vehicle?
    return true if Input.press?(Input::A) and $game_map.disable_dash?
  end
end

This snippet basically inverts the dashing.. allowing you to dash only when 'disable dashing' is checked.
This way, normal maps disable dashing, but the ones you set to disable actually allow dashing..

It should be placed where you normally place the scripts ('above main', in the materials section of the scripts window)..
Go to the top of the page
 
+Quote Post
   
onidsouza
post Jun 20 2009, 03:23 PM
Post #9


image master of doom
Group Icon

Group: Revolutionary
Posts: 603
Type: None
RM Skill: Undisclosed




No it don't. I tested it in Windows Vista, and works fine.


__________________________
Gabba Gabba Hey! enjoy your life ^^
lol (by keet's brother)
some lol
more lol
even MORE lol
Serious Discussion
why all my lol's have Teh Parakeet involved?

me ^^

bacon

Spamming is always better with bacon
Go to the top of the page
 
+Quote Post
   
AmIMeYet
post Jun 21 2009, 03:11 AM
Post #10


new av & (dynamic) sig!
Group Icon

Group: Revolutionary
Posts: 149
Type: Scripter
RM Skill: Undisclosed




QUOTE (onidsouza @ Jun 21 2009, 01:23 AM) *
No it don't. I tested it in Windows Vista, and works fine.
Yeah, I'm not doubting that.. but get(Asynch)Key (and Keyboard or something) are about the only way's to get key presses.


__________________________

>>Latest EventScripter news: Conditional Branches fully working! Currently working on a documentation site. Topic: EventScripter
>>Portals (yes, in RPG Maker VX!)
>>Working with Sojabird on his Scriptology; I also invented Scriptuzzle.. Try one; make one!
[Show/Hide] USEFULL script snippets:
[Show/Hide] Do require's in VX:
CODE
$LOAD_PATH << Dir.getwd #You only need to call this once
Kernel.require("includable.rb") #replace includable.rb with the name of the file you want to load
[Show/Hide] Invert Dash enabling:
CODE
#=============================================================================#
# # #                            ANTI DASH HACK                           # # #
# # #                              By AmIMeYet                            # # #
# # #                           please credit me                          # # #
#=============================================================================#
class Game_Player < Game_Character
  def dash?
    return false if @move_route_forcing
    return false if in_vehicle?
    return true if Input.press?(Input::A) and $game_map.disable_dash?
  end
end

This snippet basically inverts the dashing.. allowing you to dash only when 'disable dashing' is checked.
This way, normal maps disable dashing, but the ones you set to disable actually allow dashing..

It should be placed where you normally place the scripts ('above main', in the materials section of the scripts window)..
Go to the top of the page
 
+Quote Post
   
onidsouza
post Jun 21 2009, 06:45 AM
Post #11


image master of doom
Group Icon

Group: Revolutionary
Posts: 603
Type: None
RM Skill: Undisclosed




Yeah, maybe the dll's run with lvl 0 security in Windows Vista, they can be considered system processes, i dunno exactaly how me made it to work.


__________________________
Gabba Gabba Hey! enjoy your life ^^
lol (by keet's brother)
some lol
more lol
even MORE lol
Serious Discussion
why all my lol's have Teh Parakeet involved?

me ^^

bacon

Spamming is always better with bacon
Go to the top of the page
 
+Quote Post
   
Speed@
post Jun 22 2009, 12:37 AM
Post #12


Level 12
Group Icon

Group: Revolutionary
Posts: 203
Type: None
RM Skill: Undisclosed




I have just one thing to point out, the Input script was made by Aleworks, vlad just modified it for his use.
Go to the top of the page
 
+Quote Post
   
onidsouza
post Jun 22 2009, 08:26 AM
Post #13


image master of doom
Group Icon

Group: Revolutionary
Posts: 603
Type: None
RM Skill: Undisclosed




Ah.. the input library was made by him too?


__________________________
Gabba Gabba Hey! enjoy your life ^^
lol (by keet's brother)
some lol
more lol
even MORE lol
Serious Discussion
why all my lol's have Teh Parakeet involved?

me ^^

bacon

Spamming is always better with bacon
Go to the top of the page
 
+Quote Post
   
Speed@
post Jun 22 2009, 09:05 AM
Post #14


Level 12
Group Icon

Group: Revolutionary
Posts: 203
Type: None
RM Skill: Undisclosed




QUOTE (onidsouza @ Jun 22 2009, 08:26 AM) *
Ah.. the input library was made by him too?

Yes. Check in VX Phoenix. I'm using the original modules there.
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 24th May 2013 - 05:56 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker