MythTV  master
Public Member Functions | Private Member Functions | Private Attributes | List of all members
JoystickMenuThread Class Reference

Main object for injecting key strokes based on joystick movements. More...

#include <libmythui/devices/jsmenu.h>

Inheritance diagram for JoystickMenuThread:
[legend]
Collaboration diagram for JoystickMenuThread:
[legend]

Public Member Functions

 JoystickMenuThread (QObject *main_window)
 
 ~JoystickMenuThread () override
 
bool Init (QString &config_file)
 Initialise the class variables with values from the config file. More...
 
void ButtonUp (int button)
 Handle a button up event. More...
 
void AxisChange (int axis, int value)
 Handle a registered change in a joystick axis. More...
 
void EmitKey (const QString &code)
 Send a keyevent to the main UI loop with the appropriate keycode. More...
 
bool ReadConfig (const QString &config_file)
 Read from action to key mappings from flat file config file. More...
 
void Stop (void)
 
- Public Member Functions inherited from MThread
 MThread (const QString &objectName)
 Standard constructor. More...
 
 MThread (const QString &objectName, QRunnable *runnable)
 Use this constructor if you want the default run() method to run the QRunnable's run() method instead of entering the Qt event loop. More...
 
virtual ~MThread ()
 
 MThread (const MThread &)=delete
 
MThreadoperator= (const MThread &)=delete
 
void RunProlog (void)
 Sets up a thread, call this if you reimplement run(). More...
 
void RunEpilog (void)
 Cleans up a thread's resources, call this if you reimplement run(). More...
 
QThread * qthread (void)
 Returns the thread, this will always return the same pointer no matter how often you restart the thread. More...
 
void setObjectName (const QString &name)
 
QString objectName (void) const
 
void setPriority (QThread::Priority priority)
 
QThread::Priority priority (void) const
 
bool isFinished (void) const
 
bool isRunning (void) const
 
void setStackSize (uint stackSize)
 
uint stackSize (void) const
 
void exit (int retcode=0)
 Use this to exit from the thread if you are using a Qt event loop. More...
 
void start (QThread::Priority p=QThread::InheritPriority)
 Tell MThread to start running the thread in the near future. More...
 
void terminate (void)
 Kill a thread unsafely. More...
 
void quit (void)
 calls exit(0) More...
 
bool wait (std::chrono::milliseconds time=std::chrono::milliseconds::max())
 Wait for the MThread to exit, with a maximum timeout. More...
 

Private Member Functions

void run () override
 This function is the heart of a thread which looks for Joystick input and translates it into key press events. More...
 

Private Attributes

bool m_configRead {false}
 
bool m_readError {false}
 
QString m_configFile
 
QObject * m_mainWindow {nullptr}
 
QString m_devicename
 
int m_fd {-1}
 
JoystickMap m_map
 
unsigned char m_buttonCount {0}
 Track the status of the joystick buttons as we do depend slightly on state. More...
 
unsigned char m_axesCount {0}
 Track the status of the joystick axes as we do depend slightly on state. More...
 
int * m_buttons {nullptr}
 
int * m_axes {nullptr}
 
volatile bool m_bStop {false}
 

Additional Inherited Members

- Static Public Member Functions inherited from MThread
static void ThreadSetup (const QString &name)
 This is to be called on startup in those few threads that haven't been ported to MThread. More...
 
static void ThreadCleanup (void)
 This is to be called on exit in those few threads that haven't been ported to MThread. More...
 
static void Cleanup (void)
 This will print out all the running threads, call exit(1) on each and then wait up to 5 seconds total for all the threads to exit. More...
 
static void GetAllThreadNames (QStringList &list)
 
static void GetAllRunningThreadNames (QStringList &list)
 
- Protected Member Functions inherited from MThread
int exec (void)
 Enters the qt event loop. call exit or quit to exit thread. More...
 
- Static Protected Member Functions inherited from MThread
static void setTerminationEnabled (bool enabled=true)
 
static void usleep (std::chrono::microseconds time)
 
template<typename R , typename P >
static std::enable_if_t< std::chrono::treat_as_floating_point< R >::value, void > usleep (std::chrono::duration< R, P > time)
 
- Protected Attributes inherited from MThread
MThreadInternalm_thread {nullptr}
 
QRunnable * m_runnable {nullptr}
 
bool m_prologExecuted {true}
 
bool m_epilogExecuted {true}
 

Detailed Description

Main object for injecting key strokes based on joystick movements.

Definition at line 87 of file jsmenu.h.

Constructor & Destructor Documentation

◆ JoystickMenuThread()

JoystickMenuThread::JoystickMenuThread ( QObject *  main_window)
inlineexplicit

Definition at line 90 of file jsmenu.h.

◆ ~JoystickMenuThread()

JoystickMenuThread::~JoystickMenuThread ( )
override

Definition at line 59 of file jsmenu.cpp.

Member Function Documentation

◆ Init()

bool JoystickMenuThread::Init ( QString &  config_file)

Initialise the class variables with values from the config file.

Definition at line 77 of file jsmenu.cpp.

Referenced by run(), and MythInputDeviceHandler::Start().

◆ ButtonUp()

void JoystickMenuThread::ButtonUp ( int  button)

Handle a button up event.

This is mildly complicated by the support for 'chords'; holding down a button and pushing down another can create one type of event.

Definition at line 419 of file jsmenu.cpp.

Referenced by run().

◆ AxisChange()

void JoystickMenuThread::AxisChange ( int  axis,
int  value 
)

Handle a registered change in a joystick axis.

Definition at line 451 of file jsmenu.cpp.

Referenced by run().

◆ EmitKey()

void JoystickMenuThread::EmitKey ( const QString &  code)

Send a keyevent to the main UI loop with the appropriate keycode.

Definition at line 381 of file jsmenu.cpp.

Referenced by AxisChange(), and ButtonUp().

◆ ReadConfig()

bool JoystickMenuThread::ReadConfig ( const QString &  config_file)

Read from action to key mappings from flat file config file.

Config file has the following format:

Starts a comment

devicename devname - Name of physical joystick device button num keystring - Represents a button chord cnum bnum keystring - A chorded button sequence; hold down cnum and press bnum to generate a key axis num from to keystring - Represents an axis range to trigger a key move that axis into the range and the keystring is sent

Definition at line 156 of file jsmenu.cpp.

Referenced by Init().

◆ Stop()

void JoystickMenuThread::Stop ( void  )
inline

Definition at line 99 of file jsmenu.h.

Referenced by MythInputDeviceHandler::Stop().

◆ run()

void JoystickMenuThread::run ( )
overrideprivatevirtual

This function is the heart of a thread which looks for Joystick input and translates it into key press events.

Reimplemented from MThread.

Definition at line 222 of file jsmenu.cpp.

Member Data Documentation

◆ m_configRead

bool JoystickMenuThread::m_configRead {false}
private

Definition at line 104 of file jsmenu.h.

Referenced by Init(), and run().

◆ m_readError

bool JoystickMenuThread::m_readError {false}
private

Definition at line 105 of file jsmenu.h.

Referenced by Init(), and run().

◆ m_configFile

QString JoystickMenuThread::m_configFile
private

Definition at line 107 of file jsmenu.h.

Referenced by Init(), and run().

◆ m_mainWindow

QObject* JoystickMenuThread::m_mainWindow {nullptr}
private

Definition at line 109 of file jsmenu.h.

Referenced by EmitKey().

◆ m_devicename

QString JoystickMenuThread::m_devicename
private

Definition at line 110 of file jsmenu.h.

Referenced by Init(), and ReadConfig().

◆ m_fd

int JoystickMenuThread::m_fd {-1}
private

Definition at line 111 of file jsmenu.h.

Referenced by Init(), run(), and ~JoystickMenuThread().

◆ m_map

JoystickMap JoystickMenuThread::m_map
private

Definition at line 112 of file jsmenu.h.

Referenced by AxisChange(), ButtonUp(), and ReadConfig().

◆ m_buttonCount

unsigned char JoystickMenuThread::m_buttonCount {0}
private

Track the status of the joystick buttons as we do depend slightly on state.

Definition at line 118 of file jsmenu.h.

Referenced by Init(), and run().

◆ m_axesCount

unsigned char JoystickMenuThread::m_axesCount {0}
private

Track the status of the joystick axes as we do depend slightly on state.

Definition at line 124 of file jsmenu.h.

Referenced by Init(), and run().

◆ m_buttons

int* JoystickMenuThread::m_buttons {nullptr}
private

Definition at line 126 of file jsmenu.h.

Referenced by ButtonUp(), Init(), run(), and ~JoystickMenuThread().

◆ m_axes

int* JoystickMenuThread::m_axes {nullptr}
private

Definition at line 127 of file jsmenu.h.

Referenced by AxisChange(), Init(), run(), and ~JoystickMenuThread().

◆ m_bStop

volatile bool JoystickMenuThread::m_bStop {false}
private

Definition at line 129 of file jsmenu.h.

Referenced by run(), and Stop().


The documentation for this class was generated from the following files: