Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Middle pushbutton to power down

  • Loading branch information...
commit 22d1a10ed02872857c322cd1b42355a049820c4d 1 parent 91dcf3a
Sébastien Bourdeauducq authored May 01, 2011
2  src/input.c
... ...
@@ -1,6 +1,6 @@
1 1
 /*
2 2
  * Flickernoise
3  
- * Copyright (C) 2010 Sebastien Bourdeauducq
  3
+ * Copyright (C) 2010, 2011 Sebastien Bourdeauducq
4 4
  *
5 5
  * This program is free software: you can redistribute it and/or modify
6 6
  * it under the terms of the GNU General Public License as published by
23  src/shortcuts.c
@@ -16,9 +16,10 @@
16 16
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 17
  */
18 18
 
19  
-#include <mtklib.h>
20  
-#include <keycodes.h>
  19
+#include <rtems.h>
21 20
 #include <stdio.h>
  21
+#include <keycodes.h>
  22
+#include <mtklib.h>
22 23
 
23 24
 #include "input.h"
24 25
 #include "shutdown.h"
@@ -27,6 +28,8 @@
27 28
 #include "fb.h"
28 29
 
29 30
 static int ctrl, alt;
  31
+static int f10_pressed;
  32
+static rtems_interval f10_press_time;
30 33
 
31 34
 static void switch_resolution()
32 35
 {
@@ -47,6 +50,11 @@ static void shortcuts_callback(mtk_event *e, int count)
47 50
 {
48 51
 	int i;
49 52
 
  53
+	/* Handle long press on F10/middle pushbutton */
  54
+	if(f10_pressed 
  55
+	  && ((rtems_clock_get_ticks_since_boot() - f10_press_time) > 200))
  56
+		clean_shutdown(1);
  57
+
50 58
 	for(i=0;i<count;i++) {
51 59
 		if(e[i].type == EVENT_TYPE_PRESS) {
52 60
 			if(e[i].press.code == MTK_KEY_LEFTCTRL)
@@ -55,16 +63,21 @@ static void shortcuts_callback(mtk_event *e, int count)
55 63
 				alt = 1;
56 64
 			else if(ctrl && alt && (e[i].press.code == MTK_KEY_DELETE))
57 65
 				clean_shutdown(0);
58  
-			else if(ctrl && (e[i].press.code == MTK_KEY_F2))
59  
-				fbgrab(NULL);
60 66
 			else if(ctrl && (e[i].press.code == MTK_KEY_F1))
61 67
 				switch_resolution();
  68
+			else if(ctrl && (e[i].press.code == MTK_KEY_F2))
  69
+				fbgrab(NULL);
  70
+			else if(e[i].press.code == MTK_KEY_F10) {
  71
+				f10_pressed = 1;
  72
+				f10_press_time = rtems_clock_get_ticks_since_boot();
  73
+			}
62 74
 		} else if (e[i].type == EVENT_TYPE_RELEASE) {
63 75
 			if(e[i].release.code == MTK_KEY_LEFTCTRL)
64 76
 				ctrl = 0;
65 77
 			else if(e[i].release.code == MTK_KEY_LEFTALT)
66 78
 				alt = 0;
67  
-
  79
+			else if(e[i].release.code == MTK_KEY_F10)
  80
+				f10_pressed = 0;
68 81
 		}
69 82
 	}
70 83
 }

0 notes on commit 22d1a10

Please sign in to comment.
Something went wrong with that request. Please try again.