handle slot indexes automatically

This commit is contained in:
Glenn Maynard
2007-01-12 01:42:35 +00:00
parent 59da84966f
commit 3ff773e575
2 changed files with 9 additions and 5 deletions
+6 -2
View File
@@ -88,7 +88,7 @@ struct AutoJoyMapping
const char *szControllerName; // the product name of the controller const char *szControllerName; // the product name of the controller
struct InputMapper::Mapping maps[32]; struct InputMapper::Mapping maps[32];
}; };
#define END_MARKER {-1, DeviceButton_Invalid, -1, false }, // end marker #define END_MARKER {-1, DeviceButton_Invalid, GameButton_Invalid, false }, // end marker
const AutoJoyMapping g_AutoJoyMappings[] = const AutoJoyMapping g_AutoJoyMappings[] =
{ {
{ {
@@ -484,6 +484,8 @@ void InputMapper::Unmap( InputDevice id )
void InputMapper::ApplyMapping( const Mapping *maps, GameController gc, InputDevice id ) void InputMapper::ApplyMapping( const Mapping *maps, GameController gc, InputDevice id )
{ {
map<GameInput, int> MappedButtons;
for( int k=0; !maps[k].IsEndMarker(); k++ ) for( int k=0; !maps[k].IsEndMarker(); k++ )
{ {
GameController map_gc = gc; GameController map_gc = gc;
@@ -500,7 +502,9 @@ void InputMapper::ApplyMapping( const Mapping *maps, GameController gc, InputDev
DeviceInput di( id, maps[k].deviceButton ); DeviceInput di( id, maps[k].deviceButton );
GameInput gi( map_gc, maps[k].gb ); GameInput gi( map_gc, maps[k].gb );
SetInputMap( di, gi, maps[k].iSlotIndex ); int iSlot = MappedButtons[gi];
++MappedButtons[gi];
SetInputMap( di, gi, iSlot );//maps[k].iSlotIndex );
} }
} }
+3 -3
View File
@@ -80,11 +80,11 @@ public:
struct Mapping struct Mapping
{ {
bool IsEndMarker() const { return iSlotIndex==-1; } bool IsEndMarker() const { return gb == GameButton_Invalid; }
int iSlotIndex; // -1 == end marker int iSlotIndex;
DeviceButton deviceButton; DeviceButton deviceButton;
GameButton gb; GameButton gb; // GameButton_Invalid == end marker
/* /*
* If this is true, this is an auxilliary mapping assigned to the second * If this is true, this is an auxilliary mapping assigned to the second