remove IgnoreJoyAxes option. Instead, have ScreenMapControllers prefer button presses over axis presses for simultaneouly received input events.

This commit is contained in:
Chris Danford
2003-09-09 04:57:22 +00:00
parent 122891a56e
commit bc1d7650fd
6 changed files with 34 additions and 63 deletions
-11
View File
@@ -73,7 +73,6 @@ struct AutoJoyMapping
Game game;
const char *szDeviceDescription; // reported by InputHandler
const char *szControllerName; // the product name of the controller
bool bIgnoreAxes;
struct {
int iSlotIndex; // -1 == end marker
int deviceButton;
@@ -95,7 +94,6 @@ const AutoJoyMapping g_AutoJoyMappings[] =
GAME_DANCE,
"GIC USB Joystick",
"Boom USB convertor (black/gray)",
false,
{
{ 0, JOY_16, DANCE_BUTTON_LEFT },
{ 0, JOY_14, DANCE_BUTTON_RIGHT },
@@ -108,7 +106,6 @@ const AutoJoyMapping g_AutoJoyMappings[] =
GAME_DANCE,
"4 axis 16 button joystick",
"PC Magic Box",
false,
{
{ 0, JOY_16, DANCE_BUTTON_LEFT },
{ 0, JOY_14, DANCE_BUTTON_RIGHT },
@@ -121,7 +118,6 @@ const AutoJoyMapping g_AutoJoyMappings[] =
GAME_DANCE,
"GamePad Pro USB ", // yes, there is a space at the end
"GamePad Pro USB",
false,
{
{ 0, JOY_LEFT, DANCE_BUTTON_LEFT },
{ 0, JOY_RIGHT, DANCE_BUTTON_RIGHT },
@@ -142,7 +138,6 @@ const AutoJoyMapping g_AutoJoyMappings[] =
GAME_DANCE,
"4 axis 12 button joystick with hat switch",
"Super Joy Box 5",
false,
{
{ 0, JOY_HAT_LEFT, DANCE_BUTTON_LEFT },
{ 0, JOY_HAT_RIGHT, DANCE_BUTTON_RIGHT },
@@ -165,7 +160,6 @@ const AutoJoyMapping g_AutoJoyMappings[] =
GAME_DANCE,
"MP-8866 Dual USB Joypad",
"Super Dual Box",
false,
{
{ 0, JOY_HAT_LEFT, DANCE_BUTTON_LEFT },
{ 0, JOY_HAT_RIGHT, DANCE_BUTTON_RIGHT },
@@ -188,7 +182,6 @@ const AutoJoyMapping g_AutoJoyMappings[] =
GAME_DANCE,
"XBOX Gamepad Plugin V0.01",
"X-Box gamepad",
false,
{
{ 0, JOY_HAT_LEFT, DANCE_BUTTON_LEFT },
{ 0, JOY_HAT_RIGHT, DANCE_BUTTON_RIGHT },
@@ -209,7 +202,6 @@ const AutoJoyMapping g_AutoJoyMappings[] =
GAME_PUMP,
"Pump USB",
"Pump USB pad",
false,
{
{ 0, PUMP_UL, PUMP_BUTTON_UPLEFT },
{ 0, PUMP_UR, PUMP_BUTTON_UPRIGHT },
@@ -231,7 +223,6 @@ void InputMapper::AutoMapJoysticksForCurrentGame()
{
vector<InputDevice> vDevices;
vector<CString> vDescriptions;
PREFSMAN->m_bIgnoreJoyAxes = false;
INPUTMAN->GetDevicesAndDescriptions(vDevices,vDescriptions);
int iNumJoysticksMapped = 0;
@@ -256,8 +247,6 @@ void InputMapper::AutoMapJoysticksForCurrentGame()
LOG->Info( "Applying default joystick mapping #%d for device '%s' (%s)",
iNumJoysticksMapped+1, mapping.szDeviceDescription, mapping.szControllerName );
PREFSMAN->m_bIgnoreJoyAxes |= mapping.bIgnoreAxes;
for( int k=0; mapping.maps[k].iSlotIndex != -1; k++ )
{
if( mapping.maps[k].SecondController )
-1
View File
@@ -45,7 +45,6 @@ PrefsManager::PrefsManager()
m_iMovieColorDepth = 16;
m_iMaxTextureResolution = 2048;
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;
#ifdef DEBUG
m_bShowStats = true;
-1
View File
@@ -43,7 +43,6 @@ public:
bool m_bDelayedScreenLoad;
bool m_bBannerCache;
bool m_bIgnoreJoyAxes;
bool m_bOnlyDedicatedMenuButtons;
bool m_bMenuTimer;
bool m_bShowDanger;
-4
View File
@@ -24,7 +24,6 @@
enum {
IO_AUTO_MAP_JOYSTICKS = 0,
IO_IGNORE_AXES,
IO_DEDICATED_MENU_BUTTONS,
IO_AUTOPLAY,
IO_DELAYED_ESCAPE,
@@ -37,7 +36,6 @@ enum {
* preferably alongside button configuration. */
OptionRow g_InputOptionsLines[NUM_INPUT_OPTIONS_LINES] = {
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( "AutoPlay", true, "OFF","ON" ),
OptionRow( "Back\nDelayed", true, "INSTANT","HOLD" ),
@@ -63,7 +61,6 @@ ScreenInputOptions::ScreenInputOptions() :
void ScreenInputOptions::ImportOptions()
{
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_AUTOPLAY] = PREFSMAN->m_bAutoPlay;
m_iSelectedOption[0][IO_DELAYED_ESCAPE] = PREFSMAN->m_bDelayedEscape ? 1:0;
@@ -77,7 +74,6 @@ void ScreenInputOptions::ImportOptions()
void ScreenInputOptions::ExportOptions()
{
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_bDelayedEscape = m_iSelectedOption[0][IO_DELAYED_ESCAPE] == 1;
PREFSMAN->m_bAutoPlay = m_iSelectedOption[0][IO_AUTOPLAY] == 1;
+31 -46
View File
@@ -119,12 +119,18 @@ void ScreenMapControllers::Update( float fDeltaTime )
{
Screen::Update( fDeltaTime );
for( int b=0; b<GAMESTATE->GetCurrentGameDef()->m_iButtonsPerController; b++ )
{
CString sButtonName = GAMESTATE->GetCurrentGameDef()->m_szButtonNames[b];
if( m_bWaitingForPress && m_DeviceIToMap.IsValid() ) // we're going to map an input
{
GameInput curGameI( (GameController)m_iCurController,
(GameButton)m_iCurButton );
if( sButtonName == "Start" || sButtonName == "Back" )
continue;
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,8 +150,22 @@ void ScreenMapControllers::Input( const DeviceInput& DeviceI, const InputEventTy
LOG->Trace( "ScreenMapControllers::Input(): device: %d, button: %d",
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. */
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( 1 );
m_textError.SetDiffuse( RageColor(0,1,0,0) );
return;
}
static int axes[] =
else
{
JOY_LEFT, JOY_RIGHT, JOY_UP, JOY_DOWN,
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
m_DeviceIToMap = DeviceI;
}
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 )
{
@@ -257,7 +241,8 @@ void ScreenMapControllers::Input( const DeviceInput& DeviceI, const InputEventTy
break;
case SDLK_RETURN: /* Change the selection. */
case SDLK_KP_ENTER:
m_bWaitingForPress = true;
m_bWaitingForPress = true;
m_DeviceIToMap.MakeInvalid();
break;
}
}
+3
View File
@@ -16,6 +16,7 @@
#include "GrayArrow.h"
#include "InputMapper.h"
#include "MenuElements.h"
#include "RageInputDevice.h"
class ScreenMapControllers : public Screen
@@ -43,7 +44,9 @@ private:
int m_iCurController;
int m_iCurButton;
int m_iCurSlot;
bool m_bWaitingForPress;
DeviceInput m_DeviceIToMap;
BitmapText m_textError;
BitmapText m_textName[MAX_GAME_BUTTONS];