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
 
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 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, Thread *pThread=0, uintptr_t param=0)
 Installs a callback.
 
void removeCallback (callback_t callback, void *meta=0, Thread *pThread=0)
 Removes a callback.
 
bool removeCallbackByThread (Thread *pThread)
 
void mainThread ()
 Main worker thread. More...
 
bool isActive () const
 Returns whether the instance is creating notifications.
 

Static Public Member Functions

static InputManagerinstance ()
 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 Unknown = 255
 

Private Member Functions

void putNotification (InputNotification *note)
 

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.
 
Threadm_pThread
 Thread object for our worker thread.
 
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 35 of file InputManager.h.

Member Function Documentation

void InputManager::mainThread ( )

Main worker thread.

Todo:
Handle exit condition
Todo:
Verify that the callback is in fact in the kernel

Definition at line 301 of file InputManager.cc.

References Spinlock::acquire(), Semaphore::acquire(), Scheduler::instance(), isActive(), m_Callbacks, m_InputQueue, m_InputQueueSize, m_QueueLock, NOTICE, Spinlock::release(), Thread::sendEvent(), WARNING, and Scheduler::yield().

Referenced by trampoline().

+ Here is the caller graph for this function:

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 172 of file InputManager.cc.

References m_Callbacks, m_InputQueue, m_InputQueueSize, m_QueueLock, Semaphore::release(), and WARNING.

Referenced by 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

Parameters
scancodea HID scancode

Definition at line 119 of file InputManager.cc.

References putNotification().

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

+ Here is the caller graph for this function:

bool InputManager::removeCallbackByThread ( Thread pThread)

Removes a callback by searching for a Thread pointer. This can be used to avoid useless and broken links to a Thread in the callback list if the Thread doesn't clean up properly.

Definition at line 270 of file InputManager.cc.

References m_Callbacks, and m_QueueLock.

Member Data Documentation

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 40 of file InputManager.h.

Referenced by StreamingScreenLogger::callback(), DevFs::initialise(), keyPressed(), and TextIO::translate().

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 196 of file InputManager.h.

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


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