I had the same idea as you, and hacked blight-input-0.0.8 a bit to work this way. Unfortunately it's not as convenient as I hoped, the mouse not jumping back to the center automatically matters much more than you'd think. Here's the patch, if you want to try it for yourself.
(Myself, I solved this by getting a wired Xbox360 controller for Christmas
--- src/plugin.c 2003-10-15 02:44:17.000000000 +0200
+++ src/plugin.c 2005-09-17 11:11:52.000000000 +0200
@@ -757,9 +757,10 @@
// read joystick state
SDL_JoystickUpdate();
+ static int mouse_x = 0, mouse_y = 0;
+ controller[Control].buttons.stick_y = mouse_x;
+ controller[Control].buttons.stick_x = -mouse_y;
controller[Control].buttons.button = 0;
- controller[Control].buttons.stick_x = 0;
- controller[Control].buttons.stick_y = 0;
if( controller[Control].device >= 0 )
{
@@ -822,6 +823,19 @@
// else if( controller[Control].device == DEVICE_KEYBOARD )
{
Uint8 *keystate = SDL_GetKeyState( NULL );
+ if( keystate[SDLK_LCTRL] || keystate[SDLK_RCTRL] )
+ {
+ if( SDL_WM_GrabInput( SDL_GRAB_QUERY ) == SDL_GRAB_ON )
+ {
+ SDL_WM_GrabInput( SDL_GRAB_OFF );
+ SDL_ShowCursor( SDL_ENABLE );
+ }
+ else
+ {
+ SDL_WM_GrabInput( SDL_GRAB_ON );
+ SDL_ShowCursor( SDL_DISABLE );
+ }
+ }
for( b = 0; b < 14; b++ )
{
if( controller[Control].button
.key == SDLK_UNKNOWN )
@@ -856,7 +870,9 @@
{
Uint8 mstate = SDL_GetMouseState( NULL, NULL );
- for( b = 0; b < 14; b++ )
+ if( mstate & SDL_BUTTON( 2 ) )
+ controller[Control].buttons.stick_y = controller[Control].buttons.stick_x = mouse_x = mouse_y = 0;
+ else for( b = 0; b < 14; b++ )
{
if( controller[Control].button.mouse < 1 )
continue;
@@ -873,21 +889,21 @@
{
if (event.motion.xrel)
{
- axis_val = (event.motion.xrel * 10);
- if (axis_val < -80)
- axis_val = -80;
- else if (axis_val > 80)
- axis_val = 80;
- controller[Control].buttons.stick_y = axis_val;
+ mouse_x += event.motion.xrel;
+ if (mouse_x < -80)
+ mouse_x = -80;
+ else if (mouse_x > 80)
+ mouse_x = 80;
+ controller[Control].buttons.stick_y = mouse_x;
}
if (event.motion.yrel)
{
- axis_val = (event.motion.yrel * 10);
- if (axis_val < -80)
- axis_val = -80;
- else if (axis_val > 80)
- axis_val = 80;
- controller[Control].buttons.stick_x = -axis_val;
+ mouse_y += event.motion.yrel;
+ if (mouse_y < -80)
+ mouse_y = -80;
+ else if (mouse_y > 80)
+ mouse_y = 80;
+ controller[Control].buttons.stick_x = -mouse_y;
}
}
}