SWILIB API (NSG)    
Loading...
Searching...
No Matches
MISC

Detailed Description

Miscellaneous phone functions.

Usage: #include <swilib.h> or #include <swilib/misc.h>

Data Structures

struct  shortcut
 Shortcuts. More...
 
struct  LIGHT_PARAM
 Lightness settings. More...
 
struct  SEXIT_RECORD
 SExit record: what the firmware saves on a fatal exit ("Exit Info") or a warning. More...
 
struct  SEXIT_HOOKS
 SExit handler table (pointers to the handler words, 0xFFFFFFFF in a word = no handler). More...
 
struct  SEXIT_STATE
 SExit state. More...
 
struct  SEXIT_RECORDS
 Current SExit records (internal RAM). More...
 
struct  SEXIT_RECORD.regs
 

Typedefs

typedef int(* shortcut_func) (void)
 
typedef struct shortcut shortcut
 
typedef struct LIGHT_PARAM LIGHT_PARAM
 
typedef struct SEXIT_RECORD SEXIT_RECORD
 
typedef struct SEXIT_HOOKS SEXIT_HOOKS
 
typedef struct SEXIT_STATE SEXIT_STATE
 
typedef struct SEXIT_RECORDS SEXIT_RECORDS
 
typedef void(* SEXIT_HANDLER) (SEXIT_RECORD *record)
 SExit record handler.
 

Enumerations

enum  IlluminationDeviceID {
  ILLUMINATION_DEV_DISPLAY = 0 ,
  ILLUMINATION_DEV_KEYBOARD = 1 ,
  ILLUMINATION_DEV_DYNLIGHT = 2 ,
  ILLUMINATION_DEV_LIGHTER = 3
}
 Illumination device. More...
 
enum  SetLightFlags {
  SET_LIGHT_DISPLAY = 1 << 0 ,
  SET_LIGHT_KEYBOARD = 1 << 1
}
 Set light flags. More...
 
enum  CountdownToneType {
  COUNTDOWN_TONE_BEEP = 0x7 ,
  COUNTDOWN_TONE_ALERT = 0xD
}
 
enum  Accessory {
  ACC_CARKIT_COMFORT = 0x1 ,
  ACC_CK_COMFORT_MK2 = 0x2 ,
  ACC_CARKIT_PORTABLE = 0x3 ,
  ACC_CARKIT_EASY = 0x4 ,
  ACC_CK_LINEFIT_ATC = 0x5 ,
  ACC_CARKIT_LINEFIT = 0x6 ,
  ACC_CK_LINEFIT_MK2 = 0x7 ,
  ACC_CARKIT_PROFESSIONAL = 0x8 ,
  ACC_CARKIT_VOICE = 0x9 ,
  ACC_CK_VOICE_MK2 = 0xA ,
  ACC_CAR_DATA_ADAPTOR = 0xB ,
  ACC_DESKTOP_CHARGER = 0xC ,
  ACC_STANDARD_CHARGER = 0xD ,
  ACC_DATA_CABLE = 0xE ,
  ACC_USB_DATA_CABLE = 0xF ,
  ACC_DATA_CABLE_USB_USB = 0x10 ,
  ACC_HEADSET_MONO = 0x12 ,
  ACC_HEADSET_STEREO = 0x13 ,
  ACC_CLIP_ON_FLASH = 0x14 ,
  ACC_TTY_X55 = 0x15 ,
  ACC_TTY = 0x16 ,
  ACC_JAVA_DEVICE = 0x17 ,
  ACC_EMO_DEVICE = 0x18 ,
  ACC_CLIP_IT_LED = 0x19 ,
  ACC_FM_RADIO = 0x1A ,
  ACC_MP3_PLAYER = 0x1B ,
  ACC_MOBILE_MUSIC_SET = 0x1D ,
  ACC_MUSIC_CABLE = 0x1E ,
  ACC_BOOT_BOX = 0x20 ,
  ACC_UNSUPPORTED_ACCESSORY = 0x2D ,
  ACC_UNKNOWN_ACCESSORY = 0x2E
}
 Accessories. More...
 

Control

void SwitchPhoneOff ()
 Switchoff phone.
 
void RebootPhone ()
 Reboot phone.
 
void SLI_SetState (uint8_t state)
 Set state for SLI indicator.
 

IDLE

void DisableIDLETMR (void)
 Disable the IDLE timer - the phone never goes to the IDLE screen.
 
void SetIDLETMR (int timeout, int msg)
 Set custom IDLE timer.
 
void RestartIDLETMR (void)
 Restart the default idle timer.
 

Keyboard

void KeypressOn (int keycode)
 Press key (simulation).
 
void KeypressOff (int keycode)
 Release key (simulation).
 
int IsUnlocked (void)
 Get keyboard lock status.
 
int * RamIsLocked (void)
 Get keyboard lock status.
 
void KbdLock (void)
 Lock keyboard.
 
void KbdUnlock (void)
 Unlock keyboard.
 
void RestartLockTimers ()
 Restart screensaver and keyboard lock timers.
 

Backlight

char * GetIlluminationDataTable ()
 Pointer to the illumination table.
 
LIGHT_PARAM * RamScreenBrightness (void)
 Pointer to the brightness settings.
 
long SetIllumination (uint8_t dev, unsigned long unk, uint16_t level, unsigned long delay)
 Change illumination level for keyboard or LCD.
 
void IllumTimeRequest (int time_mode, int counter)
 Keep the backlight on.
 
void IllumTimeRelease (int time_mode, int counter)
 Allow backlight to turn off again.
 
void SetMaxIllumIntensity (int unk3, uint32_t level)
 Sets the maximum backlight brightness.
 
void TempLightOn (int flags, int unk)
 Trigger backlight (temporary set ON).
 
void IllumFilterSet (int flags, int unk)
 Trigger backlight (temporary set OFF).
 

Vibration

int GetVibraStatus (void)
 Check if vibration enabled.
 
void SetVibraStatus (int status)
 Enable or disable vibration.
 
uint32_t SetVibration (uint32_t power)
 Start vibration.
 

Clipboard

WSHDR * GetClipBoard (void)
 Get clipboard content.
 
void CopyTextToClipboard (const WSHDR *text, int pos, int len)
 Copy the text to the clipboard.
 
void ClearClipboard (char unk)
 Clear clipboard content.
 

AlarmClock

void AlarmClockRing (void)
 Run AlarmClock ringing.
 
int GetAlarmClockState (int state)
 Get AlarmClock state.
 
char * RamAlarmClockState ()
 Pointer to the AlarmClock state.
 
int RefreshAlarmClock ()
 Re-read changed alarmclock.pd.
 
char * RamIsAlarmClockAutorepeatOn ()
 Check if auto-repeat is enabled in AlarmClock.
 
char * RamAlarmClockHours ()
 AlarmClock scheduled time (hours).
 
char * RamAlarmClockMinutes ()
 AlarmClock scheduled time (minutes).
 

Countdown

void Countdown_Start ()
 Read countdown.pd and start the countdown.
 
void Countdown_Stop ()
 Stop the countdown.
 
int Countdown_IsEnabled ()
 Check if the countdown is enabled.
 
int Countdown_GetRemainingTime ()
 Get the remaining time of the countdown.
 
void Countdown_PlaySound (long tone_type)
 Play sound for the countdown.
 
int * RamIsCountdownRingUIActive ()
 Check if Ring UI for the countdown is active.
 

Accesories

void * RamAccPoint (void)
 Get a pointer to the current accessory connected to the phone.
 
int IsAnyOfAccessoriesConnected (const enum Accessory *accessory_ids, uint8_t count)
 Checks if any accessory from the list is connected.
 

Other functions

SEXIT_HOOKS * RamSExitHooks (void)
 SExit handler table (see SEXIT_HOOKS).
 
SEXIT_STATE * RamSExitState (void)
 SExit state (see SEXIT_STATE).
 
SEXIT_RECORDS * RamSExitRecords (void)
 Current SExit records (see SEXIT_RECORDS) in internal RAM.
 
void SExit (int code, const uint8_t *module, int type, int param)
 Fatal SExit ("default" exit): fills the current fatal record and jumps to the SEXIT_HOOKS fatal handler, which by default saves Exit Info and restarts the phone.
 
void ShowMainMenu ()
 Open FlexMenu.
 
void ShowNativeMenu ()
 Open NativeMenu.
 
int Devmenu_Config_IsCheckboxOff (int checkbox_id)
 Get checkbox state from the devmenu.
 
const shortcut * GetShortcutRecordByName (char *shortcut_name)
 Get shortcut by shortcut name.
 
const shortcut * GetFunctionPointer (char *shortcut_name)
 Get shortcut by shortcut name.
 
void StartNativeBrowserCore ()
 initialize Openwave browser.
 

Data Structure Documentation

◆ shortcut

struct shortcut

◆ LIGHT_PARAM

struct LIGHT_PARAM

◆ SEXIT_RECORD

struct SEXIT_RECORD

◆ SEXIT_HOOKS

struct SEXIT_HOOKS

◆ SEXIT_STATE

struct SEXIT_STATE

◆ SEXIT_RECORDS

struct SEXIT_RECORDS

◆ SEXIT_RECORD.regs

struct SEXIT_RECORD.regs

Typedef Documentation

◆ shortcut_func

typedef int(* shortcut_func) (void)

Definition at line 19 of file misc.h.

◆ shortcut

typedef struct shortcut shortcut

Definition at line 20 of file misc.h.

◆ LIGHT_PARAM

typedef struct LIGHT_PARAM LIGHT_PARAM

Definition at line 21 of file misc.h.

◆ SEXIT_RECORD

typedef struct SEXIT_RECORD SEXIT_RECORD

Definition at line 23 of file misc.h.

◆ SEXIT_HOOKS

typedef struct SEXIT_HOOKS SEXIT_HOOKS

Definition at line 24 of file misc.h.

◆ SEXIT_STATE

typedef struct SEXIT_STATE SEXIT_STATE

Definition at line 25 of file misc.h.

◆ SEXIT_RECORDS

typedef struct SEXIT_RECORDS SEXIT_RECORDS

Definition at line 26 of file misc.h.

◆ SEXIT_HANDLER

typedef void(* SEXIT_HANDLER) (SEXIT_RECORD *record)

SExit record handler.

The firmware jumps to it as a tail call: when it returns, the code that called SExit goes on.

Definition at line 168 of file misc.h.

Enumeration Type Documentation

◆ IlluminationDeviceID

Illumination device.

Enumerator
ILLUMINATION_DEV_DISPLAY 

LCD.

ILLUMINATION_DEV_KEYBOARD 

Keyboard.

ILLUMINATION_DEV_DYNLIGHT 

Dynamic Light.

ILLUMINATION_DEV_LIGHTER 

Camera flashlight as lighter.

Definition at line 32 of file misc.h.

◆ SetLightFlags

Set light flags.

Enumerator
SET_LIGHT_DISPLAY 

Trigger LCD backlight.

SET_LIGHT_KEYBOARD 

Trigger Keyboard backlight.

Definition at line 42 of file misc.h.

◆ CountdownToneType

Enumerator
COUNTDOWN_TONE_BEEP 
COUNTDOWN_TONE_ALERT 

Definition at line 78 of file misc.h.

◆ Accessory

enum Accessory

Accessories.

Enumerator
ACC_CARKIT_COMFORT 
ACC_CK_COMFORT_MK2 
ACC_CARKIT_PORTABLE 
ACC_CARKIT_EASY 
ACC_CK_LINEFIT_ATC 
ACC_CARKIT_LINEFIT 
ACC_CK_LINEFIT_MK2 
ACC_CARKIT_PROFESSIONAL 
ACC_CARKIT_VOICE 
ACC_CK_VOICE_MK2 
ACC_CAR_DATA_ADAPTOR 
ACC_DESKTOP_CHARGER 
ACC_STANDARD_CHARGER 
ACC_DATA_CABLE 
ACC_USB_DATA_CABLE 
ACC_DATA_CABLE_USB_USB 
ACC_HEADSET_MONO 
ACC_HEADSET_STEREO 
ACC_CLIP_ON_FLASH 
ACC_TTY_X55 
ACC_TTY 
ACC_JAVA_DEVICE 
ACC_EMO_DEVICE 
ACC_CLIP_IT_LED 
ACC_FM_RADIO 
ACC_MP3_PLAYER 
ACC_MOBILE_MUSIC_SET 
ACC_MUSIC_CABLE 
ACC_BOOT_BOX 
ACC_UNSUPPORTED_ACCESSORY 
ACC_UNKNOWN_ACCESSORY 

Definition at line 86 of file misc.h.

Function Documentation

◆ SwitchPhoneOff()

void SwitchPhoneOff ( )

Switchoff phone.

◆ RebootPhone()

void RebootPhone ( )

Reboot phone.

◆ SLI_SetState()

void SLI_SetState ( uint8_t state)

Set state for SLI indicator.

Parameters
statestate value 0...4
Available on platforms:
NSG, ELKA

◆ DisableIDLETMR()

void DisableIDLETMR ( void )

Disable the IDLE timer - the phone never goes to the IDLE screen.

Do not forget to call the RestartIDLETMR to restore the original timer.

◆ SetIDLETMR()

void SetIDLETMR ( int timeout,
int msg )

Set custom IDLE timer.

Parameters
timeouttime in ms
msgGBS message ID which will be sent after the timer expires Do not forget to call the RestartIDLETMR to restore the original timer.

◆ RestartIDLETMR()

void RestartIDLETMR ( void )

Restart the default idle timer.

◆ KeypressOn()

void KeypressOn ( int keycode)

Press key (simulation).

Parameters
keycodecode of the key

◆ KeypressOff()

void KeypressOff ( int keycode)

Release key (simulation).

Parameters
keycodecode of the key

◆ IsUnlocked()

int IsUnlocked ( void )

Get keyboard lock status.

Returns
0: locked, 1: unlocked

◆ RamIsLocked()

int * RamIsLocked ( void )

Get keyboard lock status.

Returns
1: locked, 0: unlocked
Deprecated
use IsUnlocked

◆ KbdLock()

void KbdLock ( void )

Lock keyboard.

◆ KbdUnlock()

void KbdUnlock ( void )

Unlock keyboard.

◆ RestartLockTimers()

void RestartLockTimers ( )

Restart screensaver and keyboard lock timers.

◆ GetIlluminationDataTable()

char * GetIlluminationDataTable ( )

Pointer to the illumination table.

Returns
pointer

◆ RamScreenBrightness()

LIGHT_PARAM * RamScreenBrightness ( void )

Pointer to the brightness settings.

Returns
pointer

◆ SetIllumination()

long SetIllumination ( uint8_t dev,
unsigned long unk,
uint16_t level,
unsigned long delay )

Change illumination level for keyboard or LCD.

Parameters
devdevice, see IlluminationDeviceID
unkset to 1
levelillumination level: 0-100
delaydelay in ms for smooth illumination change (fade-in/fade-out)
Returns
0 or error

◆ IllumTimeRequest()

void IllumTimeRequest ( int time_mode,
int counter )

Keep the backlight on.

Parameters
time_modeusually 1 or 4
counterusually 3 or 1

Always ON:

IllumTimeRequest(4, 3); // Keep
IllumTimeRelease(4, 3); // Release
void IllumTimeRequest(int time_mode, int counter)
Keep the backlight on.
void IllumTimeRelease(int time_mode, int counter)
Allow backlight to turn off again.

As in "mediaplayer" (???):

IllumTimeRequest(1, 1); // Keep
IllumTimeRelease(1, 1); // Release

◆ IllumTimeRelease()

void IllumTimeRelease ( int time_mode,
int counter )

Allow backlight to turn off again.

Parameters
time_modeexact as in IllumTimeRequest call
counterexact as in IllumTimeRequest call

◆ SetMaxIllumIntensity()

void SetMaxIllumIntensity ( int unk3,
uint32_t level )

Sets the maximum backlight brightness.

Parameters
unk3must be set to 3
levelbrightness level, from 0 (minimum) to 100 (maximum)

◆ TempLightOn()

void TempLightOn ( int flags,
int unk )

Trigger backlight (temporary set ON).

Parameters
flagsbitmask, see SetLightFlags
unkunknown, set to 0x7FFF

◆ IllumFilterSet()

void IllumFilterSet ( int flags,
int unk )

Trigger backlight (temporary set OFF).

Parameters
flagsbitmask, see SetLightFlags
unkunknown, set to 1 or 2

◆ GetVibraStatus()

int GetVibraStatus ( void )

Check if vibration enabled.

Returns
1: enabled, 0: disabled

◆ SetVibraStatus()

void SetVibraStatus ( int status)

Enable or disable vibration.

Parameters
status1: enabled, 0: disabled

◆ SetVibration()

uint32_t SetVibration ( uint32_t power)

Start vibration.

Parameters
power0-100
Returns
1: success, 0: error

◆ GetClipBoard()

WSHDR * GetClipBoard ( void )

Get clipboard content.

Returns
pointer to the current clipboard content

◆ CopyTextToClipboard()

void CopyTextToClipboard ( const WSHDR * text,
int pos,
int len )

Copy the text to the clipboard.

Parameters
texttext to be copied
poscopy from position
lenlength of the copied part

◆ ClearClipboard()

void ClearClipboard ( char unk)

Clear clipboard content.

Parameters
unkset to 0x12

◆ AlarmClockRing()

void AlarmClockRing ( void )

Run AlarmClock ringing.

Available on platforms:
X75, SG

◆ GetAlarmClockState()

int GetAlarmClockState ( int state)

Get AlarmClock state.

Parameters
stateunknown, set to 1
Returns
1 - enabled, 0 - disabled

◆ RamAlarmClockState()

char * RamAlarmClockState ( )

Pointer to the AlarmClock state.

Returns
1 - enabled, 0 - disabled
Deprecated
use GetAlarmClockState

◆ RefreshAlarmClock()

int RefreshAlarmClock ( )

Re-read changed alarmclock.pd.

Returns
0 or error

◆ RamIsAlarmClockAutorepeatOn()

char * RamIsAlarmClockAutorepeatOn ( )

Check if auto-repeat is enabled in AlarmClock.

Returns
unknown

◆ RamAlarmClockHours()

char * RamAlarmClockHours ( )

AlarmClock scheduled time (hours).

Returns
unknown

◆ RamAlarmClockMinutes()

char * RamAlarmClockMinutes ( )

AlarmClock scheduled time (minutes).

Returns
unknown

◆ Countdown_Start()

void Countdown_Start ( )

Read countdown.pd and start the countdown.

◆ Countdown_Stop()

void Countdown_Stop ( )

Stop the countdown.

◆ Countdown_IsEnabled()

int Countdown_IsEnabled ( )

Check if the countdown is enabled.

Returns
0 or 1

◆ Countdown_GetRemainingTime()

int Countdown_GetRemainingTime ( )

Get the remaining time of the countdown.

Returns
milliseconds

◆ Countdown_PlaySound()

void Countdown_PlaySound ( long tone_type)

Play sound for the countdown.

Parameters
tone_typetone id see CountdownToneType

◆ RamIsCountdownRingUIActive()

int * RamIsCountdownRingUIActive ( )

Check if Ring UI for the countdown is active.

Returns
0 or 1

◆ RamAccPoint()

void * RamAccPoint ( void )

Get a pointer to the current accessory connected to the phone.

Returns
pointer to the unknown structure

◆ IsAnyOfAccessoriesConnected()

int IsAnyOfAccessoriesConnected ( const enum Accessory * accessory_ids,
uint8_t count )

Checks if any accessory from the list is connected.

Parameters
accessory_idsArray of accessory IDs (see Accessory).
countNumber of elements in accessory_ids array.
Returns
1 if any accessory is connected, 0 otherwise.

◆ RamSExitHooks()

SEXIT_HOOKS * RamSExitHooks ( void )

SExit handler table (see SEXIT_HOOKS).

The fatal exit (SExit, also called from the CPU exception vectors) fills the current fatal record, calls *pre (if the table has it), then jumps to *fatal. The caller has run SWI 2 before: it continues in SYS mode with IRQ and FIQ disabled, the original CPSR is in record->regs.cpsr.

Returns
pointer to the table
Available on platforms:
NSG, ELKA

◆ RamSExitState()

SEXIT_STATE * RamSExitState ( void )

SExit state (see SEXIT_STATE).

A handler that lets a fatal exit go on must release its record as the firmware does for a warning: fatal_depth–, then SEXIT_RECORDS fatal = slot of the new depth (1: fatal_slot[0], 2: fatal_slot[1], else NULL).

Returns
pointer to the state
Available on platforms:
NSG, ELKA

◆ RamSExitRecords()

SEXIT_RECORDS * RamSExitRecords ( void )

Current SExit records (see SEXIT_RECORDS) in internal RAM.

Returns
pointer to the records
Available on platforms:
NSG, ELKA

◆ SExit()

void SExit ( int code,
const uint8_t * module,
int type,
int param )

Fatal SExit ("default" exit): fills the current fatal record and jumps to the SEXIT_HOOKS fatal handler, which by default saves Exit Info and restarts the phone.

The firmware always runs SWI 2 right before it (svc 2): that saves the registers, takes a record (SEXIT_STATE fatal_depth) and disables IRQ/FIQ. Without SWI 2 there is no record.

Parameters
codeexit code
modulemodule id (2 bytes, big endian) + name, the last character has bit 7 set
typerecord type, 2 for a fatal exit
paramsaved in the record
Available on platforms:
NSG, ELKA

◆ ShowMainMenu()

void ShowMainMenu ( )

Open FlexMenu.

◆ ShowNativeMenu()

void ShowNativeMenu ( )

Open NativeMenu.

◆ Devmenu_Config_IsCheckboxOff()

int Devmenu_Config_IsCheckboxOff ( int checkbox_id)

Get checkbox state from the devmenu.

Parameters
checkbox_iddevmenu checkbox ID
Returns
1 if unchecked, 0 if checked

◆ GetShortcutRecordByName()

const shortcut * GetShortcutRecordByName ( char * shortcut_name)

Get shortcut by shortcut name.

Parameters
shortcut_namename of the shortcut, for example: "ALARM_CLOCK"
Returns
function pointer
GetShortcutRecordByName("ALARM_CLOCK")->pointer();
shortcut_func pointer
Function which is called by shortcut.
Definition misc.h:53
const shortcut * GetShortcutRecordByName(char *shortcut_name)
Get shortcut by shortcut name.

◆ GetFunctionPointer()

const shortcut * GetFunctionPointer ( char * shortcut_name)

Get shortcut by shortcut name.

Parameters
shortcut_namename of the shortcut, for example: "ALARM_CLOCK"
Returns
function pointer
GetShortcutRecordByName("ALARM_CLOCK")->pointer();
Deprecated
use GetShortcutRecordByName()

◆ StartNativeBrowserCore()

void StartNativeBrowserCore ( )

initialize Openwave browser.

Useful when default browser is disabled by a patch.