The Pedigree Project 0.1
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
InputManager Class Reference

#include <InputManager.h>

+ Collaboration diagram for InputManager:

Classes

struct  CallbackItem
 Item in the kernel callback list. More...
 
struct  InputNotification
 

Public Types

typedef int CallbackType
 
typedef void(* callback_t) (InputNotification &)
 Callback function type.
 

Public Member Functions

 InputManager ()
 Default constructor.
 
virtual ~InputManager ()
 Default destructor.
 
void initialise ()
 Begins the worker thread.
 
void shutdown ()
 Shuts down the worker thread, clears queues, and removes callbacks.
 
void keyPressed (uint64_t key)
 Called whenever a key is pressed and needs to be added to the queue.
 
void rawKeyUpdate (uint8_t scancode, bool bKeyUp)
 
void machineKeyUpdate (uint8_t scancode, bool bKeyUp)
 Called whenever a machine-specific key scancode comes in.
 
void mouseUpdate (ssize_t relX, ssize_t relY, ssize_t relZ, uint32_t buttonBitmap)
 Called whenever mouse input comes in.
 
void absoluteMouseUpdate (uint32_t x, uint32_t y, ssize_t wheel, uint32_t buttonBitmap)
 Position coordinates use the evdev 0..0x7fff absolute pointer range.
 
void joystickUpdate (ssize_t relX, ssize_t relY, ssize_t relZ, uint32_t buttonBitmap)
 Called whenever joystick input comes in.
 
void installCallback (CallbackType filter, callback_t callback, void *meta=0)
 Installs a callback.
 
void removeCallback (callback_t callback, void *meta=0)
 Removes a callback.
 
void mainThread ()
 Main worker thread.
 
bool isActive () const
 Returns whether the instance is creating notifications.
 

Static Public Member Functions

static InputManager & instance ()
 Singleton design.
 
static int trampoline (void *ptr)
 Thread trampoline.
 

Static Public Attributes

static const int Key = 1
 
static const int Mouse = 2
 
static const int Joystick = 4
 
static const int RawKey = 8
 
static const int MachineKey = 16
 
static const int AbsoluteMouse = 32
 
static const int Unknown = 255
 

Private Member Functions

void putNotification (InputNotification *note)
 
void removeCallbacks (callback_t callback, void *meta)
 
void drainCallback (CallbackItem *item)
 

Private Attributes

List< InputNotification * > m_InputQueue
 Input queue (for distribution to applications)
 
Spinlock m_QueueLock
 
List< CallbackItem * > m_Callbacks
 Callback list.
 
Semaphore m_InputQueueSize
 Key press queue Semaphore.
 
Thread * m_pThread
 Thread object for our worker thread.
 
Thread * m_pCallbackDispatchThread
 Set only while the input worker is executing a committed callback.
 
Atomic< bool > m_bActive
 Are we active?
 

Static Private Attributes

static InputManager m_Instance
 Static instance.
 

Detailed Description

Global manager for all input from HID devices.

Definition at line 39 of file InputManager.h.

Member Typedef Documentation

◆ callback_t

typedef void(* InputManager::callback_t) (InputNotification &)

Callback function type.

Definition at line 97 of file InputManager.h.

◆ CallbackType

typedef int InputManager::CallbackType

Definition at line 51 of file InputManager.h.

Constructor & Destructor Documentation

◆ InputManager()

InputManager::InputManager ( )

Default constructor.

Definition at line 41 of file InputManager.cc.

◆ ~InputManager()

InputManager::~InputManager ( )
virtual

Default destructor.

Definition at line 55 of file InputManager.cc.

Member Function Documentation

◆ absoluteMouseUpdate()

void InputManager::absoluteMouseUpdate ( uint32_t  x,
uint32_t  y,
ssize_t  wheel,
uint32_t  buttonBitmap 
)

Position coordinates use the evdev 0..0x7fff absolute pointer range.

Definition at line 150 of file InputManager.cc.

References putNotification().

◆ drainCallback()

void InputManager::drainCallback ( CallbackItem *  item)
private

Definition at line 349 of file InputManager.cc.

◆ initialise()

void InputManager::initialise ( )

Begins the worker thread.

Definition at line 57 of file InputManager.cc.

References ProcessorBase::information(), m_bActive, m_pThread, and trampoline().

◆ installCallback()

void InputManager::installCallback ( CallbackType  filter,
callback_t  callback,
void *  meta = 0 
)

◆ instance()

static InputManager & InputManager::instance ( )
inlinestatic

◆ isActive()

bool InputManager::isActive ( ) const
inline

Returns whether the instance is creating notifications.

Definition at line 148 of file InputManager.h.

Referenced by mainThread().

+ Here is the caller graph for this function:

◆ joystickUpdate()

void InputManager::joystickUpdate ( ssize_t  relX,
ssize_t  relY,
ssize_t  relZ,
uint32_t  buttonBitmap 
)

Called whenever joystick input comes in.

Definition at line 163 of file InputManager.cc.

References putNotification().

Referenced by HidUtils::sendInputToManager().

+ Here is the caller graph for this function:

◆ keyPressed()

void InputManager::keyPressed ( uint64_t  key)

Called whenever a key is pressed and needs to be added to the queue.

Definition at line 107 of file InputManager.cc.

References Key, and putNotification().

Referenced by HidInputManager::keyDown(), and HidInputManager::timer().

+ Here is the caller graph for this function:

◆ machineKeyUpdate()

void InputManager::machineKeyUpdate ( uint8_t  scancode,
bool  bKeyUp 
)

Called whenever a machine-specific key scancode comes in.

Definition at line 124 of file InputManager.cc.

References InputManager::InputNotification::keyUp, putNotification(), and InputManager::InputNotification::scancode.

◆ mainThread()

void InputManager::mainThread ( )

◆ mouseUpdate()

void InputManager::mouseUpdate ( ssize_t  relX,
ssize_t  relY,
ssize_t  relZ,
uint32_t  buttonBitmap 
)

Called whenever mouse input comes in.

Definition at line 133 of file InputManager.cc.

References putNotification().

Referenced by HidUtils::sendInputToManager().

+ Here is the caller graph for this function:

◆ putNotification()

void InputManager::putNotification ( InputNotification *  note)
private

Puts a notification into the queue (doer for all main functions)

Note
Deletes note if THREADS is not defined

Definition at line 175 of file InputManager.cc.

References Spinlock::acquire(), Key, m_bActive, m_Callbacks, m_InputQueue, m_InputQueueSize, m_QueueLock, Vector< T >::pushBack(), Spinlock::release(), and Semaphore::release().

Referenced by absoluteMouseUpdate(), joystickUpdate(), keyPressed(), machineKeyUpdate(), mouseUpdate(), and rawKeyUpdate().

+ Here is the caller graph for this function:

◆ rawKeyUpdate()

void InputManager::rawKeyUpdate ( uint8_t  scancode,
bool  bKeyUp 
)

Called whenever a raw key signal comes in

Parameters
scancodea HID scancode

Definition at line 115 of file InputManager.cc.

References InputManager::InputNotification::keyUp, putNotification(), and InputManager::InputNotification::scancode.

Referenced by HidInputManager::keyDown(), and HidInputManager::keyUp().

+ Here is the caller graph for this function:

◆ removeCallback()

void InputManager::removeCallback ( callback_t  callback,
void *  meta = 0 
)

Removes a callback.

Definition at line 279 of file InputManager.cc.

References m_Callbacks, and m_QueueLock.

Referenced by InputFile::releaseVfsReference(), and EvdevFile::releaseVfsReference().

+ Here is the caller graph for this function:

◆ removeCallbacks()

void InputManager::removeCallbacks ( callback_t  callback,
void *  meta 
)
private

Definition at line 299 of file InputManager.cc.

◆ shutdown()

void InputManager::shutdown ( )

◆ trampoline()

int InputManager::trampoline ( void *  ptr)
static

Thread trampoline.

Definition at line 395 of file InputManager.cc.

References mainThread().

Referenced by initialise().

+ Here is the caller graph for this function:

Member Data Documentation

◆ AbsoluteMouse

const int InputManager::AbsoluteMouse = 32
static

Definition at line 48 of file InputManager.h.

◆ Joystick

const int InputManager::Joystick = 4
static

Definition at line 45 of file InputManager.h.

◆ Key

const int InputManager::Key = 1
static

The type for a given callback (enum values can't be used for bitwise operations, so we define these as constants).

Definition at line 43 of file InputManager.h.

Referenced by DevFs::initialise(), keyPressed(), mainThread(), and putNotification().

◆ m_bActive

Atomic<bool> InputManager::m_bActive
private

Are we active?

Definition at line 228 of file InputManager.h.

Referenced by initialise(), putNotification(), and shutdown().

◆ m_Callbacks

List<CallbackItem*> InputManager::m_Callbacks
private

Callback list.

Definition at line 214 of file InputManager.h.

Referenced by installCallback(), mainThread(), putNotification(), removeCallback(), and shutdown().

◆ m_InputQueue

List<InputNotification*> InputManager::m_InputQueue
private

Input queue (for distribution to applications)

Definition at line 205 of file InputManager.h.

Referenced by mainThread(), putNotification(), and shutdown().

◆ m_InputQueueSize

Semaphore InputManager::m_InputQueueSize
private

Key press queue Semaphore.

Definition at line 218 of file InputManager.h.

Referenced by mainThread(), putNotification(), and shutdown().

◆ m_Instance

InputManager InputManager::m_Instance
staticprivate

Static instance.

Definition at line 160 of file InputManager.h.

◆ m_pCallbackDispatchThread

Thread* InputManager::m_pCallbackDispatchThread
private

Set only while the input worker is executing a committed callback.

Definition at line 224 of file InputManager.h.

Referenced by mainThread().

◆ m_pThread

Thread* InputManager::m_pThread
private

Thread object for our worker thread.

Definition at line 221 of file InputManager.h.

Referenced by initialise(), and shutdown().

◆ m_QueueLock

Spinlock InputManager::m_QueueLock
private

Spinlock for work on queues.

Note
Using a Spinlock here because a lot of our work will happen in the middle of an IRQ where it's potentially dangerous to reschedule (which may happen with a Mutex or Semaphore).

Definition at line 211 of file InputManager.h.

Referenced by installCallback(), mainThread(), putNotification(), removeCallback(), and shutdown().

◆ MachineKey

const int InputManager::MachineKey = 16
static

Definition at line 47 of file InputManager.h.

◆ Mouse

const int InputManager::Mouse = 2
static

Definition at line 44 of file InputManager.h.

◆ RawKey

const int InputManager::RawKey = 8
static

Definition at line 46 of file InputManager.h.

◆ Unknown

const int InputManager::Unknown = 255
static

Definition at line 49 of file InputManager.h.


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