Voila j'ai commencer a écrire un code pour controler ma souris ainsi que le clic G/D la touche entrer, echap ect... avec ma manette Xbox 360 en C.
Sauf que je butte au passage "diriger la souris avec l'axe". Quand je bouge mon stick pour déplacer la souris, elle ne se déplace que de 1pixel. il faut que je bouge tout le temps l'axe et c assez lourd!!!
Jai donc essayé de faire un while par exemple:
while(event.jaxis.value < -3200)
SetCursorPos(CursorPos_x--, CursorPos_y);
Mais alors la quand je bouge le stick du coté de mon while le curseur fonce au bord de l'écran et y reste blocké!!! Comme si on ne sortait jamais de la boucle, meme en lachant le stick!
Et donc voila je reste blocke si vous pouviez m'aider sa serai super cool!!!
Voici le code (Sans le while que jai cité au dessu)
Code C/C++ :
---------------------------------------------------------------------------------------------
#include <stdlib.h>
#include <stdio.h>
#include <SDL/SDL.h>
#include <windows.h>
int main(int argc, char *argv[])
{
int continuer=1, tempsPrecedent = 0, tempsActuel = 0, CursorPos_x = 512, CursorPos_y = 300, stick = 1;
SDL_Event event;
SDL_Delay(1);
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK);
SDL_Joystick *joystick = NULL;
SDL_JoystickEventState(SDL_ENABLE);
joystick = SDL_JoystickOpen(0);
SetCursorPos(CursorPos_x, CursorPos_y);
SDL_EnableKeyRepeat(10, 10);
while(continuer)
{
SDL_WaitEvent(&event);
switch(event.type)
{
case SDL_QUIT:
continuer = 0;
break;
case SDL_JOYBUTTONDOWN:
if (event.jbutton.button == 0)
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
if (event.jbutton.button == 1)
mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0);
break;
case SDL_JOYBUTTONUP:
if (event.jbutton.button == 0)
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
if (event.jbutton.button == 1)
mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
break;
case SDL_JOYAXISMOTION:
if (event.jaxis.axis == 0 && event.jaxis.value < -3200) /* Vers la gauche */
{
SetCursorPos(CursorPos_x--, CursorPos_y);
}
else if (event.jaxis.axis == 0 && event.jaxis.value > 3200) /* Vers la droite */
{
SetCursorPos(CursorPos_x++, CursorPos_y);
}
else if (event.jaxis.axis == 1 && event.jaxis.value < -3200) /* Vers le haut */
{
SetCursorPos(CursorPos_x, CursorPos_y--);
}
else if (event.jaxis.axis == 1 && event.jaxis.value > 3200) /* Vers le bas */
{
SetCursorPos(CursorPos_x, CursorPos_y++);
}
}
break;
}
}
SDL_JoystickClose(joystick);
}
---------------------------------------------------------------------------------------
Je suis sous codeblocks