Fix CRASH in Help screen, when pressing PageDown in pages of less than 16 lines. Bug is present in 98.0% release:(
Internal support for action shortcuts on joystick buttons, mousewheel, mouse3. Mousewheel now scrolls lists in Save/Load, Text, Help. git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@589 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
0c26dc6459
commit
bb7f09fc8e
24
aide.c
24
aide.c
@ -339,13 +339,35 @@ void Fenetre_aide(int Section, const char *Sous_section)
|
||||
Scroller_aide();
|
||||
Touche=0;
|
||||
break;
|
||||
case (SDLK_LAST+2) : // WheelUp
|
||||
if (Position_d_aide_en_cours>3)
|
||||
Position_d_aide_en_cours-=3;
|
||||
else
|
||||
Position_d_aide_en_cours=0;
|
||||
Scroller_aide();
|
||||
Touche=0;
|
||||
break;
|
||||
case SDLK_PAGEDOWN : // PageDown
|
||||
if (Position_d_aide_en_cours<Nb_lignes-31)
|
||||
if (Nb_lignes>16)
|
||||
{
|
||||
if (Position_d_aide_en_cours<Nb_lignes-16-15)
|
||||
Position_d_aide_en_cours+=15;
|
||||
else
|
||||
Position_d_aide_en_cours=Nb_lignes-16;
|
||||
Scroller_aide();
|
||||
Touche=0;
|
||||
}
|
||||
break;
|
||||
case (SDLK_LAST+3) : // Wheeldown
|
||||
if (Nb_lignes>16)
|
||||
{
|
||||
if (Position_d_aide_en_cours<Nb_lignes-16-3)
|
||||
Position_d_aide_en_cours+=3;
|
||||
else
|
||||
Position_d_aide_en_cours=Nb_lignes-16;
|
||||
Scroller_aide();
|
||||
Touche=0;
|
||||
}
|
||||
break;
|
||||
case SDLK_HOME : // Home
|
||||
Position_d_aide_en_cours=0;
|
||||
|
||||
51
boutons.c
51
boutons.c
@ -50,6 +50,8 @@
|
||||
#include "sdlscreen.h"
|
||||
#include "windows.h"
|
||||
#include "brush.h"
|
||||
#include "input.h"
|
||||
|
||||
|
||||
#ifdef __WATCOMC__
|
||||
#include <windows.h>
|
||||
@ -2893,14 +2895,14 @@ byte Bouton_Load_ou_Save(byte Load, byte Image)
|
||||
case SDLK_PAGEDOWN : // Page Down
|
||||
*Fichier_recherche=0;
|
||||
Effacer_curseur();
|
||||
Select_Page_Down(&Principal_File_list_Position,&Principal_File_list_Decalage);
|
||||
Select_Page_Down(&Principal_File_list_Position,&Principal_File_list_Decalage,9);
|
||||
On_vient_de_scroller_dans_le_fileselect(Scroller_de_fichiers);
|
||||
Touche=0;
|
||||
break;
|
||||
case SDLK_PAGEUP : // Page Up
|
||||
*Fichier_recherche=0;
|
||||
Effacer_curseur();
|
||||
Select_Page_Up(&Principal_File_list_Position,&Principal_File_list_Decalage);
|
||||
Select_Page_Up(&Principal_File_list_Position,&Principal_File_list_Decalage,9);
|
||||
On_vient_de_scroller_dans_le_fileselect(Scroller_de_fichiers);
|
||||
Touche=0;
|
||||
break;
|
||||
@ -2918,6 +2920,20 @@ byte Bouton_Load_ou_Save(byte Load, byte Image)
|
||||
On_vient_de_scroller_dans_le_fileselect(Scroller_de_fichiers);
|
||||
Touche=0;
|
||||
break;
|
||||
case TOUCHE_MOUSEWHEELDOWN :
|
||||
*Fichier_recherche=0;
|
||||
Effacer_curseur();
|
||||
Select_Page_Down(&Principal_File_list_Position,&Principal_File_list_Decalage,3);
|
||||
On_vient_de_scroller_dans_le_fileselect(Scroller_de_fichiers);
|
||||
Touche=0;
|
||||
break;
|
||||
case TOUCHE_MOUSEWHEELUP :
|
||||
*Fichier_recherche=0;
|
||||
Effacer_curseur();
|
||||
Select_Page_Up(&Principal_File_list_Position,&Principal_File_list_Decalage,3);
|
||||
On_vient_de_scroller_dans_le_fileselect(Scroller_de_fichiers);
|
||||
Touche=0;
|
||||
break;
|
||||
case SDLK_BACKSPACE : // Backspace
|
||||
*Fichier_recherche=0;
|
||||
// Si le choix ".." est bien en tête des propositions...
|
||||
@ -6146,6 +6162,37 @@ void Bouton_Texte()
|
||||
A_redessiner=1;
|
||||
A_previsionner=1;
|
||||
}
|
||||
if (Touche == TOUCHE_MOUSEWHEELUP && Debut_liste>0)
|
||||
{
|
||||
Position_curseur+=Debut_liste;
|
||||
if (Debut_liste>=3)
|
||||
Debut_liste-=3;
|
||||
else
|
||||
Debut_liste=0;
|
||||
Position_curseur-=Debut_liste;
|
||||
// On affiche à nouveau la liste
|
||||
Effacer_curseur();
|
||||
A_redessiner=1;
|
||||
// Mise à jour du scroller
|
||||
Scroller_de_fontes->Position=Debut_liste;
|
||||
Fenetre_Dessiner_jauge(Scroller_de_fontes);
|
||||
}
|
||||
if (Touche==TOUCHE_MOUSEWHEELDOWN && Debut_liste<Fonte_nombre-NB_FONTES)
|
||||
{
|
||||
Position_curseur+=Debut_liste;
|
||||
Debut_liste+=3;
|
||||
if (Debut_liste+NB_FONTES>Fonte_nombre)
|
||||
{
|
||||
Debut_liste=Fonte_nombre-NB_FONTES;
|
||||
}
|
||||
Position_curseur-=Debut_liste;
|
||||
// On affiche à nouveau la liste
|
||||
Effacer_curseur();
|
||||
A_redessiner=1;
|
||||
// Mise à jour du scroller
|
||||
Scroller_de_fontes->Position=Debut_liste;
|
||||
Fenetre_Dessiner_jauge(Scroller_de_fontes);
|
||||
}
|
||||
if (Touche==Bouton[BOUTON_AIDE].Raccourci_gauche)
|
||||
Fenetre_aide(BOUTON_TEXTE, NULL);
|
||||
}
|
||||
|
||||
10
files.c
10
files.c
@ -561,7 +561,7 @@ void Select_Scroll_Up(short * Decalage_premier,short * Decalage_select)
|
||||
}
|
||||
|
||||
|
||||
void Select_Page_Down(short * Decalage_premier,short * Decalage_select)
|
||||
void Select_Page_Down(short * Decalage_premier,short * Decalage_select, short Lignes)
|
||||
{
|
||||
if (Liste_Nb_elements-1>*Decalage_premier+*Decalage_select)
|
||||
{
|
||||
@ -577,7 +577,7 @@ void Select_Page_Down(short * Decalage_premier,short * Decalage_select)
|
||||
else
|
||||
{
|
||||
if (Liste_Nb_elements>*Decalage_premier+18)
|
||||
*Decalage_premier+=9;
|
||||
*Decalage_premier+=Lignes;
|
||||
else
|
||||
{
|
||||
*Decalage_premier=Liste_Nb_elements-10;
|
||||
@ -589,7 +589,7 @@ void Select_Page_Down(short * Decalage_premier,short * Decalage_select)
|
||||
}
|
||||
|
||||
|
||||
void Select_Page_Up(short * Decalage_premier,short * Decalage_select)
|
||||
void Select_Page_Up(short * Decalage_premier,short * Decalage_select, short Lignes)
|
||||
{
|
||||
if (*Decalage_premier+*Decalage_select>0)
|
||||
{
|
||||
@ -597,8 +597,8 @@ void Select_Page_Up(short * Decalage_premier,short * Decalage_select)
|
||||
*Decalage_select=0;
|
||||
else
|
||||
{
|
||||
if (*Decalage_premier>9)
|
||||
*Decalage_premier-=9;
|
||||
if (*Decalage_premier>Lignes)
|
||||
*Decalage_premier-=Lignes;
|
||||
else
|
||||
*Decalage_premier=0;
|
||||
}
|
||||
|
||||
4
files.h
4
files.h
@ -39,8 +39,8 @@ void Determiner_element_de_la_liste(short Decalage_premier,short Decalage_select
|
||||
|
||||
void Select_Scroll_Down(short * Decalage_premier,short * Decalage_select);
|
||||
void Select_Scroll_Up (short * Decalage_premier,short * Decalage_select);
|
||||
void Select_Page_Down (short * Decalage_premier,short * Decalage_select);
|
||||
void Select_Page_Up (short * Decalage_premier,short * Decalage_select);
|
||||
void Select_Page_Down (short * Decalage_premier,short * Decalage_select, short Lignes);
|
||||
void Select_Page_Up (short * Decalage_premier,short * Decalage_select, short Lignes);
|
||||
void Select_End (short * Decalage_premier,short * Decalage_select);
|
||||
void Select_Home (short * Decalage_premier,short * Decalage_select);
|
||||
|
||||
|
||||
165
input.c
165
input.c
@ -28,6 +28,7 @@
|
||||
#include "windows.h"
|
||||
#include "erreurs.h"
|
||||
#include "divers.h"
|
||||
#include "input.h"
|
||||
|
||||
void Handle_Window_Resize(SDL_ResizeEvent event);
|
||||
void Handle_Window_Exit(SDL_QuitEvent event);
|
||||
@ -44,6 +45,14 @@ long Directional_delay;
|
||||
long Directional_last_move;
|
||||
long Directional_step;
|
||||
|
||||
// TODO: move to config
|
||||
short Button_shift=-1; // Button number that serves as a "shift" modifier
|
||||
short Button_control=-1; // Button number that serves as a "ctrl" modifier
|
||||
short Button_alt=-1; // Button number that serves as a "alt" modifier
|
||||
short Button_clic_gauche=0; // Button number that serves as left click
|
||||
short Button_clic_droit=0; // Button number that serves as right-click
|
||||
|
||||
|
||||
// Called each time there is a cursor move, either triggered by mouse or keyboard shortcuts
|
||||
int Move_cursor_with_constraints()
|
||||
{
|
||||
@ -156,15 +165,23 @@ int Handle_Mouse_Click(SDL_MouseButtonEvent event)
|
||||
INPUT_Nouveau_Mouse_K |= 1;
|
||||
break;
|
||||
|
||||
case SDL_BUTTON_MIDDLE:
|
||||
INPUT_Nouveau_Mouse_K |= 4;
|
||||
break;
|
||||
|
||||
case SDL_BUTTON_RIGHT:
|
||||
INPUT_Nouveau_Mouse_K |= 2;
|
||||
break;
|
||||
|
||||
case SDL_BUTTON_MIDDLE:
|
||||
Touche = TOUCHE_MOUSEMIDDLE;
|
||||
// TODO: systeme de répétition
|
||||
return 0;
|
||||
|
||||
case SDL_BUTTON_WHEELUP:
|
||||
Touche = TOUCHE_MOUSEWHEELUP;
|
||||
return 0;
|
||||
|
||||
case SDL_BUTTON_WHEELDOWN:
|
||||
Touche = TOUCHE_MOUSEWHEELDOWN;
|
||||
return 0;
|
||||
default:
|
||||
DEBUG("Unknown mouse button!",0);
|
||||
return 0;
|
||||
}
|
||||
return Move_cursor_with_constraints();
|
||||
@ -178,10 +195,6 @@ int Handle_Mouse_Release(SDL_MouseButtonEvent event)
|
||||
INPUT_Nouveau_Mouse_K &= ~1;
|
||||
break;
|
||||
|
||||
case SDL_BUTTON_MIDDLE:
|
||||
INPUT_Nouveau_Mouse_K &= ~4;
|
||||
break;
|
||||
|
||||
case SDL_BUTTON_RIGHT:
|
||||
INPUT_Nouveau_Mouse_K &= ~2;
|
||||
break;
|
||||
@ -259,6 +272,43 @@ int Handle_Key_Press(SDL_KeyboardEvent event)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Relache_controle(int CodeTouche, int Modifieur)
|
||||
{
|
||||
|
||||
if(CodeTouche == (Config_Touche[SPECIAL_MOUSE_UP]&0x0FFF) || (Config_Touche[SPECIAL_MOUSE_UP]&Modifieur))
|
||||
{
|
||||
Directional_up=0;
|
||||
}
|
||||
if(CodeTouche == (Config_Touche[SPECIAL_MOUSE_DOWN]&0x0FFF) || (Config_Touche[SPECIAL_MOUSE_DOWN]&Modifieur))
|
||||
{
|
||||
Directional_down=0;
|
||||
}
|
||||
if(CodeTouche == (Config_Touche[SPECIAL_MOUSE_LEFT]&0x0FFF) || (Config_Touche[SPECIAL_MOUSE_LEFT]&Modifieur))
|
||||
{
|
||||
Directional_left=0;
|
||||
}
|
||||
if(CodeTouche == (Config_Touche[SPECIAL_MOUSE_RIGHT]&0x0FFF) || (Config_Touche[SPECIAL_MOUSE_RIGHT]&Modifieur))
|
||||
{
|
||||
Directional_right=0;
|
||||
}
|
||||
if(CodeTouche == (Config_Touche[SPECIAL_CLICK_LEFT]&0x0FFF) || (Config_Touche[SPECIAL_CLICK_LEFT]&Modifieur))
|
||||
{
|
||||
INPUT_Nouveau_Mouse_K &= ~1;
|
||||
return Move_cursor_with_constraints();
|
||||
}
|
||||
if(CodeTouche == (Config_Touche[SPECIAL_CLICK_RIGHT]&0x0FFF) || (Config_Touche[SPECIAL_CLICK_RIGHT]&Modifieur))
|
||||
{
|
||||
INPUT_Nouveau_Mouse_K &= ~2;
|
||||
return Move_cursor_with_constraints();
|
||||
}
|
||||
|
||||
// Other keys don't need to be released : they are handled as "events" and procesed only once.
|
||||
// These clicks are apart because they need to be continuous (ie move while key pressed)
|
||||
// We are relying on "hardware" keyrepeat to achieve that.
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int Handle_Key_Release(SDL_KeyboardEvent event)
|
||||
{
|
||||
int Modifieur;
|
||||
@ -282,38 +332,7 @@ int Handle_Key_Release(SDL_KeyboardEvent event)
|
||||
default:
|
||||
Modifieur=0;
|
||||
}
|
||||
|
||||
if(ToucheR == (Config_Touche[SPECIAL_MOUSE_UP]&0x0FFF) || (Config_Touche[SPECIAL_MOUSE_UP]&Modifieur))
|
||||
{
|
||||
Directional_up=0;
|
||||
}
|
||||
if(ToucheR == (Config_Touche[SPECIAL_MOUSE_DOWN]&0x0FFF) || (Config_Touche[SPECIAL_MOUSE_DOWN]&Modifieur))
|
||||
{
|
||||
Directional_down=0;
|
||||
}
|
||||
if(ToucheR == (Config_Touche[SPECIAL_MOUSE_LEFT]&0x0FFF) || (Config_Touche[SPECIAL_MOUSE_LEFT]&Modifieur))
|
||||
{
|
||||
Directional_left=0;
|
||||
}
|
||||
if(ToucheR == (Config_Touche[SPECIAL_MOUSE_RIGHT]&0x0FFF) || (Config_Touche[SPECIAL_MOUSE_RIGHT]&Modifieur))
|
||||
{
|
||||
Directional_right=0;
|
||||
}
|
||||
if(ToucheR == (Config_Touche[SPECIAL_CLICK_LEFT]&0x0FFF) || (Config_Touche[SPECIAL_CLICK_LEFT]&Modifieur))
|
||||
{
|
||||
INPUT_Nouveau_Mouse_K &= ~1;
|
||||
return Move_cursor_with_constraints();
|
||||
}
|
||||
if(ToucheR == (Config_Touche[SPECIAL_CLICK_RIGHT]&0x0FFF) || (Config_Touche[SPECIAL_CLICK_RIGHT]&Modifieur))
|
||||
{
|
||||
INPUT_Nouveau_Mouse_K &= ~2;
|
||||
return Move_cursor_with_constraints();
|
||||
}
|
||||
|
||||
// Other keys don't need to be released : they are handled as "events" and procesed only once.
|
||||
// These clicks are apart because they need to be continuous (ie move while key pressed)
|
||||
// We are relying on "hardware" keyrepeat to achieve that.
|
||||
return 0;
|
||||
return Relache_controle(ToucheR, Modifieur);
|
||||
}
|
||||
|
||||
|
||||
@ -323,6 +342,31 @@ int Handle_Joystick_Press(SDL_JoyButtonEvent event)
|
||||
{
|
||||
if (event.which==0) // joystick number 0
|
||||
{
|
||||
if (event.button == Button_shift)
|
||||
{
|
||||
SDL_SetModState(SDL_GetModState() | KMOD_SHIFT);
|
||||
return 0;
|
||||
}
|
||||
if (event.button == Button_control)
|
||||
{
|
||||
SDL_SetModState(SDL_GetModState() | KMOD_CTRL);
|
||||
return 0;
|
||||
}
|
||||
if (event.button == Button_alt)
|
||||
{
|
||||
SDL_SetModState(SDL_GetModState() | (KMOD_ALT|KMOD_META));
|
||||
return 0;
|
||||
}
|
||||
if (event.button == Button_clic_gauche)
|
||||
{
|
||||
INPUT_Nouveau_Mouse_K=1;
|
||||
return Move_cursor_with_constraints();
|
||||
}
|
||||
if (event.button == Button_clic_droit)
|
||||
{
|
||||
INPUT_Nouveau_Mouse_K=2;
|
||||
return Move_cursor_with_constraints();
|
||||
}
|
||||
#ifdef __gp2x__
|
||||
switch(event.button)
|
||||
{
|
||||
@ -352,32 +396,37 @@ int Handle_Joystick_Press(SDL_JoyButtonEvent event)
|
||||
Directional_up_left=1;
|
||||
break;
|
||||
#endif
|
||||
case GP2X_BUTTON_A: // A
|
||||
INPUT_Nouveau_Mouse_K=1;
|
||||
break;
|
||||
case GP2X_BUTTON_B: // B
|
||||
INPUT_Nouveau_Mouse_K=2;
|
||||
break;
|
||||
}
|
||||
#else
|
||||
switch(event.button)
|
||||
{
|
||||
case 0: // A
|
||||
INPUT_Nouveau_Mouse_K=1;
|
||||
break;
|
||||
case 1: // B
|
||||
INPUT_Nouveau_Mouse_K=2;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
#endif
|
||||
}
|
||||
Touche = TOUCHE_BUTTON+event.button;
|
||||
// TODO: systeme de répétition
|
||||
|
||||
return Move_cursor_with_constraints();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Handle_Joystick_Release(SDL_JoyButtonEvent event)
|
||||
{
|
||||
if (event.which==0) // joystick number 0
|
||||
{
|
||||
if (event.button == Button_shift)
|
||||
{
|
||||
SDL_SetModState(SDL_GetModState() & ~KMOD_SHIFT);
|
||||
return Relache_controle(0,MOD_SHIFT);
|
||||
}
|
||||
if (event.button == Button_control)
|
||||
{
|
||||
SDL_SetModState(SDL_GetModState() & ~KMOD_CTRL);
|
||||
return Relache_controle(0,MOD_CTRL);
|
||||
}
|
||||
if (event.button == Button_alt)
|
||||
{
|
||||
SDL_SetModState(SDL_GetModState() & ~(KMOD_ALT|KMOD_META));
|
||||
return Relache_controle(0,MOD_ALT);
|
||||
}
|
||||
|
||||
#ifdef __gp2x__
|
||||
switch(event.button)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user