×
Namespaces

Variants
Actions
(Difference between revisions)

Using hardware keys with S60 and Maemo Platform

From Nokia Developer Wiki
Jump to: navigation, search
ebra (Talk | contribs)
(Comparison)
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot update - Add ArticleMetaData)
(14 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[Category:S60]]
+
{{ArticleMetaData <!-- v1.2 -->
[[Category:Maemo]]
+
|sourcecode= <!-- Link to example source code e.g. [[Media:The Code Example ZIP.zip]] -->
 
+
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 +
|devices= <!-- Devices tested against - e.g. ''devices=Nokia 6131 NFC, Nokia C7-00'') -->
 +
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Qt SDK 1.1.4]) -->
 +
|platform= <!-- Compatible platforms - e.g. Symbian^1 and later, Qt 4.6 and later -->
 +
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) -->
 +
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
 +
|signing= <!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer -->
 +
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
 +
|keywords= <!-- APIs, classes and methods (e.g. QSystemScreenSaver, QList, CBase -->
 +
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 +
|translated-by= <!-- [[User:XXXX]] -->
 +
|translated-from-title= <!-- Title only -->
 +
|translated-from-id= <!-- Id of translated revision -->
 +
|review-by= <!-- After re-review: [[User:username]] -->
 +
|review-timestamp= <!-- After re-review: YYYYMMDD -->
 +
|update-by= <!-- After significant update: [[User:username]]-->
 +
|update-timestamp= <!-- After significant update: YYYYMMDD -->
 +
|creationdate= 20071029
 +
|author= [[User:Ebra]]
 +
}}
 +
[[Category:Maemo]][[Category:Symbian C++]][[Category:Symbian]][[Category:Hardware]][[Category:Porting]]
 
== Comparison ==
 
== Comparison ==
 
Both S60 Platform and Maemo Platform devices have a number of hardware keys for developers to use. The number of keys available varies between different devices. Both platforms have devices with full QWERTY keyboard. For example the E90 Communicator and the Nokia N810 Internet Tablet.
 
Both S60 Platform and Maemo Platform devices have a number of hardware keys for developers to use. The number of keys available varies between different devices. Both platforms have devices with full QWERTY keyboard. For example the E90 Communicator and the Nokia N810 Internet Tablet.
  
[[Image:Nokia_E90.png]]   
+
[[File:Nokia E90.png]]   
 
Nokia E90 Communicator
 
Nokia E90 Communicator
  
[[Image:Nokia_N810.png]]
+
[[File:Nokia N810.png]]
 
Nokia N810 Internet Tablet
 
Nokia N810 Internet Tablet
 +
 +
[[Comparing S60 and Maemo Platforms]]
  
 
== S60 Platform ==
 
== S60 Platform ==
 +
[[File:S60HWKeys.png]]
 +
 +
'''\epoc32\include\e32keys.h'''
 +
<code>
 +
enum TStdScanCode
 +
{
 +
...
 +
EStdKeyLeftArrow=0x0e,                /**< Scan code for Left arrow key.*/
 +
EStdKeyRightArrow=0x0f,              /**< Scan code for Right arrow key.*/
 +
EStdKeyUpArrow=0x10,                  /**< Scan code for Up arrow key.*/
 +
EStdKeyDownArrow=0x11,                /**< Scan code for Down arrow key.*/
 +
...
 +
};
 +
</code>
 +
 +
<code>
 +
// ----------------------------------------------------
 +
// CAknExEditorAppUi::HandleKeyEventL
 +
// Handles key events.
 +
//
 +
// ----------------------------------------------------
 +
//
 +
TKeyResponse CUTFViewerAppUi::HandleKeyEventL(
 +
    const TKeyEvent& aKeyEvent,TEventCode aType )
 +
    {
 +
    if ( aType == EEventKey)
 +
    {
 +
    switch ( aKeyEvent.iScanCode )
 +
    {
 +
        case EStdKeyUpArrow:
 +
...
 +
    }
 +
    return EKeyWasNotConsumed;
 +
    }
 +
</code>
  
 
== Maemo Platform ==
 
== Maemo Platform ==
[[Image:MaemoHWKeys.png]]
+
[[File:MaemoHWKeys3.png]]
 
<code>
 
<code>
 
typedef struct _AppData AppData;
 
typedef struct _AppData AppData;
Line 43: Line 100:
 
/* Callback for hardware keys */
 
/* Callback for hardware keys */
 
gboolean callback_key_press(GtkWidget * widget, GdkEventKey * event, gpointer data)
 
gboolean callback_key_press(GtkWidget * widget, GdkEventKey * event, gpointer data)
{
+
{  
 
     switch (event->keyval) {
 
     switch (event->keyval) {
     case GDK_Up:
+
 
 +
     case HILDON_HARDKEY_UP:
 
         callback_up( NULL, data );
 
         callback_up( NULL, data );
 
         return TRUE;
 
         return TRUE;
  
     case GDK_Down:
+
     case HILDON_HARDKEY_DOWN:
 
         callback_down( NULL, data );
 
         callback_down( NULL, data );
 
         return TRUE;
 
         return TRUE;
  
     case GDK_Left:
+
     case HILDON_HARDKEY_LEFT:
 
         callback_left( NULL, data );
 
         callback_left( NULL, data );
 
         return TRUE;
 
         return TRUE;
  
     case GDK_Right:
+
     case HILDON_HARDKEY_RIGHT:
 
         callback_right( NULL, data );
 
         callback_right( NULL, data );
 
         return TRUE;
 
         return TRUE;
  
     case GDK_Return:  
+
     case HILDON_HARDKEY_SELECT:  
 
         callback_reset( NULL, data );
 
         callback_reset( NULL, data );
 
         return TRUE;
 
         return TRUE;
  
     case GDK_F6:
+
     case HILDON_HARDKEY_FULLSCREEN:
 
         callback_fullscreen( NULL, data );
 
         callback_fullscreen( NULL, data );
 
         return TRUE;
 
         return TRUE;
  
     case GDK_F7: /* "Increase (zoom in)" */
+
     case HILDON_HARDKEY_INCREASE:
 
         return FALSE;
 
         return FALSE;
  
     case GDK_F8: /* "Decrease (zoom out)" */
+
     case HILDON_HARDKEY_DECREASE :
 
         return FALSE;
 
         return FALSE;
  
     case GDK_Escape: /* "Cancel/Close" */
+
     case HILDON_HARDKEY_ESC :
 
         return FALSE;
 
         return FALSE;
  
Line 82: Line 140:
 
}
 
}
 
</code>
 
</code>
 +
<!-- Translation --> [[pt:Usando as Teclas das Plataformas S60 e Maemo]]

Revision as of 08:38, 26 July 2012

Article Metadata
Article
Created: ebra (29 Oct 2007)
Last edited: hamishwillee (26 Jul 2012)

Comparison

Both S60 Platform and Maemo Platform devices have a number of hardware keys for developers to use. The number of keys available varies between different devices. Both platforms have devices with full QWERTY keyboard. For example the E90 Communicator and the Nokia N810 Internet Tablet.

Nokia E90.png Nokia E90 Communicator

Nokia N810.png Nokia N810 Internet Tablet

Comparing S60 and Maemo Platforms

S60 Platform

S60HWKeys.png

\epoc32\include\e32keys.h

enum TStdScanCode
{
...
EStdKeyLeftArrow=0x0e, /**< Scan code for Left arrow key.*/
EStdKeyRightArrow=0x0f, /**< Scan code for Right arrow key.*/
EStdKeyUpArrow=0x10, /**< Scan code for Up arrow key.*/
EStdKeyDownArrow=0x11, /**< Scan code for Down arrow key.*/
...
};
// ----------------------------------------------------
// CAknExEditorAppUi::HandleKeyEventL
// Handles key events.
//
// ----------------------------------------------------
//
TKeyResponse CUTFViewerAppUi::HandleKeyEventL(
const TKeyEvent& aKeyEvent,TEventCode aType )
{
if ( aType == EEventKey)
{
switch ( aKeyEvent.iScanCode )
{
case EStdKeyUpArrow:
...
}
return EKeyWasNotConsumed;
}

Maemo Platform

MaemoHWKeys3.png

typedef struct _AppData AppData;
 
struct _AppData
{
HildonProgram *program; /* handle to application */
HildonWindow *window; /* handle to app's window */
osso_context_t *osso; /* handle to osso */
};
/* Creates and initialises a main_view */
MainView* interface_main_view_new( AppData *data )
{
/* Zero memory with g_new0 */
MainView* result = g_new0( MainView, 1 );
...
/* Add hardware button listener to application */
g_signal_connect(G_OBJECT(result->data->window),
"key_press_event", G_CALLBACK(callback_key_press), result);
...
}
/* Callback for hardware keys */
gboolean callback_key_press(GtkWidget * widget, GdkEventKey * event, gpointer data)
{
switch (event->keyval) {
 
case HILDON_HARDKEY_UP:
callback_up( NULL, data );
return TRUE;
 
case HILDON_HARDKEY_DOWN:
callback_down( NULL, data );
return TRUE;
 
case HILDON_HARDKEY_LEFT:
callback_left( NULL, data );
return TRUE;
 
case HILDON_HARDKEY_RIGHT:
callback_right( NULL, data );
return TRUE;
 
case HILDON_HARDKEY_SELECT:
callback_reset( NULL, data );
return TRUE;
 
case HILDON_HARDKEY_FULLSCREEN:
callback_fullscreen( NULL, data );
return TRUE;
 
case HILDON_HARDKEY_INCREASE:
return FALSE;
 
case HILDON_HARDKEY_DECREASE :
return FALSE;
 
case HILDON_HARDKEY_ESC :
return FALSE;
 
}
return FALSE;
}
52 page views in the last 30 days.
×