Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!

XControls Class - GTA iV

By: julioCCs on Jun 4th, 2013  |  syntax: VB.NET  |  size: 2.18 KB  |  views: 155  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. 'http://gtaxscripting.blogspot.com/
  2. 'http://www.facebook.com/GtaIVScripting
  3. 'https://www.youtube.com/user/GTAScripting
  4.  
  5. Imports GTA
  6.  
  7. Public Class XControls
  8.     Public leftSitck_x, leftSitck_y, rightStick_x, rightStick_y As Native.Pointer
  9.  
  10.     Public BUTTON_BACK As Int16 = 13
  11.     Public BUTTON_START As Int16 = 12
  12.     Public BUTTON_X As Int16 = 14
  13.     Public BUTTON_Y As Int16 = 15
  14.     Public BUTTON_A As Int16 = 16
  15.     Public BUTTON_B As Int16 = 17
  16.     Public BUTTON_DPAD_UP As Int16 = 8
  17.     Public BUTTON_DPAD_DOWN As Int16 = 9
  18.     Public BUTTON_DPAD_LEFT As Int16 = 10
  19.     Public BUTTON_DPAD_RIGHT As Int16 = 11
  20.     Public BUTTON_TRIGGER_LEFT As Int16 = 5
  21.     Public BUTTON_TRIGGER_RIGHT As Int16 = 7
  22.     Public BUTTON_BUMPER_LEFT As Int16 = 4
  23.     Public BUTTON_BUMPER_RIGHT As Int16 = 6
  24.     Public BUTTON_STICK_LEFT As Int16 = 18
  25.     Public BUTTON_STICK_RIGHT As Int16 = 19
  26.  
  27.     Public PacketNumber As Int32 = 0
  28.  
  29.     Public Sub New()
  30.         leftSitck_x = New Native.Pointer(GetType(Int32))
  31.         leftSitck_y = New Native.Pointer(GetType(Int32))
  32.         rightStick_x = New Native.Pointer(GetType(Int32))
  33.         rightStick_y = New Native.Pointer(GetType(Int32))
  34.  
  35.         leftSitck_x.SetValue(0)
  36.         leftSitck_y.SetValue(0)
  37.         rightStick_x.SetValue(0)
  38.         rightStick_y.SetValue(0)
  39.  
  40.         PacketNumber = 1
  41.     End Sub
  42.  
  43.     Public Function usingController() As Boolean
  44.         Return Native.Function.Call(Of Boolean)("IS_USING_CONTROLLER")
  45.     End Function
  46.  
  47.     Public Sub UpdateAnalogueSticksData(Optional control_number As Int16 = 0)
  48.         If usingController() AndAlso (PacketNumber > 0) Then _
  49.             Native.Function.Call("GET_POSITION_OF_ANALOGUE_STICKS", control_number, leftSitck_x, leftSitck_y, rightStick_x, rightStick_y)
  50.     End Sub
  51.  
  52.     Public Function isButtonDown(button As Int16, Optional control_number As Int16 = 0) As Boolean
  53.         If usingController() Then
  54.             PacketNumber += 1
  55.  
  56.             If PacketNumber > 9999 Then PacketNumber = 0
  57.  
  58.             Return Native.Function.Call(Of Boolean)("IS_BUTTON_PRESSED", control_number, button)
  59.         Else
  60.             Return False
  61.         End If
  62.     End Function
  63. End Class