I'm trying to port an old project of mine from DirectX to SDL2. I'm using SDL2-CS because the only other binding I was available to find is C# SDL2, which seems to be outdated (last unstable version is 6.1.1beta in 2010, last stable - 6.1.0 in 2008)
Joystick (Logitech Force 3D Pro/Logitech Attack 3) is fully functional and working in Linux using SDL2 and DirectX 10 in Windows. Here is my Joystick-Hello-world in C# (using default Console Application project in VS2010; reference to SDL2-CS.dll (SDL2.dll is also present in the folder where the EXE is created) is also there and compiles/runs without any errors):
using System;
using System.Collection.Generic;
using System.Linq;
using System.Text;
using SDL2;
namespace Joystick_In_SDL_2_For_CSharp
{
class Program
{
static void Main(string[] args)
{
SDL.SDL_Init(SDL.SDL_INIT_EVERYTHING);
IntPtr myJoystick = SLD.SDL_Joystick(0);
if(myJoystick == IntPtr.Zero)
System.Console.WriteLine("Ooops, something fishy's goin' on here!" + SDL.SDL_GetError());
else
System.Console.WriteLine("You have successfully loaded the joystick \"" + SDL.SDL_JoystickName(myJoystick) + "\"");
SDL.SDL_JoystickClose(myJoystick);
}
}
}
Console displays the "Ooops"-message, the result from SDL.SDL_GetError() is There are 0 joysticks available and name is naturally = null. At least in Linux device index for me has always been == 0 (I've tested with 1,2,3...), because I have only had a single joystick connected to my notebook at a certain point in time. Do I have to add something more? Ideas, tips and/or criticism is most welcome!
Thanks, RBA