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 <jsmenu.h>

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

Public Member Functions

 JoystickMenuThread (QObject *main_window)
 
 ~JoystickMenuThread ()
 
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 ()
 
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=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 (unsigned long time=ULONG_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

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 &)
 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)
 
- Static Public Attributes inherited from MThread
static const int kDefaultStartTimeout
 
- 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 sleep (unsigned long time)
 
static void msleep (unsigned long time)
 
static void usleep (unsigned long time)
 
- Protected Attributes inherited from MThread
MThreadInternalm_thread {nullptr}
 
QRunnable * m_runnable {nullptr}
 
bool m_prolog_executed {true}
 
bool m_epilog_executed {true}
 

Detailed Description

Main object for injecting key strokes based on joystick movements.

Definition at line 81 of file jsmenu.h.

Constructor & Destructor Documentation

◆ JoystickMenuThread()

JoystickMenuThread::JoystickMenuThread ( QObject *  main_window)
inlineexplicit

Definition at line 84 of file jsmenu.h.

◆ ~JoystickMenuThread()

JoystickMenuThread::~JoystickMenuThread ( )

Definition at line 54 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 72 of file jsmenu.cpp.

Referenced by MythMainWindow::MythMainWindow().

◆ 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 318 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 350 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 287 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 136 of file jsmenu.cpp.

Referenced by Init().

◆ Stop()

void JoystickMenuThread::Stop ( void  )
inline

Definition at line 93 of file jsmenu.h.

Referenced by MythMainWindow::~MythMainWindow().

◆ run()

void JoystickMenuThread::run ( void  )
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 190 of file jsmenu.cpp.

Member Data Documentation

◆ m_mainWindow

QObject* JoystickMenuThread::m_mainWindow {nullptr}
private

Definition at line 98 of file jsmenu.h.

Referenced by EmitKey().

◆ m_devicename

QString JoystickMenuThread::m_devicename
private

Definition at line 99 of file jsmenu.h.

Referenced by Init(), and ReadConfig().

◆ m_fd

int JoystickMenuThread::m_fd {-1}
private

Definition at line 100 of file jsmenu.h.

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

◆ m_map

JoystickMap JoystickMenuThread::m_map
private

Definition at line 101 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 107 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 113 of file jsmenu.h.

Referenced by Init(), and run().

◆ m_buttons

int* JoystickMenuThread::m_buttons {nullptr}
private

Definition at line 115 of file jsmenu.h.

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

◆ m_axes

int* JoystickMenuThread::m_axes {nullptr}
private

Definition at line 116 of file jsmenu.h.

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

◆ m_bStop

volatile bool JoystickMenuThread::m_bStop {false}
private

Definition at line 118 of file jsmenu.h.

Referenced by run(), and Stop().


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