No announcement yet.

3DConnexion 3D mouse

  • Filter
  • Time
  • Show
Clear All
new posts

    3DConnexion 3D mouse

    Hello, fellow devs
    Ive made a little dll for my thesis, so i though i shared it with you(i wanted to see if it works on other 3DConnexion mice). (i hope the site doesnt crash, suggest alternative sites though)
    put it in your UDK/Binaries/Win32/UserCode

    This dll uses directInput, so it should work without driver of the mouse.
    DLL polls the mouse, so if your fps goes down, you probably get too sensitive input.
    Buttons arent supported yet, so you will have to use 3Dx drivers for getting button presses.

    Heres UScript Code
    In your gameinfo:
    class YourGame extends UTGame;
      PlayerControllerClass = class'YourProject.YourPlayerController'
    In your controller:
    class YourPlayerController extends UTPlayerController;
    In your playerInput
    class YourPlayerInput extends UDKPlayerInput within YourPlayerController
    //these are not necessary, i added them for my project
    var input float aPitch;
    var input float aYaw;
    var input float aRoll;
    var	float	PitchRotationSpeed;
    var	float	YawRotationSpeed;
    var	float	RollRotationSpeed;
    //-----------------3D Mouse definitions--------------------
    var int SelectedDevice;
    var bool b3DMouseConnected;
    //------------------DLLBind definitions--------------------
        var float       TX;                     /* x-axis position              */
        var float       TY;                     /* y-axis position              */
        var float       TZ;                     /* z-axis position              */
        var float       RX;                     /* x-axis rotation              */
        var float       RY;                     /* y-axis rotation              */
        var float	      RZ;                     /* z-axis rotation              */
        var int         rglSlider[2];           /* unnecessary, does nothing */
        var int         rgdwPOV[4];          /* unnecessary,	does nothing  */
        var byte        rgbButtons[32];    /* 32 buttons  not supported yet */
    const R_OK = 0;
    const R_FAILED = -1;
    dllimport final function int Init3dCnnxn();
    dllimport final function int Exit3dCnnxn();
    dllimport final function int GetData(out SPACEPILOTSTATE state);
    dllimport final function int GetSelectedDevice();
    dllimport final function int SetDeadzone(float translationDZ, float rotationDZ);
    dllimport final function int GetNumberOfDevices();
    dllimport final function int GetTestNumber();
    //----------------DLLBind definitions end------------------
    function InitInputSystem()
    	b3DMouseConnected = false;	
    	if(Init3dCnnxn() == R_OK){
    		b3DMouseConnected = true;	
    function CloseSystem()
    function Destroy()
    event PlayerInput( float DeltaTime )
    	local float TimeScale, DeltaT;
    	local SPACEPILOTSTATE sps;
    	local int num;
    	DeltaT = DeltaTime;
    	DeltaTime /= WorldInfo.TimeDilation;
    	if (Outer.bDemoOwner && WorldInfo.NetMode == NM_Client)
    		DeltaTime /= WorldInfo.DemoPlayTimeDilation;
    	num = GetData(sps);
            //Add to axis you want. I added 3 for rotation.
    	if(num == R_OK)
    		aBaseY += sps.TX/3200;
    		aStrafe += sps.TY/3200;
    		aUp += sps.TZ/3200;
    		aRoll += sps.RX/5000;
    		aPitch += sps.RY/5000;
    		aYaw += sps.RZ/5000;
    	// Scale to game speed
    	TimeScale = 100.f*DeltaTime;
    	aPitch		*= TimeScale * PitchRotationSpeed;
    	aYaw		*= TimeScale * YawRotationSpeed;
    	aRoll		*= TimeScale * RollRotationSpeed;
    	PitchRotationSpeed = 1200
    	YawRotationSpeed = 1200
    	RollRotationSpeed = 1200
            SelectedDevice = 0
    note: tested on SpacePilot pro
    note: I am using UDK November 2012