|
The Pedigree Project 0.1
|
#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. | |
Global manager for all input from HID devices.
Definition at line 39 of file InputManager.h.
| typedef void(* InputManager::callback_t) (InputNotification &) |
Callback function type.
Definition at line 97 of file InputManager.h.
| typedef int InputManager::CallbackType |
Definition at line 51 of file InputManager.h.
| InputManager::InputManager | ( | ) |
Default constructor.
Definition at line 41 of file InputManager.cc.
|
virtual |
Default destructor.
Definition at line 55 of file InputManager.cc.
| 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().
|
private |
Definition at line 349 of file InputManager.cc.
| void InputManager::initialise | ( | ) |
Begins the worker thread.
Definition at line 57 of file InputManager.cc.
References ProcessorBase::information(), m_bActive, m_pThread, and trampoline().
| void InputManager::installCallback | ( | CallbackType | filter, |
| callback_t | callback, | ||
| void * | meta = 0 |
||
| ) |
Installs a callback.
Definition at line 258 of file InputManager.cc.
References InputManager::CallbackItem::deferredRemoval, InputManager::CallbackItem::draining, InputManager::CallbackItem::enabled, InputManager::CallbackItem::filter, InputManager::CallbackItem::func, InputManager::CallbackItem::inFlight, m_Callbacks, m_QueueLock, InputManager::CallbackItem::meta, and InputManager::CallbackItem::removers.
Referenced by DevFs::initialise().
Here is the caller graph for this function:
|
inlinestatic |
Singleton design.
Definition at line 112 of file InputManager.h.
Referenced by DevFs::initialise(), HidInputManager::keyDown(), HidInputManager::keyUp(), InputFile::releaseVfsReference(), EvdevFile::releaseVfsReference(), HidUtils::sendInputToManager(), and HidInputManager::timer().
Here is the caller graph for this function:
|
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:| 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:| 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:| 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.
| void InputManager::mainThread | ( | ) |
Main worker thread.
Definition at line 401 of file InputManager.cc.
References Spinlock::acquire(), Semaphore::acquire(), Thread::Continue, Vector< T >::count(), ProcessorBase::information(), Scheduler::instance(), isActive(), Key, m_Callbacks, m_InputQueue, m_InputQueueSize, m_pCallbackDispatchThread, m_QueueLock, Vector< T >::pushBack(), Spinlock::release(), and Scheduler::yield().
Referenced by trampoline().
Here is the caller graph for this function:| 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:
|
private |
Puts a notification into the queue (doer for all main functions)
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:| void InputManager::rawKeyUpdate | ( | uint8_t | scancode, |
| bool | bKeyUp | ||
| ) |
Called whenever a raw key signal comes in
| scancode | a 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:| 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:
|
private |
Definition at line 299 of file InputManager.cc.
| void InputManager::shutdown | ( | ) |
Shuts down the worker thread, clears queues, and removes callbacks.
Definition at line 70 of file InputManager.cc.
References Spinlock::acquire(), InputManager::CallbackItem::inFlight, Thread::joinForCompletion(), m_bActive, m_Callbacks, m_InputQueue, m_InputQueueSize, m_pThread, m_QueueLock, Vector< T >::pushBack(), Spinlock::release(), and Semaphore::release().
|
static |
Thread trampoline.
Definition at line 395 of file InputManager.cc.
References mainThread().
Referenced by initialise().
Here is the caller graph for this function:
|
static |
Definition at line 48 of file InputManager.h.
|
static |
Definition at line 45 of file InputManager.h.
|
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().
|
private |
Are we active?
Definition at line 228 of file InputManager.h.
Referenced by initialise(), putNotification(), and shutdown().
|
private |
Callback list.
Definition at line 214 of file InputManager.h.
Referenced by installCallback(), mainThread(), putNotification(), removeCallback(), and shutdown().
|
private |
Input queue (for distribution to applications)
Definition at line 205 of file InputManager.h.
Referenced by mainThread(), putNotification(), and shutdown().
|
private |
Key press queue Semaphore.
Definition at line 218 of file InputManager.h.
Referenced by mainThread(), putNotification(), and shutdown().
|
staticprivate |
Static instance.
Definition at line 160 of file InputManager.h.
|
private |
Set only while the input worker is executing a committed callback.
Definition at line 224 of file InputManager.h.
Referenced by mainThread().
|
private |
Thread object for our worker thread.
Definition at line 221 of file InputManager.h.
Referenced by initialise(), and shutdown().
|
private |
Spinlock for work on queues.
Definition at line 211 of file InputManager.h.
Referenced by installCallback(), mainThread(), putNotification(), removeCallback(), and shutdown().
|
static |
Definition at line 47 of file InputManager.h.
|
static |
Definition at line 44 of file InputManager.h.
|
static |
Definition at line 46 of file InputManager.h.
|
static |
Definition at line 49 of file InputManager.h.