Issue 275: Fixed cursor 'moving by itself' by disabling joystick control on desktop platforms

git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1251 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Yves Rizoud 2010-01-15 19:47:27 +00:00
parent 75226f6438
commit 3294a304bf
2 changed files with 15 additions and 12 deletions

View File

@ -251,6 +251,7 @@ else
NOTTF = 1 NOTTF = 1
PLATFORM = gp2x PLATFORM = gp2x
STRIP = /opt/open2x/gcc-4.1.1-glibc-2.3.6/arm-open2x-linux/bin/arm-open2x-linux-strip STRIP = /opt/open2x/gcc-4.1.1-glibc-2.3.6/arm-open2x-linux/bin/arm-open2x-linux-strip
JOYCOPT = -DUSE_JOYSTICK
else else
# Compiles a regular linux exectutable for the native platform # Compiles a regular linux exectutable for the native platform
@ -302,13 +303,13 @@ else
LUALABEL = LUALABEL =
endif endif
#To disable Joystick emulation of cursor, make NOJOY=1 (for input.o) #To enable Joystick emulation of cursor, make USE_JOYSTICK=1 (for input.o)
#This can be necessary to test keyboard cursor code, because an existing #This can be necessary to test cursor code on a PC, but by default for all
#joystick will keep reporting a contradicting position. #non-console platforms the joystick is disabled, to avoid reporting
ifeq ($(NOJOY),1) #'restless' movements when an analog joystick or a poorly-calibrated joypad
JOYCOPT = -DNO_JOYCURSOR #is plugged in.
else ifeq ($(USE_JOYSTICK),1)
JOYCOPT = JOYCOPT = -DUSE_JOYSTICK
endif endif
#To speed up rendering, can disable the layered editing #To speed up rendering, can disable the layered editing

10
input.c
View File

@ -465,7 +465,6 @@ int Handle_joystick_press(SDL_JoyButtonEvent event)
#ifdef __GP2X__ #ifdef __GP2X__
switch(event.button) switch(event.button)
{ {
#ifndef NO_JOYCURSOR
case GP2X_BUTTON_UP: case GP2X_BUTTON_UP:
Directional_up=1; Directional_up=1;
break; break;
@ -490,7 +489,6 @@ int Handle_joystick_press(SDL_JoyButtonEvent event)
case GP2X_BUTTON_UPLEFT: case GP2X_BUTTON_UPLEFT:
Directional_up_left=1; Directional_up_left=1;
break; break;
#endif
default: default:
break; break;
} }
@ -563,7 +561,6 @@ int Handle_joystick_release(SDL_JoyButtonEvent event)
void Handle_joystick_movement(SDL_JoyAxisEvent event) void Handle_joystick_movement(SDL_JoyAxisEvent event)
{ {
#ifndef NO_JOYCURSOR
if (event.axis==0) // X if (event.axis==0) // X
{ {
Directional_right=Directional_left=0; Directional_right=Directional_left=0;
@ -584,7 +581,6 @@ void Handle_joystick_movement(SDL_JoyAxisEvent event)
else if (event.value>1000) else if (event.value>1000)
Directional_down=1; Directional_down=1;
} }
#endif
} }
// Attempts to move the mouse cursor by the given deltas (may be more than 1 pixel at a time) // Attempts to move the mouse cursor by the given deltas (may be more than 1 pixel at a time)
@ -674,6 +670,9 @@ int Get_input(void)
Handle_key_release(event.key); Handle_key_release(event.key);
break; break;
// Start of Joystik handling
#ifdef USE_JOYSTICK
case SDL_JOYBUTTONUP: case SDL_JOYBUTTONUP:
Handle_joystick_release(event.jbutton); Handle_joystick_release(event.jbutton);
user_feedback_required = 1; user_feedback_required = 1;
@ -688,6 +687,9 @@ int Get_input(void)
Handle_joystick_movement(event.jaxis); Handle_joystick_movement(event.jaxis);
break; break;
#endif
// End of Joystick handling
default: default:
// DEBUG("Unhandled SDL event number : ",event.type); // DEBUG("Unhandled SDL event number : ",event.type);
break; break;