Communication entre un joystick et DirectInput
Bonjour,
je suis vraiment dans l'urgence puisque mon projet doit être soutenu le vendredi 21 février. pour le moment je n'arrive pas à me débloquer de mon problème qui consiste à intégrer un joystick sidewinder force feedback II dans unity3d (mono). j'ai deux erreurs de programmation qui sont:
- la façon avec laquel je dois utiliser la méthode: SetCooperativeLevel à la ligne 36 et qui renvoie l'erreur suivante: Aucune surcharge pour la méthode 'SetCooperativeLevel' ne prend d'arguments '1' (CS1501).
- le problème de version ou la façon d'utiliser les listes dans unity3d et qui également renvoie cette erreur: Internal compiler error. See the console log for more information. output was:
Unhandled Exception: Mono.CSharp.InternalErrorException: Assets/Movement.cs(14,12): Movement.Movement() ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualC, Version=7.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
le programme est le suivant:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| using UnityEngine;
using System;
using System.Collections;
using System.ComponentModel;
using Microsoft.DirectX;
using Microsoft.DirectX.DirectInput;
public class Movement : MonoBehaviour
{
private Device joystick;
public float MoveDirectVitesse;
public float GaucheDroiteVitesse;
public Movement()
{
foreach (DeviceInstance di in Manager.GetDevices(DeviceClass.GameControl, EnumDevicesFlags.AttachedOnly))
{
joystick = new Device(di.InstanceGuid);
break;
}
if (joystick==null)
{
throw new Exception("Aucun joystick branché");
}
foreach (DeviceObjectInstance doi in joystick.Objects)
{
if ((doi.ObjectId & (int)DeviceObjectTypeFlags.Axis) != 0)
{
joystick.Properties.SetRange(ParameterHow.ById,doi.ObjectId,new InputRange(-50, 50));
}
}
joystick.Properties.AxisModeAbsolute = true;
//joystick.SetDataFormat (DeviceDataFormat.Joystick);
//joystick.SetCooperativeLevel(CooperativeLevelFlags.Exclusive);
joystick.Acquire();
JoystickState state = joystick.CurrentJoystickState;
MoveDirectVitesse=state.X;
GaucheDroiteVitesse=state.Y;
}
void Start()
{
}
// Update is called once per frame
void Update ()
{
// Amount to Move
float direct = Input.GetAxis("Vertical") * MoveDirectVitesse * Time.deltaTime;
float gauchedroite = Input.GetAxis("Horizontal") * GaucheDroiteVitesse * Time.deltaTime;
// Move the player
transform.Translate(UnityEngine.Vector3.back * direct);
transform.Translate(UnityEngine.Vector3.left* gauchedroite);
}
} |
je solliciter votre aide et je serais très reconnaissante pour toute suggestion qui peut me guider.