- Enabled Half press for shoulder buttons
- Added a option to select controller type
- Normal controllers should use the default joystick
- Some joysticks dont have a real hat (POV) but fake this with buttons.
In this case Joystick (no hat) should be selected.
After this is selected, four new buttons will appear for the d-pad.
- Next version will probably include keyboard support.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@60 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Laurence Muller 2008-07-23 00:49:20 +00:00
parent a3bae5f132
commit f9582bef30
6 changed files with 227 additions and 40 deletions

View File

@ -56,7 +56,7 @@ IDD_CONFIG DIALOGEX 0, 0, 411, 282
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_SYSMENU
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
COMBOBOX IDC_JOYNAME,8,18,317,30,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_JOYNAME,8,18,317,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
GROUPBOX "Controller:",IDC_STATIC,3,7,405,28
CONTROL 102,IDC_STATIC,"Static",SS_BITMAP | SS_REALSIZEIMAGE | SS_SUNKEN,65,46,281,187
CONTROL "Controller attached",IDC_JOYATTACH,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,330,19,73,10
@ -90,12 +90,25 @@ BEGIN
LTEXT "Y-axis",IDC_STATIC,368,229,20,8
PUSHBUTTON "",IDC_SY,351,240,15,10,0,WS_EX_STATICEDGE
PUSHBUTTON "",IDC_MY,46,158,15,10,0,WS_EX_STATICEDGE
GROUPBOX "Extra settings",IDC_STATIC,3,236,95,43
LTEXT "Deadzone",IDC_STATIC,11,248,33,8
LTEXT "Half press",IDC_STATIC,11,263,33,8
COMBOBOX IDC_DEADZONE,45,246,48,30,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_HALFPRESS,45,261,48,30,CBS_DROPDOWN | WS_VSCROLL | WS_TABSTOP
GROUPBOX "Extra settings:",IDC_STATIC,69,236,103,43
LTEXT "Deadzone",IDC_STATIC,77,248,33,8
LTEXT "Half press",IDC_STATIC,77,263,33,8
COMBOBOX IDC_DEADZONE,111,246,40,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "www.multigesture.net",IDC_STATIC,336,271,72,8
COMBOBOX IDC_CONTROLTYPE,244,247,87,30,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
GROUPBOX "Controller type:",IDC_STATIC,239,236,95,27
PUSHBUTTON "",IDC_DPAD_DOWN,46,205,15,10,0,WS_EX_STATICEDGE
CTEXT "",IDTEXT_DPAD_DOWN,4,205,40,12,WS_BORDER
PUSHBUTTON "",IDC_DPAD_LEFT,45,228,15,10,0,WS_EX_STATICEDGE
CTEXT "",IDTEXT_DPAD_LEFT,3,227,40,12,WS_BORDER
PUSHBUTTON "",IDC_DPAD_RIGHT,45,251,15,10,0,WS_EX_STATICEDGE
CTEXT "",IDTEXT_DPAD_RIGHT,3,250,40,12,WS_BORDER
LTEXT "Up",IDC_DPAD_TEXT1,4,172,10,8
LTEXT "Down",IDC_DPAD_TEXT2,4,195,19,8
LTEXT "Left",IDC_DPAD_TEXT3,4,217,14,8
LTEXT "Right",IDC_DPAD_TEXT4,4,240,18,8
PUSHBUTTON "",IDC_HALFPRESS,153,263,15,10,0,WS_EX_STATICEDGE
CTEXT "",IDTEXT_HALFPRESS,111,261,40,12,WS_BORDER
END
IDD_ABOUT DIALOGEX 0, 0, 133, 227
@ -141,6 +154,24 @@ END
IDB_BITMAP1 BITMAP "controller.bmp"
IDB_BITMAP2 BITMAP "njoy.bmp"
/////////////////////////////////////////////////////////////////////////////
//
// Dialog Info
//
IDD_CONFIG DLGINIT
BEGIN
IDC_CONTROLTYPE, 0x403, 9, 0
0x6f4a, 0x7379, 0x6974, 0x6b63, "\000"
IDC_CONTROLTYPE, 0x403, 18, 0
0x6f4a, 0x7379, 0x6974, 0x6b63, 0x2820, 0x6f6e, 0x6820, 0x7461, 0x0029,
IDC_CONTROLTYPE, 0x403, 9, 0
0x654b, 0x6279, 0x616f, 0x6472, "\000"
0
END
#endif // Dutch (Netherlands) resources
/////////////////////////////////////////////////////////////////////////////

View File

@ -8,7 +8,6 @@
#define IDB_BITMAP2 104
#define IDC_JOYNAME 1001
#define IDC_JOYATTACH 1002
#define IDC_SHOULDERL 1010
#define IDC_SHOULDERR 1011
#define IDC_A 1012
@ -17,16 +16,24 @@
#define IDC_Y 1015
#define IDC_Z 1016
#define IDC_START 1017
#define IDC_DPAD 1018
#define IDC_MX 1019
#define IDC_MY 1020
#define IDC_SX 1021
#define IDC_SY 1022
#define IDC_DEADZONE 1023
#define IDC_HALFPRESS 1024
#define IDC_DPAD_DOWN 1025
#define IDC_DPAD_LEFT 1026
#define IDC_DPAD_RIGHT 1027
#define IDC_ABOUT_TEXT 1032
#define IDC_ABOUT_TEXT2 1033
#define IDC_ABOUT_TEXT3 1034
#define IDC_CONTROLTYPE 1036
#define IDC_DPAD_TEXT1 1037
#define IDC_DPAD_TEXT2 1038
#define IDC_DPAD_TEXT3 1039
#define IDC_DPAD_TEXT4 1040
#define IDTEXT_SHOULDERL 2010
#define IDTEXT_SHOULDERR 2011
#define IDTEXT_A 2012
@ -35,26 +42,23 @@
#define IDTEXT_Y 2015
#define IDTEXT_Z 2016
#define IDTEXT_START 2017
#define IDTEXT_DPAD 2018
#define IDTEXT_MX 2019
#define IDTEXT_MY 2020
#define IDTEXT_SX 2021
#define IDTEXT_SY 2022
#define IDC_ABOUT_TEXT 1032
#define IDC_ABOUT_TEXT2 1033
#define IDC_ABOUT_TEXT3 1034
#define IDTEXT_HALFPRESS 2024
#define IDTEXT_DPAD_DOWN 2025
#define IDTEXT_DPAD_LEFT 2026
#define IDTEXT_DPAD_RIGHT 2027
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 105
#define _APS_NEXT_RESOURCE_VALUE 106
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1036
#define _APS_NEXT_CONTROL_VALUE 1041
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@ -35,6 +35,13 @@ extern CONTROLLER_INFO *joyinfo;
extern CONTROLLER_MAPPING joysticks[4];
extern bool emulator_running;
static const char* ControllerType[] =
{
"Joystick (default)",
"Joystick (no hat)",
"Keyboard"
};
// Create dialog and pages
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
int OpenConfig(HINSTANCE hInst, HWND _hParent)
@ -128,11 +135,13 @@ BOOL ControllerTab(HWND hDlg, UINT message, UINT wParam, LONG lParam, int contro
{
ComboBox_Enable(GetDlgItem(hDlg, IDC_JOYNAME), FALSE);
Button_Enable(GetDlgItem(hDlg, IDC_JOYATTACH), FALSE);
ComboBox_Enable(GetDlgItem(hDlg, IDC_CONTROLTYPE), FALSE);
}
else
{
ComboBox_Enable(GetDlgItem(hDlg, IDC_JOYNAME), TRUE);
Button_Enable(GetDlgItem(hDlg, IDC_JOYATTACH), TRUE);
ComboBox_Enable(GetDlgItem(hDlg, IDC_CONTROLTYPE), TRUE);
}
// Search for devices and add the to the device list
@ -144,6 +153,11 @@ BOOL ControllerTab(HWND hDlg, UINT message, UINT wParam, LONG lParam, int contro
SendMessage(CB, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>((LPCTSTR)joyinfo[x].Name));
}
CB = GetDlgItem(hDlg, IDC_CONTROLTYPE);
SendMessage(CB, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>((LPCTSTR)ControllerType[CTL_TYPE_JOYSTICK]));
SendMessage(CB, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>((LPCTSTR)ControllerType[CTL_TYPE_JOYSTICK_NO_HAT]));
//SendMessage(CB, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>((LPCTSTR)ControllerType[CTL_TYPE_KEYBOARD]));
char buffer [8];
CB = GetDlgItem(hDlg, IDC_DEADZONE);
SendMessage(CB, CB_RESETCONTENT, 0, 0);
@ -179,6 +193,18 @@ BOOL ControllerTab(HWND hDlg, UINT message, UINT wParam, LONG lParam, int contro
}
break;
case IDC_CONTROLTYPE:
{
// Selected a different joystick
if(HIWORD(wParam) == CBN_SELCHANGE)
{
joysticks[controller].controllertype = (int)SendMessage(GetDlgItem(hDlg, IDC_CONTROLTYPE), CB_GETCURSEL, 0, 0);
UpdateVisibleItems(hDlg, joysticks[controller].controllertype);
}
return TRUE;
}
break;
case IDC_SHOULDERL:
case IDC_SHOULDERR:
case IDC_A:
@ -187,6 +213,10 @@ BOOL ControllerTab(HWND hDlg, UINT message, UINT wParam, LONG lParam, int contro
case IDC_Y:
case IDC_Z:
case IDC_START:
case IDC_HALFPRESS:
case IDC_DPAD_DOWN:
case IDC_DPAD_LEFT:
case IDC_DPAD_RIGHT:
{
GetButtons(hDlg, LOWORD(wParam), controller);
return TRUE;
@ -195,6 +225,9 @@ BOOL ControllerTab(HWND hDlg, UINT message, UINT wParam, LONG lParam, int contro
case IDC_DPAD:
{
if(joysticks[controller].controllertype)
GetButtons(hDlg, LOWORD(wParam), controller);
else
GetHats(hDlg, LOWORD(wParam), controller);
return TRUE;
}
@ -422,7 +455,7 @@ void SetControllerAll(HWND hDlg, int controller)
SetButton(hDlg, IDTEXT_Z, joysticks[controller].buttons[CTL_Z_TRIGGER]);
SetButton(hDlg, IDTEXT_START, joysticks[controller].buttons[CTL_START]);
SetButton(hDlg, IDTEXT_DPAD, joysticks[controller].dpad);
SetButton(hDlg, IDTEXT_HALFPRESS, joysticks[controller].halfpress);
SetButton(hDlg, IDTEXT_MX, joysticks[controller].axis[CTL_MAIN_X]);
SetButton(hDlg, IDTEXT_MY, joysticks[controller].axis[CTL_MAIN_Y]);
@ -431,7 +464,20 @@ void SetControllerAll(HWND hDlg, int controller)
SendDlgItemMessage(hDlg, IDC_JOYATTACH, BM_SETCHECK, joysticks[controller].enabled, 0);
SendMessage(GetDlgItem(hDlg, IDC_CONTROLTYPE), CB_SETCURSEL, joysticks[controller].controllertype, 0);
SendMessage(GetDlgItem(hDlg, IDC_DEADZONE), CB_SETCURSEL, joysticks[controller].deadzone, 0);
UpdateVisibleItems(hDlg, joysticks[controller].controllertype);
if(joysticks[controller].controllertype == CTL_TYPE_JOYSTICK)
SetButton(hDlg, IDTEXT_DPAD, joysticks[controller].dpad);
else
{
SetButton(hDlg, IDTEXT_DPAD, joysticks[controller].dpad2[CTL_D_PAD_UP]);
SetButton(hDlg, IDTEXT_DPAD_DOWN, joysticks[controller].dpad2[CTL_D_PAD_DOWN]);
SetButton(hDlg, IDTEXT_DPAD_LEFT, joysticks[controller].dpad2[CTL_D_PAD_LEFT]);
SetButton(hDlg, IDTEXT_DPAD_RIGHT, joysticks[controller].dpad2[CTL_D_PAD_RIGHT]);
}
}
// Get dialog items
@ -449,7 +495,17 @@ void GetControllerAll(HWND hDlg, int controller)
joysticks[controller].buttons[CTL_Z_TRIGGER] = GetButton(hDlg, IDTEXT_Z);
joysticks[controller].buttons[CTL_START] = GetButton(hDlg, IDTEXT_START);
joysticks[controller].halfpress = GetButton(hDlg, IDTEXT_HALFPRESS);
if(joysticks[controller].controllertype == CTL_TYPE_JOYSTICK)
joysticks[controller].dpad = GetButton(hDlg, IDTEXT_DPAD);
else
{
joysticks[controller].dpad2[CTL_D_PAD_UP] = GetButton(hDlg, IDTEXT_DPAD);
joysticks[controller].dpad2[CTL_D_PAD_DOWN] = GetButton(hDlg, IDTEXT_DPAD_DOWN);
joysticks[controller].dpad2[CTL_D_PAD_LEFT] = GetButton(hDlg, IDTEXT_DPAD_LEFT);
joysticks[controller].dpad2[CTL_D_PAD_RIGHT] = GetButton(hDlg, IDTEXT_DPAD_RIGHT);
}
joysticks[controller].axis[CTL_MAIN_X] = GetButton(hDlg, IDTEXT_MX);
joysticks[controller].axis[CTL_MAIN_Y] = GetButton(hDlg, IDTEXT_MY);
@ -458,9 +514,46 @@ void GetControllerAll(HWND hDlg, int controller)
joysticks[controller].enabled = (int)SendMessage(GetDlgItem(hDlg, IDC_JOYATTACH), BM_GETCHECK, 0, 0);
joysticks[controller].controllertype = (int)SendMessage(GetDlgItem(hDlg, IDC_CONTROLTYPE), CB_GETCURSEL, 0, 0);
joysticks[controller].deadzone = (int)SendMessage(GetDlgItem(hDlg, IDC_DEADZONE), CB_GETCURSEL, 0, 0);
}
void UpdateVisibleItems(HWND hDlg, int controllertype)
{
if(controllertype == CTL_TYPE_KEYBOARD)
ComboBox_Enable(GetDlgItem(hDlg, IDC_JOYNAME), FALSE);
else
ComboBox_Enable(GetDlgItem(hDlg, IDC_JOYNAME), TRUE);
if(controllertype)
{
// 4 extra buttons
ShowWindow(GetDlgItem(hDlg, IDTEXT_DPAD_DOWN), TRUE);
ShowWindow(GetDlgItem(hDlg, IDTEXT_DPAD_LEFT), TRUE);
ShowWindow(GetDlgItem(hDlg, IDTEXT_DPAD_RIGHT), TRUE);
ShowWindow(GetDlgItem(hDlg, IDC_DPAD_DOWN), TRUE);
ShowWindow(GetDlgItem(hDlg, IDC_DPAD_LEFT), TRUE);
ShowWindow(GetDlgItem(hDlg, IDC_DPAD_RIGHT), TRUE);
ShowWindow(GetDlgItem(hDlg, IDC_DPAD_TEXT1), TRUE);
ShowWindow(GetDlgItem(hDlg, IDC_DPAD_TEXT2), TRUE);
ShowWindow(GetDlgItem(hDlg, IDC_DPAD_TEXT3), TRUE);
ShowWindow(GetDlgItem(hDlg, IDC_DPAD_TEXT4), TRUE);
}
else
{
ShowWindow(GetDlgItem(hDlg, IDTEXT_DPAD_DOWN), FALSE);
ShowWindow(GetDlgItem(hDlg, IDTEXT_DPAD_LEFT), FALSE);
ShowWindow(GetDlgItem(hDlg, IDTEXT_DPAD_RIGHT), FALSE);
ShowWindow(GetDlgItem(hDlg, IDC_DPAD_DOWN), FALSE);
ShowWindow(GetDlgItem(hDlg, IDC_DPAD_LEFT), FALSE);
ShowWindow(GetDlgItem(hDlg, IDC_DPAD_RIGHT), FALSE);
ShowWindow(GetDlgItem(hDlg, IDC_DPAD_TEXT1), FALSE);
ShowWindow(GetDlgItem(hDlg, IDC_DPAD_TEXT2), FALSE);
ShowWindow(GetDlgItem(hDlg, IDC_DPAD_TEXT3), FALSE);
ShowWindow(GetDlgItem(hDlg, IDC_DPAD_TEXT4), FALSE);
}
}
// Set text in static text item
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
void SetButton(HWND hDlg, int item, int value)

View File

@ -53,6 +53,8 @@ bool GetButtons(HWND hDlg, int buttonid, int controller);
bool GetHats(HWND hDlg, int buttonid, int controller);
bool GetAxis(HWND hDlg, int buttonid, int controller);
void UpdateVisibleItems(HWND hDlg, int controllertype);
void GetControllerAll(HWND hDlg, int controller);
void SetControllerAll(HWND hDlg, int controller);

View File

@ -205,26 +205,31 @@ void PAD_GetStatus(BYTE _numPAD, SPADStatus* _pPADStatus)
if ((sub_stick_x < deadzone2) || (sub_stick_x > deadzone)) _pPADStatus->substickX += sub_stick_x;
if ((sub_stick_y < deadzone2) || (sub_stick_y > deadzone)) _pPADStatus->substickY += sub_stick_y;
int triggervalue = 255;
if (joystate[_numPAD].halfpress)
triggervalue = 100;
// Set buttons
if (joystate[_numPAD].buttons[CTL_L_SHOULDER])
{
_pPADStatus->button|=PAD_TRIGGER_L;
_pPADStatus->triggerLeft = 255; // Perhaps support halfpress/pressure
_pPADStatus->triggerLeft = triggervalue;
}
if (joystate[_numPAD].buttons[CTL_R_SHOULDER])
{
_pPADStatus->button|=PAD_TRIGGER_R;
_pPADStatus->triggerRight = 255; // Perhaps support halfpress/pressure
_pPADStatus->triggerRight = triggervalue;
}
if (joystate[_numPAD].buttons[CTL_A_BUTTON])
{
_pPADStatus->button|=PAD_BUTTON_A;
_pPADStatus->analogA = 255; // Perhaps support halfpress/pressure
_pPADStatus->analogA = 255; // Perhaps support pressure?
}
if (joystate[_numPAD].buttons[CTL_B_BUTTON])
{
_pPADStatus->button|=PAD_BUTTON_B;
_pPADStatus->analogB = 255; // Perhaps support halfpress/pressure
_pPADStatus->analogB = 255; // Perhaps support pressure?
}
if (joystate[_numPAD].buttons[CTL_X_BUTTON]) _pPADStatus->button|=PAD_BUTTON_X;
if (joystate[_numPAD].buttons[CTL_Y_BUTTON]) _pPADStatus->button|=PAD_BUTTON_Y;
@ -232,10 +237,24 @@ void PAD_GetStatus(BYTE _numPAD, SPADStatus* _pPADStatus)
if (joystate[_numPAD].buttons[CTL_START]) _pPADStatus->button|=PAD_BUTTON_START;
// Set D-pad
if(joysticks[_numPAD].controllertype == CTL_TYPE_JOYSTICK)
{
if(joystate[_numPAD].dpad == SDL_HAT_LEFTUP || joystate[_numPAD].dpad == SDL_HAT_UP || joystate[_numPAD].dpad == SDL_HAT_RIGHTUP ) _pPADStatus->button|=PAD_BUTTON_UP;
if(joystate[_numPAD].dpad == SDL_HAT_LEFTUP || joystate[_numPAD].dpad == SDL_HAT_LEFT || joystate[_numPAD].dpad == SDL_HAT_LEFTDOWN ) _pPADStatus->button|=PAD_BUTTON_LEFT;
if(joystate[_numPAD].dpad == SDL_HAT_LEFTDOWN || joystate[_numPAD].dpad == SDL_HAT_DOWN || joystate[_numPAD].dpad == SDL_HAT_RIGHTDOWN ) _pPADStatus->button|=PAD_BUTTON_DOWN;
if(joystate[_numPAD].dpad == SDL_HAT_RIGHTUP || joystate[_numPAD].dpad == SDL_HAT_RIGHT || joystate[_numPAD].dpad == SDL_HAT_RIGHTDOWN ) _pPADStatus->button|=PAD_BUTTON_RIGHT;
}
else
{
if(joystate[_numPAD].dpad2[CTL_D_PAD_UP])
_pPADStatus->button|=PAD_BUTTON_UP;
if(joystate[_numPAD].dpad2[CTL_D_PAD_DOWN])
_pPADStatus->button|=PAD_BUTTON_DOWN;
if(joystate[_numPAD].dpad2[CTL_D_PAD_LEFT])
_pPADStatus->button|=PAD_BUTTON_LEFT;
if(joystate[_numPAD].dpad2[CTL_D_PAD_RIGHT])
_pPADStatus->button|=PAD_BUTTON_RIGHT;
}
_pPADStatus->err = PAD_ERR_NONE;
}
@ -299,7 +318,17 @@ void GetJoyState(int controller)
joystate[controller].buttons[CTL_Z_TRIGGER] = SDL_JoystickGetButton(joystate[controller].joy, joysticks[controller].buttons[CTL_Z_TRIGGER]);
joystate[controller].buttons[CTL_START] = SDL_JoystickGetButton(joystate[controller].joy, joysticks[controller].buttons[CTL_START]);
joystate[controller].halfpress = SDL_JoystickGetButton(joystate[controller].joy, joysticks[controller].halfpress);
if(joysticks[controller].controllertype == CTL_TYPE_JOYSTICK)
joystate[controller].dpad = SDL_JoystickGetHat(joystate[controller].joy, joysticks[controller].dpad);
else
{
joystate[controller].dpad2[CTL_D_PAD_UP] = SDL_JoystickGetButton(joystate[controller].joy, joysticks[controller].dpad2[CTL_D_PAD_UP]);
joystate[controller].dpad2[CTL_D_PAD_DOWN] = SDL_JoystickGetButton(joystate[controller].joy, joysticks[controller].dpad2[CTL_D_PAD_DOWN]);
joystate[controller].dpad2[CTL_D_PAD_LEFT] = SDL_JoystickGetButton(joystate[controller].joy, joysticks[controller].dpad2[CTL_D_PAD_LEFT]);
joystate[controller].dpad2[CTL_D_PAD_RIGHT] = SDL_JoystickGetButton(joystate[controller].joy, joysticks[controller].dpad2[CTL_D_PAD_RIGHT]);
}
}
// Search attached devices
@ -399,7 +428,7 @@ void DEBUG_QUIT()
void SaveConfig()
{
IniFile file;
file.Load("nJoy");
file.Load("nJoy.ini");
for (int i=0; i<4; i++)
{
@ -415,6 +444,10 @@ void SaveConfig()
file.Set(SectionName, "z_trigger", joysticks[i].buttons[CTL_Z_TRIGGER]);
file.Set(SectionName, "start_button", joysticks[i].buttons[CTL_START]);
file.Set(SectionName, "dpad", joysticks[i].dpad);
file.Set(SectionName, "dpad_up", joysticks[i].dpad2[CTL_D_PAD_UP]);
file.Set(SectionName, "dpad_down", joysticks[i].dpad2[CTL_D_PAD_DOWN]);
file.Set(SectionName, "dpad_left", joysticks[i].dpad2[CTL_D_PAD_LEFT]);
file.Set(SectionName, "dpad_right", joysticks[i].dpad2[CTL_D_PAD_RIGHT]);
file.Set(SectionName, "main_x", joysticks[i].axis[CTL_MAIN_X]);
file.Set(SectionName, "main_y", joysticks[i].axis[CTL_MAIN_Y]);
file.Set(SectionName, "sub_x", joysticks[i].axis[CTL_SUB_X]);
@ -423,9 +456,10 @@ void SaveConfig()
file.Set(SectionName, "deadzone", joysticks[i].deadzone);
file.Set(SectionName, "halfpress", joysticks[i].halfpress);
file.Set(SectionName, "joy_id", joysticks[i].ID);
file.Set(SectionName, "controllertype", joysticks[i].controllertype);
}
file.Save("nJoy");
file.Save("nJoy.ini");
}
// Load settings from file
@ -433,7 +467,7 @@ void SaveConfig()
void LoadConfig()
{
IniFile file;
file.Load("nJoy");
file.Load("nJoy.ini");
for (int i=0; i<4; i++)
{
@ -449,13 +483,18 @@ void LoadConfig()
file.Get(SectionName, "z_trigger", &joysticks[i].buttons[CTL_Z_TRIGGER], 7);
file.Get(SectionName, "start_button", &joysticks[i].buttons[CTL_START], 9);
file.Get(SectionName, "dpad", &joysticks[i].dpad, 0);
file.Get(SectionName, "dpad_up", &joysticks[i].dpad2[CTL_D_PAD_UP], 0);
file.Get(SectionName, "dpad_down", &joysticks[i].dpad2[CTL_D_PAD_DOWN], 0);
file.Get(SectionName, "dpad_left", &joysticks[i].dpad2[CTL_D_PAD_LEFT], 0);
file.Get(SectionName, "dpad_right", &joysticks[i].dpad2[CTL_D_PAD_RIGHT], 0);
file.Get(SectionName, "main_x", &joysticks[i].axis[CTL_MAIN_X], 0);
file.Get(SectionName, "main_y", &joysticks[i].axis[CTL_MAIN_Y], 1);
file.Get(SectionName, "sub_x", &joysticks[i].axis[CTL_SUB_X], 2);
file.Get(SectionName, "sub_y", &joysticks[i].axis[CTL_SUB_Y], 3);
file.Get(SectionName, "enabled", &joysticks[i].enabled, 1);
file.Get(SectionName, "deadzone", &joysticks[i].deadzone, 9);
file.Get(SectionName, "halfpress", &joysticks[i].halfpress, 0);
file.Get(SectionName, "halfpress", &joysticks[i].halfpress, 6);
file.Get(SectionName, "joy_id", &joysticks[i].ID, 0);
file.Get(SectionName, "controllertype", &joysticks[i].controllertype, 0);
}
}

View File

@ -59,18 +59,22 @@
struct CONTROLLER_STATE{ // GC PAD INFO/STATE
int buttons[8]; // Amount of buttons (A B X Y Z, L-Trigger R-Trigger Start) might need to change the triggers buttons
int dpad; // 1 HAT (8 directions + neutral)
int dpad2[4]; // d-pad using buttons
int axis[4]; // 2 x 2 Axes (Main & Sub)
int halfpress; // ...
SDL_Joystick *joy; // SDL joystick device
};
struct CONTROLLER_MAPPING{ // GC PAD MAPPING
int buttons[8]; // Amount of buttons (A B X Y Z, L-Trigger R-Trigger Start) might need to change the triggers buttons
int dpad; // 1 HAT (8 directions + neutral)
int dpad2[4]; // d-pad using buttons
int axis[4]; // 2 x 2 Axes (Main & Sub)
int enabled; // Pad attached?
int deadzone; // Deadzone... what else?
int halfpress; // Not implemented
int halfpress; // Halfpress... you know, like not fully pressed ;)...
int ID; // SDL joystick device ID
int controllertype; // Joystick, Joystick no hat or a keyboard (perhaps a mouse later)
};
struct CONTROLLER_INFO{ // CONNECTED WINDOWS DEVICES INFO
@ -103,6 +107,20 @@ enum
CTL_START
};
enum
{
CTL_TYPE_JOYSTICK = 0,
CTL_TYPE_JOYSTICK_NO_HAT,
CTL_TYPE_KEYBOARD
};
enum
{
CTL_D_PAD_UP = 0,
CTL_D_PAD_DOWN,
CTL_D_PAD_LEFT,
CTL_D_PAD_RIGHT
};
//////////////////////////////////////////////////////////////////////////////////////////
// Custom Functions
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯