Ok, did make now further testing with the new code:
1. There is an error in the submitted code
Win32/Joystick.cpp - Line 97 : JoystickState State = { 0 };
JoystickState isn't a POD anymore because of the constructor, so change this line to:
JoystickState State;
2. POV is initially still on 0. I simply changed Input::ResetStates to (marked the single line nearly at the end):
void Input::ResetStates()
{
for (int i = 0; i < Key::Count; ++i)
myKeys[i] = false;
for (int i = 0; i < Mouse::ButtonCount; ++i)
myMouseButtons[i] = false;
for (int i = 0; i < Joy::Count; ++i)
{
for (int j = 0; j < Joy::ButtonCount; ++j)
myJoystickButtons[i][j] = false;
for (int j = 0; j < Joy::AxisCount; ++j)
myJoystickAxis[i][j] = 0.f;
myJoystickAxis[i][Joy::AxisPOV] = -1.f; // <- I added this
}
}
After those changes everything worked very well on Win7 x64 with 2 real joysticks. So I moved to WinXP x86 and there also was no problem too.
Well, then I made the fatal error to try this on linux (I hate linux, somehow). After "hours" of setting up sfml, I had my usual problems with linux, I finally achieved it. I think it was worth, because there were several errors. Perhaps I better say first what does work:
- Buttons
- X and Y axes.
That is it
Now to the errors:
- POV is somehow mapped to R. Only upward (0°) and downward (180°) gives any output: 100 and -100, but not degrees.
- Ruder (normaly on R) is mapped to Z. At least there are correct values.
- Throttle (normaly on Z) isn't recognized at all.
Edit: Forgot, I'm using KUbuntu Jaunty Jackalope 9.04.
Feature that I may suggest:
- Add a function to re-identify joysticks while running the app. So you can plug in a joystick while the app is running and after calling this function, the joystick will be recognized. No restart of the app is needed.
Dravere
PS: No linux guys here to test? I don't want to do this :lol: