Gammu internals  1.38.0
Keys

Enumerations

enum  GSM_KeyCode {
  GSM_KEY_NONE = 0x00, GSM_KEY_1 = 0x01, GSM_KEY_2, GSM_KEY_3,
  GSM_KEY_4, GSM_KEY_5, GSM_KEY_6, GSM_KEY_7,
  GSM_KEY_8, GSM_KEY_9, GSM_KEY_0, GSM_KEY_HASH,
  GSM_KEY_ASTERISK, GSM_KEY_POWER, GSM_KEY_GREEN, GSM_KEY_RED,
  GSM_KEY_INCREASEVOLUME, GSM_KEY_DECREASEVOLUME, GSM_KEY_UP = 0x17, GSM_KEY_DOWN,
  GSM_KEY_MENU, GSM_KEY_NAMES, GSM_KEY_LEFT, GSM_KEY_RIGHT,
  GSM_KEY_SOFT1, GSM_KEY_SOFT2, GSM_KEY_HEADSET, GSM_KEY_JOYSTICK,
  GSM_KEY_CAMERA, GSM_KEY_MEDIA, GSM_KEY_DESKTOP, GSM_KEY_OPERATOR,
  GSM_KEY_RETURN, GSM_KEY_CLEAR
}
 

Functions

GSM_Error MakeKeySequence (char *text, GSM_KeyCode *KeyCode, size_t *Length)
 
GSM_Error GSM_PressKey (GSM_StateMachine *s, GSM_KeyCode Key, gboolean Press)
 

Detailed Description

Keyboard manipulations.

Enumeration Type Documentation

§ GSM_KeyCode

Key event identifiers.

Enumerator
GSM_KEY_NONE 
GSM_KEY_1 
GSM_KEY_2 
GSM_KEY_3 
GSM_KEY_4 
GSM_KEY_5 
GSM_KEY_6 
GSM_KEY_7 
GSM_KEY_8 
GSM_KEY_9 
GSM_KEY_0 
GSM_KEY_HASH 

#

GSM_KEY_ASTERISK 
GSM_KEY_POWER 

Power key.

GSM_KEY_GREEN 

in some phone ie. N5110 sometimes works identical to POWER

GSM_KEY_RED 

(c) key in some phone: ie. N5110

GSM_KEY_INCREASEVOLUME 

Not available in some phones as separate button: ie. N5110

GSM_KEY_DECREASEVOLUME 

Not available in some phones as separate button: ie. N5110

GSM_KEY_UP 
GSM_KEY_DOWN 
GSM_KEY_MENU 
GSM_KEY_NAMES 

Not available in some phone: ie. N5110

GSM_KEY_LEFT 

Left arrow

GSM_KEY_RIGHT 

Right arrow

GSM_KEY_SOFT1 

Software key which has assigned mening on display.

GSM_KEY_SOFT2 

Software key which has assigned mening on display.

GSM_KEY_HEADSET 

Button on headset

GSM_KEY_JOYSTICK 

Joystick pressed

GSM_KEY_CAMERA 

Camera button pressed

GSM_KEY_MEDIA 

Media player button

GSM_KEY_DESKTOP 

Multi function key, desktop

GSM_KEY_OPERATOR 

Operator button

GSM_KEY_RETURN 

Return button

GSM_KEY_CLEAR 

Clear button

Definition at line 30 of file gammu-keys.h.

30  {
31  GSM_KEY_NONE = 0x00,
32  GSM_KEY_1 = 0x01,
33  GSM_KEY_2,
34  GSM_KEY_3,
35  GSM_KEY_4,
36  GSM_KEY_5,
37  GSM_KEY_6,
38  GSM_KEY_7,
39  GSM_KEY_8,
40  GSM_KEY_9,
41  GSM_KEY_0,
70  GSM_KEY_UP = 0x17,
125 } GSM_KeyCode;
GSM_KeyCode
Definition: gammu-keys.h:30

Function Documentation

§ GSM_PressKey()

GSM_Error GSM_PressKey ( GSM_StateMachine s,
GSM_KeyCode  Key,
gboolean  Press 
)

Emulates key press or key release.

Definition at line 320 of file api.c.

References CHECK_PHONE_CONNECTION, GSM_Phone::Functions, _GSM_StateMachine::Phone, GSM_Phone_Functions::PressKey, and PRINT_LOG_ERROR.

321 {
322  GSM_Error err;
323 
325 
326  err = s->Phone.Functions->PressKey(s, Key, Press);
327  PRINT_LOG_ERROR(err);
328  return err;
329 }
GSM_Error(* PressKey)(GSM_StateMachine *s, GSM_KeyCode Key, gboolean Press)
Definition: gsmstate.h:838
GSM_Error
Definition: gammu-error.h:23
GSM_Phone Phone
Definition: gsmstate.h:1431
#define PRINT_LOG_ERROR(err)
Definition: api.c:28
#define CHECK_PHONE_CONNECTION()
Definition: api.c:38
GSM_Phone_Functions * Functions
Definition: gsmstate.h:1373

§ MakeKeySequence()

GSM_Error MakeKeySequence ( char *  text,
GSM_KeyCode KeyCode,
size_t *  Length 
)

Creates key sequence from string.

Parameters
textText to convert.
KeyCodeStorage for key codes.
LengthStorage for resulting length.
Returns
Error code.

Definition at line 49 of file gsmmisc.c.

References ERR_NONE, ERR_NOTSUPPORTED, GSM_KEY_NONE, keys_table_position::whatchar, and keys_table_position::whatcode.

50 {
51  int i,j;
52  char key;
53 
54  for (i=0;i<(int)(strlen(text));i++) {
55  key = text[i];
56  KeyCode[i] = GSM_KEY_NONE;
57  j = 0;
58  while (Keys[j].whatchar!=' ') {
59  if (Keys[j].whatchar==key) {
60  KeyCode[i]=Keys[j].whatcode;
61  break;
62  }
63  j++;
64  }
65  if (KeyCode[i] == GSM_KEY_NONE) {
66  *Length = i;
67  return ERR_NOTSUPPORTED;
68  }
69  }
70  *Length = i;
71  return ERR_NONE;
72 }
static struct keys_table_position Keys[]
Definition: gsmmisc.c:23