mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-10 16:19:28 +01:00
nJoy: Fix halfpress button configuration
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1943 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
05a5333c80
commit
bede48c6b1
@ -215,7 +215,7 @@ class ConfigBox : public wxDialog
|
||||
IDTM_CONSTANT, IDTM_BUTTON,
|
||||
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// ==============================================
|
||||
// Keys objects
|
||||
// -----------------------------
|
||||
|
||||
@ -241,7 +241,9 @@ class ConfigBox : public wxDialog
|
||||
ID_DPAD_LEFT,
|
||||
ID_DPAD_RIGHT,
|
||||
|
||||
// Buttons controls (it's important that they are placed in this order)
|
||||
// -------------------------------------
|
||||
// Buttons controls (it's important that they are kept in this order)
|
||||
// ------
|
||||
IDB_ANALOG_MAIN_X = 3000,
|
||||
IDB_ANALOG_MAIN_Y,
|
||||
IDB_ANALOG_SUB_X,
|
||||
@ -262,6 +264,7 @@ class ConfigBox : public wxDialog
|
||||
IDB_BUTTONSTART,
|
||||
|
||||
IDB_BUTTONHALFPRESS,
|
||||
// ------------------ Keep this order
|
||||
|
||||
// Text controls
|
||||
IDT_ANALOG_MAIN_X = 4000,
|
||||
@ -276,6 +279,7 @@ class ConfigBox : public wxDialog
|
||||
IDT_ANALOG_SUB_Y,
|
||||
IDT_WEBSITE,
|
||||
IDT_DEBUGGING, IDT_DEBUGGING2,
|
||||
// ============
|
||||
|
||||
ID_DUMMY_VALUE_ //don't remove this value unless you have other enum values
|
||||
};
|
||||
|
@ -256,7 +256,7 @@ void ConfigBox::DoGetButtons(int GetId)
|
||||
// Collect the accepted buttons for this slot
|
||||
bool LeftRight = (GetId == IDB_SHOULDER_L || GetId == IDB_SHOULDER_R);
|
||||
bool Axis = (GetId >= IDB_ANALOG_MAIN_X && GetId <= IDB_SHOULDER_R);
|
||||
bool Button = (GetId >= IDB_BUTTON_A && GetId <= IDB_BUTTONSTART)
|
||||
bool Button = (GetId >= IDB_BUTTON_A && GetId <= IDB_BUTTONHALFPRESS)
|
||||
|| (GetId == IDB_SHOULDER_L || GetId == IDB_SHOULDER_R)
|
||||
|| (GetId >= IDB_DPAD_UP && GetId <= IDB_DPAD_RIGHT && joysticks[Controller].controllertype == CTL_DPAD_CUSTOM);
|
||||
bool Hat = (GetId >= IDB_DPAD_UP && GetId <= IDB_DPAD_RIGHT)
|
||||
@ -429,7 +429,7 @@ void ConfigBox::DoGetButtons(int GetId)
|
||||
GetButtonWaitingTimer = 0;
|
||||
}
|
||||
|
||||
// We don't need thisgamepad handle any more
|
||||
// We don't need this gamepad handle any more
|
||||
if(SDL_JoystickOpened(joysticks[Controller].ID)) SDL_JoystickClose(joy);
|
||||
|
||||
// Update the button mapping
|
||||
@ -439,126 +439,4 @@ void ConfigBox::DoGetButtons(int GetId)
|
||||
//Console::Print("IsRunning: %i\n", m_ButtonMappingTimer->IsRunning());
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
// Wait for Analog
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void ConfigBox::GetAxis(wxCommandEvent& event)
|
||||
{
|
||||
int ID = event.GetId();
|
||||
int controller = notebookpage;
|
||||
|
||||
SDL_Joystick *joy = SDL_JoystickOpen(joysticks[controller].ID);
|
||||
|
||||
char format[128];
|
||||
int axes = SDL_JoystickNumAxes(joy); // Get number of axes
|
||||
bool waiting = true;
|
||||
bool succeed = false;
|
||||
int pressed = 0;
|
||||
Sint16 value;
|
||||
|
||||
int counter1 = 0;
|
||||
int counter2 = 10;
|
||||
|
||||
sprintf(format, "[%d]", counter2);
|
||||
SetButtonText(ID, format);
|
||||
wxWindow::Update(); // Win only? doesnt seem to work in linux...
|
||||
|
||||
while(waiting)
|
||||
{
|
||||
// Go through all axes and read out their values
|
||||
SDL_JoystickUpdate();
|
||||
for(int i = 0; i < axes; i++)
|
||||
{
|
||||
value = SDL_JoystickGetAxis(joy, i);
|
||||
|
||||
if(AvoidValues(value)) continue; // Avoid values
|
||||
|
||||
pressed = i;
|
||||
waiting = false;
|
||||
succeed = true;
|
||||
break; // Stop this loop
|
||||
}
|
||||
|
||||
// Stop waiting for a button
|
||||
counter1++;
|
||||
if(counter1 == 100)
|
||||
{
|
||||
counter1 = 0;
|
||||
counter2--;
|
||||
|
||||
sprintf(format, "[%d]", counter2);
|
||||
SetButtonText(ID, format);
|
||||
wxWindow::Update(); // win only? doesnt seem to work in linux...
|
||||
wxYieldIfNeeded(); // Let through debugging events
|
||||
|
||||
if(counter2<0)
|
||||
waiting = false;
|
||||
}
|
||||
SLEEP(10);
|
||||
}
|
||||
|
||||
sprintf(format, "%d", succeed ? pressed : -1); // Update the status text box
|
||||
SetButtonText(ID, format);
|
||||
|
||||
if(SDL_JoystickOpened(joysticks[controller].ID)) // Close the handle
|
||||
SDL_JoystickClose(joy);
|
||||
|
||||
// Update the axises for the advanced settings status
|
||||
SaveButtonMapping(controller);
|
||||
}
|
||||
|
||||
|
||||
// Wait for D-Pad
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
void ConfigBox::GetHats(int ID)
|
||||
{
|
||||
// Get the active controller
|
||||
int controller = notebookpage;
|
||||
|
||||
/* Open a new joystick. Joysticks[controller].ID is the system ID of the physical joystick
|
||||
that is mapped to controller, for example 0, 1, 2, 3 for the first four joysticks */
|
||||
SDL_Joystick *joy = SDL_JoystickOpen(joysticks[controller].ID);
|
||||
|
||||
char format[128];
|
||||
int hats = SDL_JoystickNumHats(joy); // Get the number of sticks
|
||||
bool waiting = true;
|
||||
bool succeed = false;
|
||||
int pressed = 0;
|
||||
|
||||
int counter1 = 0;
|
||||
int counter2 = 10;
|
||||
|
||||
sprintf(format, "[%d]", counter2);
|
||||
SetButtonText(ID, format);
|
||||
wxWindow::Update(); // win only? doesnt seem to work in linux...
|
||||
|
||||
while(waiting)
|
||||
{
|
||||
SDL_JoystickUpdate();
|
||||
|
||||
counter1++;
|
||||
if(counter1==100)
|
||||
{
|
||||
counter1=0;
|
||||
counter2--;
|
||||
|
||||
sprintf(format, "[%d]", counter2);
|
||||
SetButtonText(ID, format);
|
||||
wxWindow::Update(); // win only? doesnt seem to work in linux...
|
||||
|
||||
if(counter2<0)
|
||||
waiting = false;
|
||||
}
|
||||
SLEEP(10);
|
||||
}
|
||||
|
||||
sprintf(format, "%d", succeed ? pressed : -1);
|
||||
SetButtonText(ID, format);
|
||||
|
||||
if(SDL_JoystickOpened(joysticks[controller].ID))
|
||||
SDL_JoystickClose(joy);
|
||||
}
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////// Configure button mapping
|
@ -280,7 +280,7 @@ void Initialize(void *init)
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
int Search_Devices()
|
||||
{
|
||||
// load config
|
||||
// Load config
|
||||
#ifdef _DEBUG
|
||||
DEBUG_INIT();
|
||||
#endif
|
||||
@ -542,10 +542,9 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
|
||||
/* Debugging
|
||||
Console::ClearScreen();
|
||||
Console::Print(
|
||||
"(%i %i) Left:%04x Right:%04x\n"
|
||||
"Left:%04x Right:%04x Value:%i\n"
|
||||
"D-Pad type: %s L:%i R:%i U:%i D:%i",
|
||||
joysticks[_numPAD].buttons[CTL_L_SHOULDER], joysticks[_numPAD].buttons[CTL_L_SHOULDER],
|
||||
TriggerLeft, TriggerRight,
|
||||
TriggerLeft, TriggerRight, triggervalue,
|
||||
(joysticks[_numPAD].controllertype ? "CTL_DPAD_CUSTOM" : "CTL_DPAD_HAT"),
|
||||
0, 0, 0, 0
|
||||
);*/
|
||||
@ -677,12 +676,15 @@ std::vector<int> Pad_Square_to_Circle(int _x, int _y)
|
||||
vec.push_back(int_y);
|
||||
return vec;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////// Convert stick values
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Supporting functions: Read current joystick status
|
||||
// Supporting functions
|
||||
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
|
||||
// Read current joystick status
|
||||
/* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
|
||||
The value joysticks[].buttons[] is the number of the assigned joypad button,
|
||||
joystate[].buttons[] is the status of the button, it becomes 0 (no pressed) or 1 (pressed) */
|
||||
|
Loading…
x
Reference in New Issue
Block a user