remove IgnoreJoyAxes option. Instead, have ScreenMapControllers prefer button presses over axis presses for simultaneouly received input events.
This commit is contained in:
@@ -73,7 +73,6 @@ struct AutoJoyMapping
|
|||||||
Game game;
|
Game game;
|
||||||
const char *szDeviceDescription; // reported by InputHandler
|
const char *szDeviceDescription; // reported by InputHandler
|
||||||
const char *szControllerName; // the product name of the controller
|
const char *szControllerName; // the product name of the controller
|
||||||
bool bIgnoreAxes;
|
|
||||||
struct {
|
struct {
|
||||||
int iSlotIndex; // -1 == end marker
|
int iSlotIndex; // -1 == end marker
|
||||||
int deviceButton;
|
int deviceButton;
|
||||||
@@ -95,7 +94,6 @@ const AutoJoyMapping g_AutoJoyMappings[] =
|
|||||||
GAME_DANCE,
|
GAME_DANCE,
|
||||||
"GIC USB Joystick",
|
"GIC USB Joystick",
|
||||||
"Boom USB convertor (black/gray)",
|
"Boom USB convertor (black/gray)",
|
||||||
false,
|
|
||||||
{
|
{
|
||||||
{ 0, JOY_16, DANCE_BUTTON_LEFT },
|
{ 0, JOY_16, DANCE_BUTTON_LEFT },
|
||||||
{ 0, JOY_14, DANCE_BUTTON_RIGHT },
|
{ 0, JOY_14, DANCE_BUTTON_RIGHT },
|
||||||
@@ -108,7 +106,6 @@ const AutoJoyMapping g_AutoJoyMappings[] =
|
|||||||
GAME_DANCE,
|
GAME_DANCE,
|
||||||
"4 axis 16 button joystick",
|
"4 axis 16 button joystick",
|
||||||
"PC Magic Box",
|
"PC Magic Box",
|
||||||
false,
|
|
||||||
{
|
{
|
||||||
{ 0, JOY_16, DANCE_BUTTON_LEFT },
|
{ 0, JOY_16, DANCE_BUTTON_LEFT },
|
||||||
{ 0, JOY_14, DANCE_BUTTON_RIGHT },
|
{ 0, JOY_14, DANCE_BUTTON_RIGHT },
|
||||||
@@ -121,7 +118,6 @@ const AutoJoyMapping g_AutoJoyMappings[] =
|
|||||||
GAME_DANCE,
|
GAME_DANCE,
|
||||||
"GamePad Pro USB ", // yes, there is a space at the end
|
"GamePad Pro USB ", // yes, there is a space at the end
|
||||||
"GamePad Pro USB",
|
"GamePad Pro USB",
|
||||||
false,
|
|
||||||
{
|
{
|
||||||
{ 0, JOY_LEFT, DANCE_BUTTON_LEFT },
|
{ 0, JOY_LEFT, DANCE_BUTTON_LEFT },
|
||||||
{ 0, JOY_RIGHT, DANCE_BUTTON_RIGHT },
|
{ 0, JOY_RIGHT, DANCE_BUTTON_RIGHT },
|
||||||
@@ -142,7 +138,6 @@ const AutoJoyMapping g_AutoJoyMappings[] =
|
|||||||
GAME_DANCE,
|
GAME_DANCE,
|
||||||
"4 axis 12 button joystick with hat switch",
|
"4 axis 12 button joystick with hat switch",
|
||||||
"Super Joy Box 5",
|
"Super Joy Box 5",
|
||||||
false,
|
|
||||||
{
|
{
|
||||||
{ 0, JOY_HAT_LEFT, DANCE_BUTTON_LEFT },
|
{ 0, JOY_HAT_LEFT, DANCE_BUTTON_LEFT },
|
||||||
{ 0, JOY_HAT_RIGHT, DANCE_BUTTON_RIGHT },
|
{ 0, JOY_HAT_RIGHT, DANCE_BUTTON_RIGHT },
|
||||||
@@ -165,7 +160,6 @@ const AutoJoyMapping g_AutoJoyMappings[] =
|
|||||||
GAME_DANCE,
|
GAME_DANCE,
|
||||||
"MP-8866 Dual USB Joypad",
|
"MP-8866 Dual USB Joypad",
|
||||||
"Super Dual Box",
|
"Super Dual Box",
|
||||||
false,
|
|
||||||
{
|
{
|
||||||
{ 0, JOY_HAT_LEFT, DANCE_BUTTON_LEFT },
|
{ 0, JOY_HAT_LEFT, DANCE_BUTTON_LEFT },
|
||||||
{ 0, JOY_HAT_RIGHT, DANCE_BUTTON_RIGHT },
|
{ 0, JOY_HAT_RIGHT, DANCE_BUTTON_RIGHT },
|
||||||
@@ -188,7 +182,6 @@ const AutoJoyMapping g_AutoJoyMappings[] =
|
|||||||
GAME_DANCE,
|
GAME_DANCE,
|
||||||
"XBOX Gamepad Plugin V0.01",
|
"XBOX Gamepad Plugin V0.01",
|
||||||
"X-Box gamepad",
|
"X-Box gamepad",
|
||||||
false,
|
|
||||||
{
|
{
|
||||||
{ 0, JOY_HAT_LEFT, DANCE_BUTTON_LEFT },
|
{ 0, JOY_HAT_LEFT, DANCE_BUTTON_LEFT },
|
||||||
{ 0, JOY_HAT_RIGHT, DANCE_BUTTON_RIGHT },
|
{ 0, JOY_HAT_RIGHT, DANCE_BUTTON_RIGHT },
|
||||||
@@ -209,7 +202,6 @@ const AutoJoyMapping g_AutoJoyMappings[] =
|
|||||||
GAME_PUMP,
|
GAME_PUMP,
|
||||||
"Pump USB",
|
"Pump USB",
|
||||||
"Pump USB pad",
|
"Pump USB pad",
|
||||||
false,
|
|
||||||
{
|
{
|
||||||
{ 0, PUMP_UL, PUMP_BUTTON_UPLEFT },
|
{ 0, PUMP_UL, PUMP_BUTTON_UPLEFT },
|
||||||
{ 0, PUMP_UR, PUMP_BUTTON_UPRIGHT },
|
{ 0, PUMP_UR, PUMP_BUTTON_UPRIGHT },
|
||||||
@@ -231,7 +223,6 @@ void InputMapper::AutoMapJoysticksForCurrentGame()
|
|||||||
{
|
{
|
||||||
vector<InputDevice> vDevices;
|
vector<InputDevice> vDevices;
|
||||||
vector<CString> vDescriptions;
|
vector<CString> vDescriptions;
|
||||||
PREFSMAN->m_bIgnoreJoyAxes = false;
|
|
||||||
INPUTMAN->GetDevicesAndDescriptions(vDevices,vDescriptions);
|
INPUTMAN->GetDevicesAndDescriptions(vDevices,vDescriptions);
|
||||||
|
|
||||||
int iNumJoysticksMapped = 0;
|
int iNumJoysticksMapped = 0;
|
||||||
@@ -256,8 +247,6 @@ void InputMapper::AutoMapJoysticksForCurrentGame()
|
|||||||
LOG->Info( "Applying default joystick mapping #%d for device '%s' (%s)",
|
LOG->Info( "Applying default joystick mapping #%d for device '%s' (%s)",
|
||||||
iNumJoysticksMapped+1, mapping.szDeviceDescription, mapping.szControllerName );
|
iNumJoysticksMapped+1, mapping.szDeviceDescription, mapping.szControllerName );
|
||||||
|
|
||||||
PREFSMAN->m_bIgnoreJoyAxes |= mapping.bIgnoreAxes;
|
|
||||||
|
|
||||||
for( int k=0; mapping.maps[k].iSlotIndex != -1; k++ )
|
for( int k=0; mapping.maps[k].iSlotIndex != -1; k++ )
|
||||||
{
|
{
|
||||||
if( mapping.maps[k].SecondController )
|
if( mapping.maps[k].SecondController )
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ PrefsManager::PrefsManager()
|
|||||||
m_iMovieColorDepth = 16;
|
m_iMovieColorDepth = 16;
|
||||||
m_iMaxTextureResolution = 2048;
|
m_iMaxTextureResolution = 2048;
|
||||||
m_iRefreshRate = REFRESH_DEFAULT;
|
m_iRefreshRate = REFRESH_DEFAULT;
|
||||||
m_bIgnoreJoyAxes = true; // ON by default because all USB convertors that are compatible with pads map to buttons
|
|
||||||
m_bOnlyDedicatedMenuButtons = false;
|
m_bOnlyDedicatedMenuButtons = false;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
m_bShowStats = true;
|
m_bShowStats = true;
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ public:
|
|||||||
bool m_bDelayedScreenLoad;
|
bool m_bDelayedScreenLoad;
|
||||||
bool m_bBannerCache;
|
bool m_bBannerCache;
|
||||||
|
|
||||||
bool m_bIgnoreJoyAxes;
|
|
||||||
bool m_bOnlyDedicatedMenuButtons;
|
bool m_bOnlyDedicatedMenuButtons;
|
||||||
bool m_bMenuTimer;
|
bool m_bMenuTimer;
|
||||||
bool m_bShowDanger;
|
bool m_bShowDanger;
|
||||||
|
|||||||
@@ -24,7 +24,6 @@
|
|||||||
|
|
||||||
enum {
|
enum {
|
||||||
IO_AUTO_MAP_JOYSTICKS = 0,
|
IO_AUTO_MAP_JOYSTICKS = 0,
|
||||||
IO_IGNORE_AXES,
|
|
||||||
IO_DEDICATED_MENU_BUTTONS,
|
IO_DEDICATED_MENU_BUTTONS,
|
||||||
IO_AUTOPLAY,
|
IO_AUTOPLAY,
|
||||||
IO_DELAYED_ESCAPE,
|
IO_DELAYED_ESCAPE,
|
||||||
@@ -37,7 +36,6 @@ enum {
|
|||||||
* preferably alongside button configuration. */
|
* preferably alongside button configuration. */
|
||||||
OptionRow g_InputOptionsLines[NUM_INPUT_OPTIONS_LINES] = {
|
OptionRow g_InputOptionsLines[NUM_INPUT_OPTIONS_LINES] = {
|
||||||
OptionRow( "Auto Map\nJoysticks", true, "OFF","ON (recommended)" ),
|
OptionRow( "Auto Map\nJoysticks", true, "OFF","ON (recommended)" ),
|
||||||
OptionRow( "Ignore\nJoy Axes", true, "OFF","ON (for NTPad or DirectPad)" ),
|
|
||||||
OptionRow( "Menu\nButtons", true, "USE GAMEPLAY BUTTONS","ONLY DEDICATED BUTTONS" ),
|
OptionRow( "Menu\nButtons", true, "USE GAMEPLAY BUTTONS","ONLY DEDICATED BUTTONS" ),
|
||||||
OptionRow( "AutoPlay", true, "OFF","ON" ),
|
OptionRow( "AutoPlay", true, "OFF","ON" ),
|
||||||
OptionRow( "Back\nDelayed", true, "INSTANT","HOLD" ),
|
OptionRow( "Back\nDelayed", true, "INSTANT","HOLD" ),
|
||||||
@@ -63,7 +61,6 @@ ScreenInputOptions::ScreenInputOptions() :
|
|||||||
void ScreenInputOptions::ImportOptions()
|
void ScreenInputOptions::ImportOptions()
|
||||||
{
|
{
|
||||||
m_iSelectedOption[0][IO_AUTO_MAP_JOYSTICKS] = PREFSMAN->m_bAutoMapJoysticks ? 1:0;
|
m_iSelectedOption[0][IO_AUTO_MAP_JOYSTICKS] = PREFSMAN->m_bAutoMapJoysticks ? 1:0;
|
||||||
m_iSelectedOption[0][IO_IGNORE_AXES] = PREFSMAN->m_bIgnoreJoyAxes ? 1:0;
|
|
||||||
m_iSelectedOption[0][IO_DEDICATED_MENU_BUTTONS] = PREFSMAN->m_bOnlyDedicatedMenuButtons ? 1:0;
|
m_iSelectedOption[0][IO_DEDICATED_MENU_BUTTONS] = PREFSMAN->m_bOnlyDedicatedMenuButtons ? 1:0;
|
||||||
m_iSelectedOption[0][IO_AUTOPLAY] = PREFSMAN->m_bAutoPlay;
|
m_iSelectedOption[0][IO_AUTOPLAY] = PREFSMAN->m_bAutoPlay;
|
||||||
m_iSelectedOption[0][IO_DELAYED_ESCAPE] = PREFSMAN->m_bDelayedEscape ? 1:0;
|
m_iSelectedOption[0][IO_DELAYED_ESCAPE] = PREFSMAN->m_bDelayedEscape ? 1:0;
|
||||||
@@ -77,7 +74,6 @@ void ScreenInputOptions::ImportOptions()
|
|||||||
void ScreenInputOptions::ExportOptions()
|
void ScreenInputOptions::ExportOptions()
|
||||||
{
|
{
|
||||||
PREFSMAN->m_bAutoMapJoysticks = m_iSelectedOption[0][IO_AUTO_MAP_JOYSTICKS] == 1;
|
PREFSMAN->m_bAutoMapJoysticks = m_iSelectedOption[0][IO_AUTO_MAP_JOYSTICKS] == 1;
|
||||||
PREFSMAN->m_bIgnoreJoyAxes = m_iSelectedOption[0][IO_IGNORE_AXES] == 1;
|
|
||||||
PREFSMAN->m_bOnlyDedicatedMenuButtons= m_iSelectedOption[0][IO_DEDICATED_MENU_BUTTONS] == 1;
|
PREFSMAN->m_bOnlyDedicatedMenuButtons= m_iSelectedOption[0][IO_DEDICATED_MENU_BUTTONS] == 1;
|
||||||
PREFSMAN->m_bDelayedEscape = m_iSelectedOption[0][IO_DELAYED_ESCAPE] == 1;
|
PREFSMAN->m_bDelayedEscape = m_iSelectedOption[0][IO_DELAYED_ESCAPE] == 1;
|
||||||
PREFSMAN->m_bAutoPlay = m_iSelectedOption[0][IO_AUTOPLAY] == 1;
|
PREFSMAN->m_bAutoPlay = m_iSelectedOption[0][IO_AUTOPLAY] == 1;
|
||||||
|
|||||||
@@ -119,12 +119,18 @@ void ScreenMapControllers::Update( float fDeltaTime )
|
|||||||
{
|
{
|
||||||
Screen::Update( fDeltaTime );
|
Screen::Update( fDeltaTime );
|
||||||
|
|
||||||
for( int b=0; b<GAMESTATE->GetCurrentGameDef()->m_iButtonsPerController; b++ )
|
|
||||||
{
|
|
||||||
CString sButtonName = GAMESTATE->GetCurrentGameDef()->m_szButtonNames[b];
|
|
||||||
|
|
||||||
if( sButtonName == "Start" || sButtonName == "Back" )
|
if( m_bWaitingForPress && m_DeviceIToMap.IsValid() ) // we're going to map an input
|
||||||
continue;
|
{
|
||||||
|
GameInput curGameI( (GameController)m_iCurController,
|
||||||
|
(GameButton)m_iCurButton );
|
||||||
|
|
||||||
|
INPUTMAPPER->SetInputMap( m_DeviceIToMap, curGameI, m_iCurSlot );
|
||||||
|
INPUTMAPPER->AddDefaultMappingsForCurrentGameIfUnmapped();
|
||||||
|
// commit to disk so we don't lose the changes!
|
||||||
|
INPUTMAPPER->SaveMappingsToDisk();
|
||||||
|
|
||||||
|
m_bWaitingForPress = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,7 +150,21 @@ void ScreenMapControllers::Input( const DeviceInput& DeviceI, const InputEventTy
|
|||||||
LOG->Trace( "ScreenMapControllers::Input(): device: %d, button: %d",
|
LOG->Trace( "ScreenMapControllers::Input(): device: %d, button: %d",
|
||||||
DeviceI.device, DeviceI.button );
|
DeviceI.device, DeviceI.button );
|
||||||
|
|
||||||
if( m_bWaitingForPress ) // we're going to map an input
|
//
|
||||||
|
// TRICKY: This eliminates the need for a separate "ignore joy axes"
|
||||||
|
// preference. Some adapters map the PlayStation digital d-pad to
|
||||||
|
// both axes and buttons. We want buttons to be used for
|
||||||
|
// any mappings where possible because presses of buttons aren't mutually
|
||||||
|
// exclusive and presses of axes are (e.g. can't read presses of both Left and
|
||||||
|
// Right simultaneously). So, when the user presses a button, we'll wait
|
||||||
|
// until the next Update before adding a mapping so that we get a chance
|
||||||
|
// to see all input events the user's press of a panel. This screen will be
|
||||||
|
// receive input events for joystick axes presses first, then the input events
|
||||||
|
// for button presses. We'll use the last input event received in the same
|
||||||
|
// Update so that a button presses are favored for mapping over axis presses.
|
||||||
|
//
|
||||||
|
|
||||||
|
if( m_bWaitingForPress )
|
||||||
{
|
{
|
||||||
/* Don't allow function keys to be mapped. */
|
/* Don't allow function keys to be mapped. */
|
||||||
if ( DeviceI.device == DEVICE_KEYBOARD && (DeviceI.button >= SDLK_F1 && DeviceI.button <= SDLK_F12) )
|
if ( DeviceI.device == DEVICE_KEYBOARD && (DeviceI.button >= SDLK_F1 && DeviceI.button <= SDLK_F12) )
|
||||||
@@ -156,47 +176,11 @@ void ScreenMapControllers::Input( const DeviceInput& DeviceI, const InputEventTy
|
|||||||
m_textError.BeginTweening( 3 );
|
m_textError.BeginTweening( 3 );
|
||||||
m_textError.BeginTweening( 1 );
|
m_textError.BeginTweening( 1 );
|
||||||
m_textError.SetDiffuse( RageColor(0,1,0,0) );
|
m_textError.SetDiffuse( RageColor(0,1,0,0) );
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
static int axes[] =
|
|
||||||
{
|
{
|
||||||
JOY_LEFT, JOY_RIGHT, JOY_UP, JOY_DOWN,
|
m_DeviceIToMap = DeviceI;
|
||||||
JOY_Z_UP, JOY_Z_DOWN,
|
|
||||||
JOY_ROT_UP, JOY_ROT_DOWN, JOY_ROT_LEFT, JOY_ROT_RIGHT, JOY_ROT_Z_UP, JOY_ROT_Z_DOWN,
|
|
||||||
JOY_HAT_LEFT, JOY_HAT_RIGHT, JOY_HAT_UP, JOY_HAT_DOWN,
|
|
||||||
JOY_AUX_1, JOY_AUX_2, JOY_AUX_3, JOY_AUX_4,
|
|
||||||
-1
|
|
||||||
};
|
|
||||||
|
|
||||||
bool IsAxis = false;
|
|
||||||
for( int ax = 0; axes[ax] != -1; ++ax )
|
|
||||||
if( DeviceI.button == axes[ax] )
|
|
||||||
IsAxis = true;
|
|
||||||
|
|
||||||
// ignore joystick D-Pad presses if the user has set their pref.
|
|
||||||
if( PREFSMAN->m_bIgnoreJoyAxes && IsAxis && DeviceI.IsJoystick() )
|
|
||||||
{
|
|
||||||
//m_textError.SetText( "Game option is set to ignore the Joystick D-Pad." );
|
|
||||||
//m_fErrorDisplayCountdown = 5; // show the error message
|
|
||||||
m_textError.StopTweening();
|
|
||||||
m_textError.SetDiffuse( RageColor(0,1,0,1) );
|
|
||||||
m_textError.BeginTweening( 3 );
|
|
||||||
m_textError.BeginTweening( 1 );
|
|
||||||
m_textError.SetDiffuse( RageColor(0,1,0,0) );
|
|
||||||
|
|
||||||
return; // ignore this press
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GameInput curGameI( (GameController)m_iCurController,
|
|
||||||
(GameButton)m_iCurButton );
|
|
||||||
|
|
||||||
INPUTMAPPER->SetInputMap( DeviceI, curGameI, m_iCurSlot );
|
|
||||||
INPUTMAPPER->AddDefaultMappingsForCurrentGameIfUnmapped();
|
|
||||||
// commit to disk so we don't lose the changes!
|
|
||||||
INPUTMAPPER->SaveMappingsToDisk();
|
|
||||||
|
|
||||||
m_bWaitingForPress = false;
|
|
||||||
}
|
}
|
||||||
else if( DeviceI.device == DEVICE_KEYBOARD )
|
else if( DeviceI.device == DEVICE_KEYBOARD )
|
||||||
{
|
{
|
||||||
@@ -258,6 +242,7 @@ void ScreenMapControllers::Input( const DeviceInput& DeviceI, const InputEventTy
|
|||||||
case SDLK_RETURN: /* Change the selection. */
|
case SDLK_RETURN: /* Change the selection. */
|
||||||
case SDLK_KP_ENTER:
|
case SDLK_KP_ENTER:
|
||||||
m_bWaitingForPress = true;
|
m_bWaitingForPress = true;
|
||||||
|
m_DeviceIToMap.MakeInvalid();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#include "GrayArrow.h"
|
#include "GrayArrow.h"
|
||||||
#include "InputMapper.h"
|
#include "InputMapper.h"
|
||||||
#include "MenuElements.h"
|
#include "MenuElements.h"
|
||||||
|
#include "RageInputDevice.h"
|
||||||
|
|
||||||
|
|
||||||
class ScreenMapControllers : public Screen
|
class ScreenMapControllers : public Screen
|
||||||
@@ -43,7 +44,9 @@ private:
|
|||||||
int m_iCurController;
|
int m_iCurController;
|
||||||
int m_iCurButton;
|
int m_iCurButton;
|
||||||
int m_iCurSlot;
|
int m_iCurSlot;
|
||||||
|
|
||||||
bool m_bWaitingForPress;
|
bool m_bWaitingForPress;
|
||||||
|
DeviceInput m_DeviceIToMap;
|
||||||
|
|
||||||
BitmapText m_textError;
|
BitmapText m_textError;
|
||||||
BitmapText m_textName[MAX_GAME_BUTTONS];
|
BitmapText m_textName[MAX_GAME_BUTTONS];
|
||||||
|
|||||||
Reference in New Issue
Block a user