Released on xbins
Oh, here's the controller code i was talking about in the nfo:
CODE |
int i; xleft=yleft=xright=yright=0; for(i=0;i xleft=SDL_JoystickGetAxis(joy, 0); yleft=SDL_JoystickGetAxis(joy, 1); xright=SDL_JoystickGetAxis(joy, 2); yright=SDL_JoystickGetAxis(joy, 3); if(xright>100||xright<-100||yright>100||yright<-100||xleft>100||xleft<-100||yleft>100||yleft<-100) break; }
if((xleft>100||xleft<-100||yleft>100||yleft<-100)&&++jscount>=3) { int dx=0,dy=0; jscount=0; if(xleft>22000||xleft<-22000||yleft>22000||yleft<-22000) { xleft=xleft > 22000 ? 22000 : xleft < -22000 ? -22000 : xleft; yleft=yleft > 22000 ? 22000 : yleft < -22000 ? -22000 : yleft; } if(xleft>20000||xleft<-20000||yleft>20000||yleft<-20000) { dx=xleft/1500; dy=yleft/1500; } else if(xleft>15000||xleft<-15000||yleft>15000||yleft<-15000) { dx=xleft/3000; dy=yleft/3000; } else { if(xleft>10000) dx=2; else if (xleft<-10000) dx=-2; if(yleft>10000) dy=2; else if(yleft<-10000) dy=-2; if(dy!=0||dx!=0) jscount=-3; } ev.motion.type=SDL_MOUSEMOTION; ev.motion.x=_cursor.pos.x+dx; ev.motion.y=_cursor.pos.y+dy; if((_cursor.pos.x+dx)<2) ev.motion.x=1; if(ev.motion.x>_screen.width-2) ev.motion.x=_screen.width-1; if((_cursor.pos.y+dy)<2) ev.motion.y=1; if(ev.motion.y>_screen.height-2) ev.motion.y=_screen.height-1; ev.motion.state=0; ev.motion.which=5; ev.motion.xrel=dx; ev.motion.yrel=dy; }
|
If anyone feels like / is willing to write a better joystick-> mouse function, please,
be my guest... joystick axes range from -32000 to +32000, but on the xbox with my s controllers i noticed they mostly go from around 10000 to around 24000 (-24000 to -10000 for opposite direction) (they go up to +32k and -32k if you pull them all left, all right, or all down/all up, but if you move them to the bottom left or bottom right, they only get to -24000, 24000 and 24000,24000 (handling controller movement without mimicking a mousemovement is also possible, but requires different changes (for if you want to use absolute movement, for example))
This post has been edited by HCl on Oct 21 2004, 10:28 AM