diff --git a/CMakeLists.txt b/CMakeLists.txt index fe33ac2974..60e71b0ec2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -125,6 +125,19 @@ else() unset(ANDROID_NDK CACHE) endif() +# Tizen options +if(SFML_OS_TIZEN) + # split device type and version (mobile-x.y.z) and retrieve device type + string(REPLACE "-" ";" DEVICE_LIST ${TIZEN_DEVICE}) + list(GET DEVICE_LIST 0 DEVICE_TYPE) + + # we install libs in a subdirectories named after the device type and architecture (lib/mobile/emulator/*.so) + set(LIB_SUFFIX "/${DEVICE_TYPE}/${TIZEN_TARGET}") + + # install everything in $TIZEN_STUDIO/library + set(CMAKE_INSTALL_PREFIX ${TIZEN_STUDIO}/library/sfml) +endif() + # define SFML_STATIC if the build type is not set to 'shared' if(NOT BUILD_SHARED_LIBS) add_definitions(-DSFML_STATIC) @@ -197,7 +210,7 @@ if(SFML_OS_MACOSX) message(FATAL_ERROR "Only 64-bit architecture is supported") return() endif() - + # configure Xcode templates set(XCODE_TEMPLATES_ARCH "\$(NATIVE_ARCH_ACTUAL)") endif() diff --git a/cmake/Config.cmake b/cmake/Config.cmake index cff54d0028..12076bfc32 100644 --- a/cmake/Config.cmake +++ b/cmake/Config.cmake @@ -22,6 +22,13 @@ elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") set(SFML_OS_ANDROID 1) # use the OpenGL ES implementation on Android set(OPENGL_ES 1) + elseif(TIZEN) + set(SFML_OS_TIZEN 1) + # use the OpenGL ES implementation on Tizen + set(OPENGL_ES 1) + + # define macro to identify the OS (has to be client side) + add_definitions(-D__TIZEN__) else() set(SFML_OS_LINUX 1) # don't use the OpenGL ES implementation on Linux @@ -114,7 +121,7 @@ else() endif() # define the install directory for miscellaneous files -if(SFML_OS_WINDOWS OR SFML_OS_IOS) +if(SFML_OS_WINDOWS OR SFML_OS_IOS OR SFML_OS_TIZEN) set(INSTALL_MISC_DIR .) elseif(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_MACOSX) set(INSTALL_MISC_DIR share/SFML) diff --git a/cmake/toolchains/tizen.toolchain.cmake b/cmake/toolchains/tizen.toolchain.cmake new file mode 100755 index 0000000000..60c6a098e5 --- /dev/null +++ b/cmake/toolchains/tizen.toolchain.cmake @@ -0,0 +1,265 @@ +# ------------------------------------------------------------------------------ +# Tizen CMake toolchain file, for use with Tizen Studio. +# Requires cmake 3.5.1 or newer. +# +# Written by Jonathan De Wachter (dewachter.jonathan@gmail.com). +# +# This toolchain was initially written to compile the SFML project but +# it's generic enough to be reused in other project. It supports every possible +# configuration +# +# This toolchain doesn't support "release minsize" and "release with debug +# info" build as well as the creation of module or executable. Only static and +# shared build in either release or debug mode are allowed. +# +# Usage Linux & Mac: +# $ export TIZEN_STUDIO=/opt/tizen-studio +# $ cmake -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchains/tizen.toolchain.cmake +# $ make +# +# Usage Windows: +# > set PATH=%PATH%;C:\TizenStudio +# > cmake -G "MinGW Makefiles" -DCMAKE_TOOLCHAIN_FILE="../cmake/toolchains/tizen.toolchain.cmake" +# > make +# +# Options (can be set as cmake parameters: -D=): +# +# * TIZEN_DEVICE="mobile-2.4" - Specifies the device type and version +# +# Can be set to target either a mobile or wearable of different +# versions. +# +# Possible devices are: +# mobile-2.4 (default) +# mobile-2.3.1 +# mobile-2.3 +# wearable-2.3.2 +# wearable-2.3.1 +# wearable-2.3 +# +# * TIZEN_TARGET="device" - Specifies the device architecture +# +# Can be set to build for either an existing device (arm) or an +# emulator (x86) +# +# Possible architectures are: +# x86 +# arm (default) +# +# * TIZEN_COMPILER="llvm-3.6" - Specifies the compiler (and its version) to use +# +# Can be set to use either Clang (llvm) or GNU GCC (gcc). +# +# Possible compilers are: +# llvm-3.6 (default) +# llvm-3.4 +# gcc-4.6 +# gcc-4.9 + +# NOTE: this script isn't finished yet! +cmake_minimum_required(VERSION 3.5.1) + +# retrieve environment info +set(TIZEN_STUDIO "$ENV{TIZEN_STUDIO}") +message(STATUS ${TIZEN_STUDIO}) +# todo: fail early if tizen studio env var is not set (or assume /opt ?) +# todo: add CMAke option to set TIZEN_STUDIO ? + +# set default options value +if(NOT DEFINED TIZEN_DEVICE) + set(TIZEN_DEVICE "mobile-2.4") +endif() +if(NOT DEFINED TIZEN_TARGET) + set(TIZEN_TARGET "device") +endif() +if(NOT DEFINED TIZEN_COMPILER) + set(TIZEN_COMPILER "llvm-3.6") +endif() + +# todo": check for unsupported values ? (this script will fail if not set +# properly + +# compute DEVICE_TYPE (mobile or wearable) and DEVICE_VERSION (2.3, +# 2.3.1, 2.4) from TIZEN_DEVICE variable +string(REPLACE "-" ";" DEVICE_LIST ${TIZEN_DEVICE}) +list(GET DEVICE_LIST 0 DEVICE_TYPE) +list(GET DEVICE_LIST 1 DEVICE_VERSION) + +# compute another useful variable +if (TIZEN_TARGET MATCHES device) + set(SYSTEM_PROCESSOR "armel") + set(TIZEN_ARCHITECTURE "arm") +elseif (TIZEN_TARGET MATCHES emulator) + set(SYSTEM_PROCESSOR "i386") + set(TIZEN_ARCHITECTURE "i386") +endif() + +# set mandatory CMAKE_SYSTEM_NAME and CMAKE_SYSTEM_PROCESSOR variables +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR ${SYSTEM_PROCESSOR}) + +# compute TIZEN_ROOTSTRAP path from variable +set(TIZEN_ROOTSTRAP "${TIZEN_STUDIO}/platforms/tizen-${DEVICE_VERSION}/${DEVICE_TYPE}/rootstraps/${TIZEN_DEVICE}-${TIZEN_TARGET}.core") + +# setup compilers +if (TIZEN_COMPILER MATCHES llvm-*) + + #include(CMakeForceCompiler) + #cmake_force_c_compiler("${TIZEN_STUDIO}/tools/${TIZEN_COMPILER}/bin/clang"LLVM) + #cmake_force_cxx_compiler("${TIZEN_STUDIO}/tools/${TIZEN_COMPILER}/bin/clang++" LLVM) + + set(CMAKE_C_COMPILER "${TIZEN_STUDIO}/tools/${TIZEN_COMPILER}/bin/clang") + set(CMAKE_CXX_COMPILER "${TIZEN_STUDIO}/tools/${TIZEN_COMPILER}/bin/clang++") + + ## With CLang compiler, it needs this set of flags + #-target i386-tizen-linux-gnueabi + #-gcc-toolchain /opt/tizen-studio/tools/i386-linux-gnueabi-gcc-4.9/ + #-ccc-gcc-name i386-linux-gnueabi-g++ + #-march=i386 + + if (TIZEN_COMPILER MATCHES "llvm-3.4") + set(GCC_TOOLCHAIN "gcc-4.6") + elseif (TIZEN_COMPILER MATCHES "llvm-3.6") + set(GCC_TOOLCHAIN "gcc-4.9") + endif() + + set(TIZEN_FLAGS "${TIZEN_FLAGS} -target ${TIZEN_ARCHITECTURE}-tizen-linux-gnueabi") + set(TIZEN_FLAGS "${TIZEN_FLAGS} -gcc-toolchain ${TIZEN_STUDIO}/tools/${TIZEN_ARCHITECTURE}-linux-gnueabi-${GCC_TOOLCHAIN}") + set(TIZEN_FLAGS "${TIZEN_FLAGS} -ccc-gcc-name ${TIZEN_ARCHITECTURE}-linux-gnueabi-g++") + + if (TIZEN_TARGET MATCHES device) + set(TIZEN_FLAGS "${TIZEN_FLAGS} -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mtune=cortex-a8") + elseif (TIZEN_TARGET MATCHES emulator) + set(TIZEN_FLAGS "${TIZEN_FLAGS} -march=i386") + endif() + + set(TIZEN_FLAGS "${TIZEN_FLAGS} --sysroot=${TIZEN_ROOTSTRAP}") + + message(STATUS ${TIZEN_FLAGS}) + +elseif(TIZEN_COMPILER MATCHES gcc-*) + # /opt/tizen-studio/tools/arm-linux-gnueabi-gcc-4.6/bin/arm-linux-gnueabi-g++ + # /opt/tizen-studio/tools/i386-linux-gnueabi-gcc-4.9/bin/i386-linux-gnueabi-gcc + + set(CMAKE_C_COMPILER "${TIZEN_STUDIO}/tools/${TIZEN_ARCHITECTURE}-linux-gnueabi-${TIZEN_COMPILER}/bin/${TIZEN_ARCHITECTURE}-linux-gnueabi-gcc") + set(CMAKE_CXX_COMPILER "${TIZEN_STUDIO}/tools/${TIZEN_ARCHITECTURE}-linux-gnueabi-${TIZEN_COMPILER}/bin/${TIZEN_ARCHITECTURE}-linux-gnueabi-g++") + set(CMAKE_SYSROOT ${TIZEN_ROOTSTRAP}) +endif() + +# global flags for cmake client scripts to change behavior +set(TIZEN 1) + +set(TEST_FLAGS "-I ${TIZEN_ROOTSTRAP}/usr/include -I ${TIZEN_ROOTSTRAP}/usr/include/elementary-1 -I ${TIZEN_ROOTSTRAP}/usr/include/efls-1") + +#list(APPEND TIZEN_LIBRARIES "include") +list(APPEND TIZEN_LIBRARIES "appcore-agent") +list(APPEND TIZEN_LIBRARIES "appfw") +list(APPEND TIZEN_LIBRARIES "attach-panel") +list(APPEND TIZEN_LIBRARIES "badge ") +list(APPEND TIZEN_LIBRARIES "base") +list(APPEND TIZEN_LIBRARIES "cairo") +list(APPEND TIZEN_LIBRARIES "calendar-service2") +list(APPEND TIZEN_LIBRARIES "ckm") +list(APPEND TIZEN_LIBRARIES "contacts-svc") +list(APPEND TIZEN_LIBRARIES "content") +list(APPEND TIZEN_LIBRARIES "context-service") +list(APPEND TIZEN_LIBRARIES "dali") +list(APPEND TIZEN_LIBRARIES "dali-toolkit") +list(APPEND TIZEN_LIBRARIES "dbus-1.0") +list(APPEND TIZEN_LIBRARIES "dbus-1.0/include") +list(APPEND TIZEN_LIBRARIES "device") +list(APPEND TIZEN_LIBRARIES "dlog") +list(APPEND TIZEN_LIBRARIES "ecore-1") +list(APPEND TIZEN_LIBRARIES "ecore-buffer-1") +list(APPEND TIZEN_LIBRARIES "ecore-con-1") +list(APPEND TIZEN_LIBRARIES "ecore-evas-1") +list(APPEND TIZEN_LIBRARIES "ecore-file-1") +list(APPEND TIZEN_LIBRARIES "ecore-imf-1") +list(APPEND TIZEN_LIBRARIES "ecore-imf-evas-1") +list(APPEND TIZEN_LIBRARIES "ecore-input-1") +list(APPEND TIZEN_LIBRARIES "ecore-input-evas-1") +list(APPEND TIZEN_LIBRARIES "ecore-ipc-1") +list(APPEND TIZEN_LIBRARIES "ecore-x-1") +list(APPEND TIZEN_LIBRARIES "e_dbus-1") +list(APPEND TIZEN_LIBRARIES "edje-1") +list(APPEND TIZEN_LIBRARIES "eet-1") +list(APPEND TIZEN_LIBRARIES "efl-1") +list(APPEND TIZEN_LIBRARIES "efl-extension") +list(APPEND TIZEN_LIBRARIES "efreet-1") +list(APPEND TIZEN_LIBRARIES "eina-1") +list(APPEND TIZEN_LIBRARIES "eina-1/eina") +list(APPEND TIZEN_LIBRARIES "eio-1") +list(APPEND TIZEN_LIBRARIES "eldbus-1") +list(APPEND TIZEN_LIBRARIES "elementary-1") +list(APPEND TIZEN_LIBRARIES "embryo-1") +list(APPEND TIZEN_LIBRARIES "eo-1") +list(APPEND TIZEN_LIBRARIES "eom") +list(APPEND TIZEN_LIBRARIES "ethumb-1") +list(APPEND TIZEN_LIBRARIES "ethumb-client-1") +list(APPEND TIZEN_LIBRARIES "evas-1") +list(APPEND TIZEN_LIBRARIES "ewebkit2-0") +list(APPEND TIZEN_LIBRARIES "feedback") +list(APPEND TIZEN_LIBRARIES "fontconfig") +list(APPEND TIZEN_LIBRARIES "freetype2") +list(APPEND TIZEN_LIBRARIES "geofence") +list(APPEND TIZEN_LIBRARIES "gio-unix-2.0") +list(APPEND TIZEN_LIBRARIES "glib-2.0") +list(APPEND TIZEN_LIBRARIES "harfbuzz") +list(APPEND TIZEN_LIBRARIES "json-glib-1.0") +list(APPEND TIZEN_LIBRARIES "libxml2") +list(APPEND TIZEN_LIBRARIES "location") +list(APPEND TIZEN_LIBRARIES "maps") +list(APPEND TIZEN_LIBRARIES "media") +list(APPEND TIZEN_LIBRARIES "media-content") +list(APPEND TIZEN_LIBRARIES "messaging") +list(APPEND TIZEN_LIBRARIES "metadata-editor") +list(APPEND TIZEN_LIBRARIES "minicontrol") +list(APPEND TIZEN_LIBRARIES "minizip") +list(APPEND TIZEN_LIBRARIES "network") +list(APPEND TIZEN_LIBRARIES "notification") +list(APPEND TIZEN_LIBRARIES "phonenumber-utils") +list(APPEND TIZEN_LIBRARIES "sensor") +list(APPEND TIZEN_LIBRARIES "shortcut") +list(APPEND TIZEN_LIBRARIES "storage") +list(APPEND TIZEN_LIBRARIES "system") +list(APPEND TIZEN_LIBRARIES "telephony") +list(APPEND TIZEN_LIBRARIES "ui") +list(APPEND TIZEN_LIBRARIES "web") +list(APPEND TIZEN_LIBRARIES "widget_service") +list(APPEND TIZEN_LIBRARIES "widget_viewer_evas") +list(APPEND TIZEN_LIBRARIES "wifi-direct") +list(APPEND TIZEN_LIBRARIES "library") + +foreach(LIBRARY ${TIZEN_LIBRARIES}) + set(TEST_FLAGS "${TEST_FLAGS} -I ${TIZEN_ROOTSTRAP}/usr/include/${LIBRARY}") +endforeach() + +set(TEST_FLAGS "${TEST_FLAGS} -I ${TIZEN_ROOTSTRAP}/usr/lib/dbus-1.0/include") + +# rpath makes low sense on Tizen +set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "") +set(CMAKE_SKIP_RPATH TRUE CACHE BOOL "If set, runtime paths are not added when using shared libraries.") + +# finalize flags +set(CMAKE_C_FLAGS "${TIZEN_FLAGS} ${TEST_FLAGS}" CACHE STRING "c flags") +set(CMAKE_CXX_FLAGS "${TIZEN_FLAGS} ${TEST_FLAGS} -Wall" CACHE STRING "c++ flags") +set(CMAKE_LINKER_FLAGS "${TIZEN_FLAGS} -lpthread" CACHE STRING "linker flags") + +# search for headers and libraries in Tizen Studio environment only +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +# append +set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${TIZEN_ROOTSTRAP}/usr/lib") +set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${TIZEN_ROOTSTRAP}/usr/include") + +# macro to find packages on the host operating systsem +macro(find_host_package) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER) + + find_package(${ARGN}) + + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +endmacro() diff --git a/examples/tizen-mobile/.cproject b/examples/tizen-mobile/.cproject new file mode 100644 index 0000000000..a41012eeec --- /dev/null +++ b/examples/tizen-mobile/.cproject @@ -0,0 +1,857 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/tizen-mobile/.exportMap b/examples/tizen-mobile/.exportMap new file mode 100644 index 0000000000..43e310e053 --- /dev/null +++ b/examples/tizen-mobile/.exportMap @@ -0,0 +1,4 @@ +{ + global: main; + local: *; +}; diff --git a/examples/tizen-mobile/.project b/examples/tizen-mobile/.project new file mode 100644 index 0000000000..bcf4fe099d --- /dev/null +++ b/examples/tizen-mobile/.project @@ -0,0 +1,93 @@ + + + MyMobileApp + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.buildCommand + sbi-make + + + org.eclipse.cdt.make.core.buildLocation + ${workspace_loc:/MyMobileApp/Debug} + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + true + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + + 1360216703005 + + 26 + + org.eclipse.ui.ide.multiFilter + 1.0-projectRelativePath-matches-false-false-*/.tpk + + + + diff --git a/examples/tizen-mobile/.tproject b/examples/tizen-mobile/.tproject new file mode 100644 index 0000000000..7a02b61f2b --- /dev/null +++ b/examples/tizen-mobile/.tproject @@ -0,0 +1,8 @@ + + + + + mobile-2.4 + + + diff --git a/examples/tizen-mobile/Build/appendix.mk b/examples/tizen-mobile/Build/appendix.mk new file mode 100644 index 0000000000..fad5ae45a2 --- /dev/null +++ b/examples/tizen-mobile/Build/appendix.mk @@ -0,0 +1 @@ +# Appendix diff --git a/examples/tizen-mobile/Build/basedef.mk b/examples/tizen-mobile/Build/basedef.mk new file mode 100644 index 0000000000..64fbf82b0a --- /dev/null +++ b/examples/tizen-mobile/Build/basedef.mk @@ -0,0 +1,34 @@ +# Add inputs and outputs from these tool invocations to the build variables + + +OS_NAME := $(shell $(UNAME)) + + +#ifeq ($(origin BUILD_CONFIG), undefined) +BUILD_CONFIG ?= Debug +#endif + +#ifeq ($(origin ARCH), undefined) +ARCH ?= i386 +#endif + +#ifeq ($(origin PROJPATH), undefined) +PROJPATH ?= . +#endif + + +#ifeq ($(origin PROJ_PATH), undefined) +PROJ_PATH ?= $(PROJPATH) +#endif + +#ifeq ($(strip $(OUTPUT_DIR)),) +OUTPUT_DIR ?= $(PROJ_PATH)/$(BUILD_CONFIG) +#endif + +#ifeq ($(strip $(BUILD_ARCH)),) +BUILD_ARCH ?= $(ARCH) +#endif + +#ifeq ($(strip $(ENVENTOR_PATH)),) +ENVENTOR_PATH ?= $(SDK_TOOLPATH)/enventor +#endif diff --git a/examples/tizen-mobile/Build/build_c.mk b/examples/tizen-mobile/Build/build_c.mk new file mode 100644 index 0000000000..81940cdc95 --- /dev/null +++ b/examples/tizen-mobile/Build/build_c.mk @@ -0,0 +1,110 @@ +# C/C++ build script + + +_FUNC_EXT2O = $(patsubst %.$(3),$(1)/%.o,$(2)) +_FUNC_C2O = $(call _FUNC_EXT2O,$(1),$(2),c) +_FUNC_CPP2O = $(call _FUNC_EXT2O,$(1),$(2),cpp) + + +# parameter : +# $(1) - C/C++ soruce file +# $(2) - output path +# $(3) - .ext +CONVERT_ESC_EXT_TO_O = $(addprefix $(2)/,$(call CONVERT_4MAKE_TO_OUT,$(patsubst %.$(3),%.o,$(1)))) + +CONVERT_ESC_C_TO_O = $(call CONVERT_ESC_EXT_TO_O,$(1),$(2),c) +CONVERT_ESC_CPP_TO_O = $(call CONVERT_ESC_EXT_TO_O,$(1),$(2),cpp) + + +# parameter : +# $(1) - encoded one C/C++ soruce file +# $(2) - output path +# $(3) - ext title (C/C++) +# $(4) - ext (c/cpp) +# $(5) - compiler ($(CC)/$(CXX)) +# $(6) - build opt +# $(7) - build opt file +# output : +# $(8) - output files list +define C_BUILD_PROC_RAW +$(call CONVERT_ESC_EXT_TO_O,$(1),$(2),$(4)) : $(call DECODE_4MAKE,$(1)) $(7) + @echo ' Building file: $$<' + @echo ' Invoking: $(3) Compiler' + $$(call MAKEDIRS,$$(@D)) + $(5) -c "$$<" -o "$$@" $(6) @$(7) + @echo ' Finished building: $$<' +$(8) += $(call CONVERT_ESC_EXT_TO_O,$(1),$(2),$(4)) +endef + + +# parameter : +# $(1) - output paths +# $(2) - src paths +# $(3) - inc paths +# $(4) - inc files +# $(5) - Defs +# $(6) - UnDefs +# $(7) - compiler opt +# $(8) - compiler opt file +# $(9) - ext title (C/C++) +# $(10) - ext (c/cpp) +# $(11) - compiler ($(CC)/$(CXX)) +# output : +# $(12) - OBJS +# return : +# none +define C_PROC_RAW + +_OUTPUT_DIR := $$(strip $(1))# +_SRCS := $(2)# +_INCS := $(3)# +_INC_FILES := $(4)# +_DEFS := $(5)# +_UNDEFS := $(6)# + +_OPT := $(7) +_OPT_FILE := $(8) + +_EXT_TITLE := $(9) +_EXT := $(10) +_COMPILER := $(11) + +#_OUTPUT_FILES := $(12) + +_ENC_SRCS := $$(call ENCODE_4MAKE,$$(_SRCS)) +_ENC_SRCS := $$(filter %.$$(_EXT),$$(_ENC_SRCS)) + +ifneq ($$(strip $$(_SRCS)),) + +_NORMAL_SRCS := $$(filter-out %*.$$(_EXT),$$(_ENC_SRCS)) +_WIDLCARD_SRCS := $$(filter %*.$$(_EXT),$$(_ENC_SRCS)) + +_ALL_SRCS := $$(call DECODE_4MAKE,$$(_NORMAL_SRCS)) \ + $$(foreach var,$$(_WIDLCARD_SRCS),$$(call FIND_FILES_4MAKE,$$(call DECODE_4MAKE,$$(var)))) + +ifneq ($$(strip $$(_ALL_SRCS)),) + +_ENC_SRCS := $$(call ENCODE_4MAKE,$$(_ALL_SRCS)) + +_CDEFS := $$(CDEFS) +_CDEFS += $$(addprefix -D,$$(_DEFS)) +_CDEFS += $$(addprefix -U,$$(_UNDEFS)) + +_ENC_C_INCS := $$(call ENCODE_4MAKE,$$(_INCS)) +_ENC_C_INCS := $$(addprefix -I,$$(_ENC_C_INCS)) + +_ENC_INC_FILES := $$(call ENCODE_4MAKE,$$(_INC_FILES)) +_ENC_INC_FILES += $$(addprefix -include,$$(_ENC_INC_FILES)) + +_C_INCS := $$(call DECODE_4MAKE,$$(_ENC_C_INCS) $$(_ENC_C_INC_FILES)) + +_DEFS := $$(_CDEFS) $$(_C_INCS) -I"pch" $$(_OPT) + +$$(foreach var,$$(_ENC_SRCS),$$(eval $$(call C_BUILD_PROC_RAW,$$(var),$$(_OUTPUT_DIR),$$(_EXT_TITLE),$$(_EXT),$$(_COMPILER),$$(_DEFS),$$(_OPT_FILE),$(12)))) + +endif # (_(strip _(_ALL_SRCS)),) + +endif # (_(strip _(_SRCS)),) + + +endef diff --git a/examples/tizen-mobile/Build/build_edc.mk b/examples/tizen-mobile/Build/build_edc.mk new file mode 100644 index 0000000000..6f85fdd962 --- /dev/null +++ b/examples/tizen-mobile/Build/build_edc.mk @@ -0,0 +1,81 @@ +# EDC build script + + +FUNC_EDC2EDJ = $(patsubst %.edc,$(2)/%.edj,$(1)) + +# parameter : +# $(1) - C/C++ soruce file +# $(2) - output path +CONVERT_ESC_EDC_TO_EDJ = $(call CONVERT_4MAKE_TO_OUT,$(call FUNC_EDC2EDJ,$(1),$(2))) + + +# parameter : +# $(1) - encoded one C/C++ soruce file +# $(2) - output path +# $(3) - build opt +# output : +# $(4) - output files list +define EDJ_BUILD_PROC_RAW +$(call CONVERT_ESC_EDC_TO_EDJ,$(1),$(2)) : $(call DECODE_4MAKE,$(1)) + @echo ' Building file: $$<' + @echo ' Invoking: EDC Resource Compiler' + $$(call MAKEDIRS,$$(@D)) + $$(EDJE_CC) $(3) "$$<" "$$@" + @echo ' Finished building: $$<' +$(4) += $(call CONVERT_ESC_EDC_TO_EDJ,$(1),$(2)) +endef + + +# parameter : +# $(1) - output paths +# $(2) - src paths +# $(3) - image inc paths +# $(4) - sound inc paths +# $(5) - font inc paths +# output : +# $(6) - OBJS +# return : +# none +define EDJ_PROC_RAW + +_OUTPUT_DIR := $$(strip $(1))# +_SRCS := $(2)# +_IMAGE_DIRS := $(3)# +_SOUND_DIRS := $(4)# +_FONT_DIRS := $(5)# + +ifneq ($$(strip $$(_SRCS)),) + +_ENC_SRCS := $$(call ENCODE_4MAKE,$$(_SRCS)) + +_NORMAL_SRCS := $$(filter-out %*.edc,$$(_ENC_SRCS)) +_WIDLCARD_SRCS := $$(filter %*.edc,$$(_ENC_SRCS)) + +_ALL_SRCS := $$(call DECODE_4MAKE,$$(_NORMAL_SRCS)) \ + $$(foreach var,$$(_WIDLCARD_SRCS),$$(call FIND_FILES_4MAKE,$$(call DECODE_4MAKE,$$(var)))) + +ifneq ($$(strip $$(_ALL_SRCS)),) + +_ENC_SRCS := $$(call ENCODE_4MAKE,$$(_ALL_SRCS)) + +_COMPILER_FLAGS := -id "$$(ENVENTOR_SHARED_RES_PATH)/images" +_COMPILER_FLAGS += -sd "$$(ENVENTOR_SHARED_RES_PATH)/sounds" +_COMPILER_FLAGS += -fd "$$(ENVENTOR_SHARED_RES_PATH)/fonts" + +ifneq ($$(strip $$(_IMAGE_DIRS)),) +_COMPILER_FLAGS += $$(addprefix -id ,$$(_IMAGE_DIRS)) +endif +ifneq ($$(strip $$(_SOUND_DIRS)),) +_COMPILER_FLAGS += $$(addprefix -sd ,$$(_SOUND_DIRS)) +endif +ifneq ($$(strip $$(_FONT_DIRS)),) +_COMPILER_FLAGS += $$(addprefix -fd ,$$(_FONT_DIRS)) +endif + +$$(foreach var,$$(_ENC_SRCS),$$(eval $$(call EDJ_BUILD_PROC_RAW,$$(var),$$(_OUTPUT_DIR),$$(_COMPILER_FLAGS),$(6)))) + +endif # (_(strip _(_ALL_SRCS)),) + +endif # (_(strip _(_SRCS)),) + +endef diff --git a/examples/tizen-mobile/Build/build_po.mk b/examples/tizen-mobile/Build/build_po.mk new file mode 100644 index 0000000000..d88d71aa61 --- /dev/null +++ b/examples/tizen-mobile/Build/build_po.mk @@ -0,0 +1,64 @@ +# PO build script + + +_FUNC_PO2MO = $(patsubst %.po,$(2)/res/locale/%/LC_MESSAGES/$(3).mo,$(notdir $(1))) + + +# parameter : +# $(1) - C/C++ soruce file +# $(2) - output path +# $(3) - app name +CONVERT_ESC_PO_TO_MO = $(call CONVERT_4MAKE_TO_OUT,$(call _FUNC_PO2MO,$(1),$(2),$(3))) + + +# parameter : +# $(1) - encoded one C/C++ soruce file +# $(2) - output path +# $(3) - app name +# output : +# $(4) - output files list +define MO_BUILD_PROC_RAW +$(call CONVERT_ESC_PO_TO_MO,$(1),$(2),$(3)) : $(call DECODE_4MAKE,$(1)) + @echo ' Building file: $$<' + @echo ' Invoking: msgfmt String Formatter' + $$(call MAKEDIRS,$$(@D)) + $$(MSGFMT) -o "$$@" "$$<" + @echo ' Finished building: $$<' +$(4) += $(call CONVERT_ESC_PO_TO_MO,$(1),$(2),$(3)) +endef + + +# parameter : +# $(1) - output dir +# $(2) - src paths +# $(3) - app name +# output : +# $(4) - OBJS + +define MO_PROC_RAW + +_OUTPUT_DIR := $(1) +_SRCS := $(2) +_APPNAME := $(3) + +ifneq ($$(strip $$(_SRCS)),) + +_ENC_SRCS := $$(call ENCODE_4MAKE,$$(_SRCS)) + +_NORMAL_SRCS := $$(filter-out %*.po,$$(_ENC_SRCS)) +_WIDLCARD_SRCS := $$(filter %*.po,$$(_ENC_SRCS)) + +_ALL_SRCS := $$(call DECODE_4MAKE,$$(_NORMAL_SRCS)) \ + $$(foreach var,$$(_WIDLCARD_SRCS),$$(call FIND_FILES_4MAKE,$$(call DECODE_4MAKE,$$(var)))) + +ifneq ($$(strip $$(_ALL_SRCS)),) + +_ENC_SRCS := $$(call ENCODE_4MAKE,$$(_ALL_SRCS)) + +$$(foreach var,$$(_ENC_SRCS),$$(eval $$(call MO_BUILD_PROC_RAW,$$(var),$$(_OUTPUT_DIR),$$(_APPNAME),$(4)))) + +endif # (_(strip _(_ALL_SRCS)),) + +endif # (_(strip _(_SRCS)),) + +endef diff --git a/examples/tizen-mobile/Build/flags.mk b/examples/tizen-mobile/Build/flags.mk new file mode 100644 index 0000000000..c460fe651a --- /dev/null +++ b/examples/tizen-mobile/Build/flags.mk @@ -0,0 +1,27 @@ +# Add tools flags defines + +ifeq ($(strip $(BUILD_CONFIG)),Debug) +OPTIMIZATION_OP := -O0 +DEBUG_OP := -g3 -D_DEBUG +CPP_OPTIMIZATION_OP := -O0 +CPP_DEBUG_OP := -g3 -D_DEBUG +LINK_OP := +else +ifeq ($(strip $(BUILD_CONFIG)),Release) +OPTIMIZATION_OP := -O3 +DEBUG_OP := +CPP_OPTIMIZATION_OP := -O3 +CPP_DEBUG_OP := +LINK_OP := -s +endif +endif + +COMPILE_FLAGS = $(DEBUG_OP) $(OPTIMIZATION_OP) -Wall -c -fmessage-length=0 + +CPP_COMPILE_FLAGS = $(CPP_DEBUG_OP) $(CPP_OPTIMIZATION_OP) -Wall -p -pg -c -fmessage-length=0 + +LINK_FLAGS = -L"$(PROJ_PATH)/lib" -Wl,--no-undefined $(LINK_OP) + +AR_FLAGS = + +EDC_COMPILE_FLAGS = -id "$(PROJ_PATH)/edje/images" -sd "$(PROJ_PATH)/edje/sounds" -fd "$(PROJ_PATH)/edje/fonts" diff --git a/examples/tizen-mobile/Build/funcs.mk b/examples/tizen-mobile/Build/funcs.mk new file mode 100644 index 0000000000..8297d1800c --- /dev/null +++ b/examples/tizen-mobile/Build/funcs.mk @@ -0,0 +1,50 @@ + +BSLASH := \\# +NULL_CHAR := # +SPACE := \ # +COLON := :# +DOTDOT := ..# +SPACE_ESC := &sp;# +COLON_ESC := &co;# +SPACE_OUT := ~sp~# +COLON_OUT := ~co~# +DOTDOT_OUT := ~dtdt~# + +BSLASH2SLASH = $(subst $(BSLASH),/,$(1)) + +REMOVE_TAIL = $(patsubst %/,%,$(1)) + +#LOWER_CASE = $(shell echo translit($(1),[A-Z],[a-z])|$(M4)) +LOWER_CASE = $(shell echo $(1)|$(TR) [A-Z] [a-z]) + +#ifneq ($(findstring Windows,$(OS)),) +# ... +#endif + +FIND_FILES = $(shell $(FIND) $(1)/$(2) | $(SED) 's/^$(subst /,$(BSLASH)/,$(1))$(BSLASH)///') +FIND_FILES_ESC = $(shell $(FIND) $(1)/$(2) | $(SED) 's/^$(subst /,$(BSLASH)/,$(1))$(BSLASH)///' -e 's/:/$(BSLASH)&co;/g' -e 's/$(BSLASH) /$(BSLASH)&sp;/g') +FIND_FILES_4MAKE = $(shell $(FIND) $(1)/$(2) | $(SED) 's/^$(subst /,$(BSLASH)/,$(1))$(BSLASH)///') + +FIND_FILES_ABS = $(shell $(FIND) $(1)) +FIND_FILES_ABS_4MAKE = $(shell $(FIND) $(1) -e 's/$(BSLASH) /$(BSLASH)&sp;/g') +FIND_FILES_ABS_ESC = $(shell $(FIND) $(1) -e 's/:/$(BSLASH)&co;/g' -e 's/$(BSLASH) /$(BSLASH)&sp;/g') + +FIND_FILES_4MAKE = $(shell $(FIND) $(1) | $(SED) 's/ /\\\ /g') + +#ENCODE_ESC = $(shell echo $(1) | $(SED) -e 's/:/$(BSLASH)&co;/g' -e 's/$(BSLASH) /$(BSLASH)&sp;/g') +#DECODE_ESC = $(shell echo $(1) | $(SED) -e 's/$(BSLASH)&co;/:/g' -e 's/$(BSLASH)&sp;/$(BSLASH) / g') +ENCODE_ESC = $(subst $(SPACE),$(SPACE_ESC),$(subst $(COLON),$(COLON_ESC),$(1))) +DECODE_ESC = $(subst $(COLON_ESC),$(COLON),$(subst $(SPACE_ESC),$(SPACE),$(1))) +ENCODE_4MAKE = $(subst $(SPACE),$(SPACE_ESC),$(1)) +DECODE_4MAKE = $(subst $(SPACE_ESC),$(SPACE),$(1)) + +CONVERT_TO_OUT = $(subst $(DOTDOT),$(DOTDOT_OUT),$(subst $(COLON),$(COLON_OUT),$(subst $(SPACE),$(SPACE_OUT),$(1)))) +CONVERT_ESC_TO_OUT = $(subst $(DOTDOT),$(DOTDOT_OUT),$(subst $(COLON_ESC),$(COLON_OUT),$(subst $(SPACE_ESC),$(SPACE_OUT),$(1)))) +CONVERT_4MAKE_TO_OUT = $(subst $(DOTDOT),$(DOTDOT_OUT),$(subst $(COLON),$(COLON_OUT),$(subst $(SPACE_ESC),$(SPACE_OUT),$(1)))) + +PROC_NO_EXIST = $(if $(wildcard $(1)),,$(call $(2),$(1))) +define MAKEDIRS0 + @echo ' Building directory: $(1)' + @$(MKDIR) $(MKDIR_OP) $(subst $(BSLASH),/,$(1)) +endef +MAKEDIRS = $(call PROC_NO_EXIST,$(1),MAKEDIRS0) diff --git a/examples/tizen-mobile/Build/makefile b/examples/tizen-mobile/Build/makefile new file mode 100644 index 0000000000..9348c50a45 --- /dev/null +++ b/examples/tizen-mobile/Build/makefile @@ -0,0 +1,34 @@ +# +# Usege : make -f /Build/makefile -C +# + +BUILD_SCRIPT_VERSION := 1.1.0 + +.PHONY : app_version app_build app_clean build_version + + +all : app_build + +clean : app_clean + +version : build_version + +#PROJ_ROOT = . +BUILD_ROOT := $(PROJ_PATH)/Build# + +ifeq ($(MAKE_NAME),mingw32-make) +ifneq ($(SHELL),) +OPTIONS += --eval="SHELL=$(SHELL)" +endif +endif + +app_build : + @echo $(MAKE) -f "$(BUILD_ROOT)/makefile.mk" + @$(MAKE) -f "$(BUILD_ROOT)/makefile.mk" -C "$(PROJ_PATH)" $(OPTIONS) + +app_clean : + @$(MAKE) -f "$(BUILD_ROOT)/makefile.mk" -C "$(PROJ_PATH)" $(OPTIONS) clean + +build_version : + @echo makefile : $(BUILD_SCRIPT_VERSION) + @$(MAKE) -f "$(BUILD_ROOT)/makefile.mk" -C "$(PROJ_PATH)" $(OPTIONS) version diff --git a/examples/tizen-mobile/Build/makefile.mk b/examples/tizen-mobile/Build/makefile.mk new file mode 100644 index 0000000000..c95b4b40b4 --- /dev/null +++ b/examples/tizen-mobile/Build/makefile.mk @@ -0,0 +1,197 @@ +# +# Usege : make -f /Build/makefile -C +# + +BUILD_SCRIPT_VERSION := 1.2.3 + +.PHONY : app_version app_clean build_version + + +all : app_build + +clean : app_clean + +version : build_version + + +#PROJ_ROOT := $(call BSLASH2SLASH,$(PROJ_PATH)) +PROJ_ROOT := . +BUILD_ROOT := $(PROJ_ROOT)/Build + +include $(BUILD_ROOT)/basedef.mk + +include $(PROJ_ROOT)/project_def.prop +-include $(PROJ_ROOT)/build_def.prop + +include $(BUILD_ROOT)/funcs.mk + +-include $(BUILD_ROOT)/tooldef.mk +-include $(BUILD_ROOT)/flags.mk +-include $(BUILD_ROOT)/platform.mk + + +APPTYPE := $(type) + +OUTPUT_DIR := $(PROJ_ROOT)/$(BUILD_CONFIG) +OBJ_OUTPUT := $(OUTPUT_DIR)/objs + +LOWER_APPNAME := $(call LOWER_CASE,$(APPNAME)) +APPID2 := $(subst $(basename $(APPID)).,,$(APPID)) + +ifeq ($(strip $(APPTYPE)),app) +APPFILE := $(OUTPUT_DIR)/$(LOWER_APPNAME) +endif +ifeq ($(strip $(APPTYPE)),staticLib) +APPFILE := $(OUTPUT_DIR)/lib$(LOWER_APPNAME).a +endif +ifeq ($(strip $(APPTYPE)),sharedLib) +APPFILE := $(OUTPUT_DIR)/lib$(LOWER_APPNAME).so +endif + +ifneq ($(strip $(PLATFORM_INCS)),) +PLATFORM_INCS_FILE := $(OBJ_OUTPUT)/platform_incs_file.inc +endif + +include $(BUILD_ROOT)/build_c.mk + + +ifeq ($(strip $(APPTYPE)),app) +EXT_OP := -fPIE +endif +ifeq ($(strip $(APPTYPE)),staticLib) +EXT_OP := -fPIE +endif +ifeq ($(strip $(APPTYPE)),sharedLib) +EXT_OP := -fPIC +endif + +C_OPT := $(COMPILE_FLAGS) $(TC_COMPILER_MISC) $(RS_COMPILER_MISC) $(EXT_OP) --sysroot="$(SYSROOT)" -Werror-implicit-function-declaration $(M_OPT) +CPP_OPT := $(CPP_COMPILE_FLAGS) $(TC_COMPILER_MISC) $(RS_COMPILER_MISC) $(EXT_OP) --sysroot="$(SYSROOT)" -Werror-implicit-function-declaration $(M_OPT) +C_OPT_FILE := $(PLATFORM_INCS_FILE) + +OBJS := # + +# Global C/C++ +ifeq ($(strip $(USER_ROOT)),) +USER_ROOT := $(PROJ_ROOT) +endif +$(eval $(call C_PROC_RAW,$(OBJ_OUTPUT),$(USER_SRCS),$(USER_INC_DIRS),$(USER_INC_FILES),$(USER_DEFS),$(USER_UNDEFS),$(C_OPT),$(C_OPT_FILE),C,c,$(CC),OBJS)) +$(foreach ext,cpp cxx cc c++ C,$(eval $(call C_PROC_RAW,$(OBJ_OUTPUT),$(USER_SRCS),$(USER_INC_DIRS),$(USER_CPP_INC_FILES),$(USER_CPP_DEFS),$(USER_CPP_UNDEFS),$(CPP_OPT),$(C_OPT_FILE),C++,$(ext),$(CXX),OBJS))) + +# Individual C/C++ +ifneq ($(strip $(USER_EXT_C_KEYS)),) +$(foreach var,$(USER_EXT_C_KEYS),$(eval $(call C_PROC_RAW,$(OBJ_OUTPUT),$(USER_EXT_$(var)_SRCS),$(USER_EXT_$(var)_INC_DIRS),$(USER_EXT_$(var)_INC_FILES),$(USER_EXT_$(var)_DEFS),$(USER_EXT_$(var)_UNDEFS),$(C_OPT),$(C_OPT_FILE),C,c,$(CC),OBJS))) +$(foreach ext,cpp cxx cc c++ C,$(foreach var,$(USER_EXT_C_KEYS),$(eval $(call C_PROC_RAW,$(OBJ_OUTPUT),$(USER_EXT_$(var)_SRCS),$(USER_EXT_$(var)_INC_DIRS),$(USER_EXT_$(var)_CPP_INC_FILES),$(USER_EXT_$(var)_CPP_DEFS),$(USER_EXT_$(var)_CPP_UNDEFS),$(C_OPT),$(C_OPT_FILE),C++,$(ext),$(CXX),OBJS)))) +endif + + +ifneq ($(strip $(USER_LIB_DIRS)),) +_ENC_USER_LIB_DIRS := $(call ENCODE_4MAKE,$(USER_LIB_DIRS)) +_ENC_USER_LIB_DIRS := $(addprefix -L,$(_ENC_USER_LIB_DIRS)) +LIBPATHS := $(call DECODE_4MAKE,$(_ENC_USER_LIB_DIRS)) +endif + +LIBS += $(addprefix -l,$(USER_LIBS)) + +UOBJS += $(USER_OBJS) + +M_OPT = -MMD -MP -MF"$(@:%.o=%.d)" + +DEPS := $(OBJS:.o=.d) + +ifneq ($(strip $(DEPS)),) +-include $(PROJ_ROOT)/Build/$(DEPS) +endif + + +ifeq ($(strip $(APPTYPE)),app) +$(APPFILE) : $(OBJS) $(UOBJS) + @echo ' Building target: $@' + @echo ' Invoking: C/C++ Linker' + $(call MAKEDIRS,$(@D)) + $(CXX) -o $(APPFILE) $(OBJS) $(UOBJS) $(LIBPATHS) -Xlinker --as-needed $(LIBS) $(LINK_FLAGS) $(TC_LINKER_MISC) $(RS_LINKER_MISC) -pie -lpthread --sysroot="$(SYSROOT)" -Xlinker --version-script="$(PROJ_ROOT)/.exportMap" $(RS_LIB_PATHS) $(RS_LIBRARIES) -Xlinker -rpath="/opt/usr/apps/$(APPID)/lib" -Werror-implicit-function-declaration + @echo ' Finished building target: $@' +endif +ifeq ($(strip $(APPTYPE)),staticLib) +$(APPFILE) : $(OBJS) $(UOBJS) + @echo ' Building target: $@' + @echo ' Invoking: Archive utility' + $(call MAKEDIRS,$(@D)) + $(AR) -r $(APPFILE) $(OBJS) $(UOBJS) $(AR_FLAGS) + @echo ' Finished building target: $@' +endif +ifeq ($(strip $(APPTYPE)),sharedLib) +$(APPFILE) : $(OBJS) $(UOBJS) + @echo ' Building target: $@' + @echo ' Invoking: C/C++ Linker' + $(call MAKEDIRS,$(@D)) + $(CXX) -o $(APPFILE) $(OBJS) $(UOBJS) $(LIBPATHS) -Xlinker --as-needed $(LIBS) $(LINK_FLAGS) $(TC_LINKER_MISC) $(RS_LINKER_MISC) -shared -lpthread --sysroot="$(SYSROOT)" $(RS_LIB_PATHS) $(RS_LIBRARIES) + @echo ' Finished building target: $@' +endif + + +$(OBJ_OUTPUT) : + $(call MAKEDIRS,$@) + +$(OUTPUT_DIR) : + $(call MAKEDIRS,$@) + + +ifneq ($(strip $(PLATFORM_INCS)),) +$(PLATFORM_INCS_FILE) : $(OBJ_OUTPUT) + @echo ' Building inc file: $@' +ifneq ($(findstring Windows,$(OS)),) +ifneq ($(findstring 3.82,$(MAKE_VERSION)),) + $(file > $@,$(PLATFORM_INCS)) +else + @echo $(PLATFORM_INCS) > $@ +endif +else + @echo $(PLATFORM_INCS) > $@ +endif +endif + + +include $(BUILD_ROOT)/build_edc.mk + +#ifeq ($(strip $(ENVENTOR_SHARED_RES_PATH)),) +ENVENTOR_SHARED_RES_PATH ?= $(ENVENTOR_PATH)/share/enventor +#endif + +EDJ_FILES := + +# Global EDCs +ifneq ($(strip $(USER_EDCS)),) +$(eval $(call EDJ_PROC_RAW,$(OUTPUT_DIR),$(USER_EDCS),$(USER_EDCS_IMAGE_DIRS),$(USER_EDCS_SOUND_DIRS),$(USER_EDCS_FONT_DIRS),EDJ_FILES)) +endif + +# Individual EDCs +ifneq ($(strip $(USER_EXT_EDC_KEYS)),) +$(foreach var,$(USER_EXT_EDC_KEYS),$(eval $(call EDJ_PROC_RAW,$(OUTPUT_DIR),$(USER_EXT_$(var)_EDCS),$(USER_EXT_$(var)_EDCS_IMAGE_DIRS),$(USER_EXT_$(var)_EDCS_SOUND_DIRS),$(USER_EXT_$(var)_EDCS_FONT_DIRS),EDJ_FILES))) +endif + + +include $(BUILD_ROOT)/build_po.mk + +MO_FILES := + +# Global POs +ifneq ($(strip $(USER_POS)),) +$(eval $(call MO_PROC_RAW,$(OUTPUT_DIR),$(USER_POS),$(APPID2),MO_FILES)) +endif + + +secondary-outputs : $(EDJ_FILES) $(MO_FILES) + +-include appendix.mk + +app_build : $(OUTPUT_DIR) $(APPFILE) secondary-outputs + @echo ========= done ========= + + +app_clean : + rm -f $(APPFILE) + rm -rf $(OUTPUT_DIR) + +build_version : + @echo makefile.mk : $(BUILD_SCRIPT_VERSION) diff --git a/examples/tizen-mobile/Build/platform.mk b/examples/tizen-mobile/Build/platform.mk new file mode 100644 index 0000000000..294a38aee2 --- /dev/null +++ b/examples/tizen-mobile/Build/platform.mk @@ -0,0 +1,15 @@ +# Add inputs and outputs from these tool invocations to the build variables + +SYSROOT = $(SBI_SYSROOT) + +USR_INCS := $(addprefix -I $(SYSROOT),$(PLATFORM_INCS_EX)) + +ifeq ($(strip $(PLATFORM_LIB_PATHS)),) +RS_LIB_PATHS := "$(SYSROOT)/usr/lib" +else +RS_LIB_PATHS := $(addprefix -L$(SYSROOT),$(PLATFORM_LIB_PATHS)) +endif + +RS_LIBRARIES := $(addprefix -l,$(RS_LIBRARIES_EX)) + +PLATFORM_INCS = $(USR_INCS) -I"$(SDK_PATH)/library" diff --git a/examples/tizen-mobile/Build/tooldef.mk b/examples/tizen-mobile/Build/tooldef.mk new file mode 100644 index 0000000000..fded35b84f --- /dev/null +++ b/examples/tizen-mobile/Build/tooldef.mk @@ -0,0 +1,63 @@ +# Add inputs and outputs from these tool invocations to the build variables + +ifneq ($(strip $(SHELL_BIN)),) +SHELL = $(SHELL_BIN) +else +SHELL = sh +endif + +ifneq ($(strip $(MKDIR_BIN)),) +MKDIR = $(MKDIR_BIN) +MKDIR_OP = -p +else +MKDIR = mkdir +MKDIR_OP = -p +endif + +ifneq ($(strip $(UNAME_BIN)),) +UNAME = $(UNAME_BIN) +else +UNAME = uname +endif + +ifneq ($(strip $(M4_BIN)),) +M4 = $(M4_BIN) +else +M4 = m4 +endif + +ifneq ($(strip $(TR_BIN)),) +TR = $(TR_BIN) +else +TR = tr +endif + +ifneq ($(strip $(FIND_BIN)),) +FIND = $(FIND_BIN) +else +FIND = find +endif + +ifneq ($(strip $(SED_BIN)),) +SED = $(SED_BIN) +else +SED = sed +endif + +ifneq ($(strip $(GREP_BIN)),) +GREP = $(GREP_BIN) +else +GREP = grep +endif + +ifneq ($(strip $(EDJE_CC_BIN)),) +EDJE_CC = $(EDJE_CC_BIN) +else +EDJE_CC = edje_cc +endif + +ifneq ($(strip $(MSGFMT_BIN)),) +MSGFMT = $(MSGFMT_BIN) +else +MSGFMT = msgfmt +endif diff --git a/examples/tizen-mobile/inc/mymobileapp.h b/examples/tizen-mobile/inc/mymobileapp.h new file mode 100644 index 0000000000..79ec193188 --- /dev/null +++ b/examples/tizen-mobile/inc/mymobileapp.h @@ -0,0 +1,19 @@ +#ifndef __mymobileapp_H__ +#define __mymobileapp_H__ + +#include +#include +#include +#include +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "mymobileapp" + +#if !defined(PACKAGE) +#define PACKAGE "org.example.mymobileapp" +#endif + +#endif /* __mymobileapp_H__ */ diff --git a/examples/tizen-mobile/project_def.prop b/examples/tizen-mobile/project_def.prop new file mode 100644 index 0000000000..9b3a74b0ec --- /dev/null +++ b/examples/tizen-mobile/project_def.prop @@ -0,0 +1,19 @@ +APPNAME = mymobileapp + +type = app +profile = mobile-2.4 + +USER_SRCS = src/main.cpp +USER_DEFS = +USER_INC_DIRS = inc +USER_OBJS = +USER_LIBS = sfml-main sfml-system sfml-window sfml-graphics sfml-audio sfml-network +USER_EDCS = + +USER_INC_DIRS = $(SDK_PATH)/library/sfml/include +USER_INC_DIRS_ABS = + +USER_LIB_DIRS = $(SDK_PATH)/library/sfml/lib/mobile/$(TARGET_EMU_OR_DEV) +USER_LIB_DIRS_ABS = + +USER_CPP_DEFS = __TIZEN__ diff --git a/examples/tizen-mobile/shared/res/mymobileapp.png b/examples/tizen-mobile/shared/res/mymobileapp.png new file mode 100644 index 0000000000..6ed97333f3 Binary files /dev/null and b/examples/tizen-mobile/shared/res/mymobileapp.png differ diff --git a/examples/tizen-mobile/src/mymobileapp.c b/examples/tizen-mobile/src/mymobileapp.c new file mode 100644 index 0000000000..1a8900a6d3 --- /dev/null +++ b/examples/tizen-mobile/src/mymobileapp.c @@ -0,0 +1,173 @@ +#include "mymobileapp.h" + +typedef struct appdata { + Evas_Object *win; + Evas_Object *conform; + Evas_Object *label; +} appdata_s; + +static void +win_delete_request_cb(void *data, Evas_Object *obj, void *event_info) +{ + ui_app_exit(); +} + +static void +win_back_cb(void *data, Evas_Object *obj, void *event_info) +{ + appdata_s *ad = data; + /* Let window go to hide state. */ + elm_win_lower(ad->win); +} + +static void +create_base_gui(appdata_s *ad) +{ + /* Window */ + /* Create and initialize elm_win. + elm_win is mandatory to manipulate window. */ + ad->win = elm_win_util_standard_add(PACKAGE, PACKAGE); + elm_win_autodel_set(ad->win, EINA_TRUE); + + if (elm_win_wm_rotation_supported_get(ad->win)) { + int rots[4] = { 0, 90, 180, 270 }; + elm_win_wm_rotation_available_rotations_set(ad->win, (const int *)(&rots), 4); + } + + evas_object_smart_callback_add(ad->win, "delete,request", win_delete_request_cb, NULL); + eext_object_event_callback_add(ad->win, EEXT_CALLBACK_BACK, win_back_cb, ad); + + /* Conformant */ + /* Create and initialize elm_conformant. + elm_conformant is mandatory for base gui to have proper size + when indicator or virtual keypad is visible. */ + ad->conform = elm_conformant_add(ad->win); + elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_SHOW); + elm_win_indicator_opacity_set(ad->win, ELM_WIN_INDICATOR_OPAQUE); + evas_object_size_hint_weight_set(ad->conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(ad->win, ad->conform); + evas_object_show(ad->conform); + + /* Label */ + /* Create an actual view of the base gui. + Modify this part to change the view. */ + ad->label = elm_label_add(ad->conform); + elm_object_text_set(ad->label, "Hello Tizen"); + evas_object_size_hint_weight_set(ad->label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_object_content_set(ad->conform, ad->label); + + /* Show window after base gui is set up */ + evas_object_show(ad->win); +} + +static bool +app_create(void *data) +{ + /* Hook to take necessary actions before main event loop starts + Initialize UI resources and application's data + If this function returns true, the main loop of application starts + If this function returns false, the application is terminated */ + appdata_s *ad = data; + + create_base_gui(ad); + + return true; +} + +static void +app_control(app_control_h app_control, void *data) +{ + /* Handle the launch request. */ +} + +static void +app_pause(void *data) +{ + /* Take necessary actions when application becomes invisible. */ +} + +static void +app_resume(void *data) +{ + /* Take necessary actions when application becomes visible. */ +} + +static void +app_terminate(void *data) +{ + /* Release all resources. */ +} + +static void +ui_app_lang_changed(app_event_info_h event_info, void *user_data) +{ + /*APP_EVENT_LANGUAGE_CHANGED*/ + + int ret; + char *language; + + ret = app_event_get_language(event_info, &language); + if (ret != APP_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "app_event_get_language() failed. Err = %d.", ret); + return; + } + + if (language != NULL) { + elm_language_set(language); + free(language); + } +} + +static void +ui_app_orient_changed(app_event_info_h event_info, void *user_data) +{ + /*APP_EVENT_DEVICE_ORIENTATION_CHANGED*/ + return; +} + +static void +ui_app_region_changed(app_event_info_h event_info, void *user_data) +{ + /*APP_EVENT_REGION_FORMAT_CHANGED*/ +} + +static void +ui_app_low_battery(app_event_info_h event_info, void *user_data) +{ + /*APP_EVENT_LOW_BATTERY*/ +} + +static void +ui_app_low_memory(app_event_info_h event_info, void *user_data) +{ + /*APP_EVENT_LOW_MEMORY*/ +} + +int +main(int argc, char *argv[]) +{ + appdata_s ad = {0,}; + int ret = 0; + + ui_app_lifecycle_callback_s event_callback = {0,}; + app_event_handler_h handlers[5] = {NULL, }; + + event_callback.create = app_create; + event_callback.terminate = app_terminate; + event_callback.pause = app_pause; + event_callback.resume = app_resume; + event_callback.app_control = app_control; + + ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, ui_app_low_battery, &ad); + ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, ui_app_low_memory, &ad); + ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, ui_app_orient_changed, &ad); + ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, ui_app_lang_changed, &ad); + ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, ui_app_region_changed, &ad); + + ret = ui_app_main(argc, argv, &event_callback, &ad); + if (ret != APP_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "app_main() is failed. err = %d", ret); + } + + return ret; +} diff --git a/examples/tizen-mobile/tizen-manifest.xml b/examples/tizen-mobile/tizen-manifest.xml new file mode 100644 index 0000000000..9a88c5bc87 --- /dev/null +++ b/examples/tizen-mobile/tizen-manifest.xml @@ -0,0 +1,8 @@ + + + + + mymobileapp.png + + + diff --git a/examples/tizen-wearable/.cproject b/examples/tizen-wearable/.cproject new file mode 100644 index 0000000000..871745ef67 --- /dev/null +++ b/examples/tizen-wearable/.cproject @@ -0,0 +1,857 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/tizen-wearable/.exportMap b/examples/tizen-wearable/.exportMap new file mode 100644 index 0000000000..43e310e053 --- /dev/null +++ b/examples/tizen-wearable/.exportMap @@ -0,0 +1,4 @@ +{ + global: main; + local: *; +}; diff --git a/examples/tizen-wearable/.project b/examples/tizen-wearable/.project new file mode 100644 index 0000000000..ced631e8b9 --- /dev/null +++ b/examples/tizen-wearable/.project @@ -0,0 +1,93 @@ + + + MyWearableApp + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + + + ?name? + + + + org.eclipse.cdt.make.core.append_environment + true + + + org.eclipse.cdt.make.core.autoBuildTarget + all + + + org.eclipse.cdt.make.core.buildArguments + + + + org.eclipse.cdt.make.core.buildCommand + sbi-make + + + org.eclipse.cdt.make.core.buildLocation + ${workspace_loc:/MyWearableApp/Debug} + + + org.eclipse.cdt.make.core.cleanBuildTarget + clean + + + org.eclipse.cdt.make.core.contents + org.eclipse.cdt.make.core.activeConfigSettings + + + org.eclipse.cdt.make.core.enableAutoBuild + true + + + org.eclipse.cdt.make.core.enableCleanBuild + true + + + org.eclipse.cdt.make.core.enableFullBuild + true + + + org.eclipse.cdt.make.core.fullBuildTarget + all + + + org.eclipse.cdt.make.core.stopOnError + true + + + org.eclipse.cdt.make.core.useDefaultBuildCmd + true + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + + + + 1360216703005 + + 26 + + org.eclipse.ui.ide.multiFilter + 1.0-projectRelativePath-matches-false-false-*/.tpk + + + + diff --git a/examples/tizen-wearable/.tproject b/examples/tizen-wearable/.tproject new file mode 100644 index 0000000000..58efa501fe --- /dev/null +++ b/examples/tizen-wearable/.tproject @@ -0,0 +1,8 @@ + + + + + wearable-2.3.2 + + + diff --git a/examples/tizen-wearable/Build/appendix.mk b/examples/tizen-wearable/Build/appendix.mk new file mode 100644 index 0000000000..fad5ae45a2 --- /dev/null +++ b/examples/tizen-wearable/Build/appendix.mk @@ -0,0 +1 @@ +# Appendix diff --git a/examples/tizen-wearable/Build/basedef.mk b/examples/tizen-wearable/Build/basedef.mk new file mode 100644 index 0000000000..64fbf82b0a --- /dev/null +++ b/examples/tizen-wearable/Build/basedef.mk @@ -0,0 +1,34 @@ +# Add inputs and outputs from these tool invocations to the build variables + + +OS_NAME := $(shell $(UNAME)) + + +#ifeq ($(origin BUILD_CONFIG), undefined) +BUILD_CONFIG ?= Debug +#endif + +#ifeq ($(origin ARCH), undefined) +ARCH ?= i386 +#endif + +#ifeq ($(origin PROJPATH), undefined) +PROJPATH ?= . +#endif + + +#ifeq ($(origin PROJ_PATH), undefined) +PROJ_PATH ?= $(PROJPATH) +#endif + +#ifeq ($(strip $(OUTPUT_DIR)),) +OUTPUT_DIR ?= $(PROJ_PATH)/$(BUILD_CONFIG) +#endif + +#ifeq ($(strip $(BUILD_ARCH)),) +BUILD_ARCH ?= $(ARCH) +#endif + +#ifeq ($(strip $(ENVENTOR_PATH)),) +ENVENTOR_PATH ?= $(SDK_TOOLPATH)/enventor +#endif diff --git a/examples/tizen-wearable/Build/build_c.mk b/examples/tizen-wearable/Build/build_c.mk new file mode 100644 index 0000000000..81940cdc95 --- /dev/null +++ b/examples/tizen-wearable/Build/build_c.mk @@ -0,0 +1,110 @@ +# C/C++ build script + + +_FUNC_EXT2O = $(patsubst %.$(3),$(1)/%.o,$(2)) +_FUNC_C2O = $(call _FUNC_EXT2O,$(1),$(2),c) +_FUNC_CPP2O = $(call _FUNC_EXT2O,$(1),$(2),cpp) + + +# parameter : +# $(1) - C/C++ soruce file +# $(2) - output path +# $(3) - .ext +CONVERT_ESC_EXT_TO_O = $(addprefix $(2)/,$(call CONVERT_4MAKE_TO_OUT,$(patsubst %.$(3),%.o,$(1)))) + +CONVERT_ESC_C_TO_O = $(call CONVERT_ESC_EXT_TO_O,$(1),$(2),c) +CONVERT_ESC_CPP_TO_O = $(call CONVERT_ESC_EXT_TO_O,$(1),$(2),cpp) + + +# parameter : +# $(1) - encoded one C/C++ soruce file +# $(2) - output path +# $(3) - ext title (C/C++) +# $(4) - ext (c/cpp) +# $(5) - compiler ($(CC)/$(CXX)) +# $(6) - build opt +# $(7) - build opt file +# output : +# $(8) - output files list +define C_BUILD_PROC_RAW +$(call CONVERT_ESC_EXT_TO_O,$(1),$(2),$(4)) : $(call DECODE_4MAKE,$(1)) $(7) + @echo ' Building file: $$<' + @echo ' Invoking: $(3) Compiler' + $$(call MAKEDIRS,$$(@D)) + $(5) -c "$$<" -o "$$@" $(6) @$(7) + @echo ' Finished building: $$<' +$(8) += $(call CONVERT_ESC_EXT_TO_O,$(1),$(2),$(4)) +endef + + +# parameter : +# $(1) - output paths +# $(2) - src paths +# $(3) - inc paths +# $(4) - inc files +# $(5) - Defs +# $(6) - UnDefs +# $(7) - compiler opt +# $(8) - compiler opt file +# $(9) - ext title (C/C++) +# $(10) - ext (c/cpp) +# $(11) - compiler ($(CC)/$(CXX)) +# output : +# $(12) - OBJS +# return : +# none +define C_PROC_RAW + +_OUTPUT_DIR := $$(strip $(1))# +_SRCS := $(2)# +_INCS := $(3)# +_INC_FILES := $(4)# +_DEFS := $(5)# +_UNDEFS := $(6)# + +_OPT := $(7) +_OPT_FILE := $(8) + +_EXT_TITLE := $(9) +_EXT := $(10) +_COMPILER := $(11) + +#_OUTPUT_FILES := $(12) + +_ENC_SRCS := $$(call ENCODE_4MAKE,$$(_SRCS)) +_ENC_SRCS := $$(filter %.$$(_EXT),$$(_ENC_SRCS)) + +ifneq ($$(strip $$(_SRCS)),) + +_NORMAL_SRCS := $$(filter-out %*.$$(_EXT),$$(_ENC_SRCS)) +_WIDLCARD_SRCS := $$(filter %*.$$(_EXT),$$(_ENC_SRCS)) + +_ALL_SRCS := $$(call DECODE_4MAKE,$$(_NORMAL_SRCS)) \ + $$(foreach var,$$(_WIDLCARD_SRCS),$$(call FIND_FILES_4MAKE,$$(call DECODE_4MAKE,$$(var)))) + +ifneq ($$(strip $$(_ALL_SRCS)),) + +_ENC_SRCS := $$(call ENCODE_4MAKE,$$(_ALL_SRCS)) + +_CDEFS := $$(CDEFS) +_CDEFS += $$(addprefix -D,$$(_DEFS)) +_CDEFS += $$(addprefix -U,$$(_UNDEFS)) + +_ENC_C_INCS := $$(call ENCODE_4MAKE,$$(_INCS)) +_ENC_C_INCS := $$(addprefix -I,$$(_ENC_C_INCS)) + +_ENC_INC_FILES := $$(call ENCODE_4MAKE,$$(_INC_FILES)) +_ENC_INC_FILES += $$(addprefix -include,$$(_ENC_INC_FILES)) + +_C_INCS := $$(call DECODE_4MAKE,$$(_ENC_C_INCS) $$(_ENC_C_INC_FILES)) + +_DEFS := $$(_CDEFS) $$(_C_INCS) -I"pch" $$(_OPT) + +$$(foreach var,$$(_ENC_SRCS),$$(eval $$(call C_BUILD_PROC_RAW,$$(var),$$(_OUTPUT_DIR),$$(_EXT_TITLE),$$(_EXT),$$(_COMPILER),$$(_DEFS),$$(_OPT_FILE),$(12)))) + +endif # (_(strip _(_ALL_SRCS)),) + +endif # (_(strip _(_SRCS)),) + + +endef diff --git a/examples/tizen-wearable/Build/build_edc.mk b/examples/tizen-wearable/Build/build_edc.mk new file mode 100644 index 0000000000..6f85fdd962 --- /dev/null +++ b/examples/tizen-wearable/Build/build_edc.mk @@ -0,0 +1,81 @@ +# EDC build script + + +FUNC_EDC2EDJ = $(patsubst %.edc,$(2)/%.edj,$(1)) + +# parameter : +# $(1) - C/C++ soruce file +# $(2) - output path +CONVERT_ESC_EDC_TO_EDJ = $(call CONVERT_4MAKE_TO_OUT,$(call FUNC_EDC2EDJ,$(1),$(2))) + + +# parameter : +# $(1) - encoded one C/C++ soruce file +# $(2) - output path +# $(3) - build opt +# output : +# $(4) - output files list +define EDJ_BUILD_PROC_RAW +$(call CONVERT_ESC_EDC_TO_EDJ,$(1),$(2)) : $(call DECODE_4MAKE,$(1)) + @echo ' Building file: $$<' + @echo ' Invoking: EDC Resource Compiler' + $$(call MAKEDIRS,$$(@D)) + $$(EDJE_CC) $(3) "$$<" "$$@" + @echo ' Finished building: $$<' +$(4) += $(call CONVERT_ESC_EDC_TO_EDJ,$(1),$(2)) +endef + + +# parameter : +# $(1) - output paths +# $(2) - src paths +# $(3) - image inc paths +# $(4) - sound inc paths +# $(5) - font inc paths +# output : +# $(6) - OBJS +# return : +# none +define EDJ_PROC_RAW + +_OUTPUT_DIR := $$(strip $(1))# +_SRCS := $(2)# +_IMAGE_DIRS := $(3)# +_SOUND_DIRS := $(4)# +_FONT_DIRS := $(5)# + +ifneq ($$(strip $$(_SRCS)),) + +_ENC_SRCS := $$(call ENCODE_4MAKE,$$(_SRCS)) + +_NORMAL_SRCS := $$(filter-out %*.edc,$$(_ENC_SRCS)) +_WIDLCARD_SRCS := $$(filter %*.edc,$$(_ENC_SRCS)) + +_ALL_SRCS := $$(call DECODE_4MAKE,$$(_NORMAL_SRCS)) \ + $$(foreach var,$$(_WIDLCARD_SRCS),$$(call FIND_FILES_4MAKE,$$(call DECODE_4MAKE,$$(var)))) + +ifneq ($$(strip $$(_ALL_SRCS)),) + +_ENC_SRCS := $$(call ENCODE_4MAKE,$$(_ALL_SRCS)) + +_COMPILER_FLAGS := -id "$$(ENVENTOR_SHARED_RES_PATH)/images" +_COMPILER_FLAGS += -sd "$$(ENVENTOR_SHARED_RES_PATH)/sounds" +_COMPILER_FLAGS += -fd "$$(ENVENTOR_SHARED_RES_PATH)/fonts" + +ifneq ($$(strip $$(_IMAGE_DIRS)),) +_COMPILER_FLAGS += $$(addprefix -id ,$$(_IMAGE_DIRS)) +endif +ifneq ($$(strip $$(_SOUND_DIRS)),) +_COMPILER_FLAGS += $$(addprefix -sd ,$$(_SOUND_DIRS)) +endif +ifneq ($$(strip $$(_FONT_DIRS)),) +_COMPILER_FLAGS += $$(addprefix -fd ,$$(_FONT_DIRS)) +endif + +$$(foreach var,$$(_ENC_SRCS),$$(eval $$(call EDJ_BUILD_PROC_RAW,$$(var),$$(_OUTPUT_DIR),$$(_COMPILER_FLAGS),$(6)))) + +endif # (_(strip _(_ALL_SRCS)),) + +endif # (_(strip _(_SRCS)),) + +endef diff --git a/examples/tizen-wearable/Build/build_po.mk b/examples/tizen-wearable/Build/build_po.mk new file mode 100644 index 0000000000..d88d71aa61 --- /dev/null +++ b/examples/tizen-wearable/Build/build_po.mk @@ -0,0 +1,64 @@ +# PO build script + + +_FUNC_PO2MO = $(patsubst %.po,$(2)/res/locale/%/LC_MESSAGES/$(3).mo,$(notdir $(1))) + + +# parameter : +# $(1) - C/C++ soruce file +# $(2) - output path +# $(3) - app name +CONVERT_ESC_PO_TO_MO = $(call CONVERT_4MAKE_TO_OUT,$(call _FUNC_PO2MO,$(1),$(2),$(3))) + + +# parameter : +# $(1) - encoded one C/C++ soruce file +# $(2) - output path +# $(3) - app name +# output : +# $(4) - output files list +define MO_BUILD_PROC_RAW +$(call CONVERT_ESC_PO_TO_MO,$(1),$(2),$(3)) : $(call DECODE_4MAKE,$(1)) + @echo ' Building file: $$<' + @echo ' Invoking: msgfmt String Formatter' + $$(call MAKEDIRS,$$(@D)) + $$(MSGFMT) -o "$$@" "$$<" + @echo ' Finished building: $$<' +$(4) += $(call CONVERT_ESC_PO_TO_MO,$(1),$(2),$(3)) +endef + + +# parameter : +# $(1) - output dir +# $(2) - src paths +# $(3) - app name +# output : +# $(4) - OBJS + +define MO_PROC_RAW + +_OUTPUT_DIR := $(1) +_SRCS := $(2) +_APPNAME := $(3) + +ifneq ($$(strip $$(_SRCS)),) + +_ENC_SRCS := $$(call ENCODE_4MAKE,$$(_SRCS)) + +_NORMAL_SRCS := $$(filter-out %*.po,$$(_ENC_SRCS)) +_WIDLCARD_SRCS := $$(filter %*.po,$$(_ENC_SRCS)) + +_ALL_SRCS := $$(call DECODE_4MAKE,$$(_NORMAL_SRCS)) \ + $$(foreach var,$$(_WIDLCARD_SRCS),$$(call FIND_FILES_4MAKE,$$(call DECODE_4MAKE,$$(var)))) + +ifneq ($$(strip $$(_ALL_SRCS)),) + +_ENC_SRCS := $$(call ENCODE_4MAKE,$$(_ALL_SRCS)) + +$$(foreach var,$$(_ENC_SRCS),$$(eval $$(call MO_BUILD_PROC_RAW,$$(var),$$(_OUTPUT_DIR),$$(_APPNAME),$(4)))) + +endif # (_(strip _(_ALL_SRCS)),) + +endif # (_(strip _(_SRCS)),) + +endef diff --git a/examples/tizen-wearable/Build/flags.mk b/examples/tizen-wearable/Build/flags.mk new file mode 100644 index 0000000000..c460fe651a --- /dev/null +++ b/examples/tizen-wearable/Build/flags.mk @@ -0,0 +1,27 @@ +# Add tools flags defines + +ifeq ($(strip $(BUILD_CONFIG)),Debug) +OPTIMIZATION_OP := -O0 +DEBUG_OP := -g3 -D_DEBUG +CPP_OPTIMIZATION_OP := -O0 +CPP_DEBUG_OP := -g3 -D_DEBUG +LINK_OP := +else +ifeq ($(strip $(BUILD_CONFIG)),Release) +OPTIMIZATION_OP := -O3 +DEBUG_OP := +CPP_OPTIMIZATION_OP := -O3 +CPP_DEBUG_OP := +LINK_OP := -s +endif +endif + +COMPILE_FLAGS = $(DEBUG_OP) $(OPTIMIZATION_OP) -Wall -c -fmessage-length=0 + +CPP_COMPILE_FLAGS = $(CPP_DEBUG_OP) $(CPP_OPTIMIZATION_OP) -Wall -p -pg -c -fmessage-length=0 + +LINK_FLAGS = -L"$(PROJ_PATH)/lib" -Wl,--no-undefined $(LINK_OP) + +AR_FLAGS = + +EDC_COMPILE_FLAGS = -id "$(PROJ_PATH)/edje/images" -sd "$(PROJ_PATH)/edje/sounds" -fd "$(PROJ_PATH)/edje/fonts" diff --git a/examples/tizen-wearable/Build/funcs.mk b/examples/tizen-wearable/Build/funcs.mk new file mode 100644 index 0000000000..8297d1800c --- /dev/null +++ b/examples/tizen-wearable/Build/funcs.mk @@ -0,0 +1,50 @@ + +BSLASH := \\# +NULL_CHAR := # +SPACE := \ # +COLON := :# +DOTDOT := ..# +SPACE_ESC := &sp;# +COLON_ESC := &co;# +SPACE_OUT := ~sp~# +COLON_OUT := ~co~# +DOTDOT_OUT := ~dtdt~# + +BSLASH2SLASH = $(subst $(BSLASH),/,$(1)) + +REMOVE_TAIL = $(patsubst %/,%,$(1)) + +#LOWER_CASE = $(shell echo translit($(1),[A-Z],[a-z])|$(M4)) +LOWER_CASE = $(shell echo $(1)|$(TR) [A-Z] [a-z]) + +#ifneq ($(findstring Windows,$(OS)),) +# ... +#endif + +FIND_FILES = $(shell $(FIND) $(1)/$(2) | $(SED) 's/^$(subst /,$(BSLASH)/,$(1))$(BSLASH)///') +FIND_FILES_ESC = $(shell $(FIND) $(1)/$(2) | $(SED) 's/^$(subst /,$(BSLASH)/,$(1))$(BSLASH)///' -e 's/:/$(BSLASH)&co;/g' -e 's/$(BSLASH) /$(BSLASH)&sp;/g') +FIND_FILES_4MAKE = $(shell $(FIND) $(1)/$(2) | $(SED) 's/^$(subst /,$(BSLASH)/,$(1))$(BSLASH)///') + +FIND_FILES_ABS = $(shell $(FIND) $(1)) +FIND_FILES_ABS_4MAKE = $(shell $(FIND) $(1) -e 's/$(BSLASH) /$(BSLASH)&sp;/g') +FIND_FILES_ABS_ESC = $(shell $(FIND) $(1) -e 's/:/$(BSLASH)&co;/g' -e 's/$(BSLASH) /$(BSLASH)&sp;/g') + +FIND_FILES_4MAKE = $(shell $(FIND) $(1) | $(SED) 's/ /\\\ /g') + +#ENCODE_ESC = $(shell echo $(1) | $(SED) -e 's/:/$(BSLASH)&co;/g' -e 's/$(BSLASH) /$(BSLASH)&sp;/g') +#DECODE_ESC = $(shell echo $(1) | $(SED) -e 's/$(BSLASH)&co;/:/g' -e 's/$(BSLASH)&sp;/$(BSLASH) / g') +ENCODE_ESC = $(subst $(SPACE),$(SPACE_ESC),$(subst $(COLON),$(COLON_ESC),$(1))) +DECODE_ESC = $(subst $(COLON_ESC),$(COLON),$(subst $(SPACE_ESC),$(SPACE),$(1))) +ENCODE_4MAKE = $(subst $(SPACE),$(SPACE_ESC),$(1)) +DECODE_4MAKE = $(subst $(SPACE_ESC),$(SPACE),$(1)) + +CONVERT_TO_OUT = $(subst $(DOTDOT),$(DOTDOT_OUT),$(subst $(COLON),$(COLON_OUT),$(subst $(SPACE),$(SPACE_OUT),$(1)))) +CONVERT_ESC_TO_OUT = $(subst $(DOTDOT),$(DOTDOT_OUT),$(subst $(COLON_ESC),$(COLON_OUT),$(subst $(SPACE_ESC),$(SPACE_OUT),$(1)))) +CONVERT_4MAKE_TO_OUT = $(subst $(DOTDOT),$(DOTDOT_OUT),$(subst $(COLON),$(COLON_OUT),$(subst $(SPACE_ESC),$(SPACE_OUT),$(1)))) + +PROC_NO_EXIST = $(if $(wildcard $(1)),,$(call $(2),$(1))) +define MAKEDIRS0 + @echo ' Building directory: $(1)' + @$(MKDIR) $(MKDIR_OP) $(subst $(BSLASH),/,$(1)) +endef +MAKEDIRS = $(call PROC_NO_EXIST,$(1),MAKEDIRS0) diff --git a/examples/tizen-wearable/Build/makefile b/examples/tizen-wearable/Build/makefile new file mode 100644 index 0000000000..9348c50a45 --- /dev/null +++ b/examples/tizen-wearable/Build/makefile @@ -0,0 +1,34 @@ +# +# Usege : make -f /Build/makefile -C +# + +BUILD_SCRIPT_VERSION := 1.1.0 + +.PHONY : app_version app_build app_clean build_version + + +all : app_build + +clean : app_clean + +version : build_version + +#PROJ_ROOT = . +BUILD_ROOT := $(PROJ_PATH)/Build# + +ifeq ($(MAKE_NAME),mingw32-make) +ifneq ($(SHELL),) +OPTIONS += --eval="SHELL=$(SHELL)" +endif +endif + +app_build : + @echo $(MAKE) -f "$(BUILD_ROOT)/makefile.mk" + @$(MAKE) -f "$(BUILD_ROOT)/makefile.mk" -C "$(PROJ_PATH)" $(OPTIONS) + +app_clean : + @$(MAKE) -f "$(BUILD_ROOT)/makefile.mk" -C "$(PROJ_PATH)" $(OPTIONS) clean + +build_version : + @echo makefile : $(BUILD_SCRIPT_VERSION) + @$(MAKE) -f "$(BUILD_ROOT)/makefile.mk" -C "$(PROJ_PATH)" $(OPTIONS) version diff --git a/examples/tizen-wearable/Build/makefile.mk b/examples/tizen-wearable/Build/makefile.mk new file mode 100644 index 0000000000..c95b4b40b4 --- /dev/null +++ b/examples/tizen-wearable/Build/makefile.mk @@ -0,0 +1,197 @@ +# +# Usege : make -f /Build/makefile -C +# + +BUILD_SCRIPT_VERSION := 1.2.3 + +.PHONY : app_version app_clean build_version + + +all : app_build + +clean : app_clean + +version : build_version + + +#PROJ_ROOT := $(call BSLASH2SLASH,$(PROJ_PATH)) +PROJ_ROOT := . +BUILD_ROOT := $(PROJ_ROOT)/Build + +include $(BUILD_ROOT)/basedef.mk + +include $(PROJ_ROOT)/project_def.prop +-include $(PROJ_ROOT)/build_def.prop + +include $(BUILD_ROOT)/funcs.mk + +-include $(BUILD_ROOT)/tooldef.mk +-include $(BUILD_ROOT)/flags.mk +-include $(BUILD_ROOT)/platform.mk + + +APPTYPE := $(type) + +OUTPUT_DIR := $(PROJ_ROOT)/$(BUILD_CONFIG) +OBJ_OUTPUT := $(OUTPUT_DIR)/objs + +LOWER_APPNAME := $(call LOWER_CASE,$(APPNAME)) +APPID2 := $(subst $(basename $(APPID)).,,$(APPID)) + +ifeq ($(strip $(APPTYPE)),app) +APPFILE := $(OUTPUT_DIR)/$(LOWER_APPNAME) +endif +ifeq ($(strip $(APPTYPE)),staticLib) +APPFILE := $(OUTPUT_DIR)/lib$(LOWER_APPNAME).a +endif +ifeq ($(strip $(APPTYPE)),sharedLib) +APPFILE := $(OUTPUT_DIR)/lib$(LOWER_APPNAME).so +endif + +ifneq ($(strip $(PLATFORM_INCS)),) +PLATFORM_INCS_FILE := $(OBJ_OUTPUT)/platform_incs_file.inc +endif + +include $(BUILD_ROOT)/build_c.mk + + +ifeq ($(strip $(APPTYPE)),app) +EXT_OP := -fPIE +endif +ifeq ($(strip $(APPTYPE)),staticLib) +EXT_OP := -fPIE +endif +ifeq ($(strip $(APPTYPE)),sharedLib) +EXT_OP := -fPIC +endif + +C_OPT := $(COMPILE_FLAGS) $(TC_COMPILER_MISC) $(RS_COMPILER_MISC) $(EXT_OP) --sysroot="$(SYSROOT)" -Werror-implicit-function-declaration $(M_OPT) +CPP_OPT := $(CPP_COMPILE_FLAGS) $(TC_COMPILER_MISC) $(RS_COMPILER_MISC) $(EXT_OP) --sysroot="$(SYSROOT)" -Werror-implicit-function-declaration $(M_OPT) +C_OPT_FILE := $(PLATFORM_INCS_FILE) + +OBJS := # + +# Global C/C++ +ifeq ($(strip $(USER_ROOT)),) +USER_ROOT := $(PROJ_ROOT) +endif +$(eval $(call C_PROC_RAW,$(OBJ_OUTPUT),$(USER_SRCS),$(USER_INC_DIRS),$(USER_INC_FILES),$(USER_DEFS),$(USER_UNDEFS),$(C_OPT),$(C_OPT_FILE),C,c,$(CC),OBJS)) +$(foreach ext,cpp cxx cc c++ C,$(eval $(call C_PROC_RAW,$(OBJ_OUTPUT),$(USER_SRCS),$(USER_INC_DIRS),$(USER_CPP_INC_FILES),$(USER_CPP_DEFS),$(USER_CPP_UNDEFS),$(CPP_OPT),$(C_OPT_FILE),C++,$(ext),$(CXX),OBJS))) + +# Individual C/C++ +ifneq ($(strip $(USER_EXT_C_KEYS)),) +$(foreach var,$(USER_EXT_C_KEYS),$(eval $(call C_PROC_RAW,$(OBJ_OUTPUT),$(USER_EXT_$(var)_SRCS),$(USER_EXT_$(var)_INC_DIRS),$(USER_EXT_$(var)_INC_FILES),$(USER_EXT_$(var)_DEFS),$(USER_EXT_$(var)_UNDEFS),$(C_OPT),$(C_OPT_FILE),C,c,$(CC),OBJS))) +$(foreach ext,cpp cxx cc c++ C,$(foreach var,$(USER_EXT_C_KEYS),$(eval $(call C_PROC_RAW,$(OBJ_OUTPUT),$(USER_EXT_$(var)_SRCS),$(USER_EXT_$(var)_INC_DIRS),$(USER_EXT_$(var)_CPP_INC_FILES),$(USER_EXT_$(var)_CPP_DEFS),$(USER_EXT_$(var)_CPP_UNDEFS),$(C_OPT),$(C_OPT_FILE),C++,$(ext),$(CXX),OBJS)))) +endif + + +ifneq ($(strip $(USER_LIB_DIRS)),) +_ENC_USER_LIB_DIRS := $(call ENCODE_4MAKE,$(USER_LIB_DIRS)) +_ENC_USER_LIB_DIRS := $(addprefix -L,$(_ENC_USER_LIB_DIRS)) +LIBPATHS := $(call DECODE_4MAKE,$(_ENC_USER_LIB_DIRS)) +endif + +LIBS += $(addprefix -l,$(USER_LIBS)) + +UOBJS += $(USER_OBJS) + +M_OPT = -MMD -MP -MF"$(@:%.o=%.d)" + +DEPS := $(OBJS:.o=.d) + +ifneq ($(strip $(DEPS)),) +-include $(PROJ_ROOT)/Build/$(DEPS) +endif + + +ifeq ($(strip $(APPTYPE)),app) +$(APPFILE) : $(OBJS) $(UOBJS) + @echo ' Building target: $@' + @echo ' Invoking: C/C++ Linker' + $(call MAKEDIRS,$(@D)) + $(CXX) -o $(APPFILE) $(OBJS) $(UOBJS) $(LIBPATHS) -Xlinker --as-needed $(LIBS) $(LINK_FLAGS) $(TC_LINKER_MISC) $(RS_LINKER_MISC) -pie -lpthread --sysroot="$(SYSROOT)" -Xlinker --version-script="$(PROJ_ROOT)/.exportMap" $(RS_LIB_PATHS) $(RS_LIBRARIES) -Xlinker -rpath="/opt/usr/apps/$(APPID)/lib" -Werror-implicit-function-declaration + @echo ' Finished building target: $@' +endif +ifeq ($(strip $(APPTYPE)),staticLib) +$(APPFILE) : $(OBJS) $(UOBJS) + @echo ' Building target: $@' + @echo ' Invoking: Archive utility' + $(call MAKEDIRS,$(@D)) + $(AR) -r $(APPFILE) $(OBJS) $(UOBJS) $(AR_FLAGS) + @echo ' Finished building target: $@' +endif +ifeq ($(strip $(APPTYPE)),sharedLib) +$(APPFILE) : $(OBJS) $(UOBJS) + @echo ' Building target: $@' + @echo ' Invoking: C/C++ Linker' + $(call MAKEDIRS,$(@D)) + $(CXX) -o $(APPFILE) $(OBJS) $(UOBJS) $(LIBPATHS) -Xlinker --as-needed $(LIBS) $(LINK_FLAGS) $(TC_LINKER_MISC) $(RS_LINKER_MISC) -shared -lpthread --sysroot="$(SYSROOT)" $(RS_LIB_PATHS) $(RS_LIBRARIES) + @echo ' Finished building target: $@' +endif + + +$(OBJ_OUTPUT) : + $(call MAKEDIRS,$@) + +$(OUTPUT_DIR) : + $(call MAKEDIRS,$@) + + +ifneq ($(strip $(PLATFORM_INCS)),) +$(PLATFORM_INCS_FILE) : $(OBJ_OUTPUT) + @echo ' Building inc file: $@' +ifneq ($(findstring Windows,$(OS)),) +ifneq ($(findstring 3.82,$(MAKE_VERSION)),) + $(file > $@,$(PLATFORM_INCS)) +else + @echo $(PLATFORM_INCS) > $@ +endif +else + @echo $(PLATFORM_INCS) > $@ +endif +endif + + +include $(BUILD_ROOT)/build_edc.mk + +#ifeq ($(strip $(ENVENTOR_SHARED_RES_PATH)),) +ENVENTOR_SHARED_RES_PATH ?= $(ENVENTOR_PATH)/share/enventor +#endif + +EDJ_FILES := + +# Global EDCs +ifneq ($(strip $(USER_EDCS)),) +$(eval $(call EDJ_PROC_RAW,$(OUTPUT_DIR),$(USER_EDCS),$(USER_EDCS_IMAGE_DIRS),$(USER_EDCS_SOUND_DIRS),$(USER_EDCS_FONT_DIRS),EDJ_FILES)) +endif + +# Individual EDCs +ifneq ($(strip $(USER_EXT_EDC_KEYS)),) +$(foreach var,$(USER_EXT_EDC_KEYS),$(eval $(call EDJ_PROC_RAW,$(OUTPUT_DIR),$(USER_EXT_$(var)_EDCS),$(USER_EXT_$(var)_EDCS_IMAGE_DIRS),$(USER_EXT_$(var)_EDCS_SOUND_DIRS),$(USER_EXT_$(var)_EDCS_FONT_DIRS),EDJ_FILES))) +endif + + +include $(BUILD_ROOT)/build_po.mk + +MO_FILES := + +# Global POs +ifneq ($(strip $(USER_POS)),) +$(eval $(call MO_PROC_RAW,$(OUTPUT_DIR),$(USER_POS),$(APPID2),MO_FILES)) +endif + + +secondary-outputs : $(EDJ_FILES) $(MO_FILES) + +-include appendix.mk + +app_build : $(OUTPUT_DIR) $(APPFILE) secondary-outputs + @echo ========= done ========= + + +app_clean : + rm -f $(APPFILE) + rm -rf $(OUTPUT_DIR) + +build_version : + @echo makefile.mk : $(BUILD_SCRIPT_VERSION) diff --git a/examples/tizen-wearable/Build/platform.mk b/examples/tizen-wearable/Build/platform.mk new file mode 100644 index 0000000000..294a38aee2 --- /dev/null +++ b/examples/tizen-wearable/Build/platform.mk @@ -0,0 +1,15 @@ +# Add inputs and outputs from these tool invocations to the build variables + +SYSROOT = $(SBI_SYSROOT) + +USR_INCS := $(addprefix -I $(SYSROOT),$(PLATFORM_INCS_EX)) + +ifeq ($(strip $(PLATFORM_LIB_PATHS)),) +RS_LIB_PATHS := "$(SYSROOT)/usr/lib" +else +RS_LIB_PATHS := $(addprefix -L$(SYSROOT),$(PLATFORM_LIB_PATHS)) +endif + +RS_LIBRARIES := $(addprefix -l,$(RS_LIBRARIES_EX)) + +PLATFORM_INCS = $(USR_INCS) -I"$(SDK_PATH)/library" diff --git a/examples/tizen-wearable/Build/tooldef.mk b/examples/tizen-wearable/Build/tooldef.mk new file mode 100644 index 0000000000..fded35b84f --- /dev/null +++ b/examples/tizen-wearable/Build/tooldef.mk @@ -0,0 +1,63 @@ +# Add inputs and outputs from these tool invocations to the build variables + +ifneq ($(strip $(SHELL_BIN)),) +SHELL = $(SHELL_BIN) +else +SHELL = sh +endif + +ifneq ($(strip $(MKDIR_BIN)),) +MKDIR = $(MKDIR_BIN) +MKDIR_OP = -p +else +MKDIR = mkdir +MKDIR_OP = -p +endif + +ifneq ($(strip $(UNAME_BIN)),) +UNAME = $(UNAME_BIN) +else +UNAME = uname +endif + +ifneq ($(strip $(M4_BIN)),) +M4 = $(M4_BIN) +else +M4 = m4 +endif + +ifneq ($(strip $(TR_BIN)),) +TR = $(TR_BIN) +else +TR = tr +endif + +ifneq ($(strip $(FIND_BIN)),) +FIND = $(FIND_BIN) +else +FIND = find +endif + +ifneq ($(strip $(SED_BIN)),) +SED = $(SED_BIN) +else +SED = sed +endif + +ifneq ($(strip $(GREP_BIN)),) +GREP = $(GREP_BIN) +else +GREP = grep +endif + +ifneq ($(strip $(EDJE_CC_BIN)),) +EDJE_CC = $(EDJE_CC_BIN) +else +EDJE_CC = edje_cc +endif + +ifneq ($(strip $(MSGFMT_BIN)),) +MSGFMT = $(MSGFMT_BIN) +else +MSGFMT = msgfmt +endif diff --git a/examples/tizen-wearable/inc/mywearableapp.h b/examples/tizen-wearable/inc/mywearableapp.h new file mode 100644 index 0000000000..8f531d6c31 --- /dev/null +++ b/examples/tizen-wearable/inc/mywearableapp.h @@ -0,0 +1,19 @@ +#ifndef __mywearableapp_H__ +#define __mywearableapp_H__ + +#include +#include +#include +#include +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "mywearableapp" + +#if !defined(PACKAGE) +#define PACKAGE "org.example.mywearableapp" +#endif + +#endif /* __mywearableapp_H__ */ diff --git a/examples/tizen-wearable/project_def.prop b/examples/tizen-wearable/project_def.prop new file mode 100644 index 0000000000..1716300a3d --- /dev/null +++ b/examples/tizen-wearable/project_def.prop @@ -0,0 +1,11 @@ +APPNAME = mywearableapp + +type = app +profile = wearable-2.3.2 + +USER_SRCS = src/mywearableapp.c +USER_DEFS = +USER_INC_DIRS = inc +USER_OBJS = +USER_LIBS = +USER_EDCS = diff --git a/examples/tizen-wearable/shared/res/mywearableapp.png b/examples/tizen-wearable/shared/res/mywearableapp.png new file mode 100644 index 0000000000..6ed97333f3 Binary files /dev/null and b/examples/tizen-wearable/shared/res/mywearableapp.png differ diff --git a/examples/tizen-wearable/src/mywearableapp.c b/examples/tizen-wearable/src/mywearableapp.c new file mode 100644 index 0000000000..349d4c4be7 --- /dev/null +++ b/examples/tizen-wearable/src/mywearableapp.c @@ -0,0 +1,158 @@ +#include "mywearableapp.h" + +typedef struct appdata { + Evas_Object *win; + Evas_Object *conform; + Evas_Object *label; +} appdata_s; + +static void +win_delete_request_cb(void *data, Evas_Object *obj, void *event_info) +{ + ui_app_exit(); +} + +static void +win_back_cb(void *data, Evas_Object *obj, void *event_info) +{ + appdata_s *ad = data; + /* Let window go to hide state. */ + elm_win_lower(ad->win); +} + +static void +create_base_gui(appdata_s *ad) +{ + /* Window */ + ad->win = elm_win_util_standard_add(PACKAGE, PACKAGE); + elm_win_autodel_set(ad->win, EINA_TRUE); + + if (elm_win_wm_rotation_supported_get(ad->win)) { + int rots[4] = { 0, 90, 180, 270 }; + elm_win_wm_rotation_available_rotations_set(ad->win, (const int *)(&rots), 4); + } + + evas_object_smart_callback_add(ad->win, "delete,request", win_delete_request_cb, NULL); + eext_object_event_callback_add(ad->win, EEXT_CALLBACK_BACK, win_back_cb, ad); + + /* Conformant */ + ad->conform = elm_conformant_add(ad->win); + elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_SHOW); + elm_win_indicator_opacity_set(ad->win, ELM_WIN_INDICATOR_OPAQUE); + evas_object_size_hint_weight_set(ad->conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(ad->win, ad->conform); + evas_object_show(ad->conform); + + /* Label */ + ad->label = elm_label_add(ad->conform); + elm_object_text_set(ad->label, "Hello Tizen"); + evas_object_size_hint_weight_set(ad->label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_object_content_set(ad->conform, ad->label); + + /* Show window after base gui is set up */ + evas_object_show(ad->win); +} + +static bool +app_create(void *data) +{ + /* Hook to take necessary actions before main event loop starts + Initialize UI resources and application's data + If this function returns true, the main loop of application starts + If this function returns false, the application is terminated */ + appdata_s *ad = data; + + create_base_gui(ad); + + return true; +} + +static void +app_control(app_control_h app_control, void *data) +{ + /* Handle the launch request. */ +} + +static void +app_pause(void *data) +{ + /* Take necessary actions when application becomes invisible. */ +} + +static void +app_resume(void *data) +{ + /* Take necessary actions when application becomes visible. */ +} + +static void +app_terminate(void *data) +{ + /* Release all resources. */ +} + +static void +ui_app_lang_changed(app_event_info_h event_info, void *user_data) +{ + /*APP_EVENT_LANGUAGE_CHANGED*/ + char *locale = NULL; + system_settings_get_value_string(SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale); + elm_language_set(locale); + free(locale); + return; +} + +static void +ui_app_orient_changed(app_event_info_h event_info, void *user_data) +{ + /*APP_EVENT_DEVICE_ORIENTATION_CHANGED*/ + return; +} + +static void +ui_app_region_changed(app_event_info_h event_info, void *user_data) +{ + /*APP_EVENT_REGION_FORMAT_CHANGED*/ +} + +static void +ui_app_low_battery(app_event_info_h event_info, void *user_data) +{ + /*APP_EVENT_LOW_BATTERY*/ +} + +static void +ui_app_low_memory(app_event_info_h event_info, void *user_data) +{ + /*APP_EVENT_LOW_MEMORY*/ +} + +int +main(int argc, char *argv[]) +{ + appdata_s ad = {0,}; + int ret = 0; + + ui_app_lifecycle_callback_s event_callback = {0,}; + app_event_handler_h handlers[5] = {NULL, }; + + event_callback.create = app_create; + event_callback.terminate = app_terminate; + event_callback.pause = app_pause; + event_callback.resume = app_resume; + event_callback.app_control = app_control; + + ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, ui_app_low_battery, &ad); + ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, ui_app_low_memory, &ad); + ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, ui_app_orient_changed, &ad); + ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, ui_app_lang_changed, &ad); + ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, ui_app_region_changed, &ad); + ui_app_remove_event_handler(handlers[APP_EVENT_LOW_MEMORY]); + + ret = ui_app_main(argc, argv, &event_callback, &ad); + if (ret != APP_ERROR_NONE) { + dlog_print(DLOG_ERROR, LOG_TAG, "app_main() is failed. err = %d", ret); + } + + return ret; +} diff --git a/examples/tizen-wearable/tizen-manifest.xml b/examples/tizen-wearable/tizen-manifest.xml new file mode 100644 index 0000000000..357b165a00 --- /dev/null +++ b/examples/tizen-wearable/tizen-manifest.xml @@ -0,0 +1,8 @@ + + + + + mywearableapp.png + + + diff --git a/extlibs/libs-tizen/mobile/device/libFLAC++.a b/extlibs/libs-tizen/mobile/device/libFLAC++.a new file mode 100644 index 0000000000..c64f589e29 Binary files /dev/null and b/extlibs/libs-tizen/mobile/device/libFLAC++.a differ diff --git a/extlibs/libs-tizen/mobile/device/libFLAC.a b/extlibs/libs-tizen/mobile/device/libFLAC.a new file mode 100644 index 0000000000..dd9c337547 Binary files /dev/null and b/extlibs/libs-tizen/mobile/device/libFLAC.a differ diff --git a/extlibs/libs-tizen/mobile/device/libjpeg.a b/extlibs/libs-tizen/mobile/device/libjpeg.a new file mode 100644 index 0000000000..457aba8cb2 Binary files /dev/null and b/extlibs/libs-tizen/mobile/device/libjpeg.a differ diff --git a/extlibs/libs-tizen/mobile/device/libogg.a b/extlibs/libs-tizen/mobile/device/libogg.a new file mode 100644 index 0000000000..95581a93f3 Binary files /dev/null and b/extlibs/libs-tizen/mobile/device/libogg.a differ diff --git a/extlibs/libs-tizen/mobile/device/libvorbis.a b/extlibs/libs-tizen/mobile/device/libvorbis.a new file mode 100644 index 0000000000..7a77d71a85 Binary files /dev/null and b/extlibs/libs-tizen/mobile/device/libvorbis.a differ diff --git a/extlibs/libs-tizen/mobile/device/libvorbisenc.a b/extlibs/libs-tizen/mobile/device/libvorbisenc.a new file mode 100644 index 0000000000..3b01b06085 Binary files /dev/null and b/extlibs/libs-tizen/mobile/device/libvorbisenc.a differ diff --git a/extlibs/libs-tizen/mobile/device/libvorbisfile.a b/extlibs/libs-tizen/mobile/device/libvorbisfile.a new file mode 100644 index 0000000000..c544df2e7b Binary files /dev/null and b/extlibs/libs-tizen/mobile/device/libvorbisfile.a differ diff --git a/extlibs/libs-tizen/mobile/emulator/libFLAC++.a b/extlibs/libs-tizen/mobile/emulator/libFLAC++.a new file mode 100644 index 0000000000..bf8bbc3cf2 Binary files /dev/null and b/extlibs/libs-tizen/mobile/emulator/libFLAC++.a differ diff --git a/extlibs/libs-tizen/mobile/emulator/libFLAC.a b/extlibs/libs-tizen/mobile/emulator/libFLAC.a new file mode 100644 index 0000000000..c3bb2194e0 Binary files /dev/null and b/extlibs/libs-tizen/mobile/emulator/libFLAC.a differ diff --git a/extlibs/libs-tizen/mobile/emulator/libjpeg.a b/extlibs/libs-tizen/mobile/emulator/libjpeg.a new file mode 100644 index 0000000000..2a6483e4f0 Binary files /dev/null and b/extlibs/libs-tizen/mobile/emulator/libjpeg.a differ diff --git a/extlibs/libs-tizen/mobile/emulator/libogg.a b/extlibs/libs-tizen/mobile/emulator/libogg.a new file mode 100644 index 0000000000..e0305fb82e Binary files /dev/null and b/extlibs/libs-tizen/mobile/emulator/libogg.a differ diff --git a/extlibs/libs-tizen/mobile/emulator/libvorbis.a b/extlibs/libs-tizen/mobile/emulator/libvorbis.a new file mode 100644 index 0000000000..95c941c3c4 Binary files /dev/null and b/extlibs/libs-tizen/mobile/emulator/libvorbis.a differ diff --git a/extlibs/libs-tizen/mobile/emulator/libvorbisenc.a b/extlibs/libs-tizen/mobile/emulator/libvorbisenc.a new file mode 100644 index 0000000000..8da3202e65 Binary files /dev/null and b/extlibs/libs-tizen/mobile/emulator/libvorbisenc.a differ diff --git a/extlibs/libs-tizen/mobile/emulator/libvorbisfile.a b/extlibs/libs-tizen/mobile/emulator/libvorbisfile.a new file mode 100644 index 0000000000..8b2b01afba Binary files /dev/null and b/extlibs/libs-tizen/mobile/emulator/libvorbisfile.a differ diff --git a/extlibs/libs-tizen/wearable/device/libFLAC++.a b/extlibs/libs-tizen/wearable/device/libFLAC++.a new file mode 100644 index 0000000000..c64f589e29 Binary files /dev/null and b/extlibs/libs-tizen/wearable/device/libFLAC++.a differ diff --git a/extlibs/libs-tizen/wearable/device/libFLAC.a b/extlibs/libs-tizen/wearable/device/libFLAC.a new file mode 100644 index 0000000000..dd9c337547 Binary files /dev/null and b/extlibs/libs-tizen/wearable/device/libFLAC.a differ diff --git a/extlibs/libs-tizen/wearable/device/libjpeg.a b/extlibs/libs-tizen/wearable/device/libjpeg.a new file mode 100644 index 0000000000..a69d284288 Binary files /dev/null and b/extlibs/libs-tizen/wearable/device/libjpeg.a differ diff --git a/extlibs/libs-tizen/wearable/device/libogg.a b/extlibs/libs-tizen/wearable/device/libogg.a new file mode 100644 index 0000000000..95581a93f3 Binary files /dev/null and b/extlibs/libs-tizen/wearable/device/libogg.a differ diff --git a/extlibs/libs-tizen/wearable/device/libvorbis.a b/extlibs/libs-tizen/wearable/device/libvorbis.a new file mode 100644 index 0000000000..cdc7e34c1b Binary files /dev/null and b/extlibs/libs-tizen/wearable/device/libvorbis.a differ diff --git a/extlibs/libs-tizen/wearable/device/libvorbisenc.a b/extlibs/libs-tizen/wearable/device/libvorbisenc.a new file mode 100644 index 0000000000..3b01b06085 Binary files /dev/null and b/extlibs/libs-tizen/wearable/device/libvorbisenc.a differ diff --git a/extlibs/libs-tizen/wearable/device/libvorbisfile.a b/extlibs/libs-tizen/wearable/device/libvorbisfile.a new file mode 100644 index 0000000000..c544df2e7b Binary files /dev/null and b/extlibs/libs-tizen/wearable/device/libvorbisfile.a differ diff --git a/extlibs/libs-tizen/wearable/emulator/libFLAC++.a b/extlibs/libs-tizen/wearable/emulator/libFLAC++.a new file mode 100644 index 0000000000..bf8bbc3cf2 Binary files /dev/null and b/extlibs/libs-tizen/wearable/emulator/libFLAC++.a differ diff --git a/extlibs/libs-tizen/wearable/emulator/libFLAC.a b/extlibs/libs-tizen/wearable/emulator/libFLAC.a new file mode 100644 index 0000000000..c9fd9c8f43 Binary files /dev/null and b/extlibs/libs-tizen/wearable/emulator/libFLAC.a differ diff --git a/extlibs/libs-tizen/wearable/emulator/libjpeg.a b/extlibs/libs-tizen/wearable/emulator/libjpeg.a new file mode 100644 index 0000000000..6064dc5254 Binary files /dev/null and b/extlibs/libs-tizen/wearable/emulator/libjpeg.a differ diff --git a/extlibs/libs-tizen/wearable/emulator/libogg.a b/extlibs/libs-tizen/wearable/emulator/libogg.a new file mode 100644 index 0000000000..e0305fb82e Binary files /dev/null and b/extlibs/libs-tizen/wearable/emulator/libogg.a differ diff --git a/extlibs/libs-tizen/wearable/emulator/libvorbis.a b/extlibs/libs-tizen/wearable/emulator/libvorbis.a new file mode 100644 index 0000000000..a710e9dec0 Binary files /dev/null and b/extlibs/libs-tizen/wearable/emulator/libvorbis.a differ diff --git a/extlibs/libs-tizen/wearable/emulator/libvorbisenc.a b/extlibs/libs-tizen/wearable/emulator/libvorbisenc.a new file mode 100644 index 0000000000..8da3202e65 Binary files /dev/null and b/extlibs/libs-tizen/wearable/emulator/libvorbisenc.a differ diff --git a/extlibs/libs-tizen/wearable/emulator/libvorbisfile.a b/extlibs/libs-tizen/wearable/emulator/libvorbisfile.a new file mode 100644 index 0000000000..8b2b01afba Binary files /dev/null and b/extlibs/libs-tizen/wearable/emulator/libvorbisfile.a differ diff --git a/include/SFML/Config.hpp b/include/SFML/Config.hpp index 497ef67f9d..7d24d19730 100644 --- a/include/SFML/Config.hpp +++ b/include/SFML/Config.hpp @@ -76,6 +76,11 @@ // Android #define SFML_SYSTEM_ANDROID + #elif defined(__TIZEN__) + + // Tizen + #define SFML_SYSTEM_TIZEN + #elif defined(__linux__) // Linux diff --git a/include/SFML/Main.hpp b/include/SFML/Main.hpp index d61b82e5e8..7567bec5ec 100644 --- a/include/SFML/Main.hpp +++ b/include/SFML/Main.hpp @@ -31,9 +31,9 @@ #include -#if defined(SFML_SYSTEM_IOS) +#if defined(SFML_SYSTEM_IOS) || defined(SFML_SYSTEM_TIZEN) - // On iOS, we have no choice but to have our own main, + // On iOS and Tizen, we have no choice but to have our own main, // so we need to rename the user one and call it later #define main sfmlMain diff --git a/include/SFML/OpenGL.hpp b/include/SFML/OpenGL.hpp index 245d9769db..f6276fe649 100644 --- a/include/SFML/OpenGL.hpp +++ b/include/SFML/OpenGL.hpp @@ -67,10 +67,15 @@ #include #include - + // We're not using OpenGL ES 2+ yet, but we can use the sRGB extension #include +#elif defined (SFML_SYSTEM_TIZEN) + + #include + EVAS_GL_GLOBAL_GLES1_DECLARE(); + #endif diff --git a/include/SFML/Window/WindowHandle.hpp b/include/SFML/Window/WindowHandle.hpp index c8b0149de8..44379ead2e 100644 --- a/include/SFML/Window/WindowHandle.hpp +++ b/include/SFML/Window/WindowHandle.hpp @@ -62,6 +62,11 @@ namespace sf // Window handle is ANativeWindow* (void*) on Android typedef void* WindowHandle; +#elif defined(SFML_SYSTEM_TIZEN) + + // Window handle is Evas_Object* (void*) on Tizen + typedef void* WindowHandle; + #elif defined(SFML_DOXYGEN) // Define typedef symbol so that Doxygen can attach some documentation to it @@ -88,6 +93,7 @@ namespace sf /// Mac OS X | either \p NSWindow* or \p NSView*, disguised as \p void* /// iOS | \p UIWindow* /// Android | \p ANativeWindow* +/// Tizen | \p Evas_Object* /// /// \par Mac OS X Specification /// diff --git a/src/SFML/Audio/CMakeLists.txt b/src/SFML/Audio/CMakeLists.txt index e375057ece..bd0487deda 100644 --- a/src/SFML/Audio/CMakeLists.txt +++ b/src/SFML/Audio/CMakeLists.txt @@ -66,14 +66,18 @@ elseif(SFML_OS_ANDROID) endif() # find external libraries -if(NOT SFML_OS_ANDROID) +if(NOT (SFML_OS_ANDROID OR SFML_OS_TIZEN)) if(NOT SFML_OS_IOS) find_package(OpenAL REQUIRED) endif() find_package(Vorbis REQUIRED) find_package(FLAC REQUIRED) else() - find_host_package(OpenAL REQUIRED) + if(SFML_OS_ANDROID) + find_host_package(OpenAL REQUIRED) + elseif(SFML_OS_TIZEN) + find_package(OpenAL REQUIRED) + endif() find_host_package(Vorbis REQUIRED) find_host_package(FLAC REQUIRED) endif() diff --git a/src/SFML/CMakeLists.txt b/src/SFML/CMakeLists.txt index 8eb334d95f..b43f20a18a 100644 --- a/src/SFML/CMakeLists.txt +++ b/src/SFML/CMakeLists.txt @@ -37,6 +37,13 @@ elseif(SFML_OS_IOS) elseif(SFML_OS_ANDROID) set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/extlibs/headers") set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/libs-android/${ANDROID_ABI}") +elseif(SFML_OS_TIZEN) + # split device type and version (mobile-x.y.z) and retrieve device type + string(REPLACE "-" ";" DEVICE_LIST ${TIZEN_DEVICE}) + list(GET DEVICE_LIST 0 DEVICE_TYPE) + + set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/extlibs/headers") + set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${PROJECT_SOURCE_DIR}/extlibs/libs-tizen/${DEVICE_TYPE}/${TIZEN_TARGET}") endif() # add the SFML sources path @@ -50,7 +57,7 @@ set(LIBRARY_OUTPUT_PATH "${PROJECT_BINARY_DIR}/lib") # add the modules subdirectories add_subdirectory(System) -if(SFML_OS_WINDOWS OR SFML_OS_ANDROID OR SFML_OS_IOS) +if(SFML_OS_WINDOWS OR SFML_OS_ANDROID OR SFML_OS_IOS OR SFML_OS_TIZEN) add_subdirectory(Main) endif() add_subdirectory(Window) diff --git a/src/SFML/Graphics/CMakeLists.txt b/src/SFML/Graphics/CMakeLists.txt index 57dfa80d58..cb4e555947 100644 --- a/src/SFML/Graphics/CMakeLists.txt +++ b/src/SFML/Graphics/CMakeLists.txt @@ -103,6 +103,8 @@ elseif(SFML_OS_IOS) elseif(SFML_OS_ANDROID) set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/extlibs/headers/jpeg") set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/extlibs/headers/freetype2") +elseif(SFML_OS_TIZEN) + set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${PROJECT_SOURCE_DIR}/extlibs/headers/jpeg") endif() # find external libraries @@ -121,6 +123,9 @@ endif() if(SFML_OS_ANDROID) find_host_package(JPEG REQUIRED) find_host_package(Freetype REQUIRED) +elseif(SFML_OS_TIZEN) + find_host_package(JPEG REQUIRED) + find_package(Freetype REQUIRED) else() find_package(JPEG REQUIRED) find_package(Freetype REQUIRED) diff --git a/src/SFML/Main/CMakeLists.txt b/src/SFML/Main/CMakeLists.txt index d18ee40950..c18d73d352 100644 --- a/src/SFML/Main/CMakeLists.txt +++ b/src/SFML/Main/CMakeLists.txt @@ -9,6 +9,8 @@ elseif(SFML_OS_IOS) set(SRC ${SRC} ${SRCROOT}/MainiOS.mm) elseif(SFML_OS_ANDROID) set(SRC ${SRC} ${SRCROOT}/MainAndroid.cpp) +elseif(SFML_OS_TIZEN) + set(SRC ${SRC} ${SRCROOT}/MainTizen.cpp) else() return() endif() diff --git a/src/SFML/Main/MainTizen.cpp b/src/SFML/Main/MainTizen.cpp new file mode 100644 index 0000000000..942d3f8387 --- /dev/null +++ b/src/SFML/Main/MainTizen.cpp @@ -0,0 +1,245 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2016 Jonathan De Wachter (dewachter.jonathan@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////// +// Tizen specific: SFML needs to hook the main function, to +// launch the application (event loop), and then call the +// user main from inside it. +// +// Our strategy is to rename the user main to 'sfmlMain' with +// a macro (see Main.hpp), and call this modified main ourselves. +// +//////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +EVAS_GL_GLOBAL_GLES1_DECLARE(); + +extern int sfmlMain(int argc, char *argv[]); + +//////////////////////////////////////////////////////////// +void onWindowResized(void* data, Evas* event, Evas_Object* window, void* event_info); + +//////////////////////////////////////////////////////////// +void userMain() +{ + // Cancel out the user main arguments + sfmlMain(0, NULL); +} + +//////////////////////////////////////////////////////////// +bool onAppCreated(void* data) +{ + // Retrieve the application state, no need to lock, the user main + // isn't launched yet + sf::priv::ApplicationState* state = static_cast(data); + + // Indicate the underlying backend to use + elm_config_accel_preference_set("opengl"); // Since 2.3.1, investigate "opengl:depth24:stencil8:msaa_high" + + // Create and setup the window + state->window = elm_win_util_standard_add("SFML", "UI Template"); + + elm_win_conformant_set(state->window, EINA_TRUE); + elm_win_indicator_mode_set(state->window, ELM_WIN_INDICATOR_SHOW); + elm_win_indicator_opacity_set(state->window, ELM_WIN_INDICATOR_TRANSPARENT); + + evas_object_show(state->window); + + // We can now register our event callbacks (later, investigate AXIS_UPDATE, etc) + evas_object_event_callback_add(state->window, EVAS_CALLBACK_RESIZE, onWindowResized, state); + + // Create a conform attached to the window and in which the image resides + state->conform = elm_conformant_add(state->window); + evas_object_size_hint_weight_set(state->conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(state->window, state->conform); + + evas_object_show(state->conform); + + // Get the initial window size (should be 1x1) + Evas_Coord width, height; + evas_object_geometry_get(state->window, NULL, NULL, &width, &height); + + if (!(width == 1 && height == 1)) + sf::err() << "Expected initial window to be of size 1x1" << std::endl; + + // Initialize Evas GL and create shared context and surface (apparently, + // that must be done in the main thread) + state->evasgl = evas_gl_new(evas_object_evas_get(state->window)); + + Evas_GL_Config* config = evas_gl_config_new(); + + config->color_format = EVAS_GL_RGBA_8888; + config->depth_bits = EVAS_GL_DEPTH_NONE; + config->stencil_bits = EVAS_GL_STENCIL_NONE; + config->multisample_bits = EVAS_GL_MULTISAMPLE_NONE; + config->options_bits = EVAS_GL_OPTIONS_NONE; + + state->sharedSurface = evas_gl_surface_create(state->evasgl, config, width, height); + state->sharedContext = evas_gl_context_version_create(state->evasgl, NULL, EVAS_GL_GLES_1_X); + + evas_gl_make_current(state->evasgl, state->sharedSurface, state->sharedContext); + EVAS_GL_GLOBAL_GLES1_USE(state->evasgl, state->sharedContext); + + evas_gl_config_free(config); + + // Detect early Evas GL errors before launching main thread + int errorCode = evas_gl_error_get(state->evasgl); + + if (errorCode != EVAS_GL_SUCCESS) + sf::err() << "Ran into early Evas GL errors; expect errors in subsequent code" << std::endl; + + // Launch the user main in a thread + sf::Thread* thread = new sf::Thread(userMain); + thread->launch(); + + // Wait until the user window grabs the underlying window and the + // Evas context is created + state->mutex.lock(); + + while (!state->initialized) + { + state->mutex.unlock(); + sf::sleep(sf::seconds(0.001)); + state->mutex.lock(); + } + + state->mutex.unlock(); + + return true; +} + +//////////////////////////////////////////////////////////// +void onAppPaused(void* data) +{ + // The application is now invisible, send sf::Event::LostFocus to + // the user main loop + sf::priv::ApplicationState* state = static_cast(data); + sf::Lock lock(state->mutex); + + assert(state->sendPauseEvent); + state->sendPauseEvent(); +} + +//////////////////////////////////////////////////////////// +void onAppResumed(void* data) +{ + // The application is now visible, send sf::Event::GainedFocus the + // user main loop + sf::priv::ApplicationState* state = static_cast(data); + sf::Lock lock(state->mutex); + + assert(state->sendResumeEvent); + state->sendResumeEvent(); +} + +//////////////////////////////////////////////////////////// +void onAppTerminated(void* data) +{ + // The application is requested to terminate, send sf::Event::Closed + // to the user main loop + sf::priv::ApplicationState* state = static_cast(data); + sf::Lock lock(state->mutex); + + assert(state->sendTerminateEvent); + state->sendTerminateEvent(); +} + +//////////////////////////////////////////////////////////// +void onWindowResized(void* data, Evas* event, Evas_Object* window, void* event_info) +{ + // The application was resized, send sf::Event::Resized to the user + // main loop + sf::priv::ApplicationState* state = static_cast(data); + + // Retrieve new window size + Evas_Coord width, height; + evas_object_geometry_get(window, NULL, NULL, &width, &height); + + // Send resize event and wait until it's handled (the Evas GL surface + // is recreated) + state->mutex.lock(); + + state->resizeHandled = false; + state->sendResizeEvent(width, height); + + while (!state->resizeHandled) + { + state->mutex.unlock(); + sf::sleep(sf::seconds(0.001)); + state->mutex.lock(); + } + + state->mutex.unlock(); +} + +//////////////////////////////////////////////////////////// +int main(int argc, char** argv) +{ + // Create the application state (will bridge the main loop and + // the user main loop) + sf::priv::ApplicationState* state = new sf::priv::ApplicationState; + + // Initialize the application state values + state->window = NULL; + state->conform = NULL; + state->evasgl = NULL; + state->sharedContext = NULL; + state->sharedSurface = NULL; + state->initialized = false; + state->resizeHandled = false; + state->context = NULL; + + // Share the application state across SFML modules + sf::priv::getApplicationState(state, true); + + // Redirect error messages to system logs + sf::err().rdbuf(&state->logs); + + // Register life cycle event callbacks + ui_app_lifecycle_callback_s eventCallback = {0,}; + + eventCallback.create = onAppCreated; + eventCallback.terminate = onAppTerminated; + eventCallback.pause = onAppPaused; + eventCallback.resume = onAppResumed; + eventCallback.app_control = NULL; + + // Run the main loop + return ui_app_main(argc, argv, &eventCallback, state); +} diff --git a/src/SFML/Window/CMakeLists.txt b/src/SFML/Window/CMakeLists.txt index a887766e51..0b52c5d224 100644 --- a/src/SFML/Window/CMakeLists.txt +++ b/src/SFML/Window/CMakeLists.txt @@ -40,7 +40,7 @@ set(SRC ${SRCROOT}/WindowImpl.hpp ${INCROOT}/WindowStyle.hpp ) -if(SFML_OPENGL_ES AND NOT SFML_OS_IOS) +if(SFML_OPENGL_ES AND NOT (SFML_OS_IOS OR SFML_OS_TIZEN)) list(APPEND SRC ${SRCROOT}/EGLCheck.cpp) list(APPEND SRC ${SRCROOT}/EGLCheck.hpp) list(APPEND SRC ${SRCROOT}/EglContext.cpp) @@ -190,6 +190,27 @@ elseif(SFML_OS_ANDROID) ${SRCROOT}/Android/SensorImpl.cpp ) source_group("android" FILES ${PLATFORM_SRC}) +elseif(SFML_OS_TIZEN) + set(PLATFORM_SRC + ${SRCROOT}/Tizen/LogStream.hpp + ${SRCROOT}/Tizen/LogStream.cpp + ${SRCROOT}/Tizen/ApplicationState.hpp + ${SRCROOT}/Tizen/ApplicationState.cpp + ${SRCROOT}/Tizen/EvasCheck.hpp + ${SRCROOT}/Tizen/EvasCheck.cpp + ${SRCROOT}/Tizen/EvasContext.hpp + ${SRCROOT}/Tizen/EvasContext.cpp + ${SRCROOT}/Tizen/WindowImplTizen.hpp + ${SRCROOT}/Tizen/WindowImplTizen.cpp + ${SRCROOT}/Tizen/VideoModeImpl.cpp + ${SRCROOT}/Tizen/InputImpl.hpp + ${SRCROOT}/Tizen/InputImpl.cpp + ${SRCROOT}/Tizen/JoystickImpl.hpp + ${SRCROOT}/Tizen/JoystickImpl.cpp + ${SRCROOT}/Tizen/SensorImpl.hpp + ${SRCROOT}/Tizen/SensorImpl.cpp + ) + source_group("tizen" FILES ${PLATFORM_SRC}) endif() # find external libraries diff --git a/src/SFML/Window/GlContext.cpp b/src/SFML/Window/GlContext.cpp index 8ae4b3abcc..d07a2ef221 100644 --- a/src/SFML/Window/GlContext.cpp +++ b/src/SFML/Window/GlContext.cpp @@ -65,6 +65,11 @@ #include typedef sf::priv::EaglContext ContextType; + #elif defined(SFML_SYSTEM_TIZEN) + + #include + typedef sf::priv::EvasContext ContextType; + #else #include diff --git a/src/SFML/Window/InputImpl.hpp b/src/SFML/Window/InputImpl.hpp index a0244e27cb..3e4a26b237 100644 --- a/src/SFML/Window/InputImpl.hpp +++ b/src/SFML/Window/InputImpl.hpp @@ -40,6 +40,8 @@ #include #elif defined(SFML_SYSTEM_ANDROID) #include +#elif defined(SFML_SYSTEM_TIZEN) + #include #endif diff --git a/src/SFML/Window/JoystickImpl.hpp b/src/SFML/Window/JoystickImpl.hpp index e7b67243e2..a0c36986a3 100644 --- a/src/SFML/Window/JoystickImpl.hpp +++ b/src/SFML/Window/JoystickImpl.hpp @@ -102,6 +102,10 @@ struct JoystickState #include +#elif defined(SFML_SYSTEM_TIZEN) + + #include + #endif diff --git a/src/SFML/Window/SensorImpl.hpp b/src/SFML/Window/SensorImpl.hpp index 25b44d2908..261009e6a6 100644 --- a/src/SFML/Window/SensorImpl.hpp +++ b/src/SFML/Window/SensorImpl.hpp @@ -51,6 +51,10 @@ #include +#elif defined(SFML_SYSTEM_TIZEN) + + #include + #endif diff --git a/src/SFML/Window/Tizen/ApplicationState.cpp b/src/SFML/Window/Tizen/ApplicationState.cpp new file mode 100644 index 0000000000..70201436c7 --- /dev/null +++ b/src/SFML/Window/Tizen/ApplicationState.cpp @@ -0,0 +1,45 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2016 Jonathan De Wachter (dewachter.jonathan@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + +namespace sf +{ +namespace priv +{ +ApplicationState* getApplicationState(ApplicationState* initializedState, bool reset) +{ + static ApplicationState* state = NULL; + + if (!state || reset) + state = initializedState; + + return state; +} +} +} diff --git a/src/SFML/Window/Tizen/ApplicationState.hpp b/src/SFML/Window/Tizen/ApplicationState.hpp new file mode 100644 index 0000000000..0bd933e0b6 --- /dev/null +++ b/src/SFML/Window/Tizen/ApplicationState.hpp @@ -0,0 +1,79 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2016 Jonathan De Wachter (dewachter.jonathan@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_APPLICATIONSTATE_HPP +#define SFML_APPLICATIONSTATE_HPP + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include + +namespace sf +{ +namespace priv +{ +struct ApplicationState +{ + Evas_Object* window; + Evas_Object* conform; + + Evas_GL* evasgl; + Evas_GL_Surface* sharedSurface; + Evas_GL_Context* sharedContext; + + EvasContext* context; + LogStream logs; + + bool initialized; + bool resizeHandled; + + Mutex mutex; + + void (*processMouseDownEvent)(void*, Evas*, void*); + void (*processMouseUpEvent) (void*, Evas*, void*); + void (*processMouseMoveEvent)(void*, Evas*, void*); + void (*processTouchDownEvent)(void*, Evas*, void*); + void (*processTouchUpEvent) (void*, Evas*, void*); + void (*processTouchMoveEvent)(void*, Evas*, void*); + void (*processKeyDownEvent) (void*, Evas*, void*); + void (*processKeyUpEvent) (void*, Evas*, void*); + + void (*sendResizeEvent)(int, int); + void (*sendPauseEvent)(); + void (*sendResumeEvent)(); + void (*sendTerminateEvent)(); +}; + +SFML_SYSTEM_API ApplicationState* getApplicationState(ApplicationState* initializedState=NULL, bool reset=false); + +} // namespace priv +} // namespace sf + + +#endif // SFML_APPLICATIONSTATE_HPP diff --git a/src/SFML/Window/Tizen/EvasCheck.cpp b/src/SFML/Window/Tizen/EvasCheck.cpp new file mode 100644 index 0000000000..5782b1f049 --- /dev/null +++ b/src/SFML/Window/Tizen/EvasCheck.cpp @@ -0,0 +1,160 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2016 Jonathan De Wachter (dewachter.jonathan@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include + +namespace sf +{ +namespace priv +{ +//////////////////////////////////////////////////////////// +void evasCheckError(Evas_GL* evasgl, const char* file, unsigned int line) +{ + // Obtain information about the success or failure of the most recent EvasGL + // function called in the current thread + int errorCode = evas_gl_error_get(evasgl); + + if (errorCode != EVAS_GL_SUCCESS) + { + std::string fileString(file); + std::string error = "unknown error"; + std::string description = "no description"; + + // Decode the error code returned + switch (errorCode) + { + case EVAS_GL_NOT_INITIALIZED: + { + error = "EVAS_GL_NOT_INITIALIZED"; + description = "Evas GL is not initialized, or could not be initialized, for the specified display"; + break; + } + + case EVAS_GL_BAD_ACCESS: + { + error = "EVAS_GL_BAD_ACCESS"; + description = "Evas GL cannot access a requested resource (for example, a context is bound in another thread)"; + break; + } + + case EVAS_GL_BAD_ALLOC: + { + error = "EVAS_GL_BAD_ALLOC"; + description = "Evas GL failed to allocate resources for the requested operation"; + break; + } + case EVAS_GL_BAD_ATTRIBUTE: + { + error = "EVAS_GL_BAD_ATTRIBUTE"; + description = "an unrecognized attribute or attribute value was passed in an attribute list"; + break; + } + + case EVAS_GL_BAD_CONTEXT: + { + error = "EVAS_GL_BAD_CONTEXT"; + description = "an Evas_GL_Context argument does not name a valid Evas_GL_Context"; + break; + } + + case EVAS_GL_BAD_CONFIG: + { + error = "EVAS_GL_BAD_CONFIG"; + description = "an Evas_GL_Config argument does not name a valid Evas_GL_Config"; + break; + } + + case EVAS_GL_BAD_CURRENT_SURFACE: + { + error = "EVAS_GL_BAD_CURRENT_SURFACE"; + description = "the current surface of the calling thread is a window or pbuffer that is no longer valid"; + break; + } + + case EVAS_GL_BAD_DISPLAY: + { + error = "EVAS_GL_BAD_DISPLAY"; + description = "an EGLDisplay argument does not name a valid EGLDisplay; or, EGL is not initialized on the specified EGLDisplay"; + break; + } + + + case EVAS_GL_BAD_SURFACE: + { + error = "EVAS_GL_BAD_SURFACE"; + description = "an EGLSurface argument does not name a valid surface (window, pbuffer, or pixmap) configured for rendering"; + break; + } + + case EVAS_GL_BAD_MATCH: + { + error = "EVAS_GL_BAD_MATCH"; + description = "arguments are inconsistent; for example, an otherwise valid context requires buffers (e.g. depth or stencil) not allocated by an otherwise valid surface"; + break; + } + + case EVAS_GL_BAD_PARAMETER: + { + error = "EVAS_GL_BAD_PARAMETER"; + description = "one or more argument values are invalid"; + break; + } + + case EVAS_GL_BAD_NATIVE_PIXMAP: + { + error = "EVAS_GL_BAD_NATIVE_PIXMAP"; + description = "an EGLNativePixmapType argument does not refer to a valid native pixmap"; + break; + } + + case EVAS_GL_BAD_NATIVE_WINDOW: + { + error = "EVAS_GL_BAD_NATIVE_WINDOW"; + description = "an EGLNativeWindowType argument does not refer to a valid native window"; + break; + } + + case EVAS_GL_CONTEXT_LOST: + { + error = "EVAS_GL_CONTEXT_LOST"; + description = "a power management event has occurred. The application must destroy all contexts and reinitialize client API state and objects to continue rendering"; + break; + } + } + + // Log the error + err() << "An internal Evas GL call failed in " + << fileString.substr(fileString.find_last_of("\\/") + 1) << " (" << line << ") : " + << error << ", " << description + << std::endl; + } +} + +} // namespace priv +} // namespace sf diff --git a/src/SFML/Window/Tizen/EvasCheck.hpp b/src/SFML/Window/Tizen/EvasCheck.hpp new file mode 100644 index 0000000000..0d1eed86ac --- /dev/null +++ b/src/SFML/Window/Tizen/EvasCheck.hpp @@ -0,0 +1,69 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2016 Jonathan De Wachter (dewachter.jonathan@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_EVASCHECK_HPP +#define SFML_EVASCHECK_HPP + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +//#include +#include +#include + + +namespace sf +{ +namespace priv +{ +//////////////////////////////////////////////////////////// +/// Define a macro to quickly check every Evas GL API call +//////////////////////////////////////////////////////////// +#ifdef SFML_DEBUG + + // In debug mode, perform a test on every Evas GL call + #define evasCheck(x, evasgl) x; sf::priv::evasCheckError(evasgl, __FILE__, __LINE__); + +#else + + // Else, we don't add any overhead + #define evasCheck(x, evasgl) (x) + +#endif + +//////////////////////////////////////////////////////////// +/// \brief Check the last Evas GL error +/// +/// \param file Source file where the call is located +/// \param line Line number of the source file where the call is located +/// +//////////////////////////////////////////////////////////// +void evasCheckError(Evas_GL* evasgl, const char* file, unsigned int line); + +} // namespace priv +} // namespace sf + + +#endif // SFML_EVASCHECK_HPP diff --git a/src/SFML/Window/Tizen/EvasContext.cpp b/src/SFML/Window/Tizen/EvasContext.cpp new file mode 100644 index 0000000000..5bce19756e --- /dev/null +++ b/src/SFML/Window/Tizen/EvasContext.cpp @@ -0,0 +1,308 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2016 Jonathan De Wachter (dewachter.jonathan@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include +#include +#include + +// Declare Evas GL API (this is where the symbol resides, in EvasContext.cpp) +SFML_WINDOW_API EVAS_GL_GLOBAL_GLES1_DEFINE(); + +namespace +{ + Evas_GL* evasgl = NULL; +} + +namespace sf +{ +namespace priv +{ +//////////////////////////////////////////////////////////// +EvasContext::EvasContext(EvasContext* shared) : +m_context (NULL), +m_surface (NULL), +m_config (NULL) +{ + priv::ApplicationState* state = priv::getApplicationState(); + Lock(state->mutex); + + // Evas GL is shared from the main thread ( this causes one Evas GL error when getting config, but...) + if (!evasgl) + evasgl = state->evasgl; + + m_config = getBestConfig(VideoMode::getDesktopMode().bitsPerPixel, ContextSettings()); + m_config->color_format = EVAS_GL_NO_FBO; + + updateSettings(); + + m_surface = evasCheck(evas_gl_pbuffer_surface_create(evasgl, m_config, 1, 1, NULL), evasgl); + + m_context = evasCheck(evas_gl_context_version_create(evasgl, state->sharedContext, EVAS_GL_GLES_1_X), evasgl); +} + + +//////////////////////////////////////////////////////////// +EvasContext::EvasContext(EvasContext* shared, const ContextSettings& settings, const WindowImpl* owner, unsigned int bitsPerPixel) : +m_context (NULL), +m_surface (NULL), +m_config (NULL) +{ + priv::ApplicationState* state = priv::getApplicationState(); + Lock(state->mutex); + + state->context = this; + + m_config = getBestConfig(bitsPerPixel, settings); + updateSettings(); + + m_context = evasCheck(evas_gl_context_version_create(evasgl, shared->m_context, EVAS_GL_GLES_1_X), evasgl); + + // Initially, the window is 1x1 (the surface is recreated later) + createSurface(static_cast(owner->getSystemHandle()), 1, 1); + + // The window with its Open GL context is initialized by then + state->initialized = true; +} + + +//////////////////////////////////////////////////////////// +EvasContext::EvasContext(EvasContext* shared, const ContextSettings& settings, unsigned int width, unsigned int height) : +m_context (NULL), +m_surface (NULL), +m_config (NULL) +{ +} + + +//////////////////////////////////////////////////////////// +EvasContext::~EvasContext() +{ + // Deactivate the current context + Evas_GL_Context* currentContext = evasCheck(evas_gl_current_context_get(evasgl), evasgl); + + if (currentContext == m_context) + { + evasCheck(evas_gl_make_current(evasgl, NULL, NULL), evasgl); + } + + // Destroy context + if (m_context != NULL) + { + evasCheck(evas_gl_context_destroy(evasgl, m_context), evasgl); + } + + // Destroy surface + if (m_surface) + { + evasCheck(evas_gl_surface_destroy(evasgl, m_surface), evasgl); + } + + // Destroy config + if (m_config) + { + evasCheck(evas_gl_config_free(m_config), evasgl); + } +} + + +//////////////////////////////////////////////////////////// +bool EvasContext::makeCurrent(bool current) +{ + if (current) + return m_surface != NULL && evasCheck(evas_gl_make_current(evasgl, m_surface, m_context), evasgl); + + return m_surface != NULL && evasCheck(evas_gl_make_current(evasgl, NULL, NULL), evasgl); +} + + +//////////////////////////////////////////////////////////// +void EvasContext::display() +{ + // Transparently done by Evas +} + + +//////////////////////////////////////////////////////////// +void EvasContext::setVerticalSyncEnabled(bool enabled) +{ + // Transparently done by Ecore and Evas +} + + +//////////////////////////////////////////////////////////// +void EvasContext::createSurface(Evas_Object* window, int width, int height) +{ + m_surface = evasCheck(evas_gl_surface_create(evasgl, m_config, width, height), evasgl); + + setActive(true); + + Evas_Native_Surface ns; + evasCheck(evas_gl_native_surface_get(evasgl, m_surface, &ns), evasgl); + + evasCheck(evas_object_image_native_surface_set(window, &ns), evasgl); +} + + +//////////////////////////////////////////////////////////// +void EvasContext::destroySurface() +{ + // Leave the following line commented, otherwise it breaks rendering (bug in Tizen ?) + //evasCheck(evas_gl_surface_destroy(evasgl, m_surface), evasgl); + m_surface = NULL; + + // Ensure that this context is no longer active since our surface is now destroyed + setActive(false); +} + + +//////////////////////////////////////////////////////////// +Evas_GL_Config* EvasContext::getBestConfig(unsigned int bitsPerPixel, const ContextSettings& settings) +{ + // With Evas GL there's no such thing as available configurations. Instead, we + // simply try to match as closely as possible the user's settings. + Evas_GL_Config* config = evasCheck(evas_gl_config_new(), evasgl); + + // Set pixel depth value (must be either 24 or 32) + if (bitsPerPixel == 24) + config->color_format = EVAS_GL_RGB_888; + else if (bitsPerPixel == 32) + config->color_format = EVAS_GL_RGBA_8888; + else + { + err() << "Pixel depth (bits per pixel) must be either 24 or 32 on Tizen; fall back on 24" << std::endl; + config->color_format = EVAS_GL_RGB_888; + } + + // Set depth bits value + if (settings.depthBits == 0) + config->depth_bits = EVAS_GL_DEPTH_NONE; + else if (settings.depthBits == 8) + config->depth_bits = EVAS_GL_DEPTH_BIT_8; + else if (settings.depthBits == 16) + config->depth_bits = EVAS_GL_DEPTH_BIT_16; + else if (settings.depthBits == 24) + config->depth_bits = EVAS_GL_DEPTH_BIT_24; + else if (settings.depthBits == 32) + config->depth_bits = EVAS_GL_DEPTH_BIT_32; + else + { + err() << "Depth bits must be either 0, 8, 16, 24 or 32 on Tizen; fall back on 0" << std::endl; + config->depth_bits = EVAS_GL_DEPTH_NONE; + } + + // Set stencil bits value + if (settings.stencilBits == 0) + config->stencil_bits = EVAS_GL_STENCIL_NONE; + else if (settings.stencilBits == 1) + config->stencil_bits = EVAS_GL_STENCIL_BIT_1; + else if (settings.stencilBits == 2) + config->stencil_bits = EVAS_GL_STENCIL_BIT_2; + else if (settings.stencilBits == 4) + config->stencil_bits = EVAS_GL_STENCIL_BIT_4; + else if (settings.stencilBits == 8) + config->stencil_bits = EVAS_GL_STENCIL_BIT_8; + else if (settings.stencilBits == 16) + config->stencil_bits = EVAS_GL_STENCIL_BIT_16; + else + { + err() << "Stencil bits must be either 0, 1, 2, 4, 8 or 16 on Tizen; fall back on 0" << std::endl; + config->stencil_bits = EVAS_GL_STENCIL_NONE; + } + + // Set the anti-aliasing level. Note that this isn't really accurate given + // Evas GL express it relatively to the total hardware capability. + if (settings.antialiasingLevel == 0) + config->multisample_bits = EVAS_GL_MULTISAMPLE_NONE; + else if (settings.antialiasingLevel == 2) + config->multisample_bits = EVAS_GL_MULTISAMPLE_LOW; + else if (settings.antialiasingLevel == 4) + config->multisample_bits = EVAS_GL_MULTISAMPLE_MED; + else if (settings.antialiasingLevel == 8) + config->multisample_bits = EVAS_GL_MULTISAMPLE_HIGH; + else + { + err() << "Anti-aliasing level must be either 0, 2, 4 or 8 on Tizen; fall back on 0" << std::endl; + config->multisample_bits = EVAS_GL_MULTISAMPLE_NONE; + } + + config->options_bits = EVAS_GL_OPTIONS_NONE; + + return config; +} + + +//////////////////////////////////////////////////////////// +void EvasContext::updateSettings() +{ + if (m_config->depth_bits == EVAS_GL_DEPTH_NONE) + m_settings.depthBits = 0; + else if (m_config->depth_bits == EVAS_GL_DEPTH_BIT_8) + m_settings.depthBits = 8; + else if (m_config->depth_bits == EVAS_GL_DEPTH_BIT_16) + m_settings.depthBits = 16; + else if (m_config->depth_bits == EVAS_GL_DEPTH_BIT_24) + m_settings.depthBits = 24; + else if (m_config->depth_bits == EVAS_GL_DEPTH_BIT_32) + m_settings.depthBits = 32; + + if (m_config->stencil_bits == EVAS_GL_STENCIL_NONE) + m_settings.stencilBits = 0; + else if (m_config->stencil_bits == EVAS_GL_STENCIL_BIT_1) + m_settings.stencilBits = 1; + else if (m_config->stencil_bits == EVAS_GL_STENCIL_BIT_2) + m_settings.stencilBits = 2; + else if (m_config->stencil_bits == EVAS_GL_STENCIL_BIT_4) + m_settings.stencilBits = 4; + else if (m_config->stencil_bits == EVAS_GL_STENCIL_BIT_8) + m_settings.stencilBits = 8; + else if (m_config->stencil_bits == EVAS_GL_STENCIL_BIT_16) + m_settings.stencilBits = 16; + + if (m_config->multisample_bits == EVAS_GL_MULTISAMPLE_NONE) + m_settings.antialiasingLevel = 0; + else if (m_config->multisample_bits == EVAS_GL_MULTISAMPLE_LOW) + m_settings.antialiasingLevel = 2; + else if (m_config->multisample_bits == EVAS_GL_MULTISAMPLE_MED) + m_settings.antialiasingLevel = 4; + else if (m_config->multisample_bits == EVAS_GL_MULTISAMPLE_HIGH) + m_settings.antialiasingLevel = 8; + + m_settings.majorVersion = 1; + m_settings.minorVersion = 1; + + m_settings.attributeFlags = ContextSettings::Default; +} + + +} // namespace priv + +} // namespace sf diff --git a/src/SFML/Window/Tizen/EvasContext.hpp b/src/SFML/Window/Tizen/EvasContext.hpp new file mode 100644 index 0000000000..3fdd367f69 --- /dev/null +++ b/src/SFML/Window/Tizen/EvasContext.hpp @@ -0,0 +1,161 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2016 Jonathan De Wachter (dewachter.jonathan@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_EVASCONTEXT_HPP +#define SFML_EVASCONTEXT_HPP + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include +#include + + +namespace sf +{ +namespace priv +{ +class EvasContext : public GlContext +{ +public: + + //////////////////////////////////////////////////////////// + /// \brief Create a new context, not associated to a window + /// + /// \param shared Context to share the new one with (can be NULL) + /// + //////////////////////////////////////////////////////////// + EvasContext(EvasContext* shared); + + //////////////////////////////////////////////////////////// + /// \brief Create a new context attached to a window + /// + /// \param shared Context to share the new one with + /// \param settings Creation parameters + /// \param owner Pointer to the owner window + /// \param bitsPerPixel Pixel depth, in bits per pixel + /// + //////////////////////////////////////////////////////////// + EvasContext(EvasContext* shared, const ContextSettings& settings, const WindowImpl* owner, unsigned int bitsPerPixel); + + //////////////////////////////////////////////////////////// + /// \brief Create a new context that embeds its own rendering target + /// + /// \param shared Context to share the new one with + /// \param settings Creation parameters + /// \param width Back buffer width, in pixels + /// \param height Back buffer height, in pixels + /// + //////////////////////////////////////////////////////////// + EvasContext(EvasContext* shared, const ContextSettings& settings, unsigned int width, unsigned int height); + + //////////////////////////////////////////////////////////// + /// \brief Destructor + /// + //////////////////////////////////////////////////////////// + ~EvasContext(); + + //////////////////////////////////////////////////////////// + /// \brief Activate the context as the current target for rendering + /// + /// \param current Whether to make the context current or no longer current + /// + /// \return True on success, false if any error happened + /// + //////////////////////////////////////////////////////////// + virtual bool makeCurrent(bool current); + + //////////////////////////////////////////////////////////// + /// \brief Display what has been rendered to the context so far + /// + //////////////////////////////////////////////////////////// + virtual void display(); + + //////////////////////////////////////////////////////////// + /// \brief Enable or disable vertical synchronization + /// + /// Activating vertical synchronization will limit the number + /// of frames displayed to the refresh rate of the monitor. + /// This can avoid some visual artifacts, and limit the framerate + /// to a good value (but not constant across different computers). + /// + /// \param enabled: True to enable v-sync, false to deactivate + /// + //////////////////////////////////////////////////////////// + virtual void setVerticalSyncEnabled(bool enabled); + + //////////////////////////////////////////////////////////// + /// \brief Create the Evas GL surface + /// + /// This function must be called when the window is resized, and + /// perhaps when other events occur. + /// + /// \param window: The native window type + /// + //////////////////////////////////////////////////////////// + void createSurface(Evas_Object* window, int width, int height); + + //////////////////////////////////////////////////////////// + /// \brief Destroy the Evas GL surface + /// + /// This function must be called when the window is resized, and + /// perhaps when other events occur. + /// + //////////////////////////////////////////////////////////// + void destroySurface(); + + //////////////////////////////////////////////////////////// + /// \brief Get the corresponding Evas GL configuration for a given set of video settings + /// + /// \param bitsPerPixel Pixel depth, in bits per pixel + /// \param settings Requested context settings + /// + /// \return The conresponding Evas GL config + /// + //////////////////////////////////////////////////////////// + static Evas_GL_Config* getBestConfig(unsigned int bitsPerPixel, const ContextSettings& settings); + +private: + + //////////////////////////////////////////////////////////// + /// \brief Helper to copy the picked Evas GL configuration + //////////////////////////////////////////////////////////// + void updateSettings(); + + //////////////////////////////////////////////////////////// + // Member data + //////////////////////////////////////////////////////////// + Evas_GL_Context* m_context; ///< The internal Evas GL context + Evas_GL_Surface* m_surface; ///< The internal Evas GL surface + Evas_GL_Config* m_config; ///< The internal Evas GL config +}; + +} // namespace priv + +} // namespace sf + + +#endif // SFML_EVASCONTEXT_HPP diff --git a/src/SFML/Window/Tizen/InputImpl.cpp b/src/SFML/Window/Tizen/InputImpl.cpp new file mode 100644 index 0000000000..4d63a382de --- /dev/null +++ b/src/SFML/Window/Tizen/InputImpl.cpp @@ -0,0 +1,109 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2016 Jonathan De Wachter (dewachter.jonathan@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +namespace sf +{ +namespace priv +{ +//////////////////////////////////////////////////////////// +bool InputImpl::isKeyPressed(Keyboard::Key key) +{ + // Not applicable + return false; +} + +//////////////////////////////////////////////////////////// +void InputImpl::setVirtualKeyboardVisible(bool visible) +{ + // To be implemented +} + +//////////////////////////////////////////////////////////// +bool InputImpl::isMouseButtonPressed(Mouse::Button button) +{ + // To be implemented + return false; +} + + +//////////////////////////////////////////////////////////// +Vector2i InputImpl::getMousePosition() +{ + // To be implemented + return sf::Vector2i(0, 0); +} + + +//////////////////////////////////////////////////////////// +Vector2i InputImpl::getMousePosition(const Window& relativeTo) +{ + return getMousePosition(); +} + + +//////////////////////////////////////////////////////////// +void InputImpl::setMousePosition(const Vector2i& position) +{ + // To be implemented +} + + +//////////////////////////////////////////////////////////// +void InputImpl::setMousePosition(const Vector2i& position, const Window& relativeTo) +{ + setMousePosition(position); +} + + +//////////////////////////////////////////////////////////// +bool InputImpl::isTouchDown(unsigned int finger) +{ + // To be implemented + return false; +} + + +//////////////////////////////////////////////////////////// +Vector2i InputImpl::getTouchPosition(unsigned int finger) +{ + // To be implemented + return sf::Vector2i(0, 0); +} + + +//////////////////////////////////////////////////////////// +Vector2i InputImpl::getTouchPosition(unsigned int finger, const Window& relativeTo) +{ + return getTouchPosition(finger); +} + +} // namespace priv + +} // namespace sf diff --git a/src/SFML/Window/Tizen/InputImpl.hpp b/src/SFML/Window/Tizen/InputImpl.hpp new file mode 100644 index 0000000000..bb067f9fdf --- /dev/null +++ b/src/SFML/Window/Tizen/InputImpl.hpp @@ -0,0 +1,168 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2016 Jonathan De Wachter (dewachter.jonathan@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_INPUTIMPLTIZEN_HPP +#define SFML_INPUTIMPLTIZEN_HPP + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include + + +namespace sf +{ +namespace priv +{ +//////////////////////////////////////////////////////////// +/// \brief Tizen implementation of inputs (keyboard + mouse) +/// +//////////////////////////////////////////////////////////// +class InputImpl +{ +public: + + //////////////////////////////////////////////////////////// + /// \brief Check if a key is pressed + /// + /// \param key Key to check + /// + /// \return True if the key is pressed, false otherwise + /// + //////////////////////////////////////////////////////////// + static bool isKeyPressed(Keyboard::Key key); + + //////////////////////////////////////////////////////////// + /// \brief Show or hide the virtual keyboard + /// + /// \param visible True to show, false to hide + /// + //////////////////////////////////////////////////////////// + static void setVirtualKeyboardVisible(bool visible); + + //////////////////////////////////////////////////////////// + /// \brief Check if a mouse button is pressed + /// + /// \param button Button to check + /// + /// \return True if the button is pressed, false otherwise + /// + //////////////////////////////////////////////////////////// + static bool isMouseButtonPressed(Mouse::Button button); + + //////////////////////////////////////////////////////////// + /// \brief Get the current position of the mouse in desktop coordinates + /// + /// This function returns the current position of the mouse + /// cursor, in global (desktop) coordinates. + /// + /// \return Current position of the mouse + /// + //////////////////////////////////////////////////////////// + static Vector2i getMousePosition(); + + //////////////////////////////////////////////////////////// + /// \brief Get the current position of the mouse in window coordinates + /// + /// This function returns the current position of the mouse + /// cursor, relative to the given window. + /// If no window is used, it returns desktop coordinates. + /// + /// \param relativeTo Reference window + /// + /// \return Current position of the mouse + /// + //////////////////////////////////////////////////////////// + static Vector2i getMousePosition(const Window& relativeTo); + + //////////////////////////////////////////////////////////// + /// \brief Set the current position of the mouse in desktop coordinates + /// + /// This function sets the current position of the mouse + /// cursor in global (desktop) coordinates. + /// If no window is used, it sets the position in desktop coordinates. + /// + /// \param position New position of the mouse + /// + //////////////////////////////////////////////////////////// + static void setMousePosition(const Vector2i& position); + + //////////////////////////////////////////////////////////// + /// \brief Set the current position of the mouse in window coordinates + /// + /// This function sets the current position of the mouse + /// cursor, relative to the given window. + /// If no window is used, it sets the position in desktop coordinates. + /// + /// \param position New position of the mouse + /// \param relativeTo Reference window + /// + //////////////////////////////////////////////////////////// + static void setMousePosition(const Vector2i& position, const Window& relativeTo); + + //////////////////////////////////////////////////////////// + /// \brief Check if a touch event is currently down + /// + /// \param finger Finger index + /// + /// \return True if \a finger is currently touching the screen, false otherwise + /// + //////////////////////////////////////////////////////////// + static bool isTouchDown(unsigned int finger); + + //////////////////////////////////////////////////////////// + /// \brief Get the current position of a touch in desktop coordinates + /// + /// This function returns the current touch position + /// in global (desktop) coordinates. + /// + /// \param finger Finger index + /// + /// \return Current position of \a finger, or undefined if it's not down + /// + //////////////////////////////////////////////////////////// + static Vector2i getTouchPosition(unsigned int finger); + + //////////////////////////////////////////////////////////// + /// \brief Get the current position of a touch in window coordinates + /// + /// This function returns the current touch position + /// in global (desktop) coordinates. + /// + /// \param finger Finger index + /// \param relativeTo Reference window + /// + /// \return Current position of \a finger, or undefined if it's not down + /// + //////////////////////////////////////////////////////////// + static Vector2i getTouchPosition(unsigned int finger, const Window& relativeTo); +}; + +} // namespace priv + +} // namespace sf + + +#endif // SFML_INPUTIMPLTIZEN_HPP diff --git a/src/SFML/Window/Tizen/JoystickImpl.cpp b/src/SFML/Window/Tizen/JoystickImpl.cpp new file mode 100644 index 0000000000..3f54065ab2 --- /dev/null +++ b/src/SFML/Window/Tizen/JoystickImpl.cpp @@ -0,0 +1,97 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2016 Jonathan De Wachter (dewachter.jonathan@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +namespace sf +{ +namespace priv +{ +//////////////////////////////////////////////////////////// +void JoystickImpl::initialize() +{ + // To implement +} + + + +//////////////////////////////////////////////////////////// +void JoystickImpl::cleanup() +{ + // To implement +} + + +//////////////////////////////////////////////////////////// +bool JoystickImpl::isConnected(unsigned int index) +{ + // To implement + return false; +} + + +//////////////////////////////////////////////////////////// +bool JoystickImpl::open(unsigned int index) +{ + // To implement + return false; +} + + +//////////////////////////////////////////////////////////// +void JoystickImpl::close() +{ + // To implement +} + + +//////////////////////////////////////////////////////////// +JoystickCaps JoystickImpl::getCapabilities() const +{ + // To implement + return JoystickCaps(); +} + + +//////////////////////////////////////////////////////////// +Joystick::Identification JoystickImpl::getIdentification() const +{ + return m_identification; +} + + +//////////////////////////////////////////////////////////// +JoystickState JoystickImpl::update() +{ + // To implement + return JoystickState(); +} + +} // namespace priv + +} // namespace sf diff --git a/src/SFML/Window/Tizen/JoystickImpl.hpp b/src/SFML/Window/Tizen/JoystickImpl.hpp new file mode 100644 index 0000000000..e8fb381196 --- /dev/null +++ b/src/SFML/Window/Tizen/JoystickImpl.hpp @@ -0,0 +1,117 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2016 Jonathan De Wachter (dewachter.jonathan@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_JOYSTICKIMPLTIZEN_HPP +#define SFML_JOYSTICKIMPLTIZEN_HPP + + +namespace sf +{ +namespace priv +{ +//////////////////////////////////////////////////////////// +/// \brief Tizen implementation of joysticks +/// +//////////////////////////////////////////////////////////// +class JoystickImpl +{ +public: + + //////////////////////////////////////////////////////////// + /// \brief Perform the global initialization of the joystick module + /// + //////////////////////////////////////////////////////////// + static void initialize(); + + //////////////////////////////////////////////////////////// + /// \brief Perform the global cleanup of the joystick module + /// + //////////////////////////////////////////////////////////// + static void cleanup(); + + //////////////////////////////////////////////////////////// + /// \brief Check if a joystick is currently connected + /// + /// \param index Index of the joystick to check + /// + /// \return True if the joystick is connected, false otherwise + /// + //////////////////////////////////////////////////////////// + static bool isConnected(unsigned int index); + + //////////////////////////////////////////////////////////// + /// \brief Open the joystick + /// + /// \param index Index assigned to the joystick + /// + /// \return True on success, false on failure + /// + //////////////////////////////////////////////////////////// + bool open(unsigned int index); + + //////////////////////////////////////////////////////////// + /// \brief Close the joystick + /// + //////////////////////////////////////////////////////////// + void close(); + + //////////////////////////////////////////////////////////// + /// \brief Get the joystick capabilities + /// + /// \return Joystick capabilities + /// + //////////////////////////////////////////////////////////// + JoystickCaps getCapabilities() const; + + //////////////////////////////////////////////////////////// + /// \brief Get the joystick identification + /// + /// \return Joystick identification + /// + //////////////////////////////////////////////////////////// + Joystick::Identification getIdentification() const; + + //////////////////////////////////////////////////////////// + /// \brief Update the joystick and get its new state + /// + /// \return Joystick state + /// + //////////////////////////////////////////////////////////// + JoystickState update(); + +private: + + //////////////////////////////////////////////////////////// + // Member data + //////////////////////////////////////////////////////////// + int m_index; ///< Index of the joystick + Joystick::Identification m_identification; ///< Joystick identification +}; + +} // namespace priv + +} // namespace sf + + +#endif // SFML_JOYSTICKIMPLTIZEN_HPP diff --git a/src/SFML/Window/Tizen/LogStream.cpp b/src/SFML/Window/Tizen/LogStream.cpp new file mode 100644 index 0000000000..4e0bf06d00 --- /dev/null +++ b/src/SFML/Window/Tizen/LogStream.cpp @@ -0,0 +1,50 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2016 Jonathan De Wachter (dewachter.jonathan@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include + +LogStream::LogStream() : +std::streambuf() +{ + // Nothing to do +} + +std::streambuf::int_type LogStream::overflow (std::streambuf::int_type c) +{ + if (c == "\n"[0]) + { + m_message.push_back(c); + dlog_print(DLOG_DEBUG, "SFML", m_message.c_str()); + m_message.clear(); + } + + m_message.push_back(c); + + return traits_type::not_eof(c); +} diff --git a/src/SFML/Window/Tizen/LogStream.hpp b/src/SFML/Window/Tizen/LogStream.hpp new file mode 100644 index 0000000000..190929e187 --- /dev/null +++ b/src/SFML/Window/Tizen/LogStream.hpp @@ -0,0 +1,47 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2016 Jonathan De Wachter (dewachter.jonathan@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_LOGSTREAM_HPP +#define SFML_LOGSTREAM_HPP + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include + + +class SFML_WINDOW_API LogStream : public std::streambuf +{ +public: + LogStream(); + + std::streambuf::int_type overflow (std::streambuf::int_type c); + +private: + std::string m_message; +}; + +#endif // SFML_LOGSTREAM_HPP diff --git a/src/SFML/Window/Tizen/SensorImpl.cpp b/src/SFML/Window/Tizen/SensorImpl.cpp new file mode 100644 index 0000000000..bf963bba04 --- /dev/null +++ b/src/SFML/Window/Tizen/SensorImpl.cpp @@ -0,0 +1,192 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2016 Jonathan De Wachter (dewachter.jonathan@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include + + +namespace +{ + sf::Vector3f sensorData[sf::Sensor::Count]; +} + +namespace sf +{ +namespace priv +{ +//////////////////////////////////////////////////////////// +void SensorImpl::initialize() +{ + // Nothing to do +} + + +//////////////////////////////////////////////////////////// +void SensorImpl::cleanup() +{ + // Nothing to do +} + + +//////////////////////////////////////////////////////////// +bool SensorImpl::isAvailable(Sensor::Type sensor) +{ + bool supported; + sensor_is_supported(SENSOR_ACCELEROMETER, &supported); + + return supported; + //sensor_type_e sensors[Sensor::Count]; + + //sensors[Accelerometer] = SENSOR_ACCELEROMETER; + //sensors[Gyroscope] = SENSOR_GYROSCOPE; + //sensors[Magnetometer] = SENSOR_MAGNETIC; + //sensors[Gravity] = SENSOR_GRAVITY; + //sensors[UserAcceleration] = SENSOR_LINEAR_ACCELERATION; + //sensors[Orientation] = SENSOR_ORIENTATION; +} + + +//////////////////////////////////////////////////////////// +bool SensorImpl::open(Sensor::Type sensor) +{ + //// Retrieve the default sensor for this specific type (might be more than one) + //int ret = sensor_get_default_sensor(sensors[sensor], &m_handle); + + //if (ret != 0) + //{ + //sf::err() << "Failed to retrieve the default sensor (is available?)" << std::endl; + //return true; + //} + + //// Create a listener handling + //ret = sensor_create_listener(m_handle, &m_listener); + + //if (ret != 0) + //{ + //sf::err() << "Failed to create the listener" << std::endl; + //return true; + //} + + //// Register callback + //sensor_listener_set_event_cb(m_listener, 100, processEvent, NULL); + ////sensor_listener_set_attribute_int(listener, SENSOR_ATTRIBUTE_PAUSE_POLICY, SENSOR_PAUSE_NONE); + + //m_index = static_cast(sensor); + + return false; +} + + +//////////////////////////////////////////////////////////// +void SensorImpl::close() +{ + //sensor_destroy_listener(m_listener); +} + + +//////////////////////////////////////////////////////////// +Vector3f SensorImpl::update() +{ + //return sensorData[m_index]; + return sf::Vector3f(0, 0, 0); +} + + +//////////////////////////////////////////////////////////// +void SensorImpl::setEnabled(bool enabled) +{ + //if (enabled) + //sensor_listener_start(m_listener); + //else + //sensor_listener_stop(m_listener); +} + + +//////////////////////////////////////////////////////////// +void processEvent(sensor_h sensor, sensor_event_s *event, void *user_data) +{ + ///* If a callback function is used to listen to different sensor types, it can check the sensor type */ + //sensor_type_e type; + //sensor_get_type(sensor, &type); + + //sf::Sensor::Type index; + //sf::Vector3f data; + + //switch (type) + //{ + //case SENSOR_ACCELEROMETER: + //index = Sensor::Accelerometer; + //data.x = event->values[0]; + //data.y = event->values[1]; + //data.z = event->values[2]; + //break; + + //case SENSOR_GYROSCOPE: + //index = Sensor::Gyroscope; + //data.x = event->values[0]; + //data.y = event->values[1]; + //data.z = event->values[2]; + //break; + + //case SENSOR_MAGNETIC: + //index = Sensor::Magnetometer; + //data.x = event->values[0]; + //data.y = event->values[1]; + //data.z = event->values[2]; + //break; + + //case SENSOR_GRAVITY: + //index = Sensor::Gravity; + //data.x = event->values[0]; + //data.y = event->values[1]; + //data.z = event->values[2]; + //break; + + //case SENSOR_LINEAR_ACCELERATION: + //index = Sensor::UserAcceleration; + //data.x = event->values[0]; + //data.y = event->values[1]; + //data.z = event->values[2]; + //break; + + //case SENSOR_ORIENTATION: + //index = Sensor::Orientation; + //data.x = event->values[0]; + //data.y = event->values[1]; + //data.z = event->values[2]; + //break; + //} + + ////// An unknown sensor event has been detected, we don't know how to process it + ////if (type == Sensor::Count) + ////continue; + + //sensorData[index] = data; +} + +} // namespace priv + +} // namespace sf diff --git a/src/SFML/Window/Tizen/SensorImpl.hpp b/src/SFML/Window/Tizen/SensorImpl.hpp new file mode 100644 index 0000000000..20a1bc5d0f --- /dev/null +++ b/src/SFML/Window/Tizen/SensorImpl.hpp @@ -0,0 +1,128 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2016 Jonathan De Wachter (dewachter.jonathan@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_SENSORIMPLTIZEN_HPP +#define SFML_SENSORIMPLTIZEN_HPP + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include + +// https://developer.tizen.org/ko/development/guides/native-application/location-and-sensors/device-sensors#sensorlistener +// https://developer.tizen.org/ko/development/api-references/native-application?redirect=/dev-guide/2.4.0/org.tizen.native.mobile.apireference/group__CAPI__SYSTEM__SENSOR__MODULE.html#ga284b030435e4c8f3cf1052cfc3b54fa3 + +namespace sf +{ +namespace priv +{ +//////////////////////////////////////////////////////////// +/// \brief Tizen implementation of sensors +/// +//////////////////////////////////////////////////////////// +class SensorImpl +{ +public: + + //////////////////////////////////////////////////////////// + /// \brief Perform the global initialization of the sensor module + /// + //////////////////////////////////////////////////////////// + static void initialize(); + + //////////////////////////////////////////////////////////// + /// \brief Perform the global cleanup of the sensor module + /// + //////////////////////////////////////////////////////////// + static void cleanup(); + + //////////////////////////////////////////////////////////// + /// \brief Check if a sensor is available + /// + /// \param sensor Sensor to check + /// + /// \return True if the sensor is available, false otherwise + /// + //////////////////////////////////////////////////////////// + static bool isAvailable(Sensor::Type sensor); + + //////////////////////////////////////////////////////////// + /// \brief Open the sensor + /// + /// \param sensor Type of the sensor + /// + /// \return True on success, false on failure + /// + //////////////////////////////////////////////////////////// + bool open(Sensor::Type sensor); + + //////////////////////////////////////////////////////////// + /// \brief Close the sensor + /// + //////////////////////////////////////////////////////////// + void close(); + + //////////////////////////////////////////////////////////// + /// \brief Update the sensor and get its new value + /// + /// \return Sensor value + /// + //////////////////////////////////////////////////////////// + Vector3f update(); + + //////////////////////////////////////////////////////////// + /// \brief Enable or disable the sensor + /// + /// \param enabled True to enable, false to disable + /// + //////////////////////////////////////////////////////////// + void setEnabled(bool enabled); + +private: + //////////////////////////////////////////////////////////// + /// \brief Process events of one sensor + /// + /// \param sensor The sensor handle + /// \param event The event data + /// \param user_data The user data + /// + //////////////////////////////////////////////////////////// + static void processEvent(sensor_h sensor, sensor_event_s *event, void *user_data); + + //////////////////////////////////////////////////////////// + // Member data + //////////////////////////////////////////////////////////// + unsigned int m_index; ///< The sensor index [0, Sensor::Count[ + sensor_type_e m_type; ///< The sensor type (SENSOR_ACCELEROMETER, etc) + sensor_h m_handle; ///< The sensor handle + sensor_listener_h m_listener; ///< The sensor listener +}; + +} // namespace priv + +} // namespace sf + + +#endif // SFML_SENSORIMPLTIZEN_HPP diff --git a/src/SFML/Window/Tizen/VideoModeImpl.cpp b/src/SFML/Window/Tizen/VideoModeImpl.cpp new file mode 100644 index 0000000000..5044eb854b --- /dev/null +++ b/src/SFML/Window/Tizen/VideoModeImpl.cpp @@ -0,0 +1,57 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2016 Jonathan De Wachter (dewachter.jonathan@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include + +namespace sf +{ +namespace priv +{ +//////////////////////////////////////////////////////////// +std::vector VideoModeImpl::getFullscreenModes() +{ + VideoMode desktop = getDesktopMode(); + + // Return both portrait and landscape resolutions + std::vector modes; + modes.push_back(desktop); + modes.push_back(VideoMode(desktop.height, desktop.width, desktop.bitsPerPixel)); + return modes; +} + + +//////////////////////////////////////////////////////////// +VideoMode VideoModeImpl::getDesktopMode() +{ + // To be implemented + return VideoMode(640, 480); +} + +} // namespace priv + +} // namespace sf diff --git a/src/SFML/Window/Tizen/WindowImplTizen.cpp b/src/SFML/Window/Tizen/WindowImplTizen.cpp new file mode 100644 index 0000000000..d3e3cc6e4c --- /dev/null +++ b/src/SFML/Window/Tizen/WindowImplTizen.cpp @@ -0,0 +1,422 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2016 Jonathan De Wachter (dewachter.jonathan@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include // important to be included first (conflict with None) +#include +#include +#include +#include +#include +#include + + +namespace +{ + std::queue systemEvents; + sf::Mutex mutex; +} + + +//////////////////////////////////////////////////////////// +void imagePixelsCallback(void* data, Evas_Object* obj) +{ + // Do nothing +} + +//////////////////////////////////////////////////////////// +// Private data +//////////////////////////////////////////////////////////// +namespace sf +{ +namespace priv +{ +//////////////////////////////////////////////////////////// +WindowImplTizen::WindowImplTizen(WindowHandle handle) : +m_image(NULL), +m_hasFocus(false), +m_size(0, 0) +{ +} + + +//////////////////////////////////////////////////////////// +WindowImplTizen::WindowImplTizen(VideoMode mode, const String& title, unsigned long style, const ContextSettings& settings) +: m_image(NULL) +, m_hasFocus(false) +{ + priv::ApplicationState* state = priv::getApplicationState(); + Lock lock(state->mutex); + + // todo: check that window is differetn from NULL + m_image = evas_object_image_filled_add(evas_object_evas_get(state->conform)); + evas_object_image_pixels_get_callback_set(m_image, imagePixelsCallback, NULL); // SANS CEtte ligne, CA BUG SEVERE OMG + elm_object_content_set(state->conform, m_image); + + state->sendResizeEvent = sendResizeEvent; + state->sendPauseEvent = sendPauseEvent; + state->sendResumeEvent = sendResumeEvent; + state->sendTerminateEvent = sendTerminateEvent; + + state->processMouseDownEvent = processMouseDownEvent; + state->processMouseUpEvent = processMouseUpEvent; + state->processMouseMoveEvent = processMouseMoveEvent; + state->processTouchDownEvent = processTouchDownEvent; + state->processTouchUpEvent = processTouchUpEvent; + state->processTouchMoveEvent = processTouchMoveEvent; + state->processKeyDownEvent = processKeyDownEvent; + state->processKeyUpEvent = processKeyUpEvent; + + //// Mark the application state as initialized + //state->initialized = true; +} + + +//////////////////////////////////////////////////////////// +WindowImplTizen::~WindowImplTizen() +{ +} + + +//////////////////////////////////////////////////////////// +WindowHandle WindowImplTizen::getSystemHandle() const +{ + // To be implemented + return m_image; +} + + +//////////////////////////////////////////////////////////// +void WindowImplTizen::processEvents() +{ + Lock lock(mutex); + + Event event; + + while (!systemEvents.empty()) + { + event = systemEvents.front(); + systemEvents.pop(); + + if (event.type == Event::Resized) + { + m_size.x = event.size.width; + m_size.y = event.size.height; + + // The window was resized, our strategy is to recreate the image + // and the Evas GL surface attached to it. + // Note: this step is a bit radical, I experimented tons of way + // to recreate the surface but it worked randomely, the thing is + // Evas objects seem to do EGL and OpenGL stuff internally and it + // probably breaks the context. With a lack of understanding, I + // couldnt really debug this, kept it for later (but I'm closed + // because I could get things working once) + priv::ApplicationState* state = priv::getApplicationState(); + Lock(state->mutex); + + // Step 1 - Detach the surface from image and destroy it + evas_object_image_native_surface_set(m_image, NULL); + state->context->destroySurface(); + + // Step 2 - Recreate image + m_image = evas_object_image_filled_add(evas_object_evas_get(state->conform)); + evas_object_resize(m_image, event.size.width, event.size.height); + + // Step 3 - Create surface and attach it to image + state->context->createSurface(m_image, event.size.width, event.size.height); + + elm_object_content_set(state->conform, m_image); + //evas_object_image_size_set(m_image, event.size.width, event.size.height); + evas_object_image_pixels_get_callback_set(m_image, imagePixelsCallback, NULL); // SANS CEtte ligne, CA BUG SEVERE OMG + evas_object_show(m_image); + evas_object_image_pixels_dirty_set(m_image, EINA_TRUE); + + // Mark the operation as done + state->resizeHandled = true; + } + else if (event.type == Event::LostFocus) + { + m_hasFocus = false; + } + else if (event.type == Event::GainedFocus) + { + m_hasFocus = true; + } + + pushEvent(event); + } +} + + +//////////////////////////////////////////////////////////// +Vector2i WindowImplTizen::getPosition() const +{ + // Not applicable + return Vector2i(0, 0); +} + + +//////////////////////////////////////////////////////////// +void WindowImplTizen::setPosition(const Vector2i& position) +{ + // Not applicable +} + + +//////////////////////////////////////////////////////////// +Vector2u WindowImplTizen::getSize() const +{ + // To be implemented + return m_size; +} + + +//////////////////////////////////////////////////////////// +void WindowImplTizen::setSize(const Vector2u& size) +{ + // To be implemented - applicable ? +} + + +//////////////////////////////////////////////////////////// +void WindowImplTizen::setTitle(const String& title) +{ + // Not applicable +} + + +//////////////////////////////////////////////////////////// +void WindowImplTizen::setIcon(unsigned int width, unsigned int height, const Uint8* pixels) +{ + // Not applicable +} + + +//////////////////////////////////////////////////////////// +void WindowImplTizen::setVisible(bool visible) +{ + // Not applicable +} + + +//////////////////////////////////////////////////////////// +void WindowImplTizen::setMouseCursorVisible(bool visible) +{ + // Not applicable +} + + +//////////////////////////////////////////////////////////// +void WindowImplTizen::setMouseCursorGrabbed(bool grabbed) +{ + // Not applicable +} + + +//////////////////////////////////////////////////////////// +void WindowImplTizen::setKeyRepeatEnabled(bool enabled) +{ + // Not applicable +} + + +//////////////////////////////////////////////////////////// +void WindowImplTizen::requestFocus() +{ + // Not applicable +} + + +//////////////////////////////////////////////////////////// +bool WindowImplTizen::hasFocus() const +{ + return m_hasFocus; +} + + +//////////////////////////////////////////////////////////// +void WindowImplTizen::sendResizeEvent(int width, int height) +{ + sf::Event event; + + event.size.width = width; + event.size.height = height; + event.type = Event::Resized; + + Lock lock(mutex); + systemEvents.push(event); +} + + +//////////////////////////////////////////////////////////// +void WindowImplTizen::sendPauseEvent() +{ + sf::Event event; + event.type = Event::LostFocus; + + Lock lock(mutex); + systemEvents.push(event); +} + + +//////////////////////////////////////////////////////////// +void WindowImplTizen::sendResumeEvent() +{ + sf::Event event; + event.type = Event::GainedFocus; + + Lock lock(mutex); + systemEvents.push(event); +} + + +//////////////////////////////////////////////////////////// +void WindowImplTizen::sendTerminateEvent() +{ + sf::Event event; + event.type = Event::Closed; + + Lock lock(mutex); + systemEvents.push(event); +} + + +//////////////////////////////////////////////////////////// +void WindowImplTizen::processMouseDownEvent(void* data, Evas* evas, void* eventInfo) +{ + Evas_Event_Mouse_Down* eventData = static_cast(eventInfo); + + sf::Event mouseButtonevent; + mouseButtonevent.type = Event::MouseButtonPressed; + //mouseButtonevent.mouseButton.button = eventData->button; + mouseButtonevent.mouseButton.button = static_cast(eventData->button); + mouseButtonevent.mouseButton.x = eventData->output.x; + mouseButtonevent.mouseButton.y = eventData->output.y; + + sf::Event touchEvent; + touchEvent.type = Event::TouchBegan; + touchEvent.touch.finger = 0; + touchEvent.touch.x = eventData->output.x; + touchEvent.touch.y = eventData->output.y; + + Lock lock(mutex); + systemEvents.push(mouseButtonevent); + systemEvents.push(touchEvent); +} + + +//////////////////////////////////////////////////////////// +void WindowImplTizen::processMouseUpEvent(void* data, Evas* evas, void* eventInfo) +{ + Evas_Event_Mouse_Up* eventData = static_cast(eventInfo); + + sf::Event mouseEvent; + mouseEvent.type = Event::MouseButtonReleased; + //mouseEvent.mouseButton.button = eventData->button; + mouseEvent.mouseButton.button = static_cast(eventData->button); + mouseEvent.mouseButton.x = eventData->output.x; + mouseEvent.mouseButton.y = eventData->output.y; + + sf::Event touchEvent; + touchEvent.type = Event::TouchEnded; + touchEvent.touch.finger = 0; + touchEvent.touch.x = eventData->output.x; + touchEvent.touch.y = eventData->output.y; + + Lock lock(mutex); + systemEvents.push(mouseEvent); + systemEvents.push(touchEvent); +} + + +//////////////////////////////////////////////////////////// +void WindowImplTizen::processMouseMoveEvent(void* data, Evas* evas, void* eventInfo) +{ + Evas_Event_Mouse_Move* eventData = static_cast(eventInfo); + + sf::Event mouseEvent; + mouseEvent.type = Event::MouseMoved; + mouseEvent.mouseMove.x = eventData->cur.output.x; + mouseEvent.mouseMove.y = eventData->cur.output.y; + + sf::Event touchEvent; + touchEvent.type = Event::TouchMoved; + touchEvent.touch.finger = 0; + touchEvent.touch.x = eventData->cur.output.x; + touchEvent.touch.y = eventData->cur.output.y; + + Lock lock(mutex); + systemEvents.push(mouseEvent); + systemEvents.push(touchEvent); +} + + +//////////////////////////////////////////////////////////// +void WindowImplTizen::processTouchDownEvent(void* data, Evas* evas, void* eventInfo) +{ + //Evas_Event_Multi_Up* data = static_cast(event_info); + + //sf::Event event; + //event.type = Event::TouchBegan; + ////event.mouseMove.button = data->button; + ////event.mouseMove.x = data->output.x; + ////event.mouseMove.y = data->output.y; + + //Lock lock(mutex); + //systemEvents.push(event); +} + + +//////////////////////////////////////////////////////////// +void WindowImplTizen::processTouchUpEvent(void* data, Evas* evas, void* eventInfo) +{ + err() << "processTouchUpEvent" << std::endl; +} + + +//////////////////////////////////////////////////////////// +void WindowImplTizen::processTouchMoveEvent(void* data, Evas* evas, void* eventInfo) +{ + err() << "processTouchMoveEvent" << std::endl; +} + + +//////////////////////////////////////////////////////////// +void WindowImplTizen::processKeyDownEvent(void* data, Evas* evas, void* eventInfo) +{ + err() << "processKeyDownEvent" << std::endl; +} + + +//////////////////////////////////////////////////////////// +void WindowImplTizen::processKeyUpEvent(void* data, Evas* evas, void* eventInfo) +{ + err() << "processKeyUpEvent" << std::endl; +} + +} // namespace priv +} // namespace sf diff --git a/src/SFML/Window/Tizen/WindowImplTizen.hpp b/src/SFML/Window/Tizen/WindowImplTizen.hpp new file mode 100644 index 0000000000..cbdf18ef15 --- /dev/null +++ b/src/SFML/Window/Tizen/WindowImplTizen.hpp @@ -0,0 +1,212 @@ +//////////////////////////////////////////////////////////// +// +// SFML - Simple and Fast Multimedia Library +// Copyright (C) 2016 Jonathan De Wachter (dewachter.jonathan@gmail.com) +// +// This software is provided 'as-is', without any express or implied warranty. +// In no event will the authors be held liable for any damages arising from the use of this software. +// +// Permission is granted to anyone to use this software for any purpose, +// including commercial applications, and to alter it and redistribute it freely, +// subject to the following restrictions: +// +// 1. The origin of this software must not be misrepresented; +// you must not claim that you wrote the original software. +// If you use this software in a product, an acknowledgment +// in the product documentation would be appreciated but is not required. +// +// 2. Altered source versions must be plainly marked as such, +// and must not be misrepresented as being the original software. +// +// 3. This notice may not be removed or altered from any source distribution. +// +//////////////////////////////////////////////////////////// + +#ifndef SFML_WINDOWIMPLTIZEN_HPP +#define SFML_WINDOWIMPLTIZEN_HPP + +//////////////////////////////////////////////////////////// +// Headers +//////////////////////////////////////////////////////////// +#include +#include +#include + + +namespace sf +{ +namespace priv +{ +class EvasContext; + +//////////////////////////////////////////////////////////// +/// \brief Tizen implementation of WindowImpl +/// +//////////////////////////////////////////////////////////// +class WindowImplTizen : public WindowImpl +{ +public: + + //////////////////////////////////////////////////////////// + /// \brief Construct the window implementation from an existing control + /// + /// \param handle Platform-specific handle of the control + /// + //////////////////////////////////////////////////////////// + WindowImplTizen(WindowHandle handle); + + //////////////////////////////////////////////////////////// + /// \brief Create the window implementation + /// + /// \param mode Video mode to use + /// \param title Title of the window + /// \param style Window style (resizable, fixed, or fullscren) + /// \param settings Additional settings for the underlying OpenGL context + /// + //////////////////////////////////////////////////////////// + WindowImplTizen(VideoMode mode, const String& title, unsigned long style, const ContextSettings& settings); + + //////////////////////////////////////////////////////////// + /// \brief Destructor + /// + //////////////////////////////////////////////////////////// + ~WindowImplTizen(); + + //////////////////////////////////////////////////////////// + /// \brief Get the OS-specific handle of the window + /// + /// \return Handle of the window + /// + //////////////////////////////////////////////////////////// + virtual WindowHandle getSystemHandle() const; + + //////////////////////////////////////////////////////////// + /// \brief Get the position of the window + /// + /// \return Position of the window, in pixels + /// + //////////////////////////////////////////////////////////// + virtual Vector2i getPosition() const; + + //////////////////////////////////////////////////////////// + /// \brief Change the position of the window on screen + /// + /// \param position New position of the window, in pixels + /// + //////////////////////////////////////////////////////////// + virtual void setPosition(const Vector2i& position); + + //////////////////////////////////////////////////////////// + /// \brief Get the client size of the window + /// + /// \return Size of the window, in pixels + /// + //////////////////////////////////////////////////////////// + virtual Vector2u getSize() const; + + //////////////////////////////////////////////////////////// + /// \brief Change the size of the rendering region of the window + /// + /// \param size New size, in pixels + /// + //////////////////////////////////////////////////////////// + virtual void setSize(const Vector2u& size); + + //////////////////////////////////////////////////////////// + /// \brief Change the title of the window + /// + /// \param title New title + /// + //////////////////////////////////////////////////////////// + virtual void setTitle(const String& title); + + //////////////////////////////////////////////////////////// + /// \brief Change the window's icon + /// + /// \param width Icon's width, in pixels + /// \param height Icon's height, in pixels + /// \param pixels Pointer to the pixels in memory, format must be RGBA 32 bits + /// + //////////////////////////////////////////////////////////// + virtual void setIcon(unsigned int width, unsigned int height, const Uint8* pixels); + + //////////////////////////////////////////////////////////// + /// \brief Show or hide the window + /// + /// \param visible True to show, false to hide + /// + //////////////////////////////////////////////////////////// + virtual void setVisible(bool visible); + + //////////////////////////////////////////////////////////// + /// \brief Show or hide the mouse cursor + /// + /// \param visible True to show, false to hide + /// + //////////////////////////////////////////////////////////// + virtual void setMouseCursorVisible(bool visible); + + //////////////////////////////////////////////////////////// + /// \brief Clips or releases the mouse cursor + /// + /// \param grabbed True to enable, false to disable + /// + //////////////////////////////////////////////////////////// + virtual void setMouseCursorGrabbed(bool grabbed); + + //////////////////////////////////////////////////////////// + /// \brief Enable or disable automatic key-repeat + /// + /// \param enabled True to enable, false to disable + /// + //////////////////////////////////////////////////////////// + virtual void setKeyRepeatEnabled(bool enabled); + + //////////////////////////////////////////////////////////// + /// \brief Request the current window to be made the active + /// foreground window + /// + //////////////////////////////////////////////////////////// + virtual void requestFocus(); + + //////////////////////////////////////////////////////////// + /// \brief Check whether the window has the input focus + /// + /// \return True if window has focus, false otherwise + /// + //////////////////////////////////////////////////////////// + virtual bool hasFocus() const; + + static void sendResizeEvent(int width, int height); + static void sendPauseEvent(); + static void sendResumeEvent(); + static void sendTerminateEvent(); + + static void processMouseDownEvent(void* data, Evas* evas, void* eventInfo); + static void processMouseUpEvent(void* data, Evas* evas, void* eventInfo); + static void processMouseMoveEvent(void* data, Evas* evas, void* eventInfo); + static void processTouchDownEvent(void* data, Evas* evas, void* eventInfo); + static void processTouchUpEvent(void* data, Evas* evas, void* eventInfo); + static void processTouchMoveEvent(void* data, Evas* evas, void* eventInfo); + static void processKeyDownEvent(void* data, Evas* evas, void* eventInfo); + static void processKeyUpEvent(void* data, Evas* evas, void* eventInfo); + +protected: + + //////////////////////////////////////////////////////////// + /// \brief Process incoming events from the operating system + /// + //////////////////////////////////////////////////////////// + virtual void processEvents(); + +private: + Evas_Object* m_image; + bool m_hasFocus; + Vector2u m_size; +}; + +} // namespace priv +} // namespace sf + + +#endif // SFML_WINDOWIMPLTIZEN_HPP diff --git a/src/SFML/Window/Window.cpp b/src/SFML/Window/Window.cpp index 70cb418e31..680521a1c8 100644 --- a/src/SFML/Window/Window.cpp +++ b/src/SFML/Window/Window.cpp @@ -110,7 +110,7 @@ void Window::create(VideoMode mode, const String& title, Uint32 style, const Con } // Check validity of style according to the underlying platform - #if defined(SFML_SYSTEM_IOS) || defined(SFML_SYSTEM_ANDROID) + #if defined(SFML_SYSTEM_IOS) || defined(SFML_SYSTEM_ANDROID) || defined(SFML_SYSTEM_TIZEN) if (style & Style::Fullscreen) style &= ~Style::Titlebar; else diff --git a/src/SFML/Window/WindowImpl.cpp b/src/SFML/Window/WindowImpl.cpp index e7133e1656..fc6437a1bd 100644 --- a/src/SFML/Window/WindowImpl.cpp +++ b/src/SFML/Window/WindowImpl.cpp @@ -58,6 +58,11 @@ #include typedef sf::priv::WindowImplAndroid WindowImplType; +#elif defined(SFML_SYSTEM_TIZEN) + + #include + typedef sf::priv::WindowImplTizen WindowImplType; + #endif diff --git a/tools/compile-tizen-extlibs.sh b/tools/compile-tizen-extlibs.sh new file mode 100755 index 0000000000..2ce0e12c35 --- /dev/null +++ b/tools/compile-tizen-extlibs.sh @@ -0,0 +1,157 @@ +#!/usr/bin/env bash + +# This script downloads and compiles the SFML external libraries for +# Tizen (OGG, FLAC, Vorbis, Freetype and JPEG). Eventually, adjust the +# global variables of this script to modify its behavior such as +# downloading different versions of these extlibs, or for more advanced +# used, tweak the compilation options, or even change the compiler. +# +# They can be compiled for various targets and in various configurations +# which must be specicy in parameters when you invoke this script. +# However it leaves no option for the compiler to use; GNU GCC is used +# rather than Clang. +# +# Command-line interface: +# +# compile-tizen-extlibs mobile|wearable version device|emulator +# +# It expects the $TIZEN_STUDIO environment variable set and its going to +# compile everything in-place (in the current directory). The result +# will look like the following. +# +# src/ - Where the extlibs tarball are downloaded +# build/ - Where the sources are extracted and compiled +# tmp/ - Temporary install (inter-dependencies between libs) +# install/ - Where result (lib*.a) is placed +# +# The compilation happens in 4 steps. First, it downloads the source +# tarball of all libraries to compile if not done yet. Then erase any +# local build/, tmp/ and install/ directory. For each libraries, the +# source code is extracted in build/, compiled, and installed in tmp/. +# If the process was successful, All .a files relevant to SFML are +# copied over in the install/ directory. + +# Request the script to fail early if any error occur +set -e + +# Parse command-line arguments and do a bit of checking (checking +# version was omitted) +if ! [ $1 == "mobile" -o $1 == "wearable" ]; then + echo "args: mobile|wearable version device|emulator" + exit 1 +fi + +if ! [ $3 == "device" -o $3 == "emulator" ]; then + echo "args: mobile|wearable version device|emulator" + exit 1 +fi + +# Set script global variables +TIZEN_STUDIO=/opt/tizen-studio + +FLAC_VERSION=1.3.1 +VORBIS_VERSION=1.3.3 +OGG_VERSION=1.3.1 +JPEG_VERSION=9 + +SRCDIR=$PWD/src +BUILDDIR=$PWD/build +TMPDIR=$PWD/tmp +INSTALLDIR=$PWD/install + +DEVICE=$1 +VERSION=$2 +TARGET=$3 + +# Step 1: download and extract source tarball according to requested versions +rm -rf $BUILDDIR +mkdir -p $BUILDDIR + +wget -nc -P src http://www.ijg.org/files/jpegsrc.v$JPEG_VERSION.tar.gz +if [ ! -d "$PWD/tmp/jpeg-$JPEG_VERSION" ] +then + tar -C build -xf src/jpegsrc.v$JPEG_VERSION.tar.gz +fi + +wget -nc -P src http://downloads.xiph.org/releases/flac/flac-$FLAC_VERSION.tar.xz +if [ ! -d "$PWD/tmp/flac-$FLAC_VERSION" ] +then + tar -C build -xf src/flac-$FLAC_VERSION.tar.xz +fi + +wget -nc -P src http://downloads.xiph.org/releases/vorbis/libvorbis-$VORBIS_VERSION.tar.gz +if [ ! -d "$PWD/tmp/libvorbis-$VORBIS_VERSION" ] +then + tar -C build -xf src/libvorbis-$VORBIS_VERSION.tar.gz +fi + +wget -nc -P src http://downloads.xiph.org/releases/ogg/libogg-$OGG_VERSION.tar.gz +if [ ! -d "$PWD/tmp/libogg-$OGG_VERSION" ] +then + tar -C build -xf src/libogg-$OGG_VERSION.tar.gz +fi + +# Step 2: set up compiler and rootstrap according to device, its version +# and target +ROOTSTRAP="${TIZEN_STUDIO}/platforms/tizen-${VERSION}/${DEVICE}/rootstraps/${DEVICE}-${VERSION}-${TARGET}.core" + +if [ $TARGET == "device" ]; then + + export CC="${TIZEN_STUDIO}/tools/arm-linux-gnueabi-gcc-4.9/bin/arm-linux-gnueabi-gcc" + export CXX="${TIZEN_STUDIO}/tools/arm-linux-gnueabi-gcc-4.9/bin/arm-linux-gnueabi-g++" + export LD="${TIZEN_STUDIO}/tools/arm-linux-gnueabi-gcc-4.9/bin/arm-linux-gnueabi-ld" + +elif [ $TARGET == "emulator" ]; then + + export CC="${TIZEN_STUDIO}/tools/i386-linux-gnueabi-gcc-4.9/bin/i386-linux-gnueabi-gcc" + export CXX="${TIZEN_STUDIO}/tools/i386-linux-gnueabi-gcc-4.9/bin/i386-linux-gnueabi-g++" + export LD="${TIZEN_STUDIO}/tools/i386-linux-gnueabi-gcc-4.9/bin/i386-linux-gnueabi-ld" + +fi + +export CFLAGS="-fPIC --sysroot=${ROOTSTRAP} -I${TMPDIR}/usr/include" +export CXXFLAGS="-fPIC --sysroot=${ROOTSTRAP} -I${TMPDIR}/usr/include" +export LDFLAGS="-fPIC --sysroot=${ROOTSTRAP} -L${TMPDIR}/usr/lib" + +# Step 3: compile the three libraries one by one +rm -rf $TMPDIR +rm -rf $INSTALLDIR + +PREFIX=$TMPDIR/usr + +if [ $TARGET == "device" ]; then + HOSTNAME=arm-linux-gnueabi +elif [ $TARGET == "emulator" ]; then + HOSTNAME=i386-linux-gnueabi +fi + +cd $BUILDDIR/jpeg-* +./configure --host=$HOSTNAME --prefix=$TMPDIR/usr --enable-shared=no +make -j4 +make install + +cd $BUILDDIR/libogg-* +./configure --host=$HOSTNAME --prefix=$TMPDIR/usr --enable-shared=no +make -j4 +make install + +cd $BUILDDIR/flac-* +./configure --host=$HOSTNAME --prefix=$TMPDIR/usr --enable-shared=no +make -j4 +make install + +cd $BUILDDIR/libvorbis-* +./configure --host=$HOSTNAME --prefix=$TMPDIR/usr --enable-shared=no +make -j4 +make install + +# Step 4: install compiled extlibs in the install directory +mkdir -p $INSTALLDIR + +cp $TMPDIR/usr/lib/libjpeg.a $INSTALLDIR +cp $TMPDIR/usr/lib/libogg.a $INSTALLDIR +cp $TMPDIR/usr/lib/libFLAC.a $INSTALLDIR +cp $TMPDIR/usr/lib/libFLAC++.a $INSTALLDIR +cp $TMPDIR/usr/lib/libvorbis.a $INSTALLDIR +cp $TMPDIR/usr/lib/libvorbisenc.a $INSTALLDIR +cp $TMPDIR/usr/lib/libvorbisfile.a $INSTALLDIR