Skip to content

Commit

Permalink
Middle pushbutton to power down
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastien Bourdeauducq committed May 1, 2011
1 parent 91dcf3a commit 22d1a10
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/input.c
@@ -1,6 +1,6 @@
/*
* Flickernoise
* Copyright (C) 2010 Sebastien Bourdeauducq
* Copyright (C) 2010, 2011 Sebastien Bourdeauducq
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
23 changes: 18 additions & 5 deletions src/shortcuts.c
Expand Up @@ -16,9 +16,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <mtklib.h>
#include <keycodes.h>
#include <rtems.h>
#include <stdio.h>
#include <keycodes.h>
#include <mtklib.h>

#include "input.h"
#include "shutdown.h"
Expand All @@ -27,6 +28,8 @@
#include "fb.h"

static int ctrl, alt;
static int f10_pressed;
static rtems_interval f10_press_time;

static void switch_resolution()
{
Expand All @@ -47,6 +50,11 @@ static void shortcuts_callback(mtk_event *e, int count)
{
int i;

/* Handle long press on F10/middle pushbutton */
if(f10_pressed
&& ((rtems_clock_get_ticks_since_boot() - f10_press_time) > 200))
clean_shutdown(1);

for(i=0;i<count;i++) {
if(e[i].type == EVENT_TYPE_PRESS) {
if(e[i].press.code == MTK_KEY_LEFTCTRL)
Expand All @@ -55,16 +63,21 @@ static void shortcuts_callback(mtk_event *e, int count)
alt = 1;
else if(ctrl && alt && (e[i].press.code == MTK_KEY_DELETE))
clean_shutdown(0);
else if(ctrl && (e[i].press.code == MTK_KEY_F2))
fbgrab(NULL);
else if(ctrl && (e[i].press.code == MTK_KEY_F1))
switch_resolution();
else if(ctrl && (e[i].press.code == MTK_KEY_F2))
fbgrab(NULL);
else if(e[i].press.code == MTK_KEY_F10) {
f10_pressed = 1;
f10_press_time = rtems_clock_get_ticks_since_boot();
}
} else if (e[i].type == EVENT_TYPE_RELEASE) {
if(e[i].release.code == MTK_KEY_LEFTCTRL)
ctrl = 0;
else if(e[i].release.code == MTK_KEY_LEFTALT)
alt = 0;

else if(e[i].release.code == MTK_KEY_F10)
f10_pressed = 0;
}
}
}
Expand Down

0 comments on commit 22d1a10

Please sign in to comment.