Last active
December 21, 2015 19:19
-
-
Save pamaury/6353512 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/apps/action.c b/apps/action.c | |
index 2492a7d..f71b03d 100644 | |
--- a/apps/action.c | |
+++ b/apps/action.c | |
@@ -294,6 +294,10 @@ static int get_action_worker(int context, int timeout, | |
{ | |
last_button = BUTTON_NONE; | |
keys_locked = false; | |
+#if defined(HAVE_TOUCHPAD) || defined(HAVE_TOUCHSCREEN) | |
+ /* enable back touch device */ | |
+ button_enable_touch(true); | |
+#endif | |
splash(HZ/2, str(LANG_KEYLOCK_OFF)); | |
return ACTION_REDRAW; | |
} | |
@@ -373,7 +377,10 @@ static int get_action_worker(int context, int timeout, | |
unlock_combo = button; | |
keys_locked = true; | |
splash(HZ/2, str(LANG_KEYLOCK_ON)); | |
- | |
+ #if defined(HAVE_TOUCHPAD) || defined(HAVE_TOUCHSCREEN) | |
+ /* disable touch device on keylock */ | |
+ button_enable_touch(false); | |
+ #endif | |
button_clear_queue(); | |
return ACTION_REDRAW; | |
} | |
diff --git a/firmware/SOURCES b/firmware/SOURCES | |
index 5f1ae3d..52c3876 100644 | |
--- a/firmware/SOURCES | |
+++ b/firmware/SOURCES | |
@@ -1734,3 +1734,7 @@ thread.c | |
#endif | |
#endif /* defined(SIMULATOR) */ | |
+ | |
+#if defined(HAVE_TOUCHPAD) | |
+drivers/touchpad.c | |
+#endif | |
\ No newline at end of file | |
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c | |
index c165e8f..298bb5d 100644 | |
--- a/firmware/drivers/button.c | |
+++ b/firmware/drivers/button.c | |
@@ -672,3 +672,15 @@ int button_apply_acceleration(const unsigned int data) | |
return delta; | |
} | |
#endif /* HAVE_WHEEL_ACCELERATION */ | |
+ | |
+#if (defined(HAVE_TOUCHPAD) || defined(HAVE_TOUCHSCREEN)) && !defined(HAS_BUTTON_HOLD) | |
+void button_enable_touch(bool en) | |
+{ | |
+#ifdef HAVE_TOUCHPAD | |
+ touchpad_enable(en); | |
+#endif | |
+#ifdef HAVE_TOUCHSCREEN | |
+ touchscreen_enable(en); | |
+#endif | |
+} | |
+#endif | |
\ No newline at end of file | |
diff --git a/firmware/drivers/touchscreen.c b/firmware/drivers/touchscreen.c | |
index 823c2e7..ad085a4 100644 | |
--- a/firmware/drivers/touchscreen.c | |
+++ b/firmware/drivers/touchscreen.c | |
@@ -31,6 +31,7 @@ | |
#define BUTTON_MARGIN_X (int)(LCD_WIDTH * 0.03) | |
#define BUTTON_MARGIN_Y (int)(LCD_HEIGHT * 0.03) | |
+static bool touch_enabled = true; | |
static enum touchscreen_mode current_mode = TOUCHSCREEN_POINT; | |
static const int touchscreen_buttons[3][3] = | |
{ | |
@@ -121,6 +122,8 @@ static void map_pixels(int *x, int *y) | |
/* TODO: add jitter (and others) filter */ | |
int touchscreen_to_pixels(int x, int y, int *data) | |
{ | |
+ if(!touch_enabled) | |
+ return 0; | |
x &= 0xFFFF; | |
y &= 0xFFFF; | |
@@ -169,6 +172,18 @@ enum touchscreen_mode touchscreen_get_mode(void) | |
return current_mode; | |
} | |
+void touchscreen_enable(bool en) | |
+{ | |
+ touch_enabled = en; | |
+#ifndef SIMULATOR | |
+ touchscreen_enable_device(en); | |
+#endif | |
+} | |
+ | |
+bool touchscreen_is_enabled(void) | |
+{ | |
+ return touch_enabled; | |
+} | |
#if ((CONFIG_PLATFORM & PLATFORM_ANDROID) == 0) | |
/* android has an API for this */ | |
diff --git a/firmware/export/button.h b/firmware/export/button.h | |
index 6276a03..7109c00 100644 | |
--- a/firmware/export/button.h | |
+++ b/firmware/export/button.h | |
@@ -119,4 +119,12 @@ int touchscreen_last_touch(void); | |
#include "touchscreen.h" | |
#endif | |
+#ifdef HAVE_TOUCHPAD | |
+#include "touchpad.h" | |
+#endif | |
+ | |
+#if (defined(HAVE_TOUCHPAD) || defined(HAVE_TOUCHSCREEN)) && !defined(HAS_BUTTON_HOLD) | |
+void button_enable_touch(bool en); | |
+#endif | |
+ | |
#endif /* _BUTTON_H_ */ | |
diff --git a/firmware/export/touchscreen.h b/firmware/export/touchscreen.h | |
index a27e60c..7421fe0 100644 | |
--- a/firmware/export/touchscreen.h | |
+++ b/firmware/export/touchscreen.h | |
@@ -51,5 +51,8 @@ enum touchscreen_mode touchscreen_get_mode(void); | |
void touchscreen_disable_mapping(void); | |
void touchscreen_reset_mapping(void); | |
int touchscreen_get_scroll_threshold(void); | |
+void touchscreen_enable(bool en); | |
+void touchscreen_enable_device(bool en); | |
+bool touchscreen_is_enabled(void); | |
#endif /* __TOUCHSCREEN_INCLUDE_H_ */ | |
diff --git a/firmware/target/arm/imx233/creative-zenxfi2/button-zenxfi2.c b/firmware/target/arm/imx233/creative-zenxfi2/button-zenxfi2.c | |
index 74b8d64..4f2a277 100644 | |
--- a/firmware/target/arm/imx233/creative-zenxfi2/button-zenxfi2.c | |
+++ b/firmware/target/arm/imx233/creative-zenxfi2/button-zenxfi2.c | |
@@ -66,7 +66,7 @@ void button_init_device(void) | |
bottomright.px_x = LCD_WIDTH; | |
bottomright.px_y = LCD_HEIGHT; | |
- | |
+ | |
imx233_touchscreen_init(); | |
imx233_touchscreen_enable(true); | |
@@ -104,6 +104,11 @@ static int touch_to_pixels(int *val_x, int *val_y) | |
return (x<<16)|y; | |
} | |
+void touchscreen_enable_device(bool en) | |
+{ | |
+ imx233_touchscreen_enable(en); | |
+} | |
+ | |
static int touchscreen_read_device(int *data) | |
{ | |
int x, y; | |
diff --git a/firmware/target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c b/firmware/target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c | |
index afabdd3..05c4da8 100644 | |
--- a/firmware/target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c | |
+++ b/firmware/target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c | |
@@ -28,6 +28,7 @@ | |
#include "string.h" | |
#include "usb.h" | |
#include "power-imx233.h" | |
+#include "touchpad.h" | |
#ifndef BOOTLOADER | |
@@ -274,7 +275,7 @@ static void do_interrupt(void) | |
imx233_pinctrl_setup_irq(0, 27, true, true, false, &rmi_attn_cb, 0); | |
} | |
-void touchdev_enable(bool en) | |
+void touchpad_enable_device(bool en) | |
{ | |
t_enable = en; | |
queue_post(&rmi_queue, RMI_SET_SLEEP_MODE, en ? RMI_SLEEP_MODE_LOW_POWER : RMI_SLEEP_MODE_SENSOR_SLEEP); | |
@@ -433,5 +434,5 @@ int button_read_device(void) | |
default: | |
break; | |
} | |
- return res | touchpad_read_device(); | |
+ return res | touchpad_filter(touchpad_read_device()); | |
} | |
diff --git a/firmware/target/arm/imx233/sansa-fuzeplus/button-target.h b/firmware/target/arm/imx233/sansa-fuzeplus/button-target.h | |
index 1c94b76..ce5ffe4 100644 | |
--- a/firmware/target/arm/imx233/sansa-fuzeplus/button-target.h | |
+++ b/firmware/target/arm/imx233/sansa-fuzeplus/button-target.h | |
@@ -24,7 +24,7 @@ | |
#include <stdbool.h> | |
bool button_debug_screen(void); | |
void touchpad_set_sensitivity(int level); | |
-void touchdev_enable(bool en); | |
+void touchpad_enable_device(bool en); | |
/* Main unit's buttons */ | |
#define BUTTON_POWER 0x00000001 | |
@@ -47,6 +47,10 @@ void touchdev_enable(bool en); | |
BUTTON_PLAYPAUSE|BUTTON_BACK| \ | |
BUTTON_BOTTOMRIGHT|BUTTON_BOTTOMLEFT) | |
+#define BUTTON_TOUCHPAD (BUTTON_LEFT|BUTTON_UP|BUTTON_RIGHT|BUTTON_DOWN| \ | |
+ BUTTON_SELECT|BUTTON_PLAYPAUSE|BUTTON_BACK| \ | |
+ BUTTON_BOTTOMRIGHT|BUTTON_BOTTOMLEFT) | |
+ | |
/* Software power-off */ | |
#define POWEROFF_BUTTON BUTTON_POWER | |
#define POWEROFF_COUNT 10 | |
diff --git a/firmware/target/hosted/android/button-android.c b/firmware/target/hosted/android/button-android.c | |
index ee8b32d..b4f3d1b 100644 | |
--- a/firmware/target/hosted/android/button-android.c | |
+++ b/firmware/target/hosted/android/button-android.c | |
@@ -129,6 +129,11 @@ void button_init_device(void) | |
set_rockbox_ready(); | |
} | |
+void touchscreen_enable_device(bool en) | |
+{ | |
+ (void)en; /* FIXME: do something smart */ | |
+} | |
+ | |
int button_read_device(int *data) | |
{ | |
int btn = last_btns; | |
diff --git a/firmware/target/hosted/sdl/button-sdl.c b/firmware/target/hosted/sdl/button-sdl.c | |
index 4bd4b8d..f69c0a5 100644 | |
--- a/firmware/target/hosted/sdl/button-sdl.c | |
+++ b/firmware/target/hosted/sdl/button-sdl.c | |
@@ -393,10 +393,14 @@ static void button_event(int key, bool pressed) | |
#endif | |
default: | |
#ifdef HAVE_TOUCHSCREEN | |
- new_btn = key_to_touch(key, mouse_coords); | |
+ if(touchscreen_is_enabled()) | |
+ new_btn = key_to_touch(key, mouse_coords); | |
if (!new_btn) | |
#endif | |
new_btn = key_to_button(key); | |
+#ifdef HAVE_TOUCHPAD | |
+ new_btn = touchpad_filter(new_btn); | |
+#endif | |
break; | |
} | |
/* Call to make up for scrollwheel target implementation. This is |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment