Verified Commit a29e2c0b authored by Thomas Bernard's avatar Thomas Bernard 💬

MOD_CTRL => GFX2_MOD_CTRL, etc.

parent fcc679ce
Pipeline #45812245 passed with stage
in 9 minutes and 25 seconds
......@@ -962,7 +962,7 @@ void Rotate_brush_1_5(void)
// On corrige les coordonnées de la ligne si la touche shift est appuyée...
cursor_x = Paintbrush_X;
cursor_y = Paintbrush_Y;
if(Get_Key_modifiers() & MOD_SHIFT)
if(Get_Key_modifiers() & GFX2_MOD_SHIFT)
Clamp_coordinates_regular_angle(Brush_rotation_center_X,Brush_rotation_center_Y,&cursor_x,&cursor_y);
if ( (cursor_x!=old_x) || (cursor_y!=old_y) || (prev_state!=2) )
......@@ -1033,7 +1033,7 @@ void Rotate_brush_0_5(void)
// On corrige les coordonnées de la ligne si la touche shift est appuyée...
cursor_x = Paintbrush_X;
cursor_y = Paintbrush_Y;
if(Get_Key_modifiers() & MOD_SHIFT)
if(Get_Key_modifiers() & GFX2_MOD_SHIFT)
Clamp_coordinates_regular_angle(Brush_rotation_center_X,Brush_rotation_center_Y,&cursor_x,&cursor_y);
if ((cursor_x!=old_x) || (cursor_y!=old_y) || (prev_state!=3))
......
......@@ -786,8 +786,8 @@ const T_Lookup Lookup_MouseSpeed[] = {
const T_Lookup Lookup_SwapButtons[] = {
{"None",0},
{"Control",MOD_CTRL},
{"Alt",MOD_ALT},
{"Control",GFX2_MOD_CTRL},
{"Alt",GFX2_MOD_ALT},
{NULL,-1},
};
......@@ -2588,7 +2588,7 @@ void Button_Gradients(int btn)
Window_set_normal_button(8,20,15,14,
(Main.backups->Pages->Gradients->Range[Current_gradient].Inverse)?"\033":"\032",0,1,KEY_TAB); // 4
// Technique
Window_set_normal_button(8,90,15,14,"",0,1,KEY_TAB|MOD_SHIFT); // 5
Window_set_normal_button(8,90,15,14,"",0,1,KEY_TAB|GFX2_MOD_SHIFT); // 5
Draw_button_gradient_style(8,90,Main.backups->Pages->Gradients->Range[Current_gradient].Technique);
Window_set_normal_button(178,128+12,51,14,"OK",0,1,KEY_RETURN); // 6
......
......@@ -1735,10 +1735,10 @@ void Button_Sieve_menu(void)
Window_set_normal_button( 8,46,131,14,"Get from brush" ,1,1,KEY_g); // 6
Window_set_normal_button(142,46,139,14,"Transfer to brush",1,1,KEY_t); // 7
Window_set_normal_button(109,114,11,11,"\030",0,1,KEY_UP|MOD_SHIFT); // 8
Window_set_normal_button(109,138,11,11,"\031",0,1,KEY_DOWN|MOD_SHIFT); // 9
Window_set_normal_button( 97,126,11,11,"\033",0,1,KEY_LEFT|MOD_SHIFT); // 10
Window_set_normal_button(121,126,11,11,"\032",0,1,KEY_RIGHT|MOD_SHIFT); // 11
Window_set_normal_button(109,114,11,11,"\030",0,1,KEY_UP|GFX2_MOD_SHIFT); // 8
Window_set_normal_button(109,138,11,11,"\031",0,1,KEY_DOWN|GFX2_MOD_SHIFT); // 9
Window_set_normal_button( 97,126,11,11,"\033",0,1,KEY_LEFT|GFX2_MOD_SHIFT); // 10
Window_set_normal_button(121,126,11,11,"\032",0,1,KEY_RIGHT|GFX2_MOD_SHIFT); // 11
button_bg_color = Window_set_normal_button(109,126,11,11,"" ,0,1,KEY_INSERT); // 12
Window_rectangle(button_bg_color->Pos_X+2,
button_bg_color->Pos_Y+2,
......
......@@ -3289,7 +3289,7 @@ short Window_get_button_shortcut(void)
T_Normal_button * temp;
T_Special_button * temp2;
if (Key & MOD_SHIFT)
if (Key & GFX2_MOD_SHIFT)
Window_attribute1=RIGHT_SIDE;
else
Window_attribute1=LEFT_SIDE;
......
......@@ -104,30 +104,15 @@ GFX2_GLOBAL char Key_Text[32];
#endif
// Keyboard modifiers
// (Name conflict with windows.h)
#ifdef WIN32
// first include windows.h so it's done and won't overwrite our
// MOD_SHIFT, etc. afterward
#include <windows.h>
#endif
#ifdef MOD_SHIFT
#undef MOD_SHIFT
#endif
#ifdef MOD_CTRL
#undef MOD_CTRL
#endif
#ifdef MOD_ALT
#undef MOD_ALT
#endif
/// Key modifier for SHIFT key. Used as mask in ::Key, for example.
#define MOD_SHIFT 0x1000
#define GFX2_MOD_SHIFT 0x1000
/// Key modifier for CONTROL key. Used as mask in ::Key, for example.
#define MOD_CTRL 0x2000
#define GFX2_MOD_CTRL 0x2000
/// Key modifier for ALT key. Used as mask in ::Key, for example.
#define MOD_ALT 0x4000
#define GFX2_MOD_ALT 0x4000
/// Key modifier for META key. Used as mask in ::Key, for example.
#define MOD_META 0x8000
#define GFX2_MOD_META 0x8000
/// Boolean set to true when the OS/window manager requests the application to close. ie: [X] button
GFX2_GLOBAL byte Quit_is_required;
......
This diff is collapsed.
......@@ -754,18 +754,18 @@ static int Handle_key_press(SDL_KeyboardEvent event)
{
case SDLK_RSHIFT:
case SDLK_LSHIFT:
modifier=MOD_SHIFT;
modifier=GFX2_MOD_SHIFT;
break;
case SDLK_RCTRL:
case SDLK_LCTRL:
modifier=MOD_CTRL;
modifier=GFX2_MOD_CTRL;
break;
case SDLK_RALT:
case SDLK_LALT:
case SDLK_MODE:
modifier=MOD_ALT;
modifier=GFX2_MOD_ALT;
break;
#if defined(USE_SDL2)
......@@ -775,7 +775,7 @@ static int Handle_key_press(SDL_KeyboardEvent event)
case SDLK_RMETA:
case SDLK_LMETA:
#endif
modifier=MOD_META;
modifier=GFX2_MOD_META;
break;
default:
......@@ -806,7 +806,7 @@ int Release_control(int key_code, int modifier)
{
int need_feedback = 0;
if (modifier == MOD_SHIFT)
if (modifier == GFX2_MOD_SHIFT)
{
// Disable "snap axis" mode
Snap_axis = 0;
......@@ -886,24 +886,24 @@ static int Handle_key_release(SDL_KeyboardEvent event)
{
case SDLK_RSHIFT:
case SDLK_LSHIFT:
modifier=MOD_SHIFT;
modifier=GFX2_MOD_SHIFT;
break;
case SDLK_RCTRL:
case SDLK_LCTRL:
modifier=MOD_CTRL;
modifier=GFX2_MOD_CTRL;
break;
case SDLK_RALT:
case SDLK_LALT:
case SDLK_MODE:
modifier=MOD_ALT;
modifier=GFX2_MOD_ALT;
break;
#ifdef RSUPER_EMULATES_META_MOD
case SDLK_RSUPER:
SDL_SetModState(SDL_GetModState() & ~KMOD_META);
modifier=MOD_META;
modifier=GFX2_MOD_META;
break;
#endif
......@@ -914,7 +914,7 @@ static int Handle_key_release(SDL_KeyboardEvent event)
case SDLK_RMETA:
case SDLK_LMETA:
#endif
modifier=MOD_META;
modifier=GFX2_MOD_META;
break;
default:
......@@ -938,7 +938,7 @@ static int Handle_joystick_press(SDL_JoyButtonEvent event)
if (event.button == Joybutton_control)
{
SDL_SetModState(SDL_GetModState() | KMOD_CTRL);
if (Config.Swap_buttons == MOD_CTRL && Button_inverter==0)
if (Config.Swap_buttons == GFX2_MOD_CTRL && Button_inverter==0)
{
Button_inverter=1;
if (Input_new_mouse_K)
......@@ -956,7 +956,7 @@ static int Handle_joystick_press(SDL_JoyButtonEvent event)
#else
SDL_SetModState(SDL_GetModState() | (KMOD_ALT|KMOD_GUI));
#endif
if (Config.Swap_buttons == MOD_ALT && Button_inverter==0)
if (Config.Swap_buttons == GFX2_MOD_ALT && Button_inverter==0)
{
Button_inverter=1;
if (Input_new_mouse_K)
......@@ -1035,12 +1035,12 @@ static int Handle_joystick_release(SDL_JoyButtonEvent event)
if (event.button == Joybutton_shift)
{
SDL_SetModState(SDL_GetModState() & ~KMOD_SHIFT);
return Release_control(0,MOD_SHIFT);
return Release_control(0,GFX2_MOD_SHIFT);
}
if (event.button == Joybutton_control)
{
SDL_SetModState(SDL_GetModState() & ~KMOD_CTRL);
return Release_control(0,MOD_CTRL);
return Release_control(0,GFX2_MOD_CTRL);
}
if (event.button == Joybutton_alt)
{
......@@ -1049,7 +1049,7 @@ static int Handle_joystick_release(SDL_JoyButtonEvent event)
#else
SDL_SetModState(SDL_GetModState() & ~(KMOD_ALT|KMOD_GUI));
#endif
return Release_control(0,MOD_ALT);
return Release_control(0,GFX2_MOD_ALT);
}
if (event.button == Joybutton_left_click)
{
......@@ -1649,13 +1649,13 @@ int Get_input(int sleep_time)
// NumLock = 10 Mod2Mask
// see "modmap"
if (event.xkey.state & ShiftMask)
mod |= MOD_SHIFT;
mod |= GFX2_MOD_SHIFT;
if (event.xkey.state & ControlMask)
mod |= MOD_CTRL;
mod |= GFX2_MOD_CTRL;
if (event.xkey.state & (Mod1Mask | Mod5Mask))
mod |= MOD_ALT;
mod |= GFX2_MOD_ALT;
if (event.xkey.state & Mod4Mask)
mod |= MOD_META;
mod |= GFX2_MOD_META;
//sym = XKeycodeToKeysym(X11_display, event.xkey.keycode, 0);
sym = XkbKeycodeToKeysym(X11_display, event.xkey.keycode, 0, 0);
GFX2_Log(GFX2_DEBUG, "key press code = %3d state=0x%08x sym = 0x%04lx %s\tmod=%04x\n",
......@@ -1698,13 +1698,13 @@ int Get_input(int sleep_time)
KeySym sym;
if (event.xkey.state & ShiftMask)
mod |= MOD_SHIFT;
mod |= GFX2_MOD_SHIFT;
if (event.xkey.state & ControlMask)
mod |= MOD_CTRL;
mod |= GFX2_MOD_CTRL;
if (event.xkey.state & (Mod1Mask | Mod5Mask))
mod |= MOD_ALT;
mod |= GFX2_MOD_ALT;
if (event.xkey.state & Mod4Mask)
mod |= MOD_META;
mod |= GFX2_MOD_META;
sym = XkbKeycodeToKeysym(X11_display, event.xkey.keycode, 0, 0);
GFX2_Log(GFX2_DEBUG, "keyrelease code= %3d state=0x%08x sym = 0x%04lx %s\tmod=%04x\n",
event.xkey.keycode, event.xkey.state, sym, XKeysymToString(sym), mod);
......@@ -1714,13 +1714,13 @@ int Get_input(int sleep_time)
case ButtonPress: // left = 1, middle = 2, right = 3, wheelup = 4, wheeldown = 5
//printf("Press button = %d state = 0x%08x\n", event.xbutton.button, event.xbutton.state);
if (event.xkey.state & ShiftMask)
mod |= MOD_SHIFT;
mod |= GFX2_MOD_SHIFT;
if (event.xkey.state & ControlMask)
mod |= MOD_CTRL;
mod |= GFX2_MOD_CTRL;
if (event.xkey.state & (Mod1Mask | Mod5Mask))
mod |= MOD_ALT;
mod |= GFX2_MOD_ALT;
if (event.xkey.state & Mod3Mask)
mod |= MOD_META;
mod |= GFX2_MOD_META;
switch(event.xbutton.button)
{
case 1:
......
......@@ -86,19 +86,19 @@ extern unsigned long X11_clipboard_size;
#if defined __HAIKU__
#define SHORTCUT_COPY (KEY_c|MOD_ALT)
#define SHORTCUT_COPY (KEY_c|GFX2_MOD_ALT)
#elif defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__) || defined(__macosx__)
#define SHORTCUT_COPY (KEY_c|MOD_META)
#define SHORTCUT_COPY (KEY_c|GFX2_MOD_META)
#else
#define SHORTCUT_COPY (KEY_c|MOD_CTRL)
#define SHORTCUT_COPY (KEY_c|GFX2_MOD_CTRL)
#endif
#if defined __HAIKU__
#define SHORTCUT_PASTE (KEY_v|MOD_ALT)
#define SHORTCUT_PASTE (KEY_v|GFX2_MOD_ALT)
#elif defined(__amigaos4__) || defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__) || defined(__macosx__)
#define SHORTCUT_PASTE (KEY_v|MOD_META)
#define SHORTCUT_PASTE (KEY_v|GFX2_MOD_META)
#else
#define SHORTCUT_PASTE (KEY_v|MOD_CTRL)
#define SHORTCUT_PASTE (KEY_v|GFX2_MOD_CTRL)
#endif
#endif
......@@ -339,13 +339,13 @@ word Get_Key_modifiers(void)
SDLMod mod = SDL_GetModState();
if (mod & KMOD_CTRL )
modifiers|=MOD_CTRL;
modifiers|=GFX2_MOD_CTRL;
if (mod & KMOD_SHIFT )
modifiers|=MOD_SHIFT;
modifiers|=GFX2_MOD_SHIFT;
if (mod & (KMOD_ALT|KMOD_MODE))
modifiers|=MOD_ALT;
modifiers|=GFX2_MOD_ALT;
if (mod & (KMOD_META))
modifiers|=MOD_META;
modifiers|=GFX2_MOD_META;
return modifiers;
}
......@@ -391,13 +391,13 @@ word Keysym_to_keycode(SDL_Keysym keysym)
#else
mod = 0;
if (keysym.mod & KMOD_CTRL)
mod |= MOD_CTRL;
mod |= GFX2_MOD_CTRL;
if (keysym.mod & KMOD_SHIFT )
mod |= MOD_SHIFT;
mod |= GFX2_MOD_SHIFT;
if (keysym.mod & (KMOD_ALT|KMOD_MODE))
mod |= MOD_ALT;
mod |= GFX2_MOD_ALT;
if (keysym.mod & (KMOD_GUI))
mod |= MOD_META;
mod |= GFX2_MOD_META;
#endif
// SDL_GetModState() seems to get the right up-to-date info.
......@@ -565,24 +565,24 @@ const char * Key_name(word key)
return "None";
#ifdef GCWZERO
if (key & MOD_CTRL)
if (key & GFX2_MOD_CTRL)
strcat(buffer, "A+");
if (key & MOD_ALT)
if (key & GFX2_MOD_ALT)
strcat(buffer, "B+");
if (key & MOD_SHIFT)
if (key & GFX2_MOD_SHIFT)
strcat(buffer, "X+");
#else
if (key & MOD_CTRL)
if (key & GFX2_MOD_CTRL)
strcat(buffer, "Ctl+");
if (key & MOD_ALT)
if (key & GFX2_MOD_ALT)
strcat(buffer, "Alt+");
if (key & MOD_SHIFT)
if (key & GFX2_MOD_SHIFT)
strcat(buffer, "Shift+");
#endif
if (key & MOD_META)
if (key & GFX2_MOD_META)
strcat(buffer, META_KEY_PREFIX);
key=key & ~(MOD_CTRL|MOD_ALT|MOD_SHIFT|MOD_META);
key=key & ~(GFX2_MOD_CTRL|GFX2_MOD_ALT|GFX2_MOD_SHIFT|GFX2_MOD_META);
// 99 is only a sanity check
if (key>=KEY_JOYBUTTON && key<=KEY_JOYBUTTON+99)
......@@ -864,23 +864,23 @@ word Get_Key_modifiers(void)
word mod = 0;
#if defined(WIN32)
if (GetKeyState(VK_SHIFT) & 0x8000)
mod |= MOD_SHIFT;
mod |= GFX2_MOD_SHIFT;
// Pressing AltGr is reported by windows as the right Alt together with the Left control keys
if ((GetKeyState(VK_RMENU) & 0x8000) && (GetKeyState(VK_LCONTROL) & 0x8000))
{
mod |= MOD_ALT; // ALT GR
mod |= GFX2_MOD_ALT; // ALT GR
if (GetKeyState(VK_RCONTROL) & 0x8000)
mod |= MOD_CTRL;
mod |= GFX2_MOD_CTRL;
}
else
{
if (GetKeyState(VK_CONTROL) & 0x8000)
mod |= MOD_CTRL;
mod |= GFX2_MOD_CTRL;
if (GetKeyState(VK_MENU) & 0x8000)
mod |= MOD_ALT;
mod |= GFX2_MOD_ALT;
}
if ((GetKeyState(VK_LWIN) | GetKeyState(VK_RWIN)) & 0x8000)
mod |= MOD_META;
mod |= GFX2_MOD_META;
#endif
return mod;
}
......
......@@ -32,10 +32,10 @@
/// - 0x0000 + SDLK_LAST+3: Mouse wheel down.
/// - 0x0000 + SDLK_LAST+4+B : Joystick button number "B", starting at B=0.
/// - 0x0800 + a number between 0 and 0x7FF: The scancode key number, for keys which have no "sym", such as keys from multimedia keyboards, and "fn" and "Thinkpad" key for a laptop.
/// Add 0x1000 for the Shift modifier MOD_SHIFT
/// Add 0x2000 for the Control modifier ::MOD_CTRL
/// Add 0x4000 for the Alt modifier ::MOD_ALT
/// Add 0x8000 for the "Meta" modifier ::MOD_META (On MacOS X it's the CMD key)
/// Add 0x1000 for the Shift modifier GFX2_MOD_SHIFT
/// Add 0x2000 for the Control modifier ::GFX2_MOD_CTRL
/// Add 0x4000 for the Alt modifier ::GFX2_MOD_ALT
/// Add 0x8000 for the "Meta" modifier ::GFX2_MOD_META (On MacOS X it's the CMD key)
//////////////////////////////////////////////////////////////////////////////
#if defined(USE_SDL)
#include <SDL.h>
......@@ -89,6 +89,6 @@ const char * Key_name(word key);
/*!
Gets the Key modifiers in our format
Returns a combination of ::MOD_SHIFT, ::MOD_ALT, ::MOD_CTRL
Returns a combination of ::GFX2_MOD_SHIFT, ::GFX2_MOD_ALT, ::GFX2_MOD_CTRL
*/
word Get_Key_modifiers(void);
......@@ -521,7 +521,7 @@ void Line_12_5(void)
cursor_y = Paintbrush_Y;
// On corrige les coordonnées de la ligne si la touche shift est appuyée...
if(Get_Key_modifiers() & MOD_SHIFT)
if(Get_Key_modifiers() & GFX2_MOD_SHIFT)
Clamp_coordinates_regular_angle(start_x,start_y,&cursor_x,&cursor_y);
// On vient de bouger
......@@ -3807,7 +3807,7 @@ void Grad_rectangle_12_9(void)
cursor_x = Paintbrush_X;
cursor_y = Paintbrush_Y;
// On corrige les coordonnées de la ligne si la touche shift est appuyée...
if(Get_Key_modifiers() & MOD_SHIFT)
if(Get_Key_modifiers() & GFX2_MOD_SHIFT)
Clamp_coordinates_regular_angle(start_x,start_y,&cursor_x,&cursor_y);
if ((cursor_x!=end_x) || (cursor_y!=end_y))
......
......@@ -983,10 +983,10 @@ int Load_INI(T_Config * conf)
switch(values[0])
{
case 1:
conf->Swap_buttons=MOD_CTRL;
conf->Swap_buttons=GFX2_MOD_CTRL;
break;
case 2:
conf->Swap_buttons=MOD_ALT;
conf->Swap_buttons=GFX2_MOD_ALT;
break;
}
}
......
......@@ -715,10 +715,10 @@ int Save_INI(const T_Config * conf)
switch(conf->Swap_buttons)
{
case MOD_CTRL:
case GFX2_MOD_CTRL:
values[0]=1;
break;
case MOD_ALT:
case GFX2_MOD_ALT:
values[0]=2;
break;
default:
......
......@@ -374,7 +374,7 @@ typedef struct
byte Right_click_colorpick; ///< Boolean, true to enable a "tablet" mode, where RMB acts as instant colorpicker
byte Sync_views; ///< Boolean, true when the Main and Spare should share their viewport settings.
byte Stylus_mode; ///< Boolean, true to tweak some tools (eg:Curve) for single-button stylus.
word Swap_buttons; ///< Sets which key swaps mouse buttons : 0=none, or MOD_CTRL, or MOD_ALT.
word Swap_buttons; ///< Sets which key swaps mouse buttons : 0=none, or GFX2_MOD_CTRL, or GFX2_MOD_ALT.
char Scripts_directory[MAX_PATH_CHARACTERS];///< Full pathname of directory for Lua scripts
byte Allow_multi_shortcuts; ///< Boolean, true if the same key combination can trigger multiple shortcuts.
byte Tilemap_allow_flipped_x; ///< Boolean, true if the Tilemap tool should detect x-flipped tiles.
......
......@@ -1967,7 +1967,7 @@ void Compute_paintbrush_coordinates(void)
// Operations that implement it
#if defined(USE_SDL) || defined(USE_SDL2)
default:
if (Snap_axis==0 && (Get_Key_modifiers() & MOD_SHIFT))
if (Snap_axis==0 && (Get_Key_modifiers() & GFX2_MOD_SHIFT))
{
// Start "Snap axis" mode
Snap_axis=1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment