Skip to content

Commit

Permalink
Add enable vibration toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
myfluxi committed Mar 16, 2012
1 parent bcc41dd commit 261622a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
18 changes: 16 additions & 2 deletions extendedcommands.c
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,14 @@ void wipe_battery_stats()
ui_print("Battery Stats wiped.\n");
}

int vibration_enabled = 1;

void toggle_vibration()
{
vibration_enabled = !vibration_enabled;
ui_print("Vibrate on touch: %s\n", vibration_enabled ? "Enabled" : "Disabled");
}

void show_advanced_menu()
{
static char* headers[] = { "Advanced Menu",
Expand All @@ -922,6 +930,7 @@ void show_advanced_menu()
"Wipe Dalvik Cache",
"Wipe Battery Stats",
"Wipe /etc/init.d",
"Toggle Vibration",
"Fix Permissions",
"Show Log",
NULL
Expand Down Expand Up @@ -984,7 +993,12 @@ void show_advanced_menu()
}
break;
}
case 6:
case 6:
{
toggle_vibration();
break;
}
case 7:
{
ensure_path_mounted("/system");
ensure_path_mounted("/data");
Expand All @@ -993,7 +1007,7 @@ void show_advanced_menu()
ui_print("Done!\n");
break;
}
case 7:
case 8:
{
ui_printlogtail(12);
break;
Expand Down
3 changes: 3 additions & 0 deletions recovery_ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,7 @@ get_menu_selection(char** headers, char** items, int menu_only, int initial_sele
void
set_sdcard_update_bootloader_message();

// Vibration toggle
extern int vibration_enabled;

#endif
8 changes: 6 additions & 2 deletions ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,9 @@ static int input_callback(int fd, short revents, void *data)
// they lifted above the touch panel region
// touch to select
if ((diff_x == TOUCH_VALUE) && (diff_y == TOUCH_VALUE)) {
vibrate(VIBRATOR_TIME_MS);
if (vibration_enabled) {
vibrate(VIBRATOR_TIME_MS);
}
ev.code = KEY_POWER;
reset_gestures();
}
Expand All @@ -516,7 +518,9 @@ static int input_callback(int fd, short revents, void *data)
ev.code = KEY_POWER;
reset_gestures();
}
vibrate(VIBRATOR_TIME_MS);
if (vibration_enabled) {
vibrate(VIBRATOR_TIME_MS);
}
}

if (slide_right == 1) {
Expand Down

0 comments on commit 261622a

Please sign in to comment.