luna-sysmgr-common
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HostBase Class Referenceabstract

#include <HostBase.h>

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

Signals

void signalBluetoothKeyboardActive (bool active)
 

Public Member Functions

virtual ~HostBase ()
 
virtual void init (int w, int h)=0
 
virtual void show ()
 
const HostInfogetInfo () const
 
virtual void run ()
 
virtual void quit ()
 
virtual const char * hardwareName () const =0
 
virtual unsigned short translateKeyWithMeta (unsigned short key, bool withShift, bool withAlt)
 
void lockPainting ()
 
void unlockPainting ()
 
virtual void setMetaModifier (bool metaKeyDown)
 
virtual bool metaModifier ()
 
virtual int getNumberOfSwitches () const
 
void turboModeSubscription (bool add)
 
virtual void setCentralWidget (QWidget *view)
 
virtual void flip ()
 
virtual bool hasAltKey (Qt::KeyboardModifiers modifiers)
 
virtual QImage takeScreenShot () const
 
virtual QImage takeAppDirectRenderingScreenShot () const
 
virtual void setAppDirectRenderingLayerEnabled (bool enable)
 
void setOrientation (OrientationEvent::Orientation o)
 
QPoint map (const QPoint &pt)
 
virtual void setRenderingLayerEnabled (bool enable)
 
virtual InputControlgetInputControlALS ()
 
virtual InputControlgetInputControlBluetoothInputDetect ()
 
virtual InputControlgetInputControlProximity ()
 
virtual InputControlgetInputControlTouchpanel ()
 
virtual InputControlgetInputControlKeys ()
 
virtual LedControlgetLedControlKeypadAndDisplay ()
 
virtual void OrientationSensorOn (bool enable)
 
virtual OrientationEventpostProcessDeviceOrientation (OrientationEvent *currOrientation)
 
virtual bool homeButtonWakesUpScreen ()
 
virtual void setBluetoothKeyboardActive (bool active)
 
virtual bool bluetoothKeyboardActive () const
 
- Public Member Functions inherited from TaskBase
 TaskBase ()
 
virtual ~TaskBase ()
 
void postEvent (sptr< Event > event, bool highPriority=false)
 
GMainLoop * mainLoop () const
 
SingletonTimermasterTimer () const
 
- Public Member Functions inherited from RefCounted
 RefCounted ()
 
virtual ~RefCounted ()
 
void ref ()
 
void deref ()
 

Static Public Member Functions

static HostBaseinstance ()
 
static bool hostIsQemu ()
 

Protected Member Functions

 HostBase ()
 
virtual void handleEvent (sptr< Event >)
 
virtual void turboMode (bool enable)
 

Protected Attributes

HostInfo m_info
 
Mutex m_paintMutex
 
bool m_metaKeyDown
 
OrientationEvent::Orientation m_orientation
 
QTransform m_trans
 
int m_numBuffers
 
unsigned m_turboModeSubscriptions
 
- Protected Attributes inherited from TaskBase
GMainContext * m_mainCtxt
 
GMainLoop * m_mainLoop
 
Mutex m_mutex
 
Mutex m_eventsMutex
 
std::list< sptr< Event > > m_eventsList
 
AsyncCaller< TaskBase > * m_asyncCaller
 
SingletonTimerm_masterTimer
 

Detailed Description

Base functionality for interfacing with the hardware of all devices which LunaSysMgr can run on

Provides information and capabilities such as:

  • Screen size and other display information.
  • Hardware keypress (dot, shift, and symbol keys) to system keypress translation (handled here since it could be different for different keyboards).
  • Taking screenshots.
  • Turning on and off diffferent device sensors.
  • Bluetooth keyboard handling.

Constructor & Destructor Documentation

HostBase::~HostBase ( )
virtual

Clean up device-specific resources

Closes down any hardware initialized when this host was constructed. Designed to be overridden by each Host class for each type of device so that all hardware of specific devices is correctly shut down.

Just runs HostBase::quit() unless overridden by a derived class.

HostBase::HostBase ( )
protected

Constructor for HostBase

Defined as protected since HostBase cannot be constructed without being derived from.

Initializes GLib and resets a number of the "current state" variables to default states.

Member Function Documentation

virtual bool HostBase::bluetoothKeyboardActive ( ) const
inlinevirtual

Checks whether Bluetooth keyboard functionality is enabled

Todo:
Verify that the documentation for this method is correct.
Returns
true if Bluetooth keyboard functionality is enabled, otherwise false.

Reimplemented in HostArm.

virtual void HostBase::flip ( )
inlinevirtual

Flips the back buffer to the display

Displays to the screen what is currently contained in the back buffer. Since there is a back buffer, drawing can be completed on the back buffer at the program's leisure before displaying it in one swift move with a flip.

Reimplemented in HostArm.

const HostInfo& HostBase::getInfo ( ) const
inline

Gets a structure of information about the current host device

The HostInfo structure mostly contains information about the display device. This allows retrieval of that from a central point.

Returns
Structure full of information about the current host device.
virtual InputControl* HostBase::getInputControlALS ( )
inlinevirtual

Gets an InputControl pointer for the ambient light sensor

Allows the ambient light sensor to be turned on/off.

Returns
Ambient light sensor control.

Reimplemented in HostArm.

virtual InputControl* HostBase::getInputControlBluetoothInputDetect ( )
inlinevirtual

Gets an InputControl pointer for Bluetooth input detection

Allows the Bluetooth input detection to be turned on/off.

Returns
Bluetooth input sensor control.

Reimplemented in HostArm.

virtual InputControl* HostBase::getInputControlKeys ( )
inlinevirtual

Gets an InputControl pointer for the keyboard

Allows the keyboard to be turned on/off.

Todo:
Confirm documentation on this.
Returns
Control keys sensor control.

Reimplemented in HostArm.

virtual InputControl* HostBase::getInputControlProximity ( )
inlinevirtual

Gets an InputControl pointer for the face proximity sensor

Allows the face proximity sensor to be turned on/off.

Returns
Face proximity sensor control.

Reimplemented in HostArm.

virtual InputControl* HostBase::getInputControlTouchpanel ( )
inlinevirtual

Gets an InputControl pointer for the touch panel

Allows the touch panel to be turned on/off.

Returns
Touch panel sensor control.

Reimplemented in HostArm.

virtual LedControl* HostBase::getLedControlKeypadAndDisplay ( )
inlinevirtual

Gets an LedControl pointer for the keyboard backlight

Allows the keyboard backlight to be turned on/off.

Todo:
Confirm documentation on this.
Returns
Keyboard backlight control.

Reimplemented in HostArm.

virtual int HostBase::getNumberOfSwitches ( ) const
inlinevirtual

Gets the number of hardware switches the current host device has

As an example, the Palm Pre has 3 switches:

  • Ringer on/off.
  • Slider opened/closed.
  • Headphones inserted/no headphones.
Returns
Number of hardware switches the device has.

Reimplemented in HostArm, HostArmQemu, HostArmBroadway, HostArmTopaz, HostArmOpal, and HostArmWindsorNot.

virtual void HostBase::handleEvent ( sptr< Event event)
inlineprotectedvirtual

Event handler

Called by the event loop to handle each event, in order, from the event queue

See Also
sptr
Parameters
eventSmart pointer to an Event with info about the event to handle

Implements TaskBase.

virtual const char* HostBase::hardwareName ( ) const
pure virtual

Return the specific name (including model revision) of the current host device

As an example, for a generic ARM device for which more information is not available, it returns "ARM Device". For a Palm Pixie device, it might return something like "Pixie DVT1".

Returns
Name of the hardware of the current host device.

Implemented in HostArm, HostArmQemu, HostArmBroadway, HostArmMantaray, HostArmTopaz, HostArmOpal, HostArmWindsorNot, HostArmUnknown, and HostQtDesktop.

bool HostBase::hasAltKey ( Qt::KeyboardModifiers  modifiers)
virtual

Maps Qt's version of the state of the modifier keys to whether or not the Alt (dot) key is pressed

On HostQtDesktop, both the Ctrl and Alt keys are mapped to the LunaSysMgr version of the Alt (dot) key.

Parameters
modifiersKeybaord modifiers, as reported by Qt
Returns
Whether or not the current state of the hardware modifier keys indicates that the Alt (dot) key is pressed.

Reimplemented in HostQtDesktop.

virtual bool HostBase::homeButtonWakesUpScreen ( )
inlinevirtual

Presumably whether the Home button wakes up the screen

This is seldom used and largely undocumented. Description is more or less a guess.

Todo:
Determine with certainty what this method is for.
Returns
Presumably true if pressing the Home button wakes up the screen and false otherwise.

Reimplemented in HostArmTopaz, HostArmOpal, and HostArmWindsorNot.

bool HostBase::hostIsQemu ( )
static

Gets whether or not the current host is running under a Qemu virtual machine

Returns
true if running under a Qemu virtual machine, otherwise false.
virtual void HostBase::init ( int  w,
int  h 
)
pure virtual

Initialize device-specific hardware

Initializes hardware, fetches display info, and generally prepares the host device for LunaSysMgr to run on it.

Must be overridden for each type of device Host class needed.

Parameters
wHint as to what the screen width probably is. Ignored by most devices since they can query the screen for its capabilities.
hHint as to what the screen height probably is. Ignored by most devices since they can query the screen for its capabilities.

Implemented in HostArm, and HostQtDesktop.

HostBase * HostBase::instance ( )
static

Gets a pointer to an instance of the current device-specific Host class

Since each host device will have different capabilities, this method allows you to retrieve the correct host information for the current device.

void HostBase::lockPainting ( )
inline

Locks the display's back buffer to draw to

If the display is currently being used by another thread, this method waits until the other method is done and exclusive access is granted before returning.

QPoint HostBase::map ( const QPoint &  pt)
inline

Map a screen touch sensor point to a point on the display screen taking into account device orientation

Parameters
ptTouchscreen point coordinates.
Returns
Translated display window coordinates translated using the same orientation rotation as the objects on-screen.
virtual bool HostBase::metaModifier ( )
inlinevirtual

Gets whether or not the meta key is currently pressed

Returns
true if the meta key is currently pressed, otherwise false.
virtual void HostBase::OrientationSensorOn ( bool  enable)
inlinevirtual

Function enables/disables the orientation sensor

Parameters
enabletrue to enable the orientation sensor, false to disable it.

Reimplemented in HostArm.

virtual OrientationEvent* HostBase::postProcessDeviceOrientation ( OrientationEvent currOrientation)
inlinevirtual

Function processes the Orientation of the device and returns the correct screen(display) orientation.

Parameters
currOrientation- Current device orientation
Returns
returns the correct device specific orientation to be used for device screen orientation
Note
ownership of the returned object is transferred back to the caller.

Reimplemented in HostArmTopaz.

void HostBase::quit ( )
virtual

Terminates this task

At this point, it doesn't appear this is used by any deriving classes. Ideally this would do cleanup from TaskBase::run().

Implements TaskBase.

void HostBase::run ( )
virtual

Runs this task

The bulk of derived classes' funcionality should reside within this method. This method should not return until the task is complete. For example, WebAppManager runs a QCoreApplication within this method, and when it terminates, this function returns.

Implements TaskBase.

virtual void HostBase::setAppDirectRenderingLayerEnabled ( bool  enable)
inlinevirtual

Unknown purpose at this time

This is used in very few other places, so I don't know exactly what it's used for. On ARM devices, executes an FBIO command that I cannot currently find documentation for. Seems to have something to do with blanking.

Todo:
Document what this is used for and how it works once it's figured out.
Parameters
enableUnknown.

Reimplemented in HostArm.

virtual void HostBase::setBluetoothKeyboardActive ( bool  active)
inlinevirtual

Enable/disable Bluetooth keyboards

Todo:
Verify that the documentation for this method is correct.
Parameters
activetrue to enable Bluetooth keyboards, false to disable

Reimplemented in HostArm.

virtual void HostBase::setCentralWidget ( QWidget view)
inlinevirtual

Sets the Qt widget that the display should reside in

Mostly unused except under the QtDesktop and Qemu hosts, where it is used to attach a keyboard remapping filter.

Called by WindowServer::WindowServer().

Parameters
viewQt widget to display within.

Reimplemented in HostArm, HostArmQemu, and HostQtDesktop.

virtual void HostBase::setMetaModifier ( bool  metaKeyDown)
inlinevirtual

Sets whether or not the meta key is currently pressed

Parameters
metaKeyDowntrue if the meta key is currently pressed, otherwise false.
void HostBase::setOrientation ( OrientationEvent::Orientation  o)

Sets the device's current orientation

Changes the display's transformation matrix so on-screen items display with the correct orientation.

Parameters
oOne of OrientationEvent::Orientation_Up, OrientationEvent::Orientation_Down, OrientationEvent::Orientation_Right, OrientationEvent::Orientation_Left indicating which edge of the screen is vertically "up".
virtual void HostBase::setRenderingLayerEnabled ( bool  enable)
inlinevirtual

Unknown purpose at this time

Almost the same as HostBase::setAppDirectRenderingLayerEnabled, but on a different fb device. Has something to do with blanking, but still don't really understand what this is used for.

Parameters
enableUnknown.

Reimplemented in HostArm.

virtual void HostBase::show ( )
inlinevirtual

Grab access to the hardware (including the display and input devices) for use by LunaSysMgr

Run this when you're ready to start using the host to display things. It grabs exclusive access to the screen and input devices (on most devices) so it can actually start displaying graphics on the screen.

Must be overridden per-device since it's fairly device-specific what needs to be enabled to be able to run LunaSysMgr.

Reimplemented in HostArm, and HostQtDesktop.

void HostBase::signalBluetoothKeyboardActive ( bool  active)
signal

Unknown at this time

Do not currently know how this works or where it is defined.

Parameters
activeUnknown.
virtual QImage HostBase::takeAppDirectRenderingScreenShot ( ) const
inlinevirtual

Takes a screenshot, including anything rendered directly to the display by an app

Currently only implemented on ARM devices, and on them is the same as a regular screenshot.

Returns
An image showing the current state of the display, even if an app has drawn to it directly.

Reimplemented in HostArm.

virtual QImage HostBase::takeScreenShot ( ) const
inlinevirtual

Takes a screenshot

Currently only implemented on ARM devices.

Returns
An image showing the current state of the display.

Reimplemented in HostArm.

unsigned short HostBase::translateKeyWithMeta ( unsigned short  key,
bool  withShift,
bool  withAlt 
)
virtual

Translate a hardware keycode to a system keycode depending on modifier keys

Takes a hardware keycode and which modifiers are currently pressed and returns a system modifier. For example, if the key is the key code for "a" and shift is down, it translates it to the key code for "A".

Parameters
keyInput hardware key code.
withShiftWhether Shift is currently pressed.
withAltWhether Alt (dot key) is currently pressed.
Returns
Translated key code.

Reimplemented in HostQtDesktop.

virtual void HostBase::turboMode ( bool  enable)
inlineprotectedvirtual

Enables/disables turbo mode

Changes CPU frequency scaling. When turbo mode is enabled, the CPU is set to run at full speed. When disabled, it turns the speed down to save on power usage.

Parameters
enabletrue to enable turbo mode, false to disable it

Reimplemented in HostArmTopaz, and HostArmOpal.

void HostBase::turboModeSubscription ( bool  add)

Enables/disables subscribing to turbo mode

Counts the number of times callers turn on turbo mode and turns it on as long as anyone needs it.

Todo:
Figure out why it's exposed like this instead of having HostBase::turboMode() exposed directly.
Parameters
addtrue to ask that turbo mode be turned on, false to tell HostBase that it's no longer needed.
void HostBase::unlockPainting ( )
inline

Unlocks the display's back buffer so other threads can draw to it

Member Data Documentation

HostInfo HostBase::m_info
protected

Host device info generated in HostBase::init() and cached here so it can be retrieved quickly

bool HostBase::m_metaKeyDown
protected

Whether or not the Meta key is currently pressed

int HostBase::m_numBuffers
protected

Presumably the number of back buffers

Currently appears to be unused.

Todo:

Confirm documentation of this member variable.

Remove this if possible.

OrientationEvent::Orientation HostBase::m_orientation
protected

Current orientation of device

See Also
HostBase::setOrientation()
Mutex HostBase::m_paintMutex
protected

Mutex that allows locking of the back buffer while a function paints to it

QTransform HostBase::m_trans
protected

Current transformation matrix used to rotate the display to match the current device orientation (so the screen image always faces "up")

unsigned HostBase::m_turboModeSubscriptions
protected

Number of running pieces of code which currently need turbo mode enabled

See Also
HostBase::turboModeSubscription()

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