コード例 #1
0
ファイル: ScpForm.cs プロジェクト: TheLastRar/SCP2vJoy
        protected void Form_Load(object sender, EventArgs e)
        {
            if (components == null)
            {
                components = new System.ComponentModel.Container();
            }
            scpProxy = new ScpProxy(components);
            scpProxy.NativeFeedReceived += new EventHandler <ScpHidReport>(Parse);

            Icon = Properties.Resources.Scp_All;
            //if DefaultConfig.txt exits in working directory, use that
            if (System.IO.File.Exists("Default_vjConfig.txt"))
            {
                string[] configfile = System.IO.File.ReadAllLines("Default_vjConfig.txt");
                config = new PadSettings(configfile);
            }
            else
            {//No Default config, use our own
                config = new PadSettings(Properties.Resources.W3C.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None));
            }

            //cbPad.SelectedIndex = (Int32) m_Pad;

            dxLocker = new X360_InputLocker(this);

            if (!FormLoadScp())
            {
                MessageBox.Show(this, "Native Feed is not available", Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                Close();
            }
        }
コード例 #2
0
ファイル: ScpForm.cs プロジェクト: TheLastRar/SCP2vJoy
 private void btnLoadConfig_Click(object sender, EventArgs e)
 {
     if (openFileDialog1.ShowDialog() == DialogResult.OK)
     {
         string[] configfile = System.IO.File.ReadAllLines(openFileDialog1.FileName);
         config = new PadSettings(configfile);
     }
 }
コード例 #3
0
ファイル: ScpForm.cs プロジェクト: TheLastRar/SCP2vJoy
 private void btnLoadConfig_Click(object sender, EventArgs e)
 {
     if (openFileDialog1.ShowDialog() == DialogResult.OK)
     {
         string[] configfile = System.IO.File.ReadAllLines(openFileDialog1.FileName);
         config = new PadSettings(configfile);
     }
 }
コード例 #4
0
ファイル: ScpForm.cs プロジェクト: TheLastRar/SCP2vJoy
        protected void Form_Load(object sender, EventArgs e)
        {
            if (components == null)
            {
                components = new System.ComponentModel.Container();
            }
            scpProxy = new ScpProxy(components);
            scpProxy.NativeFeedReceived += new EventHandler<ScpHidReport>(Parse);

            Icon = Properties.Resources.Scp_All;
            //if DefaultConfig.txt exits in working directory, use that
            if (System.IO.File.Exists("Default_vjConfig.txt"))
            {
                string[] configfile = System.IO.File.ReadAllLines("Default_vjConfig.txt");
                config = new PadSettings(configfile);
            }
            else
            {//No Default config, use our own
                config = new PadSettings(Properties.Resources.W3C.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None));
            }

            //cbPad.SelectedIndex = (Int32) m_Pad;

            dxLocker = new X360_InputLocker(this);

            if (!FormLoadScp())
            {
                MessageBox.Show(this, "Native Feed is not available", Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                Close();
            }
        }
コード例 #5
0
ファイル: PadState.cs プロジェクト: TheLastRar/SCP2vJoy
 public DXPadState(vJoyPost parVJoyPad, PadSettings parConfig)
 {
     vJPad = parVJoyPad;
     config = parConfig;
     vJPad.VibrationCommand += Rumble;
 }
コード例 #6
0
ファイル: PadState.cs プロジェクト: TheLastRar/SCP2vJoy
 public DXPadState(vJoyPost parVJoyPad, PadSettings parConfig)
 {
     vJPad  = parVJoyPad;
     config = parConfig;
     vJPad.VibrationCommand += Rumble;
 }
コード例 #7
0
ファイル: ScpForm.cs プロジェクト: nefarius/SCP2vJoy
        protected void Form_Load(object sender, EventArgs e)
        {
            Icon = Properties.Resources.Scp_All;
            //if DefaultConfig.txt exits in working directory, use that
            if (System.IO.File.Exists("Default_vjConfig.txt"))
            {
                string[] configfile = System.IO.File.ReadAllLines("Default_vjConfig.txt");
                config = new PadSettings(configfile);
            }
            else
            {//No Default config, use our own
                config = new PadSettings(Properties.Resources.W3C.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None));
            }

            //cbPad.SelectedIndex = (Int32) m_Pad;

            dxLocker = new X360_InputLocker(this);
        }
コード例 #8
0
ファイル: VJoyPost.cs プロジェクト: nefarius/SCP2vJoy
        public bool Start(bool[] parSelectedPads, PadSettings config, DeviceManagement devManLevel)
        {
            //Setup vJoy
            //Perform device enable/disable based on dll version
            //EnableVJoy needs to know which version of vJoy we are running
            joystick = new vJoy();
            UInt32 DllVer = 0, DrvVer = 0;
            joystick.DriverMatch(ref DllVer, ref DrvVer);
            //MIN Version Check 1
            vJoyVersion = DllVer;
            if (vJoyVersion < vJoyConstants.MIN_VER)
            {
                Trace.WriteLine("vJoy version less than required: Aborting\n");
                Stop(parSelectedPads, devManLevel);
                return false;
            }

            if ((devManLevel & DeviceManagement.vJoy_Config) == DeviceManagement.vJoy_Config)
            {
                EnableVJoy(false);
                SetupVjoy(parSelectedPads, config);
                vJoyInstall.RefreshvJoy(); //do it like vJConfig does (needed in 2.1.6)
                EnableVJoy(true);
            }
            else if ((devManLevel & DeviceManagement.vJoy_Device) == DeviceManagement.vJoy_Device)
            {
                EnableVJoy(true);
            }

            if (!joystick.vJoyEnabled())
            {
                Trace.WriteLine("vJoy driver not enabled: Failed Getting vJoy attributes.\n");
                return false;
            }
            else
            {
                Trace.WriteLine(String.Format("Vendor : {0}\nProduct: {1}\nVersion: {2}\n",
                joystick.GetvJoyManufacturerString(),
                joystick.GetvJoyProductString(),
                joystick.GetvJoySerialNumberString()));

                // Test if DLL matches the driver
                bool match = joystick.DriverMatch(ref DllVer, ref DrvVer);
                if (match)
                {
                    Trace.WriteLine(String.Format("Version of Driver Matches DLL Version ({0:X})", DllVer));
                    Trace.WriteLine(String.Format("Version of vJoyInterfaceWrap.dll is ({0})",
                        typeof(vJoy).Assembly.GetName().Version));
                    Trace.WriteLine(String.Format("Version of ScpControl.dll is ({0})\n",
                        typeof(ScpControl.ScpProxy).Assembly.GetName().Version));
                }
                else
                {
                    Trace.WriteLine(String.Format("Version of Driver ({0:X}) does NOT match DLL Version ({1:X})\n", DrvVer, DllVer));
                    Stop(parSelectedPads, devManLevel);
                    return false;
                }
                //MinVersion Check
                vJoyVersion = DrvVer;
                if (vJoyVersion < vJoyConstants.MIN_VER)
                {
                    Trace.WriteLine("vJoy version less than required: Aborting\n");
                    Stop(parSelectedPads, devManLevel);
                    return false;
                }
            }

            for (uint dsID = 1; dsID <= SCPConstants.MAX_XINPUT_DEVICES; dsID++)
            {
                if (parSelectedPads[dsID - 1])
                {
                    uint id = GetvjFromDS(dsID);

                    // Acquire the target
                    VjdStat status = joystick.GetVJDStatus(id);
                    if ((status == VjdStat.VJD_STAT_OWN) || ((status == VjdStat.VJD_STAT_FREE) && (!joystick.AcquireVJD(id))))
                    {
                        Trace.WriteLine(String.Format("Failed to acquire vJoy device number {0}.", id));
                        Stop(parSelectedPads, devManLevel);
                        return false;
                    }
                    else
                    {
                        Trace.WriteLine(String.Format("Acquired vJoy device number {0}.", id));
                    }
                    Trace.WriteLine(String.Format("Buttons : {0}.", joystick.GetVJDButtonNumber(id)));
                    Trace.WriteLine(String.Format("DiscPov : {0}.", joystick.GetVJDDiscPovNumber(id)));
                    Trace.WriteLine(String.Format("ContPov : {0}.", joystick.GetVJDContPovNumber(id)));
                    //FFB
                    if (config.ffb)
                    {
                        vibrationCore = new vJoyVibrate(joystick);
                        vibrationCore.FfbInterface(dsID);
                        vibrationCore.VibrationCommand += VibEventProxy;
                    }
                    // Reset this device to default values
                    joystick.ResetVJD(id);
                    //Set Axis to mid value
                    joyReport[dsID - 1].AxisX = HALF_VJOY_AXIS;
                    joyReport[dsID - 1].AxisY = HALF_VJOY_AXIS;
                    joyReport[dsID - 1].AxisZ = HALF_VJOY_AXIS;
                    joyReport[dsID - 1].AxisXRot = HALF_VJOY_AXIS;
                    joyReport[dsID - 1].AxisYRot = HALF_VJOY_AXIS;
                    joyReport[dsID - 1].AxisZRot = HALF_VJOY_AXIS;
                    joyReport[dsID - 1].Slider = HALF_VJOY_AXIS;
                    joyReport[dsID - 1].Dial = HALF_VJOY_AXIS;
                }
            }
            return true;
        }
コード例 #9
0
ファイル: VJoyPost.cs プロジェクト: nefarius/SCP2vJoy
 public void SetupVjoy(bool[] parSelectedPads, PadSettings config)
 {
     VJoyConf VJC = new VJoyConf();
     //Clear out old configs
     VJC.DeleteHidReportDescFromReg(0); //TODO, Respect DevManagement levels
     //create needed pads
     byte dpads = 0;
     if (config.dpad) { dpads = 1; }
     for (uint dsID = 1; dsID <= SCPConstants.MAX_XINPUT_DEVICES; dsID++)
     {
         if (parSelectedPads[dsID - 1])
         {
             uint id = GetvjFromDS(dsID); //
             //byte[] PadConfig = VJC.CreateHidReportDesc(config.nButtons, config.enabledAxis, dpads, 0,(byte)id,
             //    false, new bool [] {false,false,false,false,false,false,false,false,false,false,false});
             byte[] PadConfig = VJC.CreateHidReportDesc(config.nButtons, config.enabledAxis, dpads, 0, (byte)id,
                 config.ffb, //enable vibration
                 new bool[] {
                     true, //Const
                     true, //Ramp
                     true, //Square Wave
                     true, //Sine Wave
                     true, //Tri Wave
                     true, //SawUp Wave
                     true, //SawDown wave
                     false, //Spring
                     false, //Damper
                     false, //Inertia
                     false  //Friction
                 });
             VJC.WriteHidReportDescToReg((int)id, PadConfig);
         }
     }
 }