Streaming game development: https://www.twitch.tv/stabyourself Image

[MOD][1.6] 2 Mice multiplayer on single PC (Windows only)

Mods, guides how to use and install mods go right in here.
fakeuser
User avatar
Posts: 135
Joined: 04 Mar 2012, 01:20
Reputation: 0

Post » 11 Mar 2012, 17:40

2 mice multiplayer on single PC
And yes, this is not a joke. It's the end product of this topic (thanks, ducharles)
What is needed is stated there, but I'll try to make a detailed tutorial here as well.

Image

Latest standalone versions:

Latest releases of packages for loaders
Mod Loader packages:
Mario Modding System packages:


Features:
  • Now second mouse is exchanged with crosshair while in game window. And yes, it should not be flashy. And yes, you may change it. It is located in the graphics subfolder of your game (if you are using the standalone) or in the graphics subfolder of 2MiceMod folder (for loader users).
  • Now premade packages available to be loaded with Mod Loader and Mari0 Modding System. Details are found under standalone install instructions (meaning bottom of post). 2 mice multiplayer is actually compatible with ANY mod that does not modify mario:updateangle method of base game. If you do not know how to load it without using mod loader, feel free to ask for help. It's as easy as downloading one premaid pack and adding one line of code.
  • Now F12 captures (or releases) both cursors in the game
  • You get two cursors only if Mari0 window is focused! (it's sometimes buggy. If you get two cursors no matter which window is focused, try editing the .bat file with Notepad and removing the "/run /tray" part. This way script will be loaded but you will have to run it manually.)
  • Laptop users may use one external mouse and onboard device or two external mice (detected automatically)
  • Support for two mice point and shoot interface.

Changelog
  • 18 March 2012 in version 2.3 the second (fake) Cursor is exchanged with new crosshair. You may change it, but please, use 16x16 image. The pointer is in the center of the used image.
  • 17 March 2012 Mari0 1.6 is now supported. You know where to grab the new release.
  • 16 March 2012 Mari0 1.5 is now supported. Standalone version of the mod may be grabbed from latest release section of this post. Loader packages are not changed but they support 1.5 version of the game. It's up to loaders' authors when their mods will support Mari0 1.5
  • later on 12 March 2012 v2.2 - thanks to xPi's idea and code, and to TiagoTiago's demand, F12 now captures both real and fake cursors.
  • 12 March 2012 v2.1 - thanks to user comments - no more "do not move the window" rule + 2 cursors only if you have mari0 on focus
  • later on 11 March 2012 v2 - improved game logic
  • 11 March 2012 v1 - First mod. Bugged and lame
It wasn't supposed to be like firefox constant updates but...

General Info
This is a minor modification of the original code. It allows you to use two mice for two different characters in mari0, both of wich have point and shoot controls either with one of the mice. It uses PPJoy virtual joysticks driver and GlovePIE programmable emulator, so it's windows only solution. The main idea is reading two mice values and emulating two joysticks with axes. Code modification allows you to have point and click by recalculating the click point. However you will have to leave the game window centered and not move it (The "do not move the window" rule is back again). Laptop users with onboard pointing device or touchpad - I have your back covered. You may use onboard and one external mouse, or two external mice instead. However if you have two (or even more?) onboard mouse equivalents you will have to manually mod the pie script


Installing as standalone mod

Prerequisites
  1. Download PPJoy. You may use the download link in their blog or install a newer version if you find one. The linked installer can bypass windows 7x64 mandatory driver signing
  2. Download GlovePIE. Yeah, we all know that their site has been hacked, but xPi stated that the direct download still works (click here). If you do not believe that hackers did not change the executable, read the linked topic or use google
  3. Download love2d. You need version 0.8.0 (if you don't have it already). You may grab the latest windows build from here
  4. Download my mod(Link for Mari0 1.4 version is provided in the latest standalone releases above). It's mari0 1.4 with a little modification in mario.lua > mario:updateangle(). You may find my modifications by searching for fakeuser in the comments. The linked file contains emulator configurations and batch scripts, so just posting the code won't do for you.

Installing 3rd party software
  1. The hardest part - installing PPjoy. If you are running windows 7 with mandatory signing, you will have to follow the next steps:
    1. open an elevated command propt (Start button > type cmd > right click the search result > Open as administrator)
    2. type

      Code: Select all

      bcdedit -set testsigning on
    3. You should get a succeffully passed operation message. Reboot your OS. You should get a "Test mode Windows 7 Build x" text in the lower right corner of your desktop. Bear with it, as you need this testing mode to use the PPJoy drivers
  2. Now launch PPJoy installer and confirm that you want to install drivers even though windows is not the author (if asked).
  3. Install GlovePIE. Nothing really special here...
  4. Install Love. Easy

Preconfigs
  • Configure two joysticks. You may do this with launching Start > PPjoy joystick Driver > Configure Joysticks or from Control Panel. If you're too lazy to folow the attached doc in the linked forum in the linked topic, here's what you have to do:
    1. Click Add. Leave default options for virtual joysticks even if they are not greyed out. Add two controllers
    2. Select one of them and click mapping. Choose Set a custom mapping for this controller
    3. Choose 2 axes, 10 Buttons and 0 hats. Leave default names. Click Finish
    4. Do the same for the other controller. Click Done.
  • Add Love to system path. What does this mean?! doh...
    1. Right click My computer Icon and Click properties
    2. Find and click Advanced system settings
    3. Click Environment variables. Under the system variables part of the window search for PATH (ignoring the case differences), select it and click edit
    4. DO NOT DELETE ANYTHING. Just go to the end of the string, add a semicolon (;)and add the path to the folder in wich is located love.exe (e.g. C:\Program Files (x86)\LOVE)
    5. Click OK everywhere
  • Add GlovePIE to system path (Do the same for GlovePIE.exe directory)

What a long tutorial... Almost done though
Apply the mod
  1. Open the downloaded zip file (yes! finally the mod itself)
  2. Extract all the files where your mari0_1.4.exe is.
  3. You should end up with a structure like this

    Code: Select all

    -pie
    +----mari0.pie
    +----mari0_2mice.pie
    -mari0_1.4.exe
    -mari0_1.4_coop.love
    -single_mouse_coop.bat
    -two_mice_coop.bat
    -Dll files

Post configs
Please reboot for all changes to be applied. This is windows after all...
And.. Thats it, you're ready. Do not forget to attach second mouse or else you will have to restart the pie script. Launch the two_mice_coop.bat. It should launch the mari0_1.4_coop.love (the moded game) and the GlovePIE emulator with two mice script - minimized to system tray. If you are running Vista or above it will be asking for admin permissions (probably in the background o.O). Be sure to grant them. If all went well you should get an extra cursor with number 2 in its lower right corner. Configure mari0 so none of the players is mouse owner - you see cursors, but mari0 sees two joysticks. When setting the AimX and AimY be sure to move the mouse in right (for x) and up (for y). After you've closed the game be sure to stop the pie script - open GlovePIE (it's still minimized to the system tray) and quit it. You should use your false mouse to do that. Why? Read the documentation of GlovePIE. Or simply - the other one will not do.

There was a bonus mentioned. What is it?!
I've packed my two-player pie script for single mouse. It's not as cool, but works if you have only one mouse. You may launch it with single_mouse_coop.bat. It however does not use the moded game and executes the original mari0_1.4.exe, so if you have renamed it or use source distribution, then you will have to manually edit the batch file. I believe you can.
Note:You should set one of the players as mouse owner and configure the other with the 2mice script. Then you may use / and * to increase and decrease the angle of the portal gun and as well control the rotation step with Del and Insert. These mappings may be changed in the pie script.



Installing with available mod system
Currently premade packages for Mod Loader and Mari0 Modding System are available. To use them:
  1. Follow all steps above before Apply the mod part.
  2. Download the appropriate package:
  3. both are zip files that contain a folder named 2MiceMod. Extract this folder at
    • %appdata%/LOVE/mari0/customentities/ for Mod Loader
    • %appdata%/LOVE/mari0/mods/ for Mari0 Modding System
    %appdata% = C:\Users\[You user name]\AppData\Roaming for Win 7; C:\Documents and Settings\[Your user name]\Application Data for XP
  4. Open folder 2MiceMod and locate mari0_2mice.pie. Copy (or cut) this file to location you will remeber.
  5. Run glovePIE manually. File > Open > locate mari0_2mice.pie and open it.
  6. Run game from your mod loader .love file
  7. Hit Run button in GlovePIE
  8. Play. Remeber to attach the second mouse...

Bonus: Getting script to work with random compatible mod
  1. Follow above steps for one of the modpacks. Let's say you will use package made for Mod loader
  2. Get your mod source files (it's .love file), open it with WinZip or similar program, extract main.lua and open it with text editor (Notepad)
  3. Find the code

    Code: Select all

       require "musicloader"
       
       http = require("socket.http")
       http.TIMEOUT = 1
       
       love.filesystem.setIdentity("mari0")
  4. change it to

    Code: Select all

       require "musicloader"
       
       http = require("socket.http")
       http.TIMEOUT = 1
       
       require "customentities/2MiceMod/mario_2mice_patch"
       
       love.filesystem.setIdentity("mari0")
  5. save main.lua and get it back in the love file (using... WinZip?) and overwrite the old one. Close the archive
  6. Proceed with starting glovepie, loading the pie script and launching the game from your mod
Last edited by fakeuser on 18 Mar 2012, 01:47, edited 11 times in total.

fakeuser
User avatar
Posts: 135
Joined: 04 Mar 2012, 01:20
Reputation: 0

Post » 11 Mar 2012, 19:05

Updated
I have reviewed my code and found how dumb was I early in the morning. Now it's fixed and you should redownload it. Replacing the .love file with the new one will do.

Changes: Calculating coordinats of fake mice
Consequences: If you have already tested the previous version. you will have to remap your keys because of changed logic. Axes x should be positive and axes y should be negative, meaning move the mouse right and up when mapping.

Edit:
An example for mapping (just to show how axes should be mapped)
Image

P.s. If someone has a better idea for filehosting, I'm waitng

TiagoTiago
Posts: 101
Joined: 05 Mar 2012, 07:44
Reputation: 0

Post » 12 Mar 2012, 01:32

Alright, i tweaked the 2 players script a bit

Code: Select all

If (Window.Title == "Mari0") Then

// Modded version of MouseParty.pie
// The real cursor is now only controlled by mouse 1 or mouse 3 if present

mouse.Swallow = true
cursor.Visible = true

var.ActiveAreaLeft =  Window.Left
var.ActiveAreaTop = (Window.Top + Window.Height) - Window.ClientHeight
var.ActiveAreaRight = Window.Left + window.Width
var.ActiveAreaBottom = Window.Top + Window.Height
//laptop bypass for two externa mice by fakeuser
if mouse3.present then
    // How much has mouse 3 moved?
    var.deltax1 = Delta(mouse3.DirectInputX)
    var.deltay1 = Delta(mouse3.DirectInputY)

    // Mouse ballistics attempt
    var.velocity = ([(smooth(var.deltaX1) / 24ms) in inches per second, (smooth(var.deltaY1) / 24ms) in inches per second] )
    var.speed = |var.velocity|
    if var.speed <= 0.2 then
       var.deltax1 = var.deltax1 * 2
       var.deltay1 = var.deltay1 * 2
    endif
    if var.speed > 0.2 and var.speed <= 0.4 then
      var.deltax1 = var.deltax1 * 4
      var.deltay1 = var.deltay1 * 4
    endif
    if var.speed > 0.4 and var.speed <= 1.25 then
       var.deltax1 = var.deltax1 * 7
       var.deltay1 = var.deltay1 * 7
    endif
    if var.speed > 1.25 and var.speed <= 3.9 then
       var.deltax1 = var.deltax1 *12 //* 7
       var.deltay1 = var.deltay1 *12 //* 7
    endif
    if var.speed > 3.9 then
       var.deltax1 = var.deltax1 * 20// * 13.77
       var.deltay1 = var.deltay1 * 20// * 13.77
    endif

   var.mouse1x = EnsureRange((var.mouse1x in pixels) + (var.deltax1 in pixels), var.ActiveAreaLeft, var.ActiveAreaRight)
   var.mouse1y = EnsureRange((var.mouse1y in pixels) + (var.deltay1 in pixels), var.ActiveAreaTop, var.ActiveAreaBottom)
   mouse.CursorPosX = var.mouse1x  in pixels
   mouse.CursorPosY = var.mouse1y  in pixels

   mouse.LeftButton = mouse3.LeftButton
   mouse.RightButton = mouse3.RightButton
   mouse.MiddleButton = mouse3.MiddleButton
   mouse.XButton1 = mouse3.XButton1
   mouse.XButton2 = mouse3.XButton2
//end bypass
else
     // How much has mouse 1 moved?
    var.deltax1 = Delta(mouse1.DirectInputX)
    var.deltay1 = Delta(mouse1.DirectInputY)

    // Mouse ballistics attempt
    var.velocity = ([(smooth(var.deltaX1) / 24ms) in inches per second, (smooth(var.deltaY1) / 24ms) in inches per second] )
    var.speed = |var.velocity|
    if var.speed <= 0.2 then
       var.deltax1 = var.deltax1 * 2
       var.deltay1 = var.deltay1 * 2
    endif
    if var.speed > 0.2 and var.speed <= 0.4 then
      var.deltax1 = var.deltax1 * 4
      var.deltay1 = var.deltay1 * 4
    endif
    if var.speed > 0.4 and var.speed <= 1.25 then
       var.deltax1 = var.deltax1 * 7
       var.deltay1 = var.deltay1 * 7
    endif
    if var.speed > 1.25 and var.speed <= 3.9 then
       var.deltax1 = var.deltax1 *12 //* 7
       var.deltay1 = var.deltay1 *12 //* 7
    endif
    if var.speed > 3.9 then
       var.deltax1 = var.deltax1 * 20// * 13.77
       var.deltay1 = var.deltay1 * 20// * 13.77
    endif

   var.mouse1x = EnsureRange((var.mouse1x in pixels) + (var.deltax1 in pixels), var.ActiveAreaLeft, var.ActiveAreaRight)
   var.mouse1y = EnsureRange((var.mouse1y in pixels) + (var.deltay1 in pixels), var.ActiveAreaTop, var.ActiveAreaBottom)
   mouse.CursorPosX = var.mouse1x in pixels
   mouse.CursorPosY = var.mouse1y in pixels


    mouse.LeftButton = mouse1.LeftButton
    mouse.RightButton = mouse1.RightButton
    mouse.MiddleButton = mouse1.MiddleButton
    mouse.XButton1 = mouse1.XButton1
    mouse.XButton2 = mouse1.XButton2
endif

// Show a fake cursor 2
if mouse2.present but not var.shown2 then
  cursor2.visible = true
  var.Mouse2x = mouse.CursorPosX
  var.Mouse2y = mouse.CursorPosY
  var.shown2 = true
endif
// Do mouse pointer 2
if mouse2.present then
  // How much has mouse 2 moved?
  var.deltax2 = Delta(mouse2.DirectInputX)
  var.deltay2 = Delta(mouse2.DirectInputY)

  // Mouse ballistics attempt
  var.velocity = ([(smooth(var.deltaX2) / 24ms) in inches per second, (smooth(var.deltaY2) / 24ms) in inches per second] )
  var.speed = |var.velocity|
  if var.speed <= 0.2 then
    var.deltax2 = var.deltax2 * 2
    var.deltay2 = var.deltay2 * 2
  endif
  if var.speed > 0.2 and var.speed <= 0.4 then
    var.deltax2 = var.deltax2 * 4
    var.deltay2 = var.deltay2 * 4
  endif
  if var.speed > 0.4 and var.speed <= 1.25 then
    var.deltax2 = var.deltax2 * 7
    var.deltay2 = var.deltay2 * 7
  endif
  if var.speed > 1.25 and var.speed <= 3.9 then
    var.deltax2 = var.deltax2 *12 //* 7
    var.deltay2 = var.deltay2 *12 //* 7
  endif
  if var.speed > 3.9 then
    var.deltax2 = var.deltax2 * 20// * 13.77
    var.deltay2 = var.deltay2 * 20// * 13.77
  endif
  var.Mouse2x = EnsureRange(var.Mouse2x pixels + (var.deltax2 in pixels), var.ActiveAreaLeft, var.ActiveAreaRight)
  var.Mouse2y = EnsureRange(var.Mouse2y pixels + (var.deltay2 in pixels), var.ActiveAreaTop, var.ActiveAreaBottom)

endif
Cursor2.PosX = var.Mouse2x
Cursor2.PosY = var.Mouse2y
Cursor2.LeftButton = mouse2.LeftButton
Cursor2.RightButton = mouse2.RightButton
Cursor2.MiddleButton = mouse2.MiddleButton

//Fakeuser code begins here again
//Players config
//player 1
PPJoy1.Analog0 = EnsureMapRange(var.Mouse1x , var.ActiveAreaLeft, var.ActiveAreaRight, -1, 1)
PPJoy1.Analog1 = EnsureMapRange(var.Mouse1y , var.ActiveAreaTop, var.ActiveAreaBottom, -1, 1)
PPJoy1.Digital0 = Key.Up
PPJoy1.Digital1 = Key.Down
PPJoy1.Digital2 = Key.Left
PPJoy1.Digital3 = Key.Right
// another second external mouse bypass for laptops
if mouse3.present then
    PPJoy1.Digital4 = Mouse3.LeftButton
    PPJoy1.Digital5 = Mouse3.RightButton
else
    PPJoy1.Digital4 = Mouse1.LeftButton
    PPJoy1.Digital5 = Mouse1.RightButton
endif
PPJoy1.Digital6 = Key.RightShift
PPJoy1.Digital7 = Key.NumPadEnter
PPJoy1.Digital8 = Key.NUMPAD0
PPJoy1.Digital9 = Key.RightCtrl

// player 2
PPJoy2.Analog0 = EnsureMapRange(var.Mouse2x, var.ActiveAreaLeft, var.ActiveAreaRight, -1, 1)
PPJoy2.Analog1 = EnsureMapRange(var.Mouse2y, var.ActiveAreaTop, var.ActiveAreaBottom, -1, 1)
PPJoy2.Digital0 = Key.W
PPJoy2.Digital1 = Key.S
PPJoy2.Digital2 = Key.A
PPJoy2.Digital3 = Key.D
PPJoy2.Digital4 = Mouse2.LeftButton
PPJoy2.Digital5 = Mouse2.RightButton
PPJoy2.Digital6 = Key.LeftShift
PPJoy2.Digital7 = Key.Space
PPJoy2.Digital8 = Key.R
PPJoy2.Digital9 = Key.E

else

mouse.Swallow = False
cursor2.Visible = False


endif

But now the cursors are misaligned, the few attempts i made to realign them didn't seem to work the way i expected, i'm not sure how to make sense of this; any idea what i'm doing wrong? Or is the issue in the moded Mari0 code?

fakeuser
User avatar
Posts: 135
Joined: 04 Mar 2012, 01:20
Reputation: 0

Post » 12 Mar 2012, 12:58

Wow.. I never imagined you could get window bounds from within glovepie.. Yeah, I think I can give you a clue - the problem is that glove pie gets the window frame bounds (the one with the icon and the min, max, close buttons) and in the game I'm recalculating coordinates using the game field size (top left corner of love2d to right lower). Anyway, it should not be that hard to fix this even with some hardcoded numbers. I''ll see if it can be done nicely and post back

TiagoTiago
Posts: 101
Joined: 05 Mar 2012, 07:44
Reputation: 0

Post » 12 Mar 2012, 13:05

I took that in consideration:

Code: Select all

var.ActiveAreaTop = (Window.Top + Window.Height) - Window.ClientHeight

That part does away with the titlebar.

I had also coded somthing to handle different window border thickness but it turns out the unredimensionable window of Mari0 never has thicker borders, at least in WinXP; so removed that bit of code.

xPi
User avatar
Posts: 28
Joined: 11 Mar 2012, 13:17
Reputation: 0

Post » 12 Mar 2012, 13:09

hi, I am going to try and implement an OSC receiver in lua. at least with that we could cut dependence on ppjoy. this would be useful if
  1. someone doesn't want to go to the trouble of running their 64-bit windows in test signing mode
  2. ppjoy doesn't work for someone

after a quick google, http://luaforge.net/projects/luaosc/ looks promising...


also, about glovepie getting window border, here's a snippet from my terraria script that deals with window borders:

Code: Select all

// when game is windowed,
// middleX is left edge + half width
// middleY is window.top + window.height - bottom border - clientheight/2
// in windows, bottom border height is same as left border width

var.leftborder = (window.Width - window.ClientWidth) / 2
var.middleX = window.Left + window.Width / 2
var.middleY = window.Top + window.Height - var.leftborder - window.ClientHeight/2
var.topborder = window.Height - window.ClientHeight - var.leftborder

// -snip-

   //clamp mouse inside gamescreen (windowed)
   var.x = max(var.x,window.Left+var.leftborder)
   var.x = min(var.x,window.Left+var.leftborder+window.ClientWidth-1)
   var.y = max(var.y,window.Top+var.topborder)
   var.y = min(var.y,window.Top+var.topborder+window.ClientHeight-1)




TiagoTiago
Posts: 101
Joined: 05 Mar 2012, 07:44
Reputation: 0

Post » 12 Mar 2012, 13:12

OSC even works over LAN (i guess it might work over the Internet itself even, dunno if the lag and ISP limitations etc would get in the way though); you could use a WiFi enabled laptop as a wireless controller to play, with each person with a full set of keyboard and mouse!!! :P

xPi
User avatar
Posts: 28
Joined: 11 Mar 2012, 13:17
Reputation: 0

Post » 12 Mar 2012, 13:13

my phone has a bunch of OSC apps.. and also lua scripting

fakeuser
User avatar
Posts: 135
Joined: 04 Mar 2012, 01:20
Reputation: 0

Post » 12 Mar 2012, 13:43

xPi go ahead, I hate being in test signing mode myself. I'm not much of a lua coder but when I find the time will take a look at OSC as well. But I think you will have to bypass basegame controls too as it wants to read joystick input

Anyway TiagoTiago I saw you did some maths. I just moded your logic a little and here's what came out:

Code: Select all

// cool new feature by TiagoTiago
If (Window.Title == "Mari0") Then

// Modded version of MouseParty.pie
// The real cursor is now only controlled by mouse 1 or mouse 3 if present

   mouse.Swallow = true
   cursor2.Visible = true

   var.border = (Window.Width - Window.ClientWidth) / 2
   // Somewhat revised by fakeuser
   var.ActiveAreaLeft =  Window.Left + var.border
   var.ActiveAreaTop = Window.Top + window.Height - window.ClientHeight - var.border
   var.ActiveAreaRight = var.ActiveAreaLeft + window.ClientWidth - 1
   var.ActiveAreaBottom = var.ActiveAreaTop + Window.ClientHeight - 1

// Modded version of MouseParty.pie
// The real cursor is now only controlled by mouse 1 or mouse 3 if present

//laptop bypass for two externa mice by fakeuser
if mouse3.present then
   fakemouse.DirectInputX = mouse3.DirectInputX
   fakemouse.DirectInputY = mouse3.DirectInputY
   mouse.LeftButton = mouse3.LeftButton
   mouse.RightButton = mouse3.RightButton
   mouse.MiddleButton = mouse3.MiddleButton
   mouse.XButton1 = mouse3.XButton1
   mouse.XButton2 = mouse3.XButton2
//end bypass
else
    fakemouse.DirectInputX = mouse1.DirectInputX
    fakemouse.DirectInputY = mouse1.DirectInputY
    mouse.LeftButton = mouse1.LeftButton
    mouse.RightButton = mouse1.RightButton
    mouse.MiddleButton = mouse1.MiddleButton
    mouse.XButton1 = mouse1.XButton1
    mouse.XButton2 = mouse1.XButton2
endif

// Show a fake cursor 2
if mouse2.present but not var.shown2 then
  cursor2.visible = true
  var.Mouse2x = mouse.CursorPosX
  var.Mouse2y = mouse.CursorPosY
  var.shown2 = true
endif
// Do mouse pointer 2
if mouse2.present then
  // How much has mouse 2 moved?
  var.deltax2 = Delta(mouse2.DirectInputX)
  var.deltay2 = Delta(mouse2.DirectInputY)

  // Mouse ballistics attempt
  var.velocity = ([(smooth(var.deltaX2) / 24ms) in inches per second, (smooth(var.deltaY2) / 24ms) in inches per second] )
  var.speed = |var.velocity|
  if var.speed <= 0.2 then
    var.deltax2 = var.deltax2 * 2
    var.deltay2 = var.deltay2 * 2
  endif
  if var.speed > 0.2 and var.speed <= 0.4 then
    var.deltax2 = var.deltax2 * 4
    var.deltay2 = var.deltay2 * 4
  endif
  if var.speed > 0.4 and var.speed <= 1.25 then
    var.deltax2 = var.deltax2 * 7
    var.deltay2 = var.deltay2 * 7
  endif
  if var.speed > 1.25 and var.speed <= 3.9 then
    var.deltax2 = var.deltax2 *12 //* 7
    var.deltay2 = var.deltay2 *12 //* 7
  endif
  if var.speed > 3.9 then
    var.deltax2 = var.deltax2 * 20// * 13.77
    var.deltay2 = var.deltay2 * 20// * 13.77
  endif
  var.Mouse2x = var.Mouse2x pixels + (var.deltax2 in pixels)
  var.Mouse2y = var.Mouse2y pixels + (var.deltay2 in pixels)
  if var.Mouse2x < screen.DesktopLeft then var.Mouse2x = screen.DesktopLeft
  if var.Mouse2x > screen.DesktopRight then var.Mouse2x = screen.DesktopRight
  if var.Mouse2y < screen.DesktopTop then var.Mouse2y = screen.DesktopTop
  if var.Mouse2y > screen.DesktopBottom then var.Mouse2y = screen.DesktopBottom
endif
Cursor2.PosX = var.Mouse2x
Cursor2.PosY = var.Mouse2y
Cursor2.LeftButton = mouse2.LeftButton
Cursor2.RightButton = mouse2.RightButton
Cursor2.MiddleButton = mouse2.MiddleButton

//Fakeuser code begins here again
//Players config
//player 1
PPJoy1.Analog0 = MapRange(mouse1.CursorPosX, var.ActiveAreaLeft, var.ActiveAreaRight, -1, 1)
PPJoy1.Analog1 = MapRange(mouse1.CursorPosY, var.ActiveAreaTop, var.ActiveAreaBottom, -1, 1)
PPJoy1.Digital0 = Key.Up
PPJoy1.Digital1 = Key.Down
PPJoy1.Digital2 = Key.Left
PPJoy1.Digital3 = Key.Right
// another second external mouse bypass for laptops
if mouse3.present then
    PPJoy1.Digital4 = Mouse3.LeftButton
    PPJoy1.Digital5 = Mouse3.RightButton
else
    PPJoy1.Digital4 = Mouse1.LeftButton
    PPJoy1.Digital5 = Mouse1.RightButton
endif
PPJoy1.Digital6 = Key.RightShift
PPJoy1.Digital7 = Key.NumPadEnter
PPJoy1.Digital8 = Key.NUMPAD0
PPJoy1.Digital9 = Key.RightCtrl

// player 2
PPJoy2.Analog0 = MapRange(var.Mouse2x, var.ActiveAreaLeft, var.ActiveAreaRight, -1, 1)
PPJoy2.Analog1 = MapRange(var.Mouse2y, var.ActiveAreaTop, var.ActiveAreaBottom, -1, 1)
PPJoy2.Digital0 = Key.W
PPJoy2.Digital1 = Key.S
PPJoy2.Digital2 = Key.A
PPJoy2.Digital3 = Key.D
PPJoy2.Digital4 = Mouse2.LeftButton
PPJoy2.Digital5 = Mouse2.RightButton
PPJoy2.Digital6 = Key.LeftShift
PPJoy2.Digital7 = Key.Space
PPJoy2.Digital8 = Key.R
PPJoy2.Digital9 = Key.E
else
    mouse.Swallow = false
    Cursor2.visible = false
endif

No misalignment for me. Take a look, I'm gonna update gamepack. And yeah, thanks for showing me the way how to remove the stupid window moving rule

fakeuser
User avatar
Posts: 135
Joined: 04 Mar 2012, 01:20
Reputation: 0

Post » 12 Mar 2012, 13:58

New version released. You may grab it from the latest version link in the first post of the topic, or just edit manually the Mari0_2mice.pie script. Modifications are in the post above.

TiagoTiago
Posts: 101
Joined: 05 Mar 2012, 07:44
Reputation: 0

Post » 12 Mar 2012, 18:00

I'm still getting the misalignment
Image(both players have their respective cursors at exactly the middle of that floating block)




Btw, your new version doesn't trap the cursors inside the window anymore...




Oh, and about OSC; can't you just feed the OSC data to the joystick functions and make OSC stuff appear as additional joysticks internally?

killer64
Posts: 5
Joined: 12 Mar 2012, 19:00
Reputation: 0

Post » 12 Mar 2012, 19:29

-snip- axes are messed up, ill have to try again
Last edited by killer64 on 12 Mar 2012, 19:33, edited 1 time in total.

fakeuser
User avatar
Posts: 135
Joined: 04 Mar 2012, 01:20
Reputation: 0

Post » 12 Mar 2012, 19:30

Well I don't really get how you manage to acomplish that
Image
Are you sure you have the new .love file? The older one had some hardcoded 16px displacment to the right (as I was extremely dumb and sleeping)
And my mod never tried to capture the mouse inside the game.. that was xPi's idea. I used the built-in F12 shortcut. You are right I should add this in my script as well.

About the OSC. I had a similar idea, but started coding in lua like yesterday, so haven't found what and how to do yet. You are free to do it and share with us, if you know what you are doing

P.s. I'm getting some strange bug with GlovePIE. If I start GlovePIE alone and then launch mari0.love it works as expected, but when I use the batch file (which actually does the same) I get 2 cursors no matter which is the focused window. Anybody have some clues?

fakeuser
User avatar
Posts: 135
Joined: 04 Mar 2012, 01:20
Reputation: 0

Post » 12 Mar 2012, 19:37

killer64 wrote:-snip- axes are messed up, ill have to try again

I hope you went to options menu and actually set all players not to own the mouse and set controls with emulator running?

P.s. If he gets another problem that sums it up. You run XP and I run 7. Or maybe you've downloaded another version of GlovePIE? I'm runninv v0.43

fakeuser
User avatar
Posts: 135
Joined: 04 Mar 2012, 01:20
Reputation: 0

Post » 12 Mar 2012, 20:03

TiagoTiago wrote:Btw, your new version doesn't trap the cursors inside the window anymore...

You may try this script

Code: Select all

// cool new feature by TiagoTiago
If (Window.Title == "Mari0") Then

// Modded version of MouseParty.pie
// The real cursor is now only controlled by mouse 1 or mouse 3 if present

   mouse.Swallow = true
   cursor2.Visible = true

   var.border = (Window.Width - Window.ClientWidth) / 2
   // Somewhat revised by fakeuser
   var.ActiveAreaLeft =  Window.Left + var.border
   var.ActiveAreaTop = Window.Top + window.Height - window.ClientHeight - var.border
   var.ActiveAreaRight = var.ActiveAreaLeft + window.ClientWidth - 1
   var.ActiveAreaBottom = var.ActiveAreaTop + Window.ClientHeight - 1


   if key.F12 then
      var.capture = not var.capture
      wait 2s
   endif
// Modded version of MouseParty.pie
// The real cursor is now only controlled by mouse 1 or mouse 3 if present

//laptop bypass for two externa mice by fakeuser
if mouse3.present then
   fakemouse.DirectInputX = mouse3.DirectInputX
   fakemouse.DirectInputY = mouse3.DirectInputY
   mouse.LeftButton = mouse3.LeftButton
   mouse.RightButton = mouse3.RightButton
   mouse.MiddleButton = mouse3.MiddleButton
   mouse.XButton1 = mouse3.XButton1
   mouse.XButton2 = mouse3.XButton2
//end bypass
else
    fakemouse.DirectInputX = mouse1.DirectInputX
    fakemouse.DirectInputY = mouse1.DirectInputY
    mouse.LeftButton = mouse1.LeftButton
    mouse.RightButton = mouse1.RightButton
    mouse.MiddleButton = mouse1.MiddleButton
    mouse.XButton1 = mouse1.XButton1
    mouse.XButton2 = mouse1.XButton2
endif

// Show a fake cursor 2
if mouse2.present but not var.shown2 then
  cursor2.visible = true
  var.Mouse2x = mouse.CursorPosX
  var.Mouse2y = mouse.CursorPosY
  var.shown2 = true
endif
// Do mouse pointer 2
if mouse2.present then
  // How much has mouse 2 moved?
  var.deltax2 = Delta(mouse2.DirectInputX)
  var.deltay2 = Delta(mouse2.DirectInputY)

  // Mouse ballistics attempt
  var.velocity = ([(smooth(var.deltaX2) / 24ms) in inches per second, (smooth(var.deltaY2) / 24ms) in inches per second] )
  var.speed = |var.velocity|
  if var.speed <= 0.2 then
    var.deltax2 = var.deltax2 * 2
    var.deltay2 = var.deltay2 * 2
  endif
  if var.speed > 0.2 and var.speed <= 0.4 then
    var.deltax2 = var.deltax2 * 4
    var.deltay2 = var.deltay2 * 4
  endif
  if var.speed > 0.4 and var.speed <= 1.25 then
    var.deltax2 = var.deltax2 * 7
    var.deltay2 = var.deltay2 * 7
  endif
  if var.speed > 1.25 and var.speed <= 3.9 then
    var.deltax2 = var.deltax2 *12 //* 7
    var.deltay2 = var.deltay2 *12 //* 7
  endif
  if var.speed > 3.9 then
    var.deltax2 = var.deltax2 * 20// * 13.77
    var.deltay2 = var.deltay2 * 20// * 13.77
  endif
  var.Mouse2x = var.Mouse2x pixels + (var.deltax2 in pixels)
  var.Mouse2y = var.Mouse2y pixels + (var.deltay2 in pixels)
  if var.capture then
      if var.Mouse2x < var.ActiveAreaLeft then var.Mouse2x = var.ActiveAreaLeft
      if var.Mouse2x > var.ActiveAreaRight then var.Mouse2x = var.ActiveAreaRight
      if var.Mouse2y < var.ActiveAreaTop then var.Mouse2y = var.ActiveAreaTop
      if var.Mouse2y > var.ActiveAreaBottom then var.Mouse2y = var.ActiveAreaBottom
  else
      if var.Mouse2x < screen.DesktopLeft then var.Mouse2x = screen.DesktopLeft
      if var.Mouse2x > screen.DesktopRight then var.Mouse2x = screen.DesktopRight
      if var.Mouse2y < screen.DesktopTop then var.Mouse2y = screen.DesktopTop
      if var.Mouse2y > screen.DesktopBottom then var.Mouse2y = screen.DesktopBottom
  endif
endif
Cursor2.PosX = var.Mouse2x
Cursor2.PosY = var.Mouse2y
Cursor2.LeftButton = mouse2.LeftButton
Cursor2.RightButton = mouse2.RightButton
Cursor2.MiddleButton = mouse2.MiddleButton

//Fakeuser code begins here again
//Players config
//player 1
PPJoy1.Analog0 = MapRange(mouse1.CursorPosX, var.ActiveAreaLeft, var.ActiveAreaRight, -1, 1)
PPJoy1.Analog1 = MapRange(mouse1.CursorPosY, var.ActiveAreaTop, var.ActiveAreaBottom, -1, 1)
PPJoy1.Digital0 = Key.Up
PPJoy1.Digital1 = Key.Down
PPJoy1.Digital2 = Key.Left
PPJoy1.Digital3 = Key.Right
// another second external mouse bypass for laptops
if mouse3.present then
    PPJoy1.Digital4 = Mouse3.LeftButton
    PPJoy1.Digital5 = Mouse3.RightButton
else
    PPJoy1.Digital4 = Mouse1.LeftButton
    PPJoy1.Digital5 = Mouse1.RightButton
endif
PPJoy1.Digital6 = Key.RightShift
PPJoy1.Digital7 = Key.NumPadEnter
PPJoy1.Digital8 = Key.NUMPAD0
PPJoy1.Digital9 = Key.RightCtrl

// player 2
PPJoy2.Analog0 = MapRange(var.Mouse2x, var.ActiveAreaLeft, var.ActiveAreaRight, -1, 1)
PPJoy2.Analog1 = MapRange(var.Mouse2y, var.ActiveAreaTop, var.ActiveAreaBottom, -1, 1)
PPJoy2.Digital0 = Key.W
PPJoy2.Digital1 = Key.S
PPJoy2.Digital2 = Key.A
PPJoy2.Digital3 = Key.D
PPJoy2.Digital4 = Mouse2.LeftButton
PPJoy2.Digital5 = Mouse2.RightButton
PPJoy2.Digital6 = Key.LeftShift
PPJoy2.Digital7 = Key.Space
PPJoy2.Digital8 = Key.R
PPJoy2.Digital9 = Key.E
else
    mouse.Swallow = false
    Cursor2.visible = false
endif

I'm not really happy with it, but it works. When F12 is pressed a flag is flipped so the fake cursor is kept inside the Mari0 window. But is there a prettier way to ignore key holding? (to get the event only in the first emulator iterration and not in all of them while holding down the key). I'm currently using wait 2s command and I honestly don't like it.

xPi
User avatar
Posts: 28
Joined: 11 Mar 2012, 13:17
Reputation: 0

Post » 12 Mar 2012, 21:30

Code: Select all

if pressed(key.F12) then
   var.capture = not var.capture
endif

fakeuser
User avatar
Posts: 135
Joined: 04 Mar 2012, 01:20
Reputation: 0

Post » 12 Mar 2012, 23:19

I really need a thanks button here... Main post updated, you may grab the new version from the latest release link, or just get the pie file as it's the only difference

Anybody else gets misalignment?

TiagoTiago
Posts: 101
Joined: 05 Mar 2012, 07:44
Reputation: 0

Post » 13 Mar 2012, 02:34

I still get the misalignment with the 2.2 :/

fakeuser
User avatar
Posts: 135
Joined: 04 Mar 2012, 01:20
Reputation: 0

Post » 13 Mar 2012, 16:04

Well I'm gonna test it on XP tonight

fakeuser
User avatar
Posts: 135
Joined: 04 Mar 2012, 01:20
Reputation: 0

Post » 13 Mar 2012, 21:07

TiagoTiago wrote:I still get the misalignment with the 2.2 :/

Dude.. Seriosly.. What the heck are you doing? That's what I get on my XP sp3
Image
The mouse is in the center of the right floating block. The cursors are visible only while moving and blink like hell, but still aiming EXACTLY where I point. I only managed to mess things up by starting the game from mari0_1.4.exe and not the mari0_1.4_coop.love. In case you have done this wrong, please, start the .LOVE file and not the original exe. Furthermore I provided shots of controls somewhere above. You should match the axes controls like shown. If you still get misalignment, please, post how are you launching the game and the emulator. Provide me with LOVE and GlovePIE versions, OS you are using. And please be verbose on the how part.

P.s. You may try to hardcode some adjustments in the pie script to make it work for you. Is the displacment constant, or rises when the mouse goes further from Mario? I simply can't reproduce it, so I'm not getting ANY results

TiagoTiago
Posts: 101
Joined: 05 Mar 2012, 07:44
Reputation: 0

Post » 13 Mar 2012, 21:33

How many monitors do you got? You think it could be somthing to do with me having 3 monitors (with one of them running on a separated video card) ?

Btw, you didn't hardcode the joystick indexes right? I got a couple physical joysticks so my PPJoys don't got the same numbers as yours...

fakeuser
User avatar
Posts: 135
Joined: 04 Mar 2012, 01:20
Reputation: 0

Post » 13 Mar 2012, 22:10

Every PC i tested on has a single monitor attached. And I believe it should not be a probled (as GlovePIE handles their coordinates correctly). You may want to assure that both

Code: Select all

MapRange(var.Mouse2x, var.ActiveAreaLeft, var.ActiveAreaRight, -1, 1)
MapRange(var.Mouse2y, var.ActiveAreaTop, var.ActiveAreaBottom, -1, 1)

return values between -1.0 and 1.0 if mouse is in game bounds...

And no, I have not hardcoded any joystick index. I just suppose you have at least two virtual PPJoy joysticks with two analog axes named Analog0 and Analog1, and 10 buttons, named Digital0-9. Some keyboard keys are just mapped to joypad buttons (defined in the script). The mouse mapping is as follows:
  • coordinate center (0, 0) is the center of the game area
  • top left corner is recalculated as (-1.0, -1.0)
  • lower right corner is recalculated as (1.0, 1.0)
The only part that I modded in the game is what to do with read values from joystick axes. I do not know wich joystick, I use what the game gives to me (but it is supposed that you mapped the right one in the options menu). I use game dimensions retrieved by getWidth() and getHeigth() to get coordinates in system with (0, 0) in the center of the game area. I translate this coordinates in system that is based at (0, 0) = top left corner. Then I use the same line that calculates the rotation angle of the portal gun, that is used when you use real mouse (not emulated joystick mouse).

You could try testing on another machine perhaps?

LightningFire
User avatar
Posts: 1907
Joined: 10 Mar 2012, 17:24
Reputation: 133
Contact:

Post » 15 Mar 2012, 23:29

Can you make this compatible with the hat loader, because I can only either play 2 players with mouses without custom hats or custom hats without 2 players with mouses

fakeuser
User avatar
Posts: 135
Joined: 04 Mar 2012, 01:20
Reputation: 0

Post » 15 Mar 2012, 23:58

Meaning this? viewtopic.php?f=13&t=750 Mod is compatible with every other single mod of mari0 1.4 that does not modigy mario:updateangle method. I made custom archives for Mod Loader and Mari0 Modding System (currently packing and gonna release soon). Hat loader however does not provide any way for me to just plug my files somewhere.. But you may tweak hat loader so it loads my mod as well. You will just have to get the (say) Mod Loader package and load it manually in main.lua of Hat Loader.

fakeuser
User avatar
Posts: 135
Joined: 04 Mar 2012, 01:20
Reputation: 0

Post » 16 Mar 2012, 00:43

Packages for Mod Loader and Mari0 Modding System released! See first post, section Installing with available mod system for instructions. Version is not changed as this is the same version, but now you may choose not to use the standalone version. As I said before, this should be compatible with every single mod that does not modify the mario:updateangle() method. Instructions for getting it to work with random (not loader) mod can be found under the cited section of the first post.

Known bugs of ported packages
  • Package for Mod Loader gets "mod not loaded" error in the stack (the black window). Ignore it. Mod is loaded, it is just not a custom entity. But the loader doesn't really understand the possibility of not creating one. At least the game doesn't get crashed... (look below)
  • Package for Mari0 Modding System gets standard entities pack loaded as custom entities as well (well.. not tested, but I expect that might happen)They do not. This is because I do not need any entities, but the author of the loader made the absence of entities.png fatal - crashes the game. So I copied the standard entities.png. Inserted: I will silently update this mod package so it has transparent 16x16 entities.png. Just to minimize package size
Last edited by fakeuser on 17 Mar 2012, 14:47, edited 2 times in total.

fakeuser
User avatar
Posts: 135
Joined: 04 Mar 2012, 01:20
Reputation: 0

Post » 16 Mar 2012, 11:21

Mari0 1.5 was released and now 2 Mice Mod supports it. You may grab standalone mod version from the first post's latest release section. Loader packages are not changed, but they will support Mari0 1.5 as long as the loader supports it.

fakeuser
User avatar
Posts: 135
Joined: 04 Mar 2012, 01:20
Reputation: 0

Post » 17 Mar 2012, 14:43

Added standalone version of modded Mari0 version 1.6. As usual packages for mod loaders will support the new firefox.. oops, Mari0 version as long as the loader in use supports it

jakov
Posts: 20
Joined: 07 Mar 2012, 19:56
Reputation: 0

Post » 17 Mar 2012, 16:37

Hi there!

I've successfully installed your 2mice script; haven't played against anyone yet, but in testing it seems to work perfectly! Love it!

There are some minor points I want to feed back though:

  1. When the game crashes for some reason (on my pc it's when I quit to desktop, which isnt really harmful) it leaves the GlovePIE open. When I start the game through the two_mice_coop.bat it opens yet another instance of GlovePIE which results in weird double second mouse effects; maybe there's a way to kill the first instance when opening again, or to force single instance mode?
  2. Is it possible to use a third and fourth mouse? Can I use a laptop's trackpad?
  3. Would it be possible to hide the two mice from the screen altogether? My second mouse keeps flickering, which looks ugly. Maybe its possible to create some sort of a crosshair inside the game (consisting of just a few pixels). This might be a good suggestion for the game even without multiple mice; therefore maybe maurice could adress this.

fakeuser
User avatar
Posts: 135
Joined: 04 Mar 2012, 01:20
Reputation: 0

Post » 17 Mar 2012, 23:29

  1. I'm thinking about making the bat file terminate the glopie process after the game closes. This however leads me to some problems - the batch script has to be executed with elevated privileges (not possible for all users) and taskkill command seems to have no effect when glovepie is minimized to system tray... Also it is strange that when executed with elevated privileges, the batch script is unable to load the game as the working directory changes to system32... Still investigating on it. I'm open for suggestions. Also you could use shortcut (Shift + P + I + E) to terminate runing pie scripts and then close their glovepie windows
  2. third and fourth - Of course. Glove PIE supports up to 16. Haven't made such a script as I find it difficult to share the keyboard. But it is possible to map more than one keyboard as well. I bet you could modify the script to do this yourself. I was thinking of making mine map all mice to virtual joysticks. And yes. You could use your laptop's trackpad. Just don't connect 2 external mice, but only one. Then the onboard one (the trackpad) will be mapped on one of the virtual joysticks
  3. So I assume you are on XP? Yes, it is possible to hide both mice and even exchange them wih custom crosshair. I may add this for the second (fake) mouse, but think it is up to Maurice if the real one will be hidden (I just don't want to make it mandatory for all users of my mod). If you preffer invisible mouse to flashy mouse, open mari0_2mice.pie with text editor, find this code (in the begining)

    Code: Select all

        cursor2.Visible = true

    and replace it with this one

    Code: Select all

        cursor2.Visible = false

    save the document and try the game again. It will just make the custom cursor invisible. It will not make it a crosshair.

fakeuser
User avatar
Posts: 135
Joined: 04 Mar 2012, 01:20
Reputation: 0

Post » 18 Mar 2012, 01:43

version 2.3 is out! It's a small improvement but I'm sure you XP users will like it - the fake (second) cursor now gets hidden while the mouse is over the game window and a crosshair is drawn instead. You may even change the crosshair image - locate it in the graphics subfolder. If you change the image, make sure it is 16x16 and the name is unchanged. Loader packages are updated as well.

fakeuser
User avatar
Posts: 135
Joined: 04 Mar 2012, 01:20
Reputation: 0

Post » 18 Mar 2012, 01:50

If somebody managed to download the wrong packages, please redownload the update.. Sorry about that, the pie script included was unchanged

ducharles
Posts: 3
Joined: 07 Mar 2012, 22:29
Reputation: 0

Post » 27 Mar 2012, 11:11

Nice job dude :). This a way more completed solution. Its working nicely, but theres a slight misalignment on my screen. The cursor with the cross-hair graphics on works spot on, but the normal mouse looking cursor is slightly misaligned and also, when I had set up the y-axis properly, for some reason to get the cursors working properly, I had to move my mouse up instead of down(the control command in the game, tells you to move up). I am using windows 7 32 bit ultimate. Though this is still a very usable mod.

fakeuser
User avatar
Posts: 135
Joined: 04 Mar 2012, 01:20
Reputation: 0

Post » 27 Mar 2012, 19:27

ducharles wrote:The cursor with the cross-hair graphics on works spot on, but the normal mouse looking cursor is slightly misaligned

You are telling me player1 has problems with aiming and player2 doesn't? Not possible - aiming is done the same way for BOTH players. Please provide me a screenshot to prove your thesis (find a map with a single brick-block floating, place both mice in its center and make screenshot). Also do you get the misalignment with player configured to be the mouse owner? Are you using other mods?

ducharles wrote:when I had set up the y-axis properly, for some reason to get the cursors working properly, I had to move my mouse up instead of down

Please, point where did I say to move the mouse down? Because that is wrong, you just have to match the screenshots in my scecond post here

KINNG
Posts: 1
Joined: 05 Apr 2012, 19:24
Reputation: 0

Post » 05 Apr 2012, 19:25

Do I have to stay in this so called test mode?

xPi
User avatar
Posts: 28
Joined: 11 Mar 2012, 13:17
Reputation: 0

Post » 05 Apr 2012, 20:02

well, you only need to be in the test mode to use ppjoy (one of this mod's dependencies) but you can reboot out of it when not using ppjoy

xPi
User avatar
Posts: 28
Joined: 11 Mar 2012, 13:17
Reputation: 0

Post » 06 Apr 2012, 11:19

okay, I've figured out the osc stuff

glovepie 0.43 has a serious problem with encoding numbers into byte streams (source)

there is a new version of glovepie. the website is fixed apart from a rogue index.html (the real index.php [is] ok [again])

the good about this new version: numbers in osc messages are encoded properly. bad: it can't receive osc messages.. (source)

fortunately, I won't need this glovepie version to receive osc messages, but I will be making it send osc directly into mari0. I've just now got a prototype .love game to receive and decode messages with int or float in them :D

update: it now decodes true and false from osc messages, and signed int is now supported

here's a video and a demo you need love2d version 0.8.0 to run the demo and glovepie 0.45 run the pie script

update: added crosshairs to demo
update2 (01 Dec 2012): old news, no longer applies today
since march 2012, the glovepie.org website was hacked and the main page (index.php) was replaced with something that was utterly useless (defacement page) if you were visiting the site to download glovepie. I changed the link to the glovepie website to bypass the defacement page. just in case it happens again or if the whole site is gone, there are unofficial alternate download links below. the zip files should always match the ones downloaded from the official site, and have the following checksums:

File: GlovePIEWithEmotiv043.zip
CRC-32: 608f2e6a
MD4: c4fbe6e552e6c063f94f2b26baea27b5
MD5: c0a75e60241f548f42864cb1fe8f6ada
SHA-1: 662c80a93f73383d5b69d8d83eb75a4050e40cb3
SHA-256: 69c1beb707d521ed87d8aeda5784d103009557d5c2228e1060df0f28ef4f06ab

File: GlovePIE045Free.zip
CRC-32: e9e02a5f
MD4: 0e803766899b64bb5c235e00f7e2dadd
MD5: 878fdbd231de9bd929794cd13d4931dd
SHA-1: 1265b7f8569790d670ccdecb5b261d10b0873cfa
SHA-256: 1b036eedc35c5c344b8be4f5995e6018d48fb8fff05a26b06854f8ed6e9416db

update3: I noticed that the glovepie.org website was restored, so I reworded and improved the text in update 2
update4: glovepie's website was taken down in 2016, links now point to archived version. on 15th march 2017, dropbox has discontinued the "public folder" feature which means links with "/u/" in it are now broken. I've had to make dropbox generate fresh share links for every file I'm still sharing. the required version of love2d hasn't been "latest nightly" since may 2012. updated text to accurately state the version needed.
since google has reported that they have cracked SHA-1, I've added SHA-256 checksums for glovepie files in update2.
why did I update such an old post? I want to prevent a situation similar to "xkcd 979" where future readers can't access files I've posted.
Last edited by xPi on 23 Mar 2017, 07:37, edited 4 times in total.

fakeuser
User avatar
Posts: 135
Joined: 04 Mar 2012, 01:20
Reputation: 0

Post » 06 Apr 2012, 17:35

I'm not really happy with this new version as it became somewhat unresponsive (Shift + P + I + E did the trick) and it breaks my current script - the real cursor does not move when fakemouse is fed with Mouse1 data. However OSC problems of 0.43 are annoying. So you are going to make another multi-mice mod? You may get some ideas of my current implementation (e.g. for recalculating coords and painting crosshair there). If you are thinking about transferring mouse clicks as well, one way to force player i to shoot portal is

Code: Select all

shootportal(i, 1, objects["player"][i].x+6/16, objects["player"][i].y+6/16, objects["player"][i].pointingangle) -- left portal
shootportal(i, 2, objects["player"][i].x+6/16, objects["player"][i].y+6/16, objects["player"][i].pointingangle) -- right portal

(as written in mario.lua ~2726 line)
or call the game_keypressed function, passing controls[i]["portal1"][1], or controls[i]["portal2"][1] as argument.

xPi
User avatar
Posts: 28
Joined: 11 Mar 2012, 13:17
Reputation: 0

Post » 08 Apr 2012, 20:26

I just realized I wanted this since 2009, to use in desmume.. so uh... killing two birds with one stone :)

been thinking a bit about how I'm gonna present this new type of input to the user, letting the user configure the controls, and how it will accept and deal with packets from remote PCs on the LAN or wherever.

xPi
User avatar
Posts: 28
Joined: 11 Mar 2012, 13:17
Reputation: 0

Post » 23 Apr 2012, 20:57

hooray, it works

download:
dropbox

this is made to be a bit more flexible by being changeable in control settings.

all you need now is:
LÖVE from love2d.org (2014 edit: old versions, 0.8.0)
glovepie 0.45
and the download in this post

to get this version going:
plug in extra mice
run glovepie script manually
open the game
press F12 to lock the real mouse pointer
go into options > controls
on each player make sure "uses the mouse" is "no"
go to aimx, press enter and move a mouse to the right
go to aimy, set it to a mouse moving down
set portal1 to a mouse click
set portal2 to a mouse click

switch to another player's controls and repeat process with other mice

if you want, or have to because you're stuck with built-in touchpad, you can run the glovepie script on multiple computers. just edit the osc.ip line at the top to the ip you want to control

at this point you should be ready for onescreen multiplayer

edit: now supports keyboard
edit: updated dropbox link
Last edited by xPi on 23 Mar 2017, 07:39, edited 2 times in total.

marrio33
User avatar
Posts: 8
Joined: 21 Sep 2012, 15:09
Reputation: 0

Post » 03 Oct 2012, 15:32

If you connect the two mice that happen chevo

xPi
User avatar
Posts: 28
Joined: 11 Mar 2012, 13:17
Reputation: 0

Post » 24 Feb 2013, 16:59

hi, I have finally had a chance to try my own mod with multiple keyboards:

there is a problem on all the menus with taking keyboard input from glovepie as well as directly.

SOLUTION: click on a different window and then press F12 to lock keyboard and mouse
once you're done configuring, every keyboard button and mouse button should begin with "OSC" and aimx and aimy should also have "OSC"


one more thing: I have found an old version that has a working OSC, this may also solve fakeuser's unresponsive problem

the the last version that had working OSC is 0.29 https:// sites.google.com /site/carlkenner /GlovePIE029.zip

unfortunately this version has broken swallow on vista/win7 so run these alternate scripts in 2 versions at the same time
https://www.dropbox.com/s/cep27pcym8a6a52/altscripts.zip?dl=1 enjoy!
Last edited by xPi on 23 Mar 2017, 07:40, edited 1 time in total.

dragonballfan1231
Posts: 8
Joined: 09 Mar 2013, 15:18
Reputation: 0

Post » 10 Mar 2013, 07:41

can u play over the internet with other people?

xPi
User avatar
Posts: 28
Joined: 11 Mar 2012, 13:17
Reputation: 0

Post » 10 Mar 2013, 17:53

you should be in the same room (in real life) as the person running the game

using this over the internet is not feasible. you could try sharing the screen with the other players but the result will be terrible for them. (worse than castle crashers since screen sharing is involved)

Wirespark
User avatar
Posts: 20
Joined: 23 Nov 2013, 08:01
Reputation: 2

Post » 14 Oct 2014, 23:13

i love the mod and i've been working with a wiimote and glovepie,
but i need help inserting a wiimote into mari0.


here are my minecraft scripts for glovepie
#1

Code: Select all

Cursor1.x = ((Nunchuk.JoyX/15) + mouse.x)
Cursor1.y = ((Nunchuk.JoyY/15)  + mouse.y)
Cursor1.LeftButton = Nunchuk.C
Cursor1.RightButton = Nunchuk.Z
wiimote.led2 = nunchuk.exists
mouse.leftbutton = wiimote.Shake

wiimote.led3 = wiimote.shake
wiimote.led4 = wiimote.shake
mouse.wheelup = wiimote.Minus
mouse.wheeldown = wiimote.plus
w = wiimote.Up
a = wiimote.Left
s = wiimote.Down
d = wiimote.right
e = wiimote.A
space = wiimote.b
ESCAPE = WIIMOTE.HOME



#2

Code: Select all

Cursor1.x = ((Nunchuk.JoyX/4) + mouse.x)
Cursor1.y = ((Nunchuk.Joyy/4) + mouse.y)
Cursor1.LeftButton = Nunchuk.C
Cursor1.RightButton = Nunchuk.Z
wiimote.led2 = nunchuk.exists
mouse.leftbutton = wiimote.Shake

wiimote.led3 = wiimote.shake
wiimote.led4 = wiimote.shake
mouse.wheelup = wiimote.Minus
mouse.wheeldown = wiimote.plus
w = wiimote.Up
a = wiimote.Left
s = wiimote.Down
d = wiimote.right
e = wiimote.A
space = wiimote.b


xPi
User avatar
Posts: 28
Joined: 11 Mar 2012, 13:17
Reputation: 0

Post » 15 Oct 2014, 16:38

Wirespark wrote:i love the mod and i've been working with a wiimote and glovepie,
but i need help inserting a wiimote into mari0.


here are my minecraft scripts for glovepie
#1

Code: Select all

Cursor1.x = ((Nunchuk.JoyX/15) + mouse.x)
Cursor1.y = ((Nunchuk.JoyY/15)  + mouse.y)
Cursor1.LeftButton = Nunchuk.C
Cursor1.RightButton = Nunchuk.Z
wiimote.led2 = nunchuk.exists
mouse.leftbutton = wiimote.Shake

wiimote.led3 = wiimote.shake
wiimote.led4 = wiimote.shake
mouse.wheelup = wiimote.Minus
mouse.wheeldown = wiimote.plus
w = wiimote.Up
a = wiimote.Left
s = wiimote.Down
d = wiimote.right
e = wiimote.A
space = wiimote.b
ESCAPE = WIIMOTE.HOME



#2

Code: Select all

Cursor1.x = ((Nunchuk.JoyX/4) + mouse.x)
Cursor1.y = ((Nunchuk.Joyy/4) + mouse.y)
Cursor1.LeftButton = Nunchuk.C
Cursor1.RightButton = Nunchuk.Z
wiimote.led2 = nunchuk.exists
mouse.leftbutton = wiimote.Shake

wiimote.led3 = wiimote.shake
wiimote.led4 = wiimote.shake
mouse.wheelup = wiimote.Minus
mouse.wheeldown = wiimote.plus
w = wiimote.Up
a = wiimote.Left
s = wiimote.Down
d = wiimote.right
e = wiimote.A
space = wiimote.b





if you're using my osc mouse mod:

use this glovepie script (based on your minecraft script)

Code: Select all

osc.ip = "127.0.0.1"
osc.port = 28436

var.x += deadzone(Nunchuk.JoyX,0.03) * 15 // fiddle with this number to adjust mouse speed!
var.y += deadzone(Nunchuk.JoyY,0.03) * 15 // fiddle with this number to adjust mouse speed!


if delta([var.x,var.y]) != [0,0] then
   osc.mouse.1.x = var.x
   osc.mouse.1.y = var.y
endif


if delta(Nunchuk.C     ) then osc.keyboard.1.wiinc       = Nunchuk.C
if delta(Nunchuk.Z     ) then osc.keyboard.1.wiinz       = Nunchuk.Z
if delta(wiimote.Minus ) then osc.keyboard.1.wiiminus    = wiimote.Minus
if delta(wiimote.plus  ) then osc.keyboard.1.wiiplus     = wiimote.plus
if delta(wiimote.Up    ) then osc.keyboard.1.wiiup       = wiimote.Up
if delta(wiimote.Left  ) then osc.keyboard.1.wiileft     = wiimote.Left
if delta(wiimote.Down  ) then osc.keyboard.1.wiidown     = wiimote.Down
if delta(wiimote.right ) then osc.keyboard.1.wiiright    = wiimote.right
if delta(wiimote.A     ) then osc.keyboard.1.wiia        = wiimote.A
if delta(wiimote.b     ) then osc.keyboard.1.wiib        = wiimote.b
if delta(WIIMOTE.HOME  ) then osc.keyboard.1.wiihome     = WIIMOTE.HOME   
if delta(wiimote.One   ) then osc.keyboard.1.wiione      = wiimote.One
if delta(wiimote.Two   ) then osc.keyboard.1.wiitwo      = wiimote.Two



then setup the controls similar to this

Image

the controls shown in this screenshot seem pretty awkward. not sure how to press LEFT RIGHT while holding the RUN or JUMP key

for this reason, I urge you to look into setting up a wii remote sensor bar near your computer

the glovepie script will need further changes to make the nunchuck stick work like keys and add sensor bar support

edit: modified the glovepie script to add sensor bar support and nunchuck stick as buttons

Code: Select all

osc.ip = "127.0.0.1"
osc.port = 28436

if delta(wiimote1.PointerXY) != [0,0] then
   //osc.mouse.1.x = wiimote.PointerX * 1000
   //osc.mouse.1.y = wiimote.PointerY * 1000
   osc.mouse.1.x = -wiimote.dot1x
   osc.mouse.1.y = wiimote.dot1y
endif


if delta(Nunchuk1.Left  ) then osc.keyboard.1.wiinleft    = Nunchuk1.Left
if delta(Nunchuk1.Right ) then osc.keyboard.1.wiinright   = Nunchuk1.Right
if delta(Nunchuk1.Up    ) then osc.keyboard.1.wiinup      = Nunchuk1.Up
if delta(Nunchuk1.Down  ) then osc.keyboard.1.wiindown    = Nunchuk1.Down
if delta(Nunchuk1.C     ) then osc.keyboard.1.wiinc       = Nunchuk1.C
if delta(Nunchuk1.Z     ) then osc.keyboard.1.wiinz       = Nunchuk1.Z
if delta(wiimote1.Minus ) then osc.keyboard.1.wiiminus    = wiimote1.Minus
if delta(wiimote1.plus  ) then osc.keyboard.1.wiiplus     = wiimote1.plus
if delta(wiimote1.Up    ) then osc.keyboard.1.wiiup       = wiimote1.Up
if delta(wiimote1.Left  ) then osc.keyboard.1.wiileft     = wiimote1.Left
if delta(wiimote1.Down  ) then osc.keyboard.1.wiidown     = wiimote1.Down
if delta(wiimote1.right ) then osc.keyboard.1.wiiright    = wiimote1.right
if delta(wiimote1.A     ) then osc.keyboard.1.wiia        = wiimote1.A
if delta(wiimote1.b     ) then osc.keyboard.1.wiib        = wiimote1.b
if delta(WIIMOTE1.HOME  ) then osc.keyboard.1.wiihome     = WIIMOTE1.HOME
if delta(wiimote1.One   ) then osc.keyboard.1.wiione      = wiimote1.One
if delta(wiimote1.Two   ) then osc.keyboard.1.wiitwo      = wiimote1.Two


example controls:
Image




ok, one more edit to add 4 wii remotes with nunchucks glovepie script!

Code: Select all

osc.ip = "127.0.0.1"
osc.port = 28436


if delta(wiimote1.PointerXY) != [0,0] then
   //osc.mouse.1.x = wiimote1.PointerX * 1000
   //osc.mouse.1.y = wiimote1.PointerY * 1000
   osc.mouse.1.x = -wiimote1.dot1x
   osc.mouse.1.y = wiimote1.dot1y
endif


if delta(wiimote1.Nunchuk.Left  ) then osc.keyboard.1.wiinleft    = wiimote1.Nunchuk.Left
if delta(wiimote1.Nunchuk.Right ) then osc.keyboard.1.wiinright   = wiimote1.Nunchuk.Right
if delta(wiimote1.Nunchuk.Up    ) then osc.keyboard.1.wiinup      = wiimote1.Nunchuk.Up
if delta(wiimote1.Nunchuk.Down  ) then osc.keyboard.1.wiindown    = wiimote1.Nunchuk.Down
if delta(wiimote1.Nunchuk.C     ) then osc.keyboard.1.wiinc       = wiimote1.Nunchuk.C
if delta(wiimote1.Nunchuk.Z     ) then osc.keyboard.1.wiinz       = wiimote1.Nunchuk.Z
if delta(wiimote1.Minus ) then osc.keyboard.1.wiiminus    = wiimote1.Minus
if delta(wiimote1.plus  ) then osc.keyboard.1.wiiplus     = wiimote1.plus
if delta(wiimote1.Up    ) then osc.keyboard.1.wiiup       = wiimote1.Up
if delta(wiimote1.Left  ) then osc.keyboard.1.wiileft     = wiimote1.Left
if delta(wiimote1.Down  ) then osc.keyboard.1.wiidown     = wiimote1.Down
if delta(wiimote1.right ) then osc.keyboard.1.wiiright    = wiimote1.right
if delta(wiimote1.A     ) then osc.keyboard.1.wiia        = wiimote1.A
if delta(wiimote1.b     ) then osc.keyboard.1.wiib        = wiimote1.b
if delta(WIIMOTE1.HOME  ) then osc.keyboard.1.wiihome     = WIIMOTE1.HOME
if delta(wiimote1.One   ) then osc.keyboard.1.wiione      = wiimote1.One
if delta(wiimote1.Two   ) then osc.keyboard.1.wiitwo      = wiimote1.Two




if delta(wiimote2.PointerXY) != [0,0] then
   //osc.mouse.2.x = wiimote2.PointerX * 1000
   //osc.mouse.2.y = wiimote2.PointerY * 1000
   osc.mouse.2.x = -wiimote2.dot1x
   osc.mouse.2.y = wiimote2.dot1y
endif


if delta(wiimote2.Nunchuk.Left  ) then osc.keyboard.2.wiinleft    = wiimote2.Nunchuk.Left
if delta(wiimote2.Nunchuk.Right ) then osc.keyboard.2.wiinright   = wiimote2.Nunchuk.Right
if delta(wiimote2.Nunchuk.Up    ) then osc.keyboard.2.wiinup      = wiimote2.Nunchuk.Up
if delta(wiimote2.Nunchuk.Down  ) then osc.keyboard.2.wiindown    = wiimote2.Nunchuk.Down
if delta(wiimote2.Nunchuk.C     ) then osc.keyboard.2.wiinc       = wiimote2.Nunchuk.C
if delta(wiimote2.Nunchuk.Z     ) then osc.keyboard.2.wiinz       = wiimote2.Nunchuk.Z
if delta(wiimote2.Minus ) then osc.keyboard.2.wiiminus    = wiimote2.Minus
if delta(wiimote2.plus  ) then osc.keyboard.2.wiiplus     = wiimote2.plus
if delta(wiimote2.Up    ) then osc.keyboard.2.wiiup       = wiimote2.Up
if delta(wiimote2.Left  ) then osc.keyboard.2.wiileft     = wiimote2.Left
if delta(wiimote2.Down  ) then osc.keyboard.2.wiidown     = wiimote2.Down
if delta(wiimote2.right ) then osc.keyboard.2.wiiright    = wiimote2.right
if delta(wiimote2.A     ) then osc.keyboard.2.wiia        = wiimote2.A
if delta(wiimote2.b     ) then osc.keyboard.2.wiib        = wiimote2.b
if delta(WIIMOTE2.HOME  ) then osc.keyboard.2.wiihome     = WIIMOTE2.HOME
if delta(wiimote2.One   ) then osc.keyboard.2.wiione      = wiimote2.One
if delta(wiimote2.Two   ) then osc.keyboard.2.wiitwo      = wiimote2.Two


if delta(wiimote3.PointerXY) != [0,0] then
   //osc.mouse.3.x = wiimote3.PointerX * 1000
   //osc.mouse.3.y = wiimote3.PointerY * 1000
   osc.mouse.3.x = -wiimote3.dot1x
   osc.mouse.3.y = wiimote3.dot1y
endif


if delta(wiimote3.Nunchuk.Left  ) then osc.keyboard.3.wiinleft    = wiimote3.Nunchuk.Left
if delta(wiimote3.Nunchuk.Right ) then osc.keyboard.3.wiinright   = wiimote3.Nunchuk.Right
if delta(wiimote3.Nunchuk.Up    ) then osc.keyboard.3.wiinup      = wiimote3.Nunchuk.Up
if delta(wiimote3.Nunchuk.Down  ) then osc.keyboard.3.wiindown    = wiimote3.Nunchuk.Down
if delta(wiimote3.Nunchuk.C     ) then osc.keyboard.3.wiinc       = wiimote3.Nunchuk.C
if delta(wiimote3.Nunchuk.Z     ) then osc.keyboard.3.wiinz       = wiimote3.Nunchuk.Z
if delta(wiimote3.Minus ) then osc.keyboard.3.wiiminus    = wiimote3.Minus
if delta(wiimote3.plus  ) then osc.keyboard.3.wiiplus     = wiimote3.plus
if delta(wiimote3.Up    ) then osc.keyboard.3.wiiup       = wiimote3.Up
if delta(wiimote3.Left  ) then osc.keyboard.3.wiileft     = wiimote3.Left
if delta(wiimote3.Down  ) then osc.keyboard.3.wiidown     = wiimote3.Down
if delta(wiimote3.right ) then osc.keyboard.3.wiiright    = wiimote3.right
if delta(wiimote3.A     ) then osc.keyboard.3.wiia        = wiimote3.A
if delta(wiimote3.b     ) then osc.keyboard.3.wiib        = wiimote3.b
if delta(WIIMOTE3.HOME  ) then osc.keyboard.3.wiihome     = WIIMOTE3.HOME
if delta(wiimote3.One   ) then osc.keyboard.3.wiione      = wiimote3.One
if delta(wiimote3.Two   ) then osc.keyboard.3.wiitwo      = wiimote3.Two


if delta(wiimote4.PointerXY) != [0,0] then
   //osc.mouse.4.x = wiimote4.PointerX * 1000
   //osc.mouse.4.y = wiimote4.PointerY * 1000
   osc.mouse.4.x = -wiimote4.dot1x
   osc.mouse.4.y = wiimote4.dot1y
endif


if delta(wiimote4.Nunchuk.Left  ) then osc.keyboard.4.wiinleft    = wiimote4.Nunchuk.Left
if delta(wiimote4.Nunchuk.Right ) then osc.keyboard.4.wiinright   = wiimote4.Nunchuk.Right
if delta(wiimote4.Nunchuk.Up    ) then osc.keyboard.4.wiinup      = wiimote4.Nunchuk.Up
if delta(wiimote4.Nunchuk.Down  ) then osc.keyboard.4.wiindown    = wiimote4.Nunchuk.Down
if delta(wiimote4.Nunchuk.C     ) then osc.keyboard.4.wiinc       = wiimote4.Nunchuk.C
if delta(wiimote4.Nunchuk.Z     ) then osc.keyboard.4.wiinz       = wiimote4.Nunchuk.Z
if delta(wiimote4.Minus ) then osc.keyboard.4.wiiminus    = wiimote4.Minus
if delta(wiimote4.plus  ) then osc.keyboard.4.wiiplus     = wiimote4.plus
if delta(wiimote4.Up    ) then osc.keyboard.4.wiiup       = wiimote4.Up
if delta(wiimote4.Left  ) then osc.keyboard.4.wiileft     = wiimote4.Left
if delta(wiimote4.Down  ) then osc.keyboard.4.wiidown     = wiimote4.Down
if delta(wiimote4.right ) then osc.keyboard.4.wiiright    = wiimote4.right
if delta(wiimote4.A     ) then osc.keyboard.4.wiia        = wiimote4.A
if delta(wiimote4.b     ) then osc.keyboard.4.wiib        = wiimote4.b
if delta(WIIMOTE4.HOME  ) then osc.keyboard.4.wiihome     = WIIMOTE4.HOME
if delta(wiimote4.One   ) then osc.keyboard.4.wiione      = wiimote4.One
if delta(wiimote4.Two   ) then osc.keyboard.4.wiitwo      = wiimote4.Two



unable to really test, would like to know if this works with 4 wii remotes with nunchucks plugged in


Return to “Modding”

Who is online

Users browsing this forum: stivan._ and 3 guests

cron