Advertisement
Guest User

Untitled

a guest
Oct 19th, 2011
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.72 KB | None | 0 0
  1. #==============================================================================
  2. # Requiem Keyboard (Thanks to Aleworks to source)
  3. #==============================================================================
  4. Requiem_Masterpiece.register("Requiem Keyboard", 1.0, "08/01/2009")
  5. #------------------------------------------------------------------------------
  6. module Keys
  7.  
  8. Keyboard = "PT-BR"
  9.  
  10. Mouse_Left = 1
  11. Mouse_Right = 2
  12. Mouse_Middle = 4
  13.  
  14. Back = 8
  15. Tab = 9
  16. Clear = 12
  17. Enter = 13
  18. Shift = 16
  19. Ctrl = 17
  20. Alt = 18
  21. Pause = 19
  22. CapsLock = 20
  23. Esc = 27
  24. Space = 32
  25. PGUP = 33
  26. PGDN = 34
  27. End = 35
  28. Home = 36
  29. Left = 37
  30. Up = 38
  31. Right = 39
  32. Down = 40
  33. PrintScreen = 44
  34. Insert = 45
  35. Delete = 46
  36.  
  37. Num0 = 48
  38. Num1 = 49
  39. Num2 = 50
  40. Num3 = 51
  41. Num4 = 52
  42. Num5 = 53
  43. Num6 = 54
  44. Num7 = 55
  45. Num8 = 56
  46. Num9 = 57
  47.  
  48. A = 65
  49. B = 66
  50. C = 67
  51. D = 68
  52. E = 69
  53. F = 70
  54. G = 71
  55. H = 72
  56. I = 73
  57. J = 74
  58. K = 75
  59. L = 76
  60. M = 77
  61. N = 78
  62. O = 79
  63. P = 80
  64. Q = 81
  65. R = 82
  66. S = 83
  67. T = 84
  68. U = 85
  69. V = 86
  70. W = 87
  71. X = 88
  72. Y = 89
  73. Z = 90
  74.  
  75. Win = [91, 92]
  76. Apps = 93
  77.  
  78. Pad0 = 96
  79. Pad1 = 97
  80. Pad2 = 98
  81. Pad3 = 99
  82. Pad4 = 100
  83. Pad5 = 101
  84. Pad6 = 102
  85. Pad7 = 103
  86. Pad8 = 104
  87. Pad9 = 105
  88. Multiply = 106
  89. Add = 107
  90. Subtract = 109
  91. Decimal = 110
  92. Divide = 111
  93.  
  94. F1 = 112
  95. F2 = 113
  96. F3 = 114
  97. F4 = 115
  98. F5 = 116
  99. F6 = 117
  100. F7 = 118
  101. F8 = 119
  102. F9 = 120
  103. F10 = 121
  104. F11 = 122
  105. F12 = 123
  106.  
  107. NumLock = 144
  108. ScrollLock = 145
  109.  
  110. Collon = 186 # EN-US: ;: PT-BR: çÇ
  111. Equal = 187 # EN-US: =+ PT-BR: =+
  112. Comma = 188 # EN-US: ,< PT-BR: ,<
  113. Underscore = 189 # EN-US: -_ PT-BR: -_
  114. Dot = 190 # EN-US: .> PT-BR: .>
  115. Backslash = 191 # EN-US: /? PT-BR: ;:
  116. Accent = 192 # EN-US: '~ PT-BR: "'
  117. Query = 193 # EN-US: PT-BR: /?
  118. Float = 194 # EN-US: PT-BT: .
  119. LHook = 219 # EN-US: [{ PT-BR: ´`
  120. RBar = 220 # EN-US: \| PT-BR: ]}
  121. RHook = 221 # EN-US: ]} PT-BR: [{
  122. Quote = 222 # EN-US: "' PT-BR: ^~
  123. LBar = 226 # PT-BR: \|
  124.  
  125. Names = {1 => 'Mouse Left', 2 => 'Mouse Right', 3 => 'Cancel',
  126. 4 => 'Mouse Middle', 5 => 'Mouse 4th', 6 => 'Mouse 5th', 8 => 'Backspace',
  127. 9 => 'Tab', 12 => 'Clear', 13 => 'Enter', 16 => 'Shift', 17 => 'Control',
  128. 18 => 'Alt', 19 => 'Pause', 20 => 'Caps Lock', 21 => 'Kana', 23 => 'Junja',
  129. 24 => 'Final', 25 => 'Kanji', 27 => 'Escape', 28 => 'Convert', 29 => 'Non Convert',
  130. 30 => 'Accept', 31 => 'Mode Change', 32 => 'Space', 33 => 'Page Up',
  131. 34 => 'Page Down', 35 => 'End', 36 => 'Home', 37 => 'Left', 38 => 'Up',
  132. 39 => 'Right', 40 => 'Down', 41 => 'Select', 42 => 'Print', 43 => 'Execute',
  133. 44 => 'PrintScreen', 45 => 'Insert', 46 => 'Delete', 47 => 'Help',
  134. 48 => '0', 49 => '1', 50 => '2', 51 => '3', 52 => '4', 53 => '5', 54 => '6',
  135. 55 => '7', 56 => '8', 57 => '9', 65 => 'A', 66 => 'B', 67 => 'C', 68 => 'D',
  136. 69 => 'E', 70 => 'F', 71 => 'G', 72 => 'H', 73 => 'I', 74 => 'J', 75 => 'K',
  137. 76 => 'L', 77 => 'M', 78 => 'N', 79 => 'O', 80 => 'P', 81 => 'Q', 82 => 'R',
  138. 83 => 'S', 84 => 'T', 85 => 'U', 86 => 'V', 87 => 'W', 88 => 'X', 89 => 'Y',
  139. 90 => 'Z', 91 => 'Left Windows', 92 => 'Right Windows', 93 => 'Application',
  140. 95 => 'Sleep', 96 => 'PAD 0', 97 => 'PAD 1', 98 => 'PAD 2', 99 => 'PAD 3',
  141. 100 => 'PAD 4', 101 => 'PAD 5', 102 => 'PAD 6', 103 => 'PAD 7', 104 => 'PAD 8',
  142. 105 => 'PAD 9', 106 => '*', 107 => '+', 108 => 'Separator', 109 => '-',
  143. 110 => '.', 111 => '/', 112 => 'F1', 113 => 'F2', 114 => 'F3', 115 => 'F4',
  144. 116 => 'F5', 117 => 'F6', 118 => 'F7', 119 => 'F8', 120 => 'F9', 121 => 'F10',
  145. 122 => 'F11', 123 => 'F12', 124 => 'F13', 125 => 'F14', 126 => 'F15',
  146. 127 => 'F16', 128 => 'F17', 129 => 'F18', 130 => 'F19', 131 => 'F20',
  147. 132 => 'F21', 133 => 'F22', 134 => 'F23', 135 => 'F24', 144 => 'Number Lock',
  148. 145 => 'Scroll Lock', 146 => 'OEM 15', 147 => 'OEM 16', 148 => 'OEM 17',
  149. 149 => 'OEM 18', 150 => 'OEM 19', 160 => 'Left Shift', 161 => 'Right Shift',
  150. 162 => 'Left Control', 163 => 'Right Control', 164 => 'Left Alt',
  151. 165 => 'Right Alt', 166 => 'Browser Back', 167 => 'Browser Forward',
  152. 168 => 'Browser Refresh', 169 => 'Browser Stop', 170 => 'Browser Search',
  153. 171 => 'Browser Favorites', 172 => 'Browser Home', 173 => 'Volume Mute',
  154. 174 => 'Volume Down', 175 => 'Volume Up', 176 => 'Media Next Track',
  155. 177 => 'Media Previous Track', 178 => 'Media Stop', 179 => 'Media Play Pause',
  156. 180 => 'Launch Mail', 181 => 'Launch Media Select', 182 => 'Launch Application',
  157. 183 => 'Launch Application', 186 => 'OEM 1', 187 => 'OEM 2', 188 => 'OEM 3',
  158. 189 => 'OEM 4', 190 => 'OEM 5', 191 => 'OEM 6', 192 => 'OEM 7', 219 => 'OEM 8',
  159. 220 => 'OEM 9', 221 => 'OEM 10', 222 => 'OEM 11', 223 => 'OEM 13', 225 => 'OEM 20',
  160. 226 => 'OEM 14', 227 => 'OEM 21', 228 => 'OEM 22', 229 => 'Proccess',
  161. 230 => 'OEM 23', 232 => 'OEM 24', 240 => 'OEM 25', 241 => 'OEM 26',
  162. 242 => 'OEM 27', 243 => 'OEM 28', 244 => 'OEM 29', 245 => 'OEM 30', 246 => 'ATTN',
  163. 247 => 'CRSEL', 248 => 'EXSEL', 249 => 'EREOF', 250 => 'Play', 251 => 'Zoom',
  164. 253 => 'PA1', 254 => 'OEM Clear'}
  165.  
  166. Numbers = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
  167. 96, 97, 98, 99, 100, 101, 102, 103, 104, 105]
  168.  
  169. Values = {}
  170.  
  171. Values["ALL"] = {32 => [" "], 49 => ["1", "!"], 50 => ["2", "@"],
  172. 51 => ["3", "#"], 52 => ["4", "$"], 53 => ["5", "%"], 54 => ["6", "¨"],
  173. 55 => ["7", "&"], 56 => ["8", "*"], 57 => ["9", "("], 48 => ["0", ")"],
  174. 65 => ["a", "A"], 66 => ["b", "B"], 67 => ["c", "C"], 68 => ["d", "D"],
  175. 69 => ["e", "E"], 70 => ["f", "F"], 71 => ["g", "G"], 72 => ["h", "H"],
  176. 73 => ["i", "I"], 74 => ["j", "J"], 75 => ["k", "K"], 76 => ["l", "L"],
  177. 77 => ["m", "M"], 78 => ["n", "N"], 79 => ["o", "O"], 80 => ["p", "P"],
  178. 81 => ["q", "Q"], 82 => ["r", "R"], 83 => ["s", "S"], 84 => ["t", "T"],
  179. 85 => ["u", "U"], 86 => ["v", "V"], 87 => ["w", "W"], 88 => ["x", "X"],
  180. 89 => ["y", "Y"], 90 => ["z", "Z"], 96 => ["0"], 97 => ["1"], 98 => ["2"],
  181. 99 => ["3"], 100 => ["4"], 101 => ["5"], 102 => ["6"], 103 => ["7"],
  182. 104 => ["8"], 105 => ["9"], 106 => ["*"], 107 => ["+"], 109 => ["-"],
  183. 110 => [","], 111 => ["/"]}
  184.  
  185. Values["EN-US"] = {186 => [";", ":"], 187 => ["=", "+"], 188 => [",", "<"],
  186. 189 => ["-", "_"], 190 => [".", ">"], 191 => ["/", "?"], 192 => ["'", "~"],
  187. 219 => ["[", "{"], 220 => ["","|"], 221 => ["]", "}"], 222 => ['"', "'"]}
  188.  
  189. Values["PT-BR"] = {186 => ["ç", "Ç"], 187 => ["=", "+"], 188 => [",", "<"],
  190. 189 => ["-", "_"], 190 => [".", ">"], 191 => [";", ":"], 192 => ["'", '"'],
  191. 193 => ["/", '?'], 194 =>["."], 219 => ["´", "`"], 220 => ["]", "}"],
  192. 221 => ["[", "{"], 222 => ['~', "^"], 226 => ["","|"]}
  193.  
  194. def self.name(id)
  195. return (Names.keys.include?(id) ? Names[id] : "???")
  196. end
  197.  
  198. def self.value(id)
  199. if Values["ALL"].keys.include?(id)
  200. return Values["ALL"][id]
  201. elsif Values[Keyboard].keys.include?(id)
  202. return Values[Keyboard][id]
  203. else
  204. return Values["EN-US"][id]
  205. end
  206. end
  207.  
  208. end
  209.  
  210. #------------------------------------------------------------------------------
  211. module Input
  212.  
  213. @time = Array.new(256, 0)
  214. @press = Array.new(256, false)
  215. @trigger = Array.new(256, false)
  216. @repeat = Array.new(256, false)
  217. @release = Array.new(256, false)
  218. @dirs = [0, 0]
  219.  
  220. InputInitialize = Win32API.new("Input", 'InputInitialize', 'LLLLLL', '')
  221. InputUpdate = Win32API.new("Input", 'InputUpdate', '', '')
  222.  
  223. InputInitialize.call(@time.object_id, @press.object_id, @trigger.object_id,
  224. @repeat.object_id, @release.object_id, @dirs.object_id)
  225.  
  226. LEFT = 37
  227. UP = 38
  228. RIGHT = 39
  229. DOWN = 40
  230. A = [160, 161]
  231. B = [27, 88, 96]
  232. C = [13, 32, 90]
  233. X = 65
  234. Y = 83
  235. Z = 68
  236. L = 81
  237. R = 87
  238. SHIFT = 16
  239. CTRL = 17
  240. ALT = 18
  241. F5 = 116
  242. F6 = 117
  243. F7 = 118
  244. F8 = 119
  245. F9 = 120
  246.  
  247. def self.update
  248. InputUpdate.call
  249. end
  250.  
  251. def self.trigger?(id)
  252. @trigger.indexes(*id.to_a).include?(true)
  253. end
  254.  
  255. def self.press?(id)
  256. @press.indexes(*id.to_a).include?(true)
  257. end
  258.  
  259. def self.triggerd?(what)
  260. if triggered.include?(what)
  261. return true
  262. end
  263. end
  264.  
  265. def self.triggered
  266. array = Array.new
  267. @trigger.each_index {|i| array.push(i) if @trigger[i]}
  268. array
  269. end
  270.  
  271. def self.pressed?(what)
  272. if pressed.include?(what)
  273. return true
  274. end
  275. end
  276.  
  277. def self.pressed
  278. array = Array.new
  279. @press.each_index {|i| array.push(i) if @press[i]}
  280. array
  281. end
  282.  
  283. def self.repeat?(id)
  284. @repeat.indexes(*id.to_a).include?(true)
  285. end
  286.  
  287. def self.repeated
  288. array = Array.new
  289. @repeat.each_index {|i| array.push(i) if @repeat[i]}
  290. array
  291. end
  292.  
  293. def self.release?(id)
  294. @release.indexes(*id.to_a).include?(true)
  295. end
  296.  
  297. def self.released
  298. array = Array.new
  299. @release.each_index {|i| array.push(i) if @release[i]}
  300. array
  301. end
  302.  
  303. def self.dir4
  304. return 2 if self.pressed?(DOWN)
  305. return 4 if self.pressed?(LEFT)
  306. return 6 if self.pressed?(RIGHT)
  307. return 8 if self.pressed?(UP)
  308. return 0
  309. end
  310.  
  311. def self.dir8
  312. if self.pressed?(UP)
  313. return 9 if self.pressed?(RIGHT)
  314. return 7 if self.pressed?(LEFT)
  315. return 8
  316. end
  317. if self.pressed?(DOWN)
  318. return 3 if self.pressed?(RIGHT)
  319. return 1 if self.pressed?(LEFT)
  320. return 2
  321. end
  322. return 6 if self.pressed?(RIGHT)
  323. return 4 if self.pressed?(LEFT)
  324. return 0
  325. end
  326.  
  327. end
  328.  
  329. #------------------------------------------------------------------------------
  330. =begin
  331. loop do
  332. Input.update
  333. for i in 0...256
  334. next unless Input.trigger?(i)
  335. p i
  336. end
  337. end
  338. =end
  339.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement