#============================================================================== # Requiem Keyboard (Thanks to Aleworks to source) #============================================================================== Requiem_Masterpiece.register("Requiem Keyboard", 1.0, "08/01/2009") #------------------------------------------------------------------------------ module Keys Keyboard = "PT-BR" Mouse_Left = 1 Mouse_Right = 2 Mouse_Middle = 4 Back = 8 Tab = 9 Clear = 12 Enter = 13 Shift = 16 Ctrl = 17 Alt = 18 Pause = 19 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 Num0 = 48 Num1 = 49 Num2 = 50 Num3 = 51 Num4 = 52 Num5 = 53 Num6 = 54 Num7 = 55 Num8 = 56 Num9 = 57 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 Win = [91, 92] Apps = 93 Pad0 = 96 Pad1 = 97 Pad2 = 98 Pad3 = 99 Pad4 = 100 Pad5 = 101 Pad6 = 102 Pad7 = 103 Pad8 = 104 Pad9 = 105 Multiply = 106 Add = 107 Subtract = 109 Decimal = 110 Divide = 111 F1 = 112 F2 = 113 F3 = 114 F4 = 115 F5 = 116 F6 = 117 F7 = 118 F8 = 119 F9 = 120 F10 = 121 F11 = 122 F12 = 123 NumLock = 144 ScrollLock = 145 Collon = 186 # EN-US: ;: PT-BR: çÇ Equal = 187 # EN-US: =+ PT-BR: =+ Comma = 188 # EN-US: ,< PT-BR: ,< Underscore = 189 # EN-US: -_ PT-BR: -_ Dot = 190 # EN-US: .> PT-BR: .> Backslash = 191 # EN-US: /? PT-BR: ;: Accent = 192 # EN-US: '~ PT-BR: "' Query = 193 # EN-US: PT-BR: /? Float = 194 # EN-US: PT-BT: . LHook = 219 # EN-US: [{ PT-BR: ´` RBar = 220 # EN-US: \| PT-BR: ]} RHook = 221 # EN-US: ]} PT-BR: [{ Quote = 222 # EN-US: "' PT-BR: ^~ LBar = 226 # PT-BR: \| 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 => 'Caps 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'} Numbers = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105] Values = {} Values["ALL"] = {32 => [" "], 49 => ["1", "!"], 50 => ["2", "@"], 51 => ["3", "#"], 52 => ["4", "$"], 53 => ["5", "%"], 54 => ["6", "¨"], 55 => ["7", "&"], 56 => ["8", "*"], 57 => ["9", "("], 48 => ["0", ")"], 65 => ["a", "A"], 66 => ["b", "B"], 67 => ["c", "C"], 68 => ["d", "D"], 69 => ["e", "E"], 70 => ["f", "F"], 71 => ["g", "G"], 72 => ["h", "H"], 73 => ["i", "I"], 74 => ["j", "J"], 75 => ["k", "K"], 76 => ["l", "L"], 77 => ["m", "M"], 78 => ["n", "N"], 79 => ["o", "O"], 80 => ["p", "P"], 81 => ["q", "Q"], 82 => ["r", "R"], 83 => ["s", "S"], 84 => ["t", "T"], 85 => ["u", "U"], 86 => ["v", "V"], 87 => ["w", "W"], 88 => ["x", "X"], 89 => ["y", "Y"], 90 => ["z", "Z"], 96 => ["0"], 97 => ["1"], 98 => ["2"], 99 => ["3"], 100 => ["4"], 101 => ["5"], 102 => ["6"], 103 => ["7"], 104 => ["8"], 105 => ["9"], 106 => ["*"], 107 => ["+"], 109 => ["-"], 110 => [","], 111 => ["/"]} Values["EN-US"] = {186 => [";", ":"], 187 => ["=", "+"], 188 => [",", "<"], 189 => ["-", "_"], 190 => [".", ">"], 191 => ["/", "?"], 192 => ["'", "~"], 219 => ["[", "{"], 220 => ["","|"], 221 => ["]", "}"], 222 => ['"', "'"]} Values["PT-BR"] = {186 => ["ç", "Ç"], 187 => ["=", "+"], 188 => [",", "<"], 189 => ["-", "_"], 190 => [".", ">"], 191 => [";", ":"], 192 => ["'", '"'], 193 => ["/", '?'], 194 =>["."], 219 => ["´", "`"], 220 => ["]", "}"], 221 => ["[", "{"], 222 => ['~', "^"], 226 => ["","|"]} def self.name(id) return (Names.keys.include?(id) ? Names[id] : "???") end def self.value(id) if Values["ALL"].keys.include?(id) return Values["ALL"][id] elsif Values[Keyboard].keys.include?(id) return Values[Keyboard][id] else return Values["EN-US"][id] end end end #------------------------------------------------------------------------------ module Input @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', '', '') InputInitialize.call(@time.object_id, @press.object_id, @trigger.object_id, @repeat.object_id, @release.object_id, @dirs.object_id) LEFT = 37 UP = 38 RIGHT = 39 DOWN = 40 A = [160, 161] B = [27, 88, 96] C = [13, 32, 90] X = 65 Y = 83 Z = 68 L = 81 R = 87 SHIFT = 16 CTRL = 17 ALT = 18 F5 = 116 F6 = 117 F7 = 118 F8 = 119 F9 = 120 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 return 2 if self.pressed?(DOWN) return 4 if self.pressed?(LEFT) return 6 if self.pressed?(RIGHT) return 8 if self.pressed?(UP) return 0 end def self.dir8 if self.pressed?(UP) return 9 if self.pressed?(RIGHT) return 7 if self.pressed?(LEFT) return 8 end if self.pressed?(DOWN) return 3 if self.pressed?(RIGHT) return 1 if self.pressed?(LEFT) return 2 end return 6 if self.pressed?(RIGHT) return 4 if self.pressed?(LEFT) return 0 end end #------------------------------------------------------------------------------ =begin loop do Input.update for i in 0...256 next unless Input.trigger?(i) p i end end =end