diff --git a/src/gui/sdl_mapper.cpp b/src/gui/sdl_mapper.cpp index 923eb2ec..aa861cd7 100644 --- a/src/gui/sdl_mapper.cpp +++ b/src/gui/sdl_mapper.cpp @@ -36,13 +36,15 @@ #include "support.h" #include "mapper.h" #include "setup.h" +#include "pic.h" enum { CLR_BLACK=0, - CLR_WHITE=1, - CLR_RED=2, - CLR_BLUE=3, - CLR_GREEN=4 + CLR_GREY=1, + CLR_WHITE=2, + CLR_RED=3, + CLR_BLUE=4, + CLR_GREEN=5 }; enum BB_Types { @@ -1263,7 +1265,6 @@ void CBindGroup::ActivateBindList(CBindList * list,Bits value,bool ev_trigger) { } } for (it=list->begin();it!=list->end();it++) { - /*BUG:CRASH if keymapper key is removed*/ if (validmod==(*it)->mods) (*it)->ActivateBind(value,ev_trigger); } } @@ -1317,6 +1318,7 @@ public: virtual bool OnTop(Bitu _x,Bitu _y) { return ( enabled && (_x>=x) && (_x=y) && (_ySetColor(event->bindlist.begin()==event->bindlist.end() ? CLR_GREY : CLR_WHITE); + } void Click(void) { - if (last_clicked) last_clicked->SetColor(CLR_WHITE); + if (last_clicked) last_clicked->BindColor(); this->SetColor(CLR_GREEN); SetActiveEvent(event); last_clicked=this; @@ -1748,7 +1753,7 @@ struct KeyBlock { KBD_KEYS key; }; static KeyBlock combo_f[12]={ - {"F1","f1",KBD_f1}, {"F2","f2",KBD_f2}, {"F3","f3",KBD_f3}, + {"F1","f1",KBD_f1}, {"F2","f2",KBD_f2}, {"F3","f3",KBD_f3}, {"F4","f4",KBD_f4}, {"F5","f5",KBD_f5}, {"F6","f6",KBD_f6}, {"F7","f7",KBD_f7}, {"F8","f8",KBD_f8}, {"F9","f9",KBD_f9}, {"F10","f10",KBD_f10}, {"F11","f11",KBD_f11}, {"F12","f12",KBD_f12}, @@ -1758,32 +1763,32 @@ static KeyBlock combo_1[14]={ {"`~","grave",KBD_grave}, {"1!","1",KBD_1}, {"2@","2",KBD_2}, {"3#","3",KBD_3}, {"4$","4",KBD_4}, {"5%","5",KBD_5}, {"6^","6",KBD_6}, {"7&","7",KBD_7}, {"8*","8",KBD_8}, - {"9(","9",KBD_9}, {"0)","0",KBD_0}, {"-_","minus",KBD_minus}, + {"9(","9",KBD_9}, {"0)","0",KBD_0}, {"-_","minus",KBD_minus}, {"=+","equals",KBD_equals}, {"\x1B","bspace",KBD_backspace}, }; static KeyBlock combo_2[12]={ - {"q","q",KBD_q}, {"w","w",KBD_w}, {"e","e",KBD_e}, - {"r","r",KBD_r}, {"t","t",KBD_t}, {"y","y",KBD_y}, - {"u","u",KBD_u}, {"i","i",KBD_i}, {"o","o",KBD_o}, - {"p","p",KBD_p}, {"[","lbracket",KBD_leftbracket}, - {"]","rbracket",KBD_rightbracket}, + {"Q","q",KBD_q}, {"W","w",KBD_w}, {"E","e",KBD_e}, + {"R","r",KBD_r}, {"T","t",KBD_t}, {"Y","y",KBD_y}, + {"U","u",KBD_u}, {"I","i",KBD_i}, {"O","o",KBD_o}, + {"P","p",KBD_p}, {"[{","lbracket",KBD_leftbracket}, + {"]}","rbracket",KBD_rightbracket}, }; static KeyBlock combo_3[12]={ - {"a","a",KBD_a}, {"s","s",KBD_s}, {"d","d",KBD_d}, - {"f","f",KBD_f}, {"g","g",KBD_g}, {"h","h",KBD_h}, - {"j","j",KBD_j}, {"k","k",KBD_k}, {"l","l",KBD_l}, - {";","semicolon",KBD_semicolon}, {"'","quote",KBD_quote}, - {"\\","backslash",KBD_backslash}, + {"A","a",KBD_a}, {"S","s",KBD_s}, {"D","d",KBD_d}, + {"F","f",KBD_f}, {"G","g",KBD_g}, {"H","h",KBD_h}, + {"J","j",KBD_j}, {"K","k",KBD_k}, {"L","l",KBD_l}, + {";:","semicolon",KBD_semicolon}, {"'\"","quote",KBD_quote}, + {"\\|","backslash",KBD_backslash}, }; static KeyBlock combo_4[11]={ - {"<","lessthan",KBD_extra_lt_gt}, - {"z","z",KBD_z}, {"x","x",KBD_x}, {"c","c",KBD_c}, - {"v","v",KBD_v}, {"b","b",KBD_b}, {"n","n",KBD_n}, - {"m","m",KBD_m}, {",","comma",KBD_comma}, - {".","period",KBD_period}, {"/","slash",KBD_slash}, + {"<>","lessthan",KBD_extra_lt_gt}, + {"Z","z",KBD_z}, {"X","x",KBD_x}, {"C","c",KBD_c}, + {"V","v",KBD_v}, {"B","b",KBD_b}, {"N","n",KBD_n}, + {"M","m",KBD_m}, {",<","comma",KBD_comma}, + {".>","period",KBD_period}, {"/?","slash",KBD_slash}, }; static CKeyEvent * caps_lock_event=NULL; @@ -1928,14 +1933,17 @@ static void CreateLayout(void) { AddJHatButton(PX(XO+8+2),PY(YO+1),BW,BH,"RGT",0,0,1); /* Labels for the joystick */ + CTextButton * btn; if (joytype ==JOY_2AXIS) { new CTextButton(PX(XO+0),PY(YO-1),3*BW,20,"Joystick 1"); new CTextButton(PX(XO+4),PY(YO-1),3*BW,20,"Joystick 2"); - new CTextButton(PX(XO+8),PY(YO-1),3*BW,20,"Disabled"); + btn=new CTextButton(PX(XO+8),PY(YO-1),3*BW,20,"Disabled"); + btn->SetColor(CLR_GREY); } else if(joytype ==JOY_4AXIS || joytype == JOY_4AXIS_2) { new CTextButton(PX(XO+0),PY(YO-1),3*BW,20,"Axis 1/2"); new CTextButton(PX(XO+4),PY(YO-1),3*BW,20,"Axis 3/4"); - new CTextButton(PX(XO+8),PY(YO-1),3*BW,20,"Disabled"); + btn=new CTextButton(PX(XO+8),PY(YO-1),3*BW,20,"Disabled"); + btn->SetColor(CLR_GREY); } else if(joytype == JOY_CH) { new CTextButton(PX(XO+0),PY(YO-1),3*BW,20,"Axis 1/2"); new CTextButton(PX(XO+4),PY(YO-1),3*BW,20,"Axis 3/4"); @@ -1945,9 +1953,12 @@ static void CreateLayout(void) { new CTextButton(PX(XO+4),PY(YO-1),3*BW,20,"Axis 3"); new CTextButton(PX(XO+8),PY(YO-1),3*BW,20,"Hat/D-pad"); } else if(joytype == JOY_NONE) { - new CTextButton(PX(XO+0),PY(YO-1),3*BW,20,"Disabled"); - new CTextButton(PX(XO+4),PY(YO-1),3*BW,20,"Disabled"); - new CTextButton(PX(XO+8),PY(YO-1),3*BW,20,"Disabled"); + btn=new CTextButton(PX(XO+0),PY(YO-1),3*BW,20,"Disabled"); + btn->SetColor(CLR_GREY); + btn=new CTextButton(PX(XO+4),PY(YO-1),3*BW,20,"Disabled"); + btn->SetColor(CLR_GREY); + btn=new CTextButton(PX(XO+8),PY(YO-1),3*BW,20,"Disabled"); + btn->SetColor(CLR_GREY); } @@ -1969,7 +1980,7 @@ static void CreateLayout(void) { // new CTextButton(PX(6),0,124,20,"Keyboard Layout"); // new CTextButton(PX(17),0,124,20,"Joystick Layout"); - bind_but.action=new CCaptionButton(180,330,0,0); + bind_but.action=new CCaptionButton(180,350,0,0); bind_but.event_title=new CCaptionButton(0,350,0,0); bind_but.bind_title=new CCaptionButton(0,365,0,0); @@ -1992,12 +2003,13 @@ static void CreateLayout(void) { bind_but.bind_title->Change("Bind Title"); } -static SDL_Color map_pal[5]={ +static SDL_Color map_pal[6]={ {0x00,0x00,0x00,0x00}, //0=black - {0xff,0xff,0xff,0x00}, //1=white - {0xff,0x00,0x00,0x00}, //2=red - {0x10,0x30,0xff,0x00}, //3=blue - {0x00,0xff,0x20,0x00} //4=green + {0x7f,0x7f,0x7f,0x00}, //1=grey + {0xff,0xff,0xff,0x00}, //2=white + {0xff,0x00,0x00,0x00}, //3=red + {0x10,0x30,0xff,0x00}, //4=blue + {0x00,0xff,0x20,0x00} //5=green }; static void CreateStringBind(char * line) { @@ -2321,14 +2333,18 @@ void MAPPER_LosingFocus(void) { } } -void MAPPER_Run(bool pressed) { - if (pressed) - return; +void MAPPER_RunEvent(Bitu /*val*/) { KEYBOARD_ClrBuffer(); //Clear buffer GFX_LosingFocus(); //Release any keys pressed (buffer gets filled again). MAPPER_RunInternal(); } +void MAPPER_Run(bool pressed) { + if (pressed) + return; + PIC_AddEvent(MAPPER_RunEvent,0); //In case mapper deletes the key object that ran it +} + SDL_Surface* SDL_SetVideoMode_Wrap(int width,int height,int bpp,Bit32u flags); void MAPPER_RunInternal() { @@ -2346,9 +2362,9 @@ void MAPPER_RunInternal() { if (mapper.surface == NULL) E_Exit("Could not initialize video mode for mapper: %s",SDL_GetError()); /* Set some palette entries */ - SDL_SetPalette(mapper.surface, SDL_LOGPAL|SDL_PHYSPAL, map_pal, 0, 5); + SDL_SetPalette(mapper.surface, SDL_LOGPAL|SDL_PHYSPAL, map_pal, 0, 6); if (last_clicked) { - last_clicked->SetColor(CLR_WHITE); + last_clicked->BindColor(); last_clicked=NULL; } /* Go in the event loop */ @@ -2379,6 +2395,9 @@ void MAPPER_Init(void) { CreateLayout(); CreateBindGroups(); if (!MAPPER_LoadBinds()) CreateDefaultBinds(); + for (CButton_it but_it = buttons.begin();but_it!=buttons.end();but_it++) { + (*but_it)->BindColor(); + } if (SDL_GetModState()&KMOD_CAPS) { for (CBindList_it bit=caps_lock_event->bindlist.begin();bit!=caps_lock_event->bindlist.end();bit++) { #if SDL_VERSION_ATLEAST(1, 2, 14) @@ -2409,19 +2428,7 @@ void MAPPER_StartUp(Section * sec) { Section_prop * section=static_cast(sec); mapper.sticks.num=0; mapper.sticks.num_groups=0; - Bitu i; - for (i=0; i