Homebrew GlovePIE Citra script thread, play games (and touchscreen) fully with controllers

jamieyello

Professional Dumbass
OP
Member
Joined
Mar 11, 2013
Messages
385
Trophies
0
XP
556
Country
United States
This thread is a collection of my GlovePIE scripts, as time goes on I'll be adding more and more scripts and updating old ones as new features in Citra are implemented. If you have a suggestion or request for a game you would like to see, let me know. All my scripts are tested on my own 1080p screen, let me know if a script isn't working right at the resolution your screen is at. Currently I cannot test on 4k screens, and I have no idea if my scripts work on them or not.


Instructions;
1) Download GlovePIE (I'm using version 0.45 on Windows 10) Make sure your 360 controller is on before you open GlovePIE.
2) Copy and paste my script into GlovePIE, or open a .PIE file with it.
3) Press run
4) Set Citra to large screen mode (Currently only in the bleeding edge builds)
5) Map the buttons in Citra to this;

Rwd4S1o.png



Scripts

Legend of Zelda: Ocarina of Time -> 360 Controller (Updated 11/7/2016)

D-Pad controls "GEAR" "MAP" "ITEMS" icons
D-Pad down - Ocarina
C-Stick controls item selection
Left Thumb Click to the "VIEW" icon
360 Triggers and Shoulder Buttons are L and R

Copy and paste this into GlovePIE, then press run.
Code:
//Zelda OoT 360 controller to key bindings and touch screen
//Version 1.2

//C-stick deadzone, set higher if automatic presses are happening.
var.DeadZone = 35

var.XMod = Screen.DesktopWidth/1920
var.YMod = var.XMod

//Global J control layout
key.Zero = Xinput.LeftShoulder | (Xinput.LeftTrigger > 0)
key.Five = Xinput.RightShoulder | (Xinput.RightTrigger > 0)
key.Six = Xinput.Y

key.Eight = Xinput.Left
key.Seven = Xinput.Right
key.Nine = Xinput.Down

key.Four = Xinput.Back


//Below is emulated mouse movement and clicking

//360 d-pad to "GEAR" "MAP" "ITEMS" menu icons
//Right to "ITEMS"
if Xinput.Right then {
   //CHANGE THESE X AND Y CORDS TO CLICK WHEREVER YOU WANT!!
   Mouse.CursorPosX = 1800*var.XMod
   Mouse.CursorPosY = 1000*var.YMod
   Mouse.LeftButton = 1
}else {
   Mouse.LeftButton = 0
   key.m = 0
}

//Up to "MAP"
if Xinput.Up then {
   //CHANGE THESE X AND Y CORDS TO CLICK WHEREVER YOU WANT!!
   Mouse.CursorPosX = 1730*var.XMod
   Mouse.CursorPosY = 1000*var.YMod
   Mouse.LeftButton = 1
}else {
   Mouse.LeftButton = 0
   key.m = 0
}

//Left to "GEAR"
if Xinput.Left then {
   //CHANGE THESE X AND Y CORDS TO CLICK WHEREVER YOU WANT!!
   Mouse.CursorPosX = 1670*var.XMod
   Mouse.CursorPosY = 1000*var.YMod
   Mouse.LeftButton = 1
}else {
   Mouse.LeftButton = 0
   key.m = 0
}

//Down to ocarina
if Xinput.Down then {
   //CHANGE THESE X AND Y CORDS TO CLICK WHEREVER YOU WANT!!
   Mouse.CursorPosX = 1560*var.XMod
   Mouse.CursorPosY = 1000*var.YMod
   Mouse.LeftButton = 1
}else {
   Mouse.LeftButton = 0
   key.m = 0
}

//C-stick to item selection
//C-stick up to X slot select
if Xinput.RightStickY > var.DeadZone*0.01 then {
   //CHANGE THESE X AND Y CORDS TO CLICK WHEREVER YOU WANT!!
   Mouse.CursorPosX = 1900*var.XMod
   Mouse.CursorPosY = 830*var.YMod
   Mouse.LeftButton = 1
}else {
   Mouse.LeftButton = 0
   key.m = 0
}

//C-stick left to Y slot select
if Xinput.RightStickX < -var.DeadZone*0.01 then {
   //CHANGE THESE X AND Y CORDS TO CLICK WHEREVER YOU WANT!!
   Mouse.CursorPosX = 1870*var.XMod
   Mouse.CursorPosY = 880*var.YMod
   Mouse.LeftButton = 1
}else {
   Mouse.LeftButton = 0
   key.m = 0
}

//C-stick right to I slot select
if Xinput.RightStickX > var.DeadZone*0.01 then {
   //CHANGE THESE X AND Y CORDS TO CLICK WHEREVER YOU WANT!!
   Mouse.CursorPosX = 1870*var.XMod
   Mouse.CursorPosY = 770*var.YMod
   Mouse.LeftButton = 1
}else {
   Mouse.LeftButton = 0
   key.m = 0
}

//C-stick down to II slot select
if Xinput.RightStickY < -var.DeadZone*0.01 then {
   //CHANGE THESE X AND Y CORDS TO CLICK WHEREVER YOU WANT!!
   Mouse.CursorPosX = 1900*var.XMod
   Mouse.CursorPosY = 1000*var.YMod
   Mouse.LeftButton = 1
}else {
   Mouse.LeftButton = 0
   key.m = 0
}

//Right thumb click to "VIEW" icon
if Xinput.RightThumb then {
   //CHANGE THESE X AND Y CORDS TO CLICK WHEREVER YOU WANT!!
   Mouse.CursorPosX = 1570*var.XMod
   Mouse.CursorPosY = 770*var.YMod
   Mouse.LeftButton = 1
}else {
   Mouse.LeftButton = 0
   key.m = 0
}
Or Download the PIE file (open with GlovePIE)



Kid Icarus: Uprising


Kid Icarus: Uprising -> 360 Controller/Mouse (NEW 11/7/2016)

(This script is meant to be played in areas at full speed and will likely glitch out if played in laggy areas. If you want to change the script to run better in laggy areas, ctrl+f and search for "glovepie.FrameRate = 120", and lower the number until the jumpiness goes away. (Will also lower precision.) The fastest running area I've found in the game is the training area on the ground.)

Shoulder buttons - switch active power
Left Trigger - Use active power
Right Trigger/A - Shoot
Right Joystick - Aim reticle
Press P or (360) X to toggle mouse lock controls
Press O or (360) Back button to toggle flight mode controls
Press Escape to end script

Copy and paste this into GlovePIE, then press run.
Code:
//360 controller/Mouse to touchscreen drag control template by jamieyello
//Version 1.2

//Limitations of this version;
//    - The left mouse button is being used to aim on the bottom screen, so it
//      can't be used to shoot or anything else.
//    - Calculating the direct location of the touch screen is iffy due to Citra
//      having no x/y touchscreen touch mapping.
//    - Lack of mouse clicks and multiple keys on one input mapping in Citra
//      means additional temporary controls in GlovePIE. It also makes
//      simultaneous mouse/keyboard and 360 controls impossible.

//This script will be completed when Citra adds the following;
//    - Multiple button mappings per input (From different input devices)
//    - Button mapping from left click
//    - Button mapping for touch screen touch and x/y position

//Press P or (360) X to toggle mouse lock controls
//Press O or (360) Back button to toggle flight mode controls
//Press Escape to end script

//Temporary Citra controls------------------------------------------------------
//Because mouse clicks and multiple keys on one input can't be mapped in Citra,
//Some specific mapping here is recommended.

//Set the 3ds L button in Citra to the 0 key.
key.Zero = Mouse.RightButton or (XInput.RightTrigger > 0)

//Set the D-Pad DOWN key in Citra to the 9 key.
key.Nine = Mouse.MiddleButton or XInput.Down or (Xinput.LeftTrigger > 0)

//Set the D-Pad LEFT key in Citra to the 8 key.
key.Eight = Mouse.WheelUp or Xinput.Left or Xinput.LeftShoulder

//Set the D-Pad RIGHT key in Citra to the 7 key.
key.Seven = Mouse.WheelDown or Xinput.Right or Xinput.RightShoulder

//Set the 3ds X button to the 6 key.
key.Six = Xinput.Y or XInput.RightThumb

//Un-map the SELECT button in Citra.
//Un-map the R button in Citra.

//------------------------------------------------------------------------------

//Set this to 1 to enable 360 controller reticle timeout. Enabling lets you use
//KI:U's natural camera when not aiming with the 360 joystick, but may interfere
//with staff aiming. Recommended you leave this off atm. If you decide to enable
//it, you should make sure var.FireButton is mapped to whatever you use to shoot
//to prevent timeout while shooting. Default is 0.
var.ReticleTimeOutToggle = 0
var.FireButton = key.A

//End script if Escape is pressed
Shift+P+I+E = key.escape

//Toggle mouse control script if P or 360 X is pressed
if clicked(key.p) or clicked(xinput.x) then {
   var.disable = not var.disable
   if var.disable then mouse.leftbutton = 0
}

//Toggle flying mode controls, feel free to delete or comment out the lines with
//the "say" text-to-speech commands.
if clicked(xinput.back) or clicked(key.O) then {
   var.FlyingMode = not var.FlyingMode
   if var.FlyingMode then {
      say("Flying mode on.")
   } else {
      say("Flying mode off.")
   }
}

//360 auto controls, auto turn mouse lock on if right joystick is moved, turn
//off if 360 Start is pressed. Enable "360 inactive mouse lift" mode if joystick
//is moved.
if (abs(Xinput.RightStickX) || abs(Xinput.RightStickY)) > (var.ControllerDeadzone * 0.01) then {
   var.disable = 0
   var.MouseLiftMode = 1
}
if Xinput.Start then {
   var.disable = 1
   mouse.leftbutton = 0
}

//
//
//
//
//

//Initialization run once startup code.
if not var.Init {
   //8 set as default, higher is faster, but will increase chance of reticle
   //jumping. Recommended that you modify this in-game instead.
   var.ControllerSensitivity = 8

   //0.5 is the default, raising increases chance of reticle jumping.
   //Recommended that you modify this in-game instead.
   var.MouseSensitivity = 0.5

   //23 recommended, higher is a larger deadzone. Raise if your reticle is
   //moving on it's own, higher means lower precision though.
   var.ControllerDeadzone = 23

   //-1 is off, set to 1 to invert camera. Default is -1.
   var.InvertYCamera = -1

   //GlovePIE script refresh rate (per second). Default is 120.
   glovepie.FrameRate = 120

   //Inactive reticle timeout for the 360 controller (when the option above is
   //toggled) (on mouse mode it never times out) Default is 120 (120 = 1 second)
   var.ReticleTimeOut = 120

   //Touch screen position variables.
   var.BoxXPos = screen.DesktopWidth - (380 * screen.DesktopWidth/1920)
   var.BoxyPos = screen.DesktopHeight - ((340 + (screen.DesktopWidth / screen.DesktopHeight <= 4/3 )*80) * screen.DesktopHeight/1080)
   var.BoxXSize = 387 * screen.DesktopWidth/1920
   var.BoxYSize = 250 * screen.DesktopHeight/1080

   var.BoxXCenter = var.BoxXPos + var.BoxXSize/2
   var.BoxYCenter = var.BoxYPos + var.BoxYSize/2

   //How long the mouse lift action takes before recentering and clicking again.
   //Raise if the screen is jumping around, but that will lower precision.
   //Default is 4.
   var.LimitRefresh = 4

   //Variable to prevent the initialization from happening again.
   var.Init = 1
}

if not var.disable {
   mouse.swallow = 1

   //Emulate the mouse, with itself, giving glovepie better control of it.
   var.MouseMX = mouse.DirectInputX - var.MouseMXLast
   var.MouseMXLast = mouse.DirectInputX

   var.SetX += var.MouseMX * var.MouseSensitivity

   var.MouseMY = mouse.DirectInputY - var.MouseMYLast
   var.MouseMYLast = mouse.DirectInputY

   var.SetY += var.MouseMY * var.MouseSensitivity

   //Disable "360 inactive mouse lift" if mouse movement is detected.
   if (abs(var.MouseMX) | abs(var.MouseMY)) > 0 then var.MouseLiftMode = 0

   if var.ReticleTimeOutToggle and var.MouseliftMode and not var.FireButton and not var.FlyingMode and not (abs(Xinput.RightStickX) || abs(Xinput.RightStickY)) > (var.ControllerDeadzone * 0.01) then {
      var.MouseLiftSkip += 1
   } else {
      var.MouseLiftSkip = 0
   }

   //360 controllers will move the mouse as well.
   if abs(XInput.RightStickX) > var.ControllerDeadzone * 0.01 then {
      var.SetX += xinput.RightStickX * abs(xinput.RightStickX) * var.ControllerSensitivity
   }

   if abs(XInput.RightStickY) > var.ControllerDeadzone * 0.01 then {
      var.SetY += var.InvertYCamera * xinput.RightStickY * abs(xinput.RightStickY) * var.ControllerSensitivity
   }

   //Script to keep mouse in bounds.
   if var.MouseLift == 0 and (var.MouseLiftSkip < var.ReticleTimeOut) then {
      mouse.LeftButton = 1
      if var.SetX < var.BoxXPos then {
         if var.Flyingmode then {
            var.SetX = var.BoxXPos
         } Else {
            mouse.LeftButton = 0
            var.SetX = var.BoxXCenter
            var.SetY = var.BoxYCenter
            var.MouseLift = 1
         }
      }

      if var.SetX > var.BoxXPos + var.BoxXSize then {
         if var.Flyingmode then {
             var.SetX = var.BoxXPos + var.BoxXSize
         } Else {
            mouse.LeftButton = 0
            var.SetX = var.BoxXCenter
            var.SetY = var.BoxYCenter
            var.MouseLift = 1
         }
      }

      if var.SetY < var.BoxYPos then {
         if var.Flyingmode then {
            var.SetY = var.BoxYPos
         } Else {
            mouse.LeftButton = 0
            var.SetX = var.BoxXCenter
            var.SetY = var.BoxYCenter
            var.MouseLift = 1
         }
      }

      if var.SetY > var.BoxYPos + var.BoxYSize then {
         if var.Flyingmode then {
            var.SetY = var.BoxYPos + var.BoxYSize
         } Else {
            mouse.LeftButton = 0
            var.SetX = var.BoxXCenter
            var.SetY = var.BoxYCenter
            var.MouseLift = 1
         }
      }

   } else {
      if not (var.MouseLiftSkip < var.ReticleTimeOut) {
         var.MouseLiftSkip = var.ReticleTimeOut
         mouse.LeftButton = 0
      }

      if not (var.MouseLift == 0) then {
         if var.MouseLift > var.LimitRefresh {
            var.mouselift = 0
            mouse.LeftButton = 0
         } else {
           var.MouseLift += 1
         }
      }
   }

   mouse.CursorPosX = var.SetX
   mouse.CursorPosY = var.SetY
} else {
   mouse.Swallow = 0
}
Or Download the PIE file (open with GlovePIE)
 

Attachments

  • jamieyello_GlovePIE_scripts_v1_2.zip
    16 KB · Views: 901
Last edited by jamieyello,

jamieyello

Professional Dumbass
OP
Member
Joined
Mar 11, 2013
Messages
385
Trophies
0
XP
556
Country
United States
oh wow a way to actually play kid icarus?
Yup, I figured it would be next to literally impossible to actually play that game on Citra without a script of some kind so I made one, it being my favorite game and all. Also OoT because I find going from controller to bending over to the mouse really annoying.
 

Kionea

Well-Known Member
Newcomer
Joined
Jan 5, 2014
Messages
79
Trophies
1
Age
27
XP
175
Country
United States
Sorry to revive an old thread, but I've got a somewhat unique set up with my controller. I'm using a DirectInput (wireless, can't get Xinput to work, yada yada) and mapping the buttons to keyboard keys. I'm completely unfamiliar with GlovePIE, so how how would I go about editing your script to fit my controller? Just replace all the Xinput prompts with the keyboard keys I want them to be?

As a side note, the latest bleeding edge build disabled all mapping of CPP buttons which means that could become a permanent thing soon. Dunno if that's an issue, but it seemed important to mention.
 
Last edited by Kionea,

jamieyello

Professional Dumbass
OP
Member
Joined
Mar 11, 2013
Messages
385
Trophies
0
XP
556
Country
United States
Sorry to revive an old thread, but I've got a somewhat unique set up with my controller. I'm using a DirectInput (wireless, can't get Xinput to work, yada yada) and mapping the buttons to keyboard keys. I'm completely unfamiliar with GlovePIE, so how how would I go about editing your script to fit my controller? Just replace all the Xinput prompts with the keyboard keys I want them to be?

As a side note, the latest bleeding edge build disabled all mapping of CPP buttons which means that could become a permanent thing soon. Dunno if that's an issue, but it seemed important to mention.
Go ahead and bump all you want, I'm waiting for Citra to add a few features before I bring back this topic, so it's only dead for now. I'm actually waiting until I can map to X and Y touch screen coordinates. Actually, I kind of just want to be able to run scripts in Citra. I'll make my own build that does that some day.

So, you might be able to get it to work just in glovepie by itself. Go to the GUI tab - Detect Output to Emulate, mash the button you want and see if it detects it. Yeah, you'd have to rename a lot of things, but as long as you map them right it should work the same.
 

Kionea

Well-Known Member
Newcomer
Joined
Jan 5, 2014
Messages
79
Trophies
1
Age
27
XP
175
Country
United States
Go ahead and bump all you want, I'm waiting for Citra to add a few features before I bring back this topic, so it's only dead for now. I'm actually waiting until I can map to X and Y touch screen coordinates. Actually, I kind of just want to be able to run scripts in Citra. I'll make my own build that does that some day.

So, you might be able to get it to work just in glovepie by itself. Go to the GUI tab - Detect Output to Emulate, mash the button you want and see if it detects it. Yeah, you'd have to rename a lot of things, but as long as you map them right it should work the same.

Cool. I'll try it out.
 

yashua

New Member
Newbie
Joined
Feb 1, 2019
Messages
1
Trophies
0
Age
42
XP
44
Country
India
hey jamieyellow, I really wanted to use my right joystick for the touchscreen in citra but whenever I run your script I get this error in the snippet contained with my attachment. I'm using a ds3 remote registered as xinput.
 

Attachments

  • icarus.PNG
    icarus.PNG
    40.4 KB · Views: 352

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    Maximumbeans @ Maximumbeans: butte