Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Removed useless code.
Source Link
Vaillancourt
  • 16.4k
  • 17
  • 55
  • 61
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using SharpDX;
using SharpDX.DirectInput;


namespace Ps4_Controller
{
    public partial class Form1 : Form
    {
        DirectInput input = new DirectInput();
        Joystick stick;

        public Form1()
        {
            InitializeComponent();

            stick = ListJoysticks()[0];
        }

        private Joystick[] ListJoysticks()
        {
            List<Joystick> sticks = new List<Joystick>();

            foreach (DeviceInstance device in input.GetDevices(DeviceClass.GameControl, DeviceEnumerationFlags.AttachedOnly))
            {
                Joystick stick = new Joystick(input, device.InstanceGuid);
                stick.Acquire();
                
                foreach (DeviceObjectInstance deviceObject in stick.GetObjects(DeviceObjectTypeFlags.Axis))
                {
                    stick.GetObjectPropertiesById(deviceObject.ObjectId).Range = new InputRange(-100, 100);
                }
                sticks.Add(stick);
            }
            return sticks.ToArray();
        }

        private void HandleJoystick()
        {
            Joystick stick = ListJoysticks()[0];
            int[] axis = new int[0];

            foreach (DeviceObjectInstance doi in stick.GetObjects())
            {
                axis = new int[axis.Length + 1];
                axis[axis.Length - 1] = doi.Offset;
            }

            EffectParameters ep = new EffectParameters();
            DeviceInstance stick1 = new DeviceInstance();
            

            Effect effect = new Effect(stick.);
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using SharpDX;
using SharpDX.DirectInput;


namespace Ps4_Controller
{
    public partial class Form1 : Form
    {
        DirectInput input = new DirectInput();
        Joystick stick;

        public Form1()
        {
            InitializeComponent();

            stick = ListJoysticks()[0];
        }

        private Joystick[] ListJoysticks()
        {
            List<Joystick> sticks = new List<Joystick>();

            foreach (DeviceInstance device in input.GetDevices(DeviceClass.GameControl, DeviceEnumerationFlags.AttachedOnly))
            {
                Joystick stick = new Joystick(input, device.InstanceGuid);
                stick.Acquire();
                
                foreach (DeviceObjectInstance deviceObject in stick.GetObjects(DeviceObjectTypeFlags.Axis))
                {
                    stick.GetObjectPropertiesById(deviceObject.ObjectId).Range = new InputRange(-100, 100);
                }
                sticks.Add(stick);
            }
            return sticks.ToArray();
        }

        private void HandleJoystick()
        {
            Joystick stick = ListJoysticks()[0];
            int[] axis = new int[0];

            foreach (DeviceObjectInstance doi in stick.GetObjects())
            {
                axis = new int[axis.Length + 1];
                axis[axis.Length - 1] = doi.Offset;
            }

            EffectParameters ep = new EffectParameters();
            DeviceInstance stick1 = new DeviceInstance();
            

            Effect effect = new Effect(stick.);
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
}
namespace Ps4_Controller
{
    public partial class Form1 : Form
    {
        DirectInput input = new DirectInput();
        Joystick stick;

        public Form1()
        {
            InitializeComponent();

            stick = ListJoysticks()[0];
        }

        private Joystick[] ListJoysticks()
        {
            List<Joystick> sticks = new List<Joystick>();

            foreach (DeviceInstance device in input.GetDevices(DeviceClass.GameControl, DeviceEnumerationFlags.AttachedOnly))
            {
                Joystick stick = new Joystick(input, device.InstanceGuid);
                stick.Acquire();
                
                foreach (DeviceObjectInstance deviceObject in stick.GetObjects(DeviceObjectTypeFlags.Axis))
                {
                    stick.GetObjectPropertiesById(deviceObject.ObjectId).Range = new InputRange(-100, 100);
                }
                sticks.Add(stick);
            }
            return sticks.ToArray();
        }

        private void HandleJoystick()
        {
            Joystick stick = ListJoysticks()[0];
            int[] axis = new int[0];

            foreach (DeviceObjectInstance doi in stick.GetObjects())
            {
                axis = new int[axis.Length + 1];
                axis[axis.Length - 1] = doi.Offset;
            }

            EffectParameters ep = new EffectParameters();
            DeviceInstance stick1 = new DeviceInstance();
            

            Effect effect = new Effect(stick.);
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
}
Forgot to add J as for joystick in the title.
Source Link
Pikalek
  • 12.5k
  • 5
  • 45
  • 52

How can iI send effects to joystick connected to my pc usbPC USB using csharpC# and sharpdx?

So far iI can get a Listlist of the joysticks connected to my pcPC. But now iI want to send effects for example to send a command that will make a button click for example the triangle button or the square button.

But i'mI'm not sure how to continue with the Effectseffects and how to send the commands to the buttons.

How can i send effects to joystick connected to my pc usb using csharp and sharpdx?

So far i can get a List of the joysticks connected to my pc. But now i want to send effects for example to send a command that will make a button click for example the triangle button or the square button.

But i'm not sure how to continue with the Effects and how to send the commands to the buttons.

How can I send effects to joystick connected to my PC USB using C# and sharpdx?

I can get a list of the joysticks connected to my PC. But now I want to send effects for example to send a command that will make a button click for example the triangle button or the square button.

But I'm not sure how to continue with the effects and how to send the commands to the buttons.

How can i send effects to hoystickjoystick connected to my pc usb using csharp and sharpdx?

Source Link
Loading