add hotkey config values.
duplicate DlgInputConfig so that it can also do hotkey config. also prevent from opening those config dialogs a billion times.
This commit is contained in:
parent
cb1e6ce750
commit
ff1e21733d
|
@ -34,6 +34,9 @@ const char* kConfigFile = "melonDS.ini";
|
||||||
int KeyMapping[12];
|
int KeyMapping[12];
|
||||||
int JoyMapping[12];
|
int JoyMapping[12];
|
||||||
|
|
||||||
|
int HKKeyMapping[HK_MAX];
|
||||||
|
int HKJoyMapping[HK_MAX];
|
||||||
|
|
||||||
int WindowWidth;
|
int WindowWidth;
|
||||||
int WindowHeight;
|
int WindowHeight;
|
||||||
|
|
||||||
|
@ -90,6 +93,12 @@ ConfigEntry ConfigFile[] =
|
||||||
{"Joy_X", 0, &JoyMapping[10], -1, NULL, 0},
|
{"Joy_X", 0, &JoyMapping[10], -1, NULL, 0},
|
||||||
{"Joy_Y", 0, &JoyMapping[11], -1, NULL, 0},
|
{"Joy_Y", 0, &JoyMapping[11], -1, NULL, 0},
|
||||||
|
|
||||||
|
{"HKKey_Lid", 0, &HKKeyMapping[HK_Lid], 0x0E, NULL, 0},
|
||||||
|
{"HKKey_Mic", 0, &HKKeyMapping[HK_Mic], 0x35, NULL, 0},
|
||||||
|
|
||||||
|
{"HKJoy_Lid", 0, &HKJoyMapping[HK_Lid], -1, NULL, 0},
|
||||||
|
{"HKJoy_Mic", 0, &HKJoyMapping[HK_Mic], -1, NULL, 0},
|
||||||
|
|
||||||
{"WindowWidth", 0, &WindowWidth, 256, NULL, 0},
|
{"WindowWidth", 0, &WindowWidth, 256, NULL, 0},
|
||||||
{"WindowHeight", 0, &WindowHeight, 384, NULL, 0},
|
{"WindowHeight", 0, &WindowHeight, 384, NULL, 0},
|
||||||
|
|
||||||
|
|
11
src/Config.h
11
src/Config.h
|
@ -21,6 +21,14 @@
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
HK_Lid = 0,
|
||||||
|
HK_Mic,
|
||||||
|
|
||||||
|
HK_MAX
|
||||||
|
};
|
||||||
|
|
||||||
namespace Config
|
namespace Config
|
||||||
{
|
{
|
||||||
FILE* GetConfigFile(const char* fileName, const char* permissions);
|
FILE* GetConfigFile(const char* fileName, const char* permissions);
|
||||||
|
@ -31,6 +39,9 @@ void Save();
|
||||||
extern int KeyMapping[12];
|
extern int KeyMapping[12];
|
||||||
extern int JoyMapping[12];
|
extern int JoyMapping[12];
|
||||||
|
|
||||||
|
extern int HKKeyMapping[HK_MAX];
|
||||||
|
extern int HKJoyMapping[HK_MAX];
|
||||||
|
|
||||||
extern int WindowWidth;
|
extern int WindowWidth;
|
||||||
extern int WindowHeight;
|
extern int WindowHeight;
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ void ApplyNewSettings();
|
||||||
namespace DlgEmuSettings
|
namespace DlgEmuSettings
|
||||||
{
|
{
|
||||||
|
|
||||||
|
bool opened;
|
||||||
uiWindow* win;
|
uiWindow* win;
|
||||||
|
|
||||||
uiCheckbox* cbDirectBoot;
|
uiCheckbox* cbDirectBoot;
|
||||||
|
@ -42,12 +43,14 @@ uiCheckbox* cbBindAnyAddr;
|
||||||
|
|
||||||
int OnCloseWindow(uiWindow* window, void* blarg)
|
int OnCloseWindow(uiWindow* window, void* blarg)
|
||||||
{
|
{
|
||||||
|
opened = false;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnCancel(uiButton* btn, void* blarg)
|
void OnCancel(uiButton* btn, void* blarg)
|
||||||
{
|
{
|
||||||
uiControlDestroy(uiControl(win));
|
uiControlDestroy(uiControl(win));
|
||||||
|
opened = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnOk(uiButton* btn, void* blarg)
|
void OnOk(uiButton* btn, void* blarg)
|
||||||
|
@ -59,12 +62,20 @@ void OnOk(uiButton* btn, void* blarg)
|
||||||
Config::Save();
|
Config::Save();
|
||||||
|
|
||||||
uiControlDestroy(uiControl(win));
|
uiControlDestroy(uiControl(win));
|
||||||
|
opened = false;
|
||||||
|
|
||||||
ApplyNewSettings();
|
ApplyNewSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Open()
|
void Open()
|
||||||
{
|
{
|
||||||
|
if (opened)
|
||||||
|
{
|
||||||
|
uiControlSetFocus(uiControl(win));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
opened = true;
|
||||||
win = uiNewWindow("Emu settings - melonDS", 300, 200, 0, 0);
|
win = uiNewWindow("Emu settings - melonDS", 300, 200, 0, 0);
|
||||||
uiWindowSetMargined(win, 1);
|
uiWindowSetMargined(win, 1);
|
||||||
uiWindowOnClosing(win, OnCloseWindow, NULL);
|
uiWindowOnClosing(win, OnCloseWindow, NULL);
|
||||||
|
|
|
@ -35,19 +35,33 @@ extern SDL_Joystick* Joystick;
|
||||||
namespace DlgInputConfig
|
namespace DlgInputConfig
|
||||||
{
|
{
|
||||||
|
|
||||||
uiWindow* win;
|
typedef struct
|
||||||
|
{
|
||||||
|
int type;
|
||||||
|
uiWindow* win;
|
||||||
|
|
||||||
uiAreaHandler areahandler;
|
uiAreaHandler areahandler;
|
||||||
uiArea* keypresscatcher;
|
uiArea* keypresscatcher;
|
||||||
|
|
||||||
int keyorder[12] = {0, 1, 10, 11, 5, 4, 6, 7, 9, 8, 3, 2};
|
int numkeys;
|
||||||
char keylabels[12][8] = {"A:", "B:", "Select:", "Start:", "Right:", "Left:", "Up:", "Down:", "R:", "L:", "X:", "Y:"};
|
int keymap[32];
|
||||||
|
int joymap[32];
|
||||||
|
|
||||||
int keymap[12];
|
int pollid;
|
||||||
int joymap[12];
|
uiButton* pollbtn;
|
||||||
|
|
||||||
int pollid;
|
} InputDlgData;
|
||||||
uiButton* pollbtn;
|
|
||||||
|
|
||||||
|
int dskeyorder[12] = {0, 1, 10, 11, 5, 4, 6, 7, 9, 8, 3, 2};
|
||||||
|
char dskeylabels[12][8] = {"A:", "B:", "Select:", "Start:", "Right:", "Left:", "Up:", "Down:", "R:", "L:", "X:", "Y:"};
|
||||||
|
|
||||||
|
int identity[32] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31};
|
||||||
|
|
||||||
|
char hotkeylabels[HK_MAX][32] = {"Close/open lid:", "Microphone:"};
|
||||||
|
|
||||||
|
int openedmask;
|
||||||
|
InputDlgData inputdlg[2];
|
||||||
|
|
||||||
|
|
||||||
void JoyMappingName(int id, char* str)
|
void JoyMappingName(int id, char* str)
|
||||||
|
@ -97,7 +111,9 @@ void OnAreaResize(uiAreaHandler* handler, uiArea* area, int width, int height)
|
||||||
|
|
||||||
int OnAreaKeyEvent(uiAreaHandler* handler, uiArea* area, uiAreaKeyEvent* evt)
|
int OnAreaKeyEvent(uiAreaHandler* handler, uiArea* area, uiAreaKeyEvent* evt)
|
||||||
{
|
{
|
||||||
if (pollid < 0)
|
InputDlgData* dlg = (InputDlgData*)uiControl(area)->UserData;
|
||||||
|
|
||||||
|
if (dlg->pollid < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (evt->Scancode == 0x38) // ALT
|
if (evt->Scancode == 0x38) // ALT
|
||||||
|
@ -105,27 +121,27 @@ int OnAreaKeyEvent(uiAreaHandler* handler, uiArea* area, uiAreaKeyEvent* evt)
|
||||||
if (evt->Modifiers == 0x2) // ALT+key
|
if (evt->Modifiers == 0x2) // ALT+key
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (pollid > 12)
|
if (dlg->pollid > 12)
|
||||||
{
|
{
|
||||||
if (pollid < 0x100) return 0;
|
if (dlg->pollid < 0x100) return 0;
|
||||||
int id = pollid & 0xFF;
|
int id = dlg->pollid & 0xFF;
|
||||||
if (id > 12) return 0;
|
if (id > 12) return 0;
|
||||||
if (evt->Scancode != 0x1) // ESC
|
if (evt->Scancode != 0x1) // ESC
|
||||||
{
|
{
|
||||||
if (evt->Scancode == 0xE) // backspace
|
if (evt->Scancode == 0xE) // backspace
|
||||||
joymap[id] = -1;
|
dlg->joymap[id] = -1;
|
||||||
else
|
else
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
char keyname[16];
|
char keyname[16];
|
||||||
JoyMappingName(joymap[id], keyname);
|
JoyMappingName(dlg->joymap[id], keyname);
|
||||||
uiButtonSetText(pollbtn, keyname);
|
uiButtonSetText(dlg->pollbtn, keyname);
|
||||||
uiControlEnable(uiControl(pollbtn));
|
uiControlEnable(uiControl(dlg->pollbtn));
|
||||||
|
|
||||||
pollid = -1;
|
dlg->pollid = -1;
|
||||||
|
|
||||||
uiControlSetFocus(uiControl(pollbtn));
|
uiControlSetFocus(uiControl(dlg->pollbtn));
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -134,16 +150,16 @@ int OnAreaKeyEvent(uiAreaHandler* handler, uiArea* area, uiAreaKeyEvent* evt)
|
||||||
{
|
{
|
||||||
// set key.
|
// set key.
|
||||||
if (evt->Scancode != 0x1) // ESC
|
if (evt->Scancode != 0x1) // ESC
|
||||||
keymap[pollid] = evt->Scancode;
|
dlg->keymap[dlg->pollid] = evt->Scancode;
|
||||||
|
|
||||||
char* keyname = uiKeyName(keymap[pollid]);
|
char* keyname = uiKeyName(dlg->keymap[dlg->pollid]);
|
||||||
uiButtonSetText(pollbtn, keyname);
|
uiButtonSetText(dlg->pollbtn, keyname);
|
||||||
uiControlEnable(uiControl(pollbtn));
|
uiControlEnable(uiControl(dlg->pollbtn));
|
||||||
uiFreeText(keyname);
|
uiFreeText(keyname);
|
||||||
|
|
||||||
pollid = -1;
|
dlg->pollid = -1;
|
||||||
|
|
||||||
uiControlSetFocus(uiControl(pollbtn));
|
uiControlSetFocus(uiControl(dlg->pollbtn));
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -151,8 +167,10 @@ int OnAreaKeyEvent(uiAreaHandler* handler, uiArea* area, uiAreaKeyEvent* evt)
|
||||||
|
|
||||||
Uint32 JoyPoll(Uint32 interval, void* param)
|
Uint32 JoyPoll(Uint32 interval, void* param)
|
||||||
{
|
{
|
||||||
if (pollid < 0x100) return 0;
|
InputDlgData* dlg = (InputDlgData*)param;
|
||||||
int id = pollid & 0xFF;
|
|
||||||
|
if (dlg->pollid < 0x100) return 0;
|
||||||
|
int id = dlg->pollid & 0xFF;
|
||||||
if (id > 12) return 0;
|
if (id > 12) return 0;
|
||||||
|
|
||||||
SDL_JoystickUpdate();
|
SDL_JoystickUpdate();
|
||||||
|
@ -165,16 +183,16 @@ Uint32 JoyPoll(Uint32 interval, void* param)
|
||||||
{
|
{
|
||||||
if (SDL_JoystickGetButton(joy, i))
|
if (SDL_JoystickGetButton(joy, i))
|
||||||
{
|
{
|
||||||
joymap[id] = i;
|
dlg->joymap[id] = i;
|
||||||
|
|
||||||
char keyname[16];
|
char keyname[16];
|
||||||
JoyMappingName(joymap[id], keyname);
|
JoyMappingName(dlg->joymap[id], keyname);
|
||||||
uiButtonSetText(pollbtn, keyname);
|
uiButtonSetText(dlg->pollbtn, keyname);
|
||||||
uiControlEnable(uiControl(pollbtn));
|
uiControlEnable(uiControl(dlg->pollbtn));
|
||||||
|
|
||||||
pollid = -1;
|
dlg->pollid = -1;
|
||||||
|
|
||||||
uiControlSetFocus(uiControl(pollbtn));
|
uiControlSetFocus(uiControl(dlg->pollbtn));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -187,16 +205,16 @@ Uint32 JoyPoll(Uint32 interval, void* param)
|
||||||
else if (blackhat & 0x4) blackhat = 0x4;
|
else if (blackhat & 0x4) blackhat = 0x4;
|
||||||
else blackhat = 0x8;
|
else blackhat = 0x8;
|
||||||
|
|
||||||
joymap[id] = 0x100 | blackhat;
|
dlg->joymap[id] = 0x100 | blackhat;
|
||||||
|
|
||||||
char keyname[16];
|
char keyname[16];
|
||||||
JoyMappingName(joymap[id], keyname);
|
JoyMappingName(dlg->joymap[id], keyname);
|
||||||
uiButtonSetText(pollbtn, keyname);
|
uiButtonSetText(dlg->pollbtn, keyname);
|
||||||
uiControlEnable(uiControl(pollbtn));
|
uiControlEnable(uiControl(dlg->pollbtn));
|
||||||
|
|
||||||
pollid = -1;
|
dlg->pollid = -1;
|
||||||
|
|
||||||
uiControlSetFocus(uiControl(pollbtn));
|
uiControlSetFocus(uiControl(dlg->pollbtn));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,98 +224,147 @@ Uint32 JoyPoll(Uint32 interval, void* param)
|
||||||
|
|
||||||
void OnKeyStartConfig(uiButton* btn, void* data)
|
void OnKeyStartConfig(uiButton* btn, void* data)
|
||||||
{
|
{
|
||||||
if (pollid != -1)
|
InputDlgData* dlg = (InputDlgData*)uiControl(btn)->UserData;
|
||||||
|
|
||||||
|
if (dlg->pollid != -1)
|
||||||
{
|
{
|
||||||
// TODO: handle this better?
|
// TODO: handle this better?
|
||||||
if (pollid <= 12)
|
if (dlg->pollid <= 12)
|
||||||
uiControlSetFocus(uiControl(keypresscatcher));
|
uiControlSetFocus(uiControl(dlg->keypresscatcher));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int id = *(int*)data;
|
int id = *(int*)data;
|
||||||
pollid = id;
|
dlg->pollid = id;
|
||||||
pollbtn = btn;
|
dlg->pollbtn = btn;
|
||||||
|
|
||||||
uiButtonSetText(btn, "[press key]");
|
uiButtonSetText(btn, "[press key]");
|
||||||
uiControlDisable(uiControl(btn));
|
uiControlDisable(uiControl(btn));
|
||||||
|
|
||||||
uiControlSetFocus(uiControl(keypresscatcher));
|
uiControlSetFocus(uiControl(dlg->keypresscatcher));
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnJoyStartConfig(uiButton* btn, void* data)
|
void OnJoyStartConfig(uiButton* btn, void* data)
|
||||||
{
|
{
|
||||||
if (pollid != -1)
|
InputDlgData* dlg = (InputDlgData*)uiControl(btn)->UserData;
|
||||||
|
|
||||||
|
if (dlg->pollid != -1)
|
||||||
{
|
{
|
||||||
// TODO: handle this better?
|
// TODO: handle this better?
|
||||||
if (pollid <= 12)
|
if (dlg->pollid <= 12)
|
||||||
uiControlSetFocus(uiControl(keypresscatcher));
|
uiControlSetFocus(uiControl(dlg->keypresscatcher));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int id = *(int*)data;
|
int id = *(int*)data;
|
||||||
pollid = id | 0x100;
|
dlg->pollid = id | 0x100;
|
||||||
pollbtn = btn;
|
dlg->pollbtn = btn;
|
||||||
|
|
||||||
uiButtonSetText(btn, "[press button]");
|
uiButtonSetText(btn, "[press button]");
|
||||||
uiControlDisable(uiControl(btn));
|
uiControlDisable(uiControl(btn));
|
||||||
|
|
||||||
SDL_AddTimer(100, JoyPoll, NULL);
|
SDL_AddTimer(100, JoyPoll, dlg);
|
||||||
uiControlSetFocus(uiControl(keypresscatcher));
|
uiControlSetFocus(uiControl(dlg->keypresscatcher));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int OnCloseWindow(uiWindow* window, void* blarg)
|
int OnCloseWindow(uiWindow* window, void* blarg)
|
||||||
{
|
{
|
||||||
|
InputDlgData* dlg = (InputDlgData*)(uiControl(window)->UserData);
|
||||||
|
openedmask &= ~(1 << dlg->type);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnGetFocus(uiWindow* window, void* blarg)
|
void OnGetFocus(uiWindow* window, void* blarg)
|
||||||
{
|
{
|
||||||
if (pollid >= 0)
|
InputDlgData* dlg = (InputDlgData*)(uiControl(window)->UserData);
|
||||||
uiControlSetFocus(uiControl(keypresscatcher));
|
|
||||||
|
if (dlg->pollid >= 0)
|
||||||
|
uiControlSetFocus(uiControl(dlg->keypresscatcher));
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnLoseFocus(uiWindow* window, void* blarg)
|
void OnLoseFocus(uiWindow* window, void* blarg)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnCancel(uiButton* btn, void* blarg)
|
void OnCancel(uiButton* btn, void* data)
|
||||||
{
|
{
|
||||||
uiControlDestroy(uiControl(win));
|
InputDlgData* dlg = (InputDlgData*)data;
|
||||||
|
|
||||||
|
uiControlDestroy(uiControl(dlg->win));
|
||||||
|
openedmask &= ~(1 << dlg->type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnOk(uiButton* btn, void* blarg)
|
void OnOk(uiButton* btn, void* data)
|
||||||
{
|
{
|
||||||
memcpy(Config::KeyMapping, keymap, sizeof(int)*12);
|
InputDlgData* dlg = (InputDlgData*)data;
|
||||||
memcpy(Config::JoyMapping, joymap, sizeof(int)*12);
|
|
||||||
|
if (dlg->type == 0)
|
||||||
|
{
|
||||||
|
memcpy(Config::KeyMapping, dlg->keymap, sizeof(int)*12);
|
||||||
|
memcpy(Config::JoyMapping, dlg->joymap, sizeof(int)*12);
|
||||||
|
}
|
||||||
|
else if (dlg->type == 1)
|
||||||
|
{
|
||||||
|
memcpy(Config::HKKeyMapping, dlg->keymap, sizeof(int)*HK_MAX);
|
||||||
|
memcpy(Config::HKJoyMapping, dlg->joymap, sizeof(int)*HK_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
Config::Save();
|
Config::Save();
|
||||||
|
|
||||||
uiControlDestroy(uiControl(win));
|
uiControlDestroy(uiControl(dlg->win));
|
||||||
|
openedmask &= ~(1 << dlg->type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Open()
|
void Open(int type)
|
||||||
{
|
{
|
||||||
pollid = -1;
|
InputDlgData* dlg = &inputdlg[type];
|
||||||
|
|
||||||
memcpy(keymap, Config::KeyMapping, sizeof(int)*12);
|
int mask = 1 << type;
|
||||||
memcpy(joymap, Config::JoyMapping, sizeof(int)*12);
|
if (openedmask & mask)
|
||||||
|
{
|
||||||
|
uiControlSetFocus(uiControl(dlg->win));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
win = uiNewWindow("Input config - melonDS", 600, 400, 0, 0);
|
openedmask |= mask;
|
||||||
uiWindowSetMargined(win, 1);
|
|
||||||
uiWindowOnClosing(win, OnCloseWindow, NULL);
|
|
||||||
uiWindowOnGetFocus(win, OnGetFocus, NULL);
|
|
||||||
uiWindowOnLoseFocus(win, OnLoseFocus, NULL);
|
|
||||||
|
|
||||||
areahandler.Draw = OnAreaDraw;
|
dlg->type = type;
|
||||||
areahandler.MouseEvent = OnAreaMouseEvent;
|
dlg->pollid = -1;
|
||||||
areahandler.MouseCrossed = OnAreaMouseCrossed;
|
|
||||||
areahandler.DragBroken = OnAreaDragBroken;
|
if (type == 0)
|
||||||
areahandler.KeyEvent = OnAreaKeyEvent;
|
{
|
||||||
areahandler.Resize = OnAreaResize;
|
dlg->numkeys = 12;
|
||||||
|
memcpy(dlg->keymap, Config::KeyMapping, sizeof(int)*12);
|
||||||
|
memcpy(dlg->joymap, Config::JoyMapping, sizeof(int)*12);
|
||||||
|
|
||||||
|
dlg->win = uiNewWindow("Input config - melonDS", 600, 100, 0, 0);
|
||||||
|
}
|
||||||
|
else if (type == 1)
|
||||||
|
{
|
||||||
|
dlg->numkeys = HK_MAX;
|
||||||
|
memcpy(dlg->keymap, Config::HKKeyMapping, sizeof(int)*HK_MAX);
|
||||||
|
memcpy(dlg->joymap, Config::HKJoyMapping, sizeof(int)*HK_MAX);
|
||||||
|
|
||||||
|
dlg->win = uiNewWindow("Hotkey config - melonDS", 600, 100, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
uiControl(dlg->win)->UserData = dlg;
|
||||||
|
|
||||||
|
uiWindowSetMargined(dlg->win, 1);
|
||||||
|
uiWindowOnClosing(dlg->win, OnCloseWindow, NULL);
|
||||||
|
uiWindowOnGetFocus(dlg->win, OnGetFocus, NULL);
|
||||||
|
uiWindowOnLoseFocus(dlg->win, OnLoseFocus, NULL);
|
||||||
|
|
||||||
|
dlg->areahandler.Draw = OnAreaDraw;
|
||||||
|
dlg->areahandler.MouseEvent = OnAreaMouseEvent;
|
||||||
|
dlg->areahandler.MouseCrossed = OnAreaMouseCrossed;
|
||||||
|
dlg->areahandler.DragBroken = OnAreaDragBroken;
|
||||||
|
dlg->areahandler.KeyEvent = OnAreaKeyEvent;
|
||||||
|
dlg->areahandler.Resize = OnAreaResize;
|
||||||
|
|
||||||
uiBox* top = uiNewVerticalBox();
|
uiBox* top = uiNewVerticalBox();
|
||||||
uiWindowSetChild(win, uiControl(top));
|
uiWindowSetChild(dlg->win, uiControl(top));
|
||||||
uiControlHide(uiControl(top));
|
uiControlHide(uiControl(top));
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -312,19 +379,20 @@ void Open()
|
||||||
|
|
||||||
const int width = 120;
|
const int width = 120;
|
||||||
|
|
||||||
for (int i = 0; i < 12; i++)
|
for (int i = 0; i < dlg->numkeys; i++)
|
||||||
{
|
{
|
||||||
int j = keyorder[i];
|
int j = (type==0) ? dskeyorder[i] : i;
|
||||||
|
|
||||||
uiLabel* label = uiNewLabel(keylabels[j]);
|
uiLabel* label = uiNewLabel((type==0) ? dskeylabels[j] : hotkeylabels[j]);
|
||||||
uiGridAppend(b_key, uiControl(label), 0, i, 1, 1, 1, uiAlignStart, 1, uiAlignCenter);
|
uiGridAppend(b_key, uiControl(label), 0, i, 1, 1, 1, uiAlignStart, 1, uiAlignCenter);
|
||||||
uiControlSetMinSize(uiControl(label), width, 1);
|
uiControlSetMinSize(uiControl(label), width, 1);
|
||||||
|
|
||||||
char* keyname = uiKeyName(Config::KeyMapping[j]);
|
char* keyname = uiKeyName(dlg->keymap[j]);
|
||||||
|
|
||||||
uiButton* btn = uiNewButton(keyname);
|
uiButton* btn = uiNewButton(keyname);
|
||||||
|
uiControl(btn)->UserData = dlg;
|
||||||
uiGridAppend(b_key, uiControl(btn), 1, i, 1, 1, 1, uiAlignFill, 1, uiAlignCenter);
|
uiGridAppend(b_key, uiControl(btn), 1, i, 1, 1, 1, uiAlignFill, 1, uiAlignCenter);
|
||||||
uiButtonOnClicked(btn, OnKeyStartConfig, &keyorder[i]);
|
uiButtonOnClicked(btn, OnKeyStartConfig, (type==0) ? &dskeyorder[i] : &identity[i]);
|
||||||
uiControlSetMinSize(uiControl(btn), width, 1);
|
uiControlSetMinSize(uiControl(btn), width, 1);
|
||||||
|
|
||||||
uiFreeText(keyname);
|
uiFreeText(keyname);
|
||||||
|
@ -335,20 +403,21 @@ void Open()
|
||||||
uiGrid* b_joy = uiNewGrid();
|
uiGrid* b_joy = uiNewGrid();
|
||||||
uiGroupSetChild(g_joy, uiControl(b_joy));
|
uiGroupSetChild(g_joy, uiControl(b_joy));
|
||||||
|
|
||||||
for (int i = 0; i < 12; i++)
|
for (int i = 0; i < dlg->numkeys; i++)
|
||||||
{
|
{
|
||||||
int j = keyorder[i];
|
int j = (type==0) ? dskeyorder[i] : i;
|
||||||
|
|
||||||
uiLabel* label = uiNewLabel(keylabels[j]);
|
uiLabel* label = uiNewLabel((type==0) ? dskeylabels[j] : hotkeylabels[j]);
|
||||||
uiGridAppend(b_joy, uiControl(label), 0, i, 1, 1, 1, uiAlignStart, 1, uiAlignCenter);
|
uiGridAppend(b_joy, uiControl(label), 0, i, 1, 1, 1, uiAlignStart, 1, uiAlignCenter);
|
||||||
uiControlSetMinSize(uiControl(label), width, 1);
|
uiControlSetMinSize(uiControl(label), width, 1);
|
||||||
|
|
||||||
char keyname[16];
|
char keyname[16];
|
||||||
JoyMappingName(Config::JoyMapping[j], keyname);
|
JoyMappingName(dlg->joymap[j], keyname);
|
||||||
|
|
||||||
uiButton* btn = uiNewButton(keyname);
|
uiButton* btn = uiNewButton(keyname);
|
||||||
|
uiControl(btn)->UserData = dlg;
|
||||||
uiGridAppend(b_joy, uiControl(btn), 1, i, 1, 1, 1, uiAlignFill, 1, uiAlignCenter);
|
uiGridAppend(b_joy, uiControl(btn), 1, i, 1, 1, 1, uiAlignFill, 1, uiAlignCenter);
|
||||||
uiButtonOnClicked(btn, OnJoyStartConfig, &keyorder[i]);
|
uiButtonOnClicked(btn, OnJoyStartConfig, (type==0) ? &dskeyorder[i] : &identity[i]);
|
||||||
uiControlSetMinSize(uiControl(btn), width, 1);
|
uiControlSetMinSize(uiControl(btn), width, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -364,21 +433,22 @@ void Open()
|
||||||
uiLabel* dummy = uiNewLabel("");
|
uiLabel* dummy = uiNewLabel("");
|
||||||
uiBoxAppend(in_ctrl, uiControl(dummy), 1);
|
uiBoxAppend(in_ctrl, uiControl(dummy), 1);
|
||||||
|
|
||||||
keypresscatcher = uiNewArea(&areahandler);
|
dlg->keypresscatcher = uiNewArea(&dlg->areahandler);
|
||||||
uiBoxAppend(in_ctrl, uiControl(keypresscatcher), 0);
|
uiControl(dlg->keypresscatcher)->UserData = dlg;
|
||||||
|
uiBoxAppend(in_ctrl, uiControl(dlg->keypresscatcher), 0);
|
||||||
|
|
||||||
uiButton* btncancel = uiNewButton("Cancel");
|
uiButton* btncancel = uiNewButton("Cancel");
|
||||||
uiButtonOnClicked(btncancel, OnCancel, NULL);
|
uiButtonOnClicked(btncancel, OnCancel, dlg);
|
||||||
uiBoxAppend(in_ctrl, uiControl(btncancel), 0);
|
uiBoxAppend(in_ctrl, uiControl(btncancel), 0);
|
||||||
|
|
||||||
uiButton* btnok = uiNewButton("Ok");
|
uiButton* btnok = uiNewButton("Ok");
|
||||||
uiButtonOnClicked(btnok, OnOk, NULL);
|
uiButtonOnClicked(btnok, OnOk, dlg);
|
||||||
uiBoxAppend(in_ctrl, uiControl(btnok), 0);
|
uiBoxAppend(in_ctrl, uiControl(btnok), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
uiControlShow(uiControl(top));
|
uiControlShow(uiControl(top));
|
||||||
|
|
||||||
uiControlShow(uiControl(win));
|
uiControlShow(uiControl(dlg->win));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
namespace DlgInputConfig
|
namespace DlgInputConfig
|
||||||
{
|
{
|
||||||
|
|
||||||
void Open();
|
void Open(int type);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,6 +76,8 @@ struct uiControl {
|
||||||
void (*SetMinSize)(uiControl*, int, int);
|
void (*SetMinSize)(uiControl*, int, int);
|
||||||
|
|
||||||
int MinWidth, MinHeight;
|
int MinWidth, MinHeight;
|
||||||
|
|
||||||
|
void* UserData;
|
||||||
};
|
};
|
||||||
// TOOD add argument names to all arguments
|
// TOOD add argument names to all arguments
|
||||||
#define uiControl(this) ((uiControl *) (this))
|
#define uiControl(this) ((uiControl *) (this))
|
||||||
|
|
|
@ -1309,7 +1309,12 @@ void OnOpenEmuSettings(uiMenuItem* item, uiWindow* window, void* blarg)
|
||||||
|
|
||||||
void OnOpenInputConfig(uiMenuItem* item, uiWindow* window, void* blarg)
|
void OnOpenInputConfig(uiMenuItem* item, uiWindow* window, void* blarg)
|
||||||
{
|
{
|
||||||
DlgInputConfig::Open();
|
DlgInputConfig::Open(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnOpenHotkeyConfig(uiMenuItem* item, uiWindow* window, void* blarg)
|
||||||
|
{
|
||||||
|
DlgInputConfig::Open(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1581,6 +1586,8 @@ int main(int argc, char** argv)
|
||||||
uiMenuItemOnClicked(menuitem, OnOpenEmuSettings, NULL);
|
uiMenuItemOnClicked(menuitem, OnOpenEmuSettings, NULL);
|
||||||
menuitem = uiMenuAppendItem(menu, "Input config");
|
menuitem = uiMenuAppendItem(menu, "Input config");
|
||||||
uiMenuItemOnClicked(menuitem, OnOpenInputConfig, NULL);
|
uiMenuItemOnClicked(menuitem, OnOpenInputConfig, NULL);
|
||||||
|
menuitem = uiMenuAppendItem(menu, "Hotkey config");
|
||||||
|
uiMenuItemOnClicked(menuitem, OnOpenHotkeyConfig, NULL);
|
||||||
uiMenuAppendSeparator(menu);
|
uiMenuAppendSeparator(menu);
|
||||||
{
|
{
|
||||||
uiMenu* submenu = uiNewMenu("Savestate settings");
|
uiMenu* submenu = uiNewMenu("Savestate settings");
|
||||||
|
|
Loading…
Reference in New Issue