Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions yabause/src/peripheral.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ typedef struct
int canScan;
void (*Flush)(void);
void (*KeyName)(u32 key, char * name, int size);
void (*ScanIgnoreAxisFlags)(u32 flags);
} PerInterface_struct;

/** @brief Pointer to the current peripheral core.
Expand Down
16 changes: 15 additions & 1 deletion yabause/src/persdljoy.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ int PERSDLJoyHandleEvents(void);
u32 PERSDLJoyScan(u32 flags);
void PERSDLJoyFlush(void);
void PERSDLKeyName(u32 key, char * name, int size);
void PERSDLScanIgnoreAxisFlags(u32 flags);

PerInterface_struct PERSDLJoy = {
PERCORE_SDLJOY,
Expand All @@ -61,7 +62,8 @@ PERSDLJoyHandleEvents,
PERSDLJoyScan,
1,
PERSDLJoyFlush,
PERSDLKeyName
PERSDLKeyName,
PERSDLScanIgnoreAxisFlags
};

typedef struct {
Expand All @@ -75,6 +77,7 @@ unsigned int SDL_PERCORE_JOYSTICKS_INITIALIZED = 0;
PERSDLJoystick* SDL_PERCORE_JOYSTICKS = 0;
unsigned int SDL_HAT_VALUES[] = { SDL_HAT_UP, SDL_HAT_RIGHT, SDL_HAT_LEFT, SDL_HAT_DOWN };
const unsigned int SDL_HAT_VALUES_NUM = sizeof(SDL_HAT_VALUES) / sizeof(SDL_HAT_VALUES[0]);
u32 SDL_PERCORE_SCAN_IGNORE_AXIS_FLAGS = 0;

//////////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -295,6 +298,8 @@ u32 PERSDLJoyScan( u32 flags ) {
// check axis
for ( i = 0; i < SDL_JoystickNumAxes( joy ); i++ )
{
if (SDL_PERCORE_SCAN_IGNORE_AXIS_FLAGS & (1 << i)) continue;

cur = SDL_JoystickGetAxis( joy, i );

if ( cur != SDL_PERCORE_JOYSTICKS[ joyId ].mScanStatus[ i ] )
Expand Down Expand Up @@ -354,11 +359,20 @@ u32 PERSDLJoyScan( u32 flags ) {
}

void PERSDLJoyFlush(void) {
#ifdef WIN32
PERSDLJoyDeInit();
PERSDLJoyInit();
#endif
}

void PERSDLKeyName(u32 key, char * name, UNUSED int size)
{
sprintf(name, "%x", (int)key);
}

void PERSDLScanIgnoreAxisFlags(u32 flags)
{
SDL_PERCORE_SCAN_IGNORE_AXIS_FLAGS = flags;
}

#endif
12 changes: 12 additions & 0 deletions yabause/src/qt/ui/UIControllerSetting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ UIControllerSetting::UIControllerSetting( PerInterface_struct* core, uint port,
mPadKey = 0;
mlInfos = NULL;
scanFlags = PERSF_ALL;
mScanIgnoreAxisFlags = 0;
QtYabause::retranslateWidget( this );
}

Expand Down Expand Up @@ -173,6 +174,13 @@ void UIControllerSetting::loadPadSettings()
setPadKey( settings->value( settingsKey ).toUInt() );
}
}

const QString keyScanIgnoreAxisFlags = QString("Input/Port/%1/Id/%2/Controller/%3/ScanIgnoreAxisFlags")
.arg(mPort)
.arg(mPad)
.arg(mPerType);

mScanIgnoreAxisFlags = settings->contains(keyScanIgnoreAxisFlags) ? settings->value(keyScanIgnoreAxisFlags).toUInt() : 0;
}

bool UIControllerSetting::eventFilter( QObject* object, QEvent* event )
Expand Down Expand Up @@ -234,6 +242,10 @@ void UIControllerSetting::tbButton_clicked()
void UIControllerSetting::timer_timeout()
{
u32 key = 0;
if (mCore->ScanIgnoreAxisFlags)
{
mCore->ScanIgnoreAxisFlags(mScanIgnoreAxisFlags);
}
key = mCore->Scan(scanFlags);

if ( key != 0 )
Expand Down
1 change: 1 addition & 0 deletions yabause/src/qt/ui/UIControllerSetting.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class UIControllerSetting : public QDialog
QLabel *mlInfos;
u32 scanFlags;
QToolButton * curTb;
u32 mScanIgnoreAxisFlags;

void keyPressEvent( QKeyEvent* event );
void mouseMoveEvent(QMouseEvent * event);
Expand Down