From 84d3619f78ee311c93c3b6e63330d60682267547 Mon Sep 17 00:00:00 2001 From: Simon Busch Date: Mon, 8 Oct 2012 18:37:46 +0200 Subject: [PATCH 1/3] touchpanel: rename emulator implementation to evdev The current emulator implementation is using the evdev input protocol which is appropiate for other devices as well so we make it unrelated to the emulator here. Differences between different target machines (and emulator) should be implemented as config options. Open-webOS-DCO-1.0-Signed-off-by: Simon Busch --- src/rockhopper/touchpanel/CMakeLists.txt | 2 +- src/rockhopper/touchpanel/{emulator => evdev}/touchpanel.c | 0 .../touchpanel/{emulator => evdev}/touchpanel_common.c | 0 .../touchpanel/{emulator => evdev}/touchpanel_common.h | 0 .../touchpanel/{emulator => evdev}/touchpanel_gestures.c | 0 .../touchpanel/{emulator => evdev}/touchpanel_gestures.h | 0 6 files changed, 1 insertion(+), 1 deletion(-) rename src/rockhopper/touchpanel/{emulator => evdev}/touchpanel.c (100%) rename src/rockhopper/touchpanel/{emulator => evdev}/touchpanel_common.c (100%) rename src/rockhopper/touchpanel/{emulator => evdev}/touchpanel_common.h (100%) rename src/rockhopper/touchpanel/{emulator => evdev}/touchpanel_gestures.c (100%) rename src/rockhopper/touchpanel/{emulator => evdev}/touchpanel_gestures.h (100%) diff --git a/src/rockhopper/touchpanel/CMakeLists.txt b/src/rockhopper/touchpanel/CMakeLists.txt index 1fb53f3..a21fe08 100644 --- a/src/rockhopper/touchpanel/CMakeLists.txt +++ b/src/rockhopper/touchpanel/CMakeLists.txt @@ -17,5 +17,5 @@ # LICENSE@@@ if(${WEBOS_TARGET_MACHINE_IMPL} STREQUAL emulator) - nyx_create_module(TouchpanelMain emulator/touchpanel_common.c emulator/touchpanel_gestures.c emulator/touchpanel.c) + nyx_create_module(TouchpanelMain evdev/touchpanel_common.c evdev/touchpanel_gestures.c evdev/touchpanel.c) endif() diff --git a/src/rockhopper/touchpanel/emulator/touchpanel.c b/src/rockhopper/touchpanel/evdev/touchpanel.c similarity index 100% rename from src/rockhopper/touchpanel/emulator/touchpanel.c rename to src/rockhopper/touchpanel/evdev/touchpanel.c diff --git a/src/rockhopper/touchpanel/emulator/touchpanel_common.c b/src/rockhopper/touchpanel/evdev/touchpanel_common.c similarity index 100% rename from src/rockhopper/touchpanel/emulator/touchpanel_common.c rename to src/rockhopper/touchpanel/evdev/touchpanel_common.c diff --git a/src/rockhopper/touchpanel/emulator/touchpanel_common.h b/src/rockhopper/touchpanel/evdev/touchpanel_common.h similarity index 100% rename from src/rockhopper/touchpanel/emulator/touchpanel_common.h rename to src/rockhopper/touchpanel/evdev/touchpanel_common.h diff --git a/src/rockhopper/touchpanel/emulator/touchpanel_gestures.c b/src/rockhopper/touchpanel/evdev/touchpanel_gestures.c similarity index 100% rename from src/rockhopper/touchpanel/emulator/touchpanel_gestures.c rename to src/rockhopper/touchpanel/evdev/touchpanel_gestures.c diff --git a/src/rockhopper/touchpanel/emulator/touchpanel_gestures.h b/src/rockhopper/touchpanel/evdev/touchpanel_gestures.h similarity index 100% rename from src/rockhopper/touchpanel/emulator/touchpanel_gestures.h rename to src/rockhopper/touchpanel/evdev/touchpanel_gestures.h From e26cc846364ca4eba8a0add7be13d3035b759915 Mon Sep 17 00:00:00 2001 From: Simon Busch Date: Tue, 9 Oct 2012 06:42:25 +0200 Subject: [PATCH 2/3] touchpanel: evdev: read screen size from framebuffer when possible * read screen size when not defined by machine config from framebuffer * define static screen size for qemuarm and qemux86 machines Open-webOS-DCO-1.0-Signed-off-by: Simon Busch --- src/machine/qemuarm.cmake | 3 +- src/machine/qemux86.cmake | 2 ++ src/rockhopper/touchpanel/evdev/touchpanel.c | 30 ++++++++++++++++---- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/machine/qemuarm.cmake b/src/machine/qemuarm.cmake index 8119811..1649ece 100644 --- a/src/machine/qemuarm.cmake +++ b/src/machine/qemuarm.cmake @@ -24,4 +24,5 @@ set(MODULE_KEYS_WEBOS_LINUX YES) set(MODULE_TOUCHPANEL_WEBOS_LINUX YES) add_definitions(-DKEYPAD_INPUT_DEVICE=\"/dev/input/event0\") - +add_definitions(-DSCREEN_HORIZONTAL_RES=1024) +add_definitions(-DSCREEN_VERTICAL_RES=768) diff --git a/src/machine/qemux86.cmake b/src/machine/qemux86.cmake index 769d39f..ef0b659 100644 --- a/src/machine/qemux86.cmake +++ b/src/machine/qemux86.cmake @@ -24,3 +24,5 @@ set(MODULE_KEYS_WEBOS_LINUX YES) set(MODULE_TOUCHPANEL_WEBOS_LINUX YES) add_definitions(-DKEYPAD_INPUT_DEVICE=\"/dev/input/event1\") +add_definitions(-DSCREEN_HORIZONTAL_RES=1024) +add_definitions(-DSCREEN_VERTICAL_RES=768) diff --git a/src/rockhopper/touchpanel/evdev/touchpanel.c b/src/rockhopper/touchpanel/evdev/touchpanel.c index 3460468..3ceff9b 100644 --- a/src/rockhopper/touchpanel/evdev/touchpanel.c +++ b/src/rockhopper/touchpanel/evdev/touchpanel.c @@ -166,17 +166,16 @@ static general_settings_t sGeneralSettings = static float scaleX, scaleY; -/* Using hardcoded values for now ,since ioctl FBIOGET_VSCREENINFO - on /dev/fb0 is returning invalid values in qemux86 */ - -#define SCREEN_HORIZONTAL_RES 1024 -#define SCREEN_VERTICAL_RES 768 - static int init_touchpanel(void) { struct input_absinfo abs; int maxX, maxY, ret = -1; +#if !defined(SCREEN_HORIZONTAL_RES) && !defined(SCREEN_VERTICAL_RES) + struct fb_var_screeninfo scr_info; + int16_t fd; +#endif + touchpanel_event_fd = open("/dev/input/touchscreen0", O_RDWR); if(touchpanel_event_fd < 0) { @@ -200,8 +199,27 @@ init_touchpanel(void) init_gesture_state_machine(&sGeneralSettings, 1); +#if !defined(SCREEN_HORIZONTAL_RES) && !defined(SCREEN_VERTICAL_RES) + fd = open("/dev/fb0", O_RDWR); + if (fd < 0) { + return NYX_ERROR_INVALID_FILE_ACCESS; + } + + memset(&scr_info,0,sizeof(struct fb_var_screeninfo)); + + if (ioctl(fd, FBIOGET_VSCREENINFO, &scr_info) != 0) { + ret = NYX_ERROR_INVALID_OPERATION; + goto error; + } + + close(fd); + + scaleX = (float)scr_info.xres / (float)maxX; + scaleY = (float)scr_info.yres / (float)maxY; +#else scaleX = (float)SCREEN_HORIZONTAL_RES / (float)maxX; scaleY = (float)SCREEN_VERTICAL_RES / (float)maxY; +#endif return 0; error: From c5e16d09c23a007298d1a4aea5ed4999608bba4d Mon Sep 17 00:00:00 2001 From: Simon Busch Date: Tue, 9 Oct 2012 08:02:03 +0200 Subject: [PATCH 3/3] touchpanel: build evdev implementation for WEBOS_TARGET_MACHINE_IMPL device The evdev implementation should be suitable for most devices until we have a real multi touch implementation for the MT protocol. Open-webOS-DCO-1.0-Signed-off-by: Simon Busch --- src/rockhopper/touchpanel/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/rockhopper/touchpanel/CMakeLists.txt b/src/rockhopper/touchpanel/CMakeLists.txt index a21fe08..bf0713b 100644 --- a/src/rockhopper/touchpanel/CMakeLists.txt +++ b/src/rockhopper/touchpanel/CMakeLists.txt @@ -16,6 +16,7 @@ # # LICENSE@@@ -if(${WEBOS_TARGET_MACHINE_IMPL} STREQUAL emulator) + +if(${WEBOS_TARGET_MACHINE_IMPL} STREQUAL emulator OR ${WEBOS_TARGET_MACHINE_IMPL} STREQUAL device) nyx_create_module(TouchpanelMain evdev/touchpanel_common.c evdev/touchpanel_gestures.c evdev/touchpanel.c) endif()