Complete XBox Controller Script

Have trouble running Grimrock 1 or you're wondering if your graphics card is supported? Look for help here.
Post Reply
Lemny
Posts: 2
Joined: Wed Apr 11, 2012 11:16 am

Complete XBox Controller Script

Post by Lemny »

Because I love playing PC Games in my living room like on my XBox and PS3, I made a script for full XBox Controller support:
Use this in GlovePIE... feel free to modify to your needs.
Its designed for Full HD Resolution (1920 x 1080)

Layout:

Left stick = move/turn
Shoulder bottons = strafe
Right stick = Mousepointer
Trigger left/right = Mousebuttons left/right

A = Attack (all 4 Chars will attack)
Y = Cast Mode (use right stick to select runes / click for center rune)
B = Cast spell in cast mode

Digipad = Inventory of the Chars
Back = Map
Start = Menu
LeftStickClick = Quicksave

Code: Select all

var.dz = 0.3

if xinput.B and var.cast then
  var.cast = false
  mouse.CursorPosX = 1860 pixels
  mouse.CursorPosY = 1024 pixels
  wait 0.05
  mouse.RightButton = true
  wait 0.01
  mouse.RightButton = false
  wait 0.1
endif

if xinput.Y then

 [var.r, var.g, var.b] = ScreenPixel(1860 pixel,1024 pixel)
 var.cast = var.r < 0.5
 wait 0.1

 if var.cast then
  mouse.CursorPosX = 1820 pixels
  mouse.CursorPosY = 1020 pixels
  wait 0.05
  mouse.RightButton = true
  wait 0.01
  mouse.RightButton = false
  wait 0.1
  mouse.CursorPosX = 1770 pixels
  mouse.CursorPosY = 995 pixels
 endif

 if not var.cast then
  mouse.CursorPosX = 1860 pixels
  mouse.CursorPosY = 950 pixels
  wait 0.05
  mouse.RightButton = true
  wait 0.01
  mouse.RightButton = false
  wait 0.1
  mouse.CursorPosX = 1920 pixels
  mouse.CursorPosY = 1080 pixels
 endif

 [var.r, var.g, var.b] = ScreenPixel(1860 pixel,1024 pixel)
 var.cast = var.r < 0.5
 wait 0.1

endif

if not var.cast then
   if xinput.Joy2X > var.dz then mouse.x = mouse.x + ((xinput.Joy2X - var.dz) / 30)
   if xinput.Joy2X < -var.dz then mouse.x = mouse.x + ((xinput.Joy2X + var.dz) / 30)
   if xinput.Joy2Y > var.dz then mouse.y = mouse.y - ((xinput.Joy2Y - var.dz) / 30)
   if xinput.Joy2Y < -var.dz then mouse.y = mouse.y - ((xinput.Joy2Y + var.dz) / 30)
endif

if var.cast then
   if xinput.RightThumb then
     mouse.CursorPosX = 1770 pixels
     mouse.CursorPosY = 995 pixels
     wait 0.05
     mouse.RightButton = true
     wait 0.01
     mouse.RightButton = false
     wait 0.2
   endif

   if (abs(xinput.Joy2X) > var.dz) and (abs(xinput.Joy2Y) > var.dz) then
   mouse.CursorPosX = (1770 + (sign(xinput.Joy2X) * 45));
   mouse.CursorPosY = (995 - (sign(xinput.Joy2Y) * 45));
     wait 0.05
     mouse.RightButton = true
     wait 0.01
     mouse.RightButton = false
     wait 0.2
   endif

   if (abs(xinput.Joy2X) > var.dz * 2) and (abs(xinput.Joy2Y) < var.dz) then
   mouse.CursorPosX = (1770 + (sign(xinput.Joy2X) * 45));
   mouse.CursorPosY = (995);
     wait 0.05
     mouse.RightButton = true
     wait 0.01
     mouse.RightButton = false
     wait 0.2
   endif

   if (abs(xinput.Joy2Y) > var.dz * 2) and (abs(xinput.Joy2X) < var.dz) then
   mouse.CursorPosX = (1770);
   mouse.CursorPosY = (995 - (sign(xinput.Joy2Y) * 45));
     wait 0.05
     mouse.RightButton = true
     wait 0.01
     mouse.RightButton = false
     wait 0.2
   endif

endif

mouse.LeftButton = xinput.RightTrigger > 0.5
mouse.RightButton = xinput.LeftTrigger > 0.5

key.q = (xinput.Joy1X < -0.4)
key.e = (xinput.Joy1X > 0.4)
key.s = (xinput.Joy1Y < -0.4)
key.w = (xinput.Joy1Y > 0.4)
key.a = xinput.LeftShoulder
key.d = xinput.RightShoulder

key.tab = xinput.Back
key.esc = xinput.Start

key.f5 = xinput.LeftThumb

key.1 = xinput.up
key.2 = xinput.right
key.3 = xinput.Left
key.4 = xinput.down

if xinput.a then

 mouse.CursorPosX = 1620 pixels
 mouse.CursorPosY = 840 pixels
 wait 0.05
 mouse.RightButton = true
 wait 0.01
 mouse.RightButton = false
 wait 0.01

 mouse.CursorPosX = 1820 pixels
 wait 0.05
 mouse.RightButton = true
 wait 0.01
 mouse.RightButton = false
 wait 0.01

 mouse.CursorPosX = 1620 pixels
 mouse.CursorPosY = 1020 pixels
 wait 0.05
 mouse.RightButton = true
 wait 0.01
 mouse.RightButton = false
 wait 0.01

endif
Post Reply