My source code on how to programm joysticks :
/*_FIL73R_ joystick control [Version 1.3.37]
(C) Copyright 2006/2007 _FIL73R_.*/
#include <windows.h>
#define SM_X 0
#define SM_Y 1
double x;
double y;
double Z = 0.1;
int xsm;
int ysm;
int axis_x;
int axis_y;
int buttonpress;
int main()
{
x = GetSystemMetrics(SM_X);
y = GetSystemMetrics(SM_Y);
xsm = GetSystemMetrics(SM_X);
ysm = GetSystemMetrics(SM_Y);
JOYINFOEX joyinfo;
joyinfo.dwSize = 64;
joyinfo.dwFlags = 255;
JOYCAPS joycaps;
if(joyGetDevCapsA(0,&joycaps,404)==0)
{
MessageBoxA(0,"Joystick check sucessfull ! Joystick found !","Joystick check info!",64);
MessageBoxA(0,"Now you can control the mouse with your joystick! Press 'OK' to begin...","Info!",64);
x = x/2;
y = y/2;
SetCursorPos(x,y);
while(1)
{
joyGetPosEx(0,&joyinfo);
axis_x = joyinfo.dwXpos;
axis_y = joyinfo.dwYpos;
buttonpress = joyinfo.dwButtons;
if(buttonpress>0)
{
if(buttonpress==1) { mouse_event(0x2,0,0,0,0); mouse_event(0x4,0,0,0,0); Sleep(150); }
if(buttonpress==2) { mouse_event(MOUSEEVENTF_RIGHTDOWN,0,0,0,0); mouse_event(MOUSEEVENTF_RIGHTUP,0,0,0,0); Sleep(200); }
if(buttonpress==4) { mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0); }
if(buttonpress==8) { mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0); }
if(buttonpress==16){ if(Z>0.01){ Z = Z-0.01; Sleep(20); } }
if(buttonpress==32){ if(Z<2.0){ Z = Z+0.01; Sleep(20); } }
if(buttonpress==64) { MessageBoxA(0,"You have pressed the quit button! Press 'OK' to quit !","Exit info!",48); return 0; }
}
if(axis_x == 0) { x = x-Z; }
if(axis_x == 65535) { x = x+Z; }
if(axis_y == 0) { y = y-Z; }
if(axis_y == 65535) { y = y+Z; }
SetCursorPos(x,y);
if(x<0) { x = 0 ; }
if(y<0>ysm) { y = ysm ; }
if(x>xsm) { x = xsm ; }
}
}
else{MessageBoxA(0,"Joystick check failed! No joysticks found!","Joystick check error info!",64);}
}
