Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CEC support for Emulationstation #38

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
1f3b71c
CMakeLists.txt: Fix indentation
CeRiAl May 31, 2015
bdf4242
Add cec-keypresses.sh from https://gist.github.com/bahamas10/6996290 …
CeRiAl May 31, 2015
da0bd0c
CMake/Packages: Add FindLibCEC.cmake
CeRiAl May 31, 2015
ec82cef
CMake: Add libCEC as a dependency ("REQUIRED" for now, should be opti…
CeRiAl May 31, 2015
edb4a03
README: Build out-of-source, mention libCEC dependency
CeRiAl May 31, 2015
e030cff
CMake/Packages: Make FindLibCEC.cmake a bit more flexible
CeRiAl May 31, 2015
4ebbbd1
cec-keypresses.sh: Fix indentation
CeRiAl May 31, 2015
e39bbff
Remove cec-keypresses.sh (not needed any more)
CeRiAl Jun 13, 2015
507d67e
CREDITS: Mention libCEC, add credits to myself
CeRiAl Jun 13, 2015
662af77
README: Add libcec-dev to "apt-get install" commandline, fix typo
CeRiAl Jun 13, 2015
c927c6a
ES-App/Main: Add code to handle our new custom SDL_Event (for CEC)
CeRiAl Jun 13, 2015
a641f4d
ES-Core/InputConfig: Add new InputType "TYPE_CEC", add method to tran…
CeRiAl Jun 13, 2015
93eafb0
ES-Core/InputManager: Add support for CEC-devices
CeRiAl Jun 13, 2015
3f842b2
ES-Core/GUIs/GuiDetectDevice: Add "TYPE_CEC" as an allowed inputType
CeRiAl Jun 13, 2015
988a5a8
ES-Core/InputManager: Clean up the logging
CeRiAl Jun 13, 2015
8334e7b
Fixed build with libCEC 3
Jun 10, 2016
046c624
added ${CMAKE_DL_LIBS} to libraries in CMakeLists.txt
Jun 10, 2016
cdc8f0a
Fix SegFault when no CEC adapter is found
Jun 10, 2016
24f484c
fixed crash on exit because of to early unloaded libcec
Jun 22, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions CMake/Packages/FindLibCEC.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# - Try to find libCEC
# Once done, this will define
#
# LIBCEC_FOUND - system has libCEC
# LIBCEC_INCLUDE_DIRS - the libCEC include directories
# LIBCEC_LIBRARIES - link these to use libCEC

include(FindPkgMacros)
findpkg_begin(LIBCEC)

# Get path, convert backslashes as ${ENV_${var}}
getenv_path(LIBCEC_HOME)

# construct search paths
set(LIBCEC_PREFIX_PATH ${LIBCEC_HOME} ${ENV_LIBCEC_HOME})
create_search_paths(LIBCEC)

# redo search if prefix path changed
clear_if_changed(
LIBCEC_PREFIX_PATH
LIBCEC_LIBRARY_REL
LIBCEC_INCLUDE_DIR
)

set(LIBCEC_LIBRARY_NAMES libcec.a libcec.dylib)

use_pkgconfig(LIBCEC_PKGC libcec)

findpkg_framework(libCEC)

find_path(LIBCEC_INCLUDE_DIR NAMES cec.h HINTS ${LIBCEC_INC_SEARCH_PATH} ${LIBCEC_PKGC_INCLUDE_DIRS})

find_library(LIBCEC_LIBRARY_REL NAMES ${LIBCEC_LIBRARY_NAMES} HINTS ${LIBCEC_LIB_SEARCH_PATH} ${LIBCEC_PKGC_LIBDIR})

make_library_set(LIBCEC_LIBRARY)

findpkg_finish(LIBCEC)
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ find_package(SDL2 REQUIRED)
find_package(Boost REQUIRED COMPONENTS system filesystem date_time locale)
find_package(Eigen3 REQUIRED)
find_package(CURL REQUIRED)
find_package(LibCEC REQUIRED)

#add ALSA for Linux
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
Expand Down Expand Up @@ -96,6 +97,7 @@ set(COMMON_INCLUDE_DIRS
${Boost_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIR}
${CURL_INCLUDE_DIR}
${LIBCEC_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/external
${CMAKE_CURRENT_SOURCE_DIR}/es-core/src
)
Expand Down Expand Up @@ -143,8 +145,10 @@ set(COMMON_LIBRARIES
${Boost_LIBRARIES}
${FREETYPE_LIBRARIES}
${FreeImage_LIBRARIES}
${SDL2_LIBRARY}
${SDL2_LIBRARY}
${CURL_LIBRARIES}
${CMAKE_DL_LIBS}
${LIBCEC_LIBRARY}
pugixml
nanosvg
)
Expand Down
7 changes: 6 additions & 1 deletion CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Programming
UI Art & Design
Nils Bonenberger

libCEC Support
Ismail "CeRiAl" Khatib

Libraries
=========
Expand All @@ -29,8 +31,11 @@ Boost
nanosvg
https://github.com/memononen/nanosvg

libCEC
http://www.pulse-eight.net/

Resources
=========

Open Sans font
http://www.google.com/fonts/specimen/Open+Sans
http://www.google.com/fonts/specimen/Open+Sans
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,32 @@ Building

EmulationStation uses some C++11 code, which means you'll need to use at least g++-4.7 on Linux, or VS2010 on Windows, to compile.

EmulationStation has a few dependencies. For building, you'll need CMake, SDL2, Boost (System, Filesystem, DateTime, Locale), FreeImage, FreeType, Eigen3, and cURL. You also should probably install the `fonts-droid` package which contains fallback fonts for Chinese/Japanese/Korean characters, but ES will still work fine without it (this package is only used at run-time).
EmulationStation has a few dependencies. For building, you'll need CMake, SDL2, Boost (System, Filesystem, DateTime, Locale), FreeImage, FreeType, Eigen3, libCEC, and cURL. You also should probably install the `fonts-droid` package which contains fallback fonts for Chinese/Japanese/Korean characters, but ES will still work fine without it (this package is only used at run-time).

**On Debian/Ubuntu:**
All of this be easily installed with apt-get:
```bash
sudo apt-get install libsdl2-dev libboost-system-dev libboost-filesystem-dev libboost-date-time-dev libboost-locale-dev libfreeimage-dev libfreetype6-dev libeigen3-dev libcurl4-openssl-dev libasound2-dev libgl1-mesa-dev build-essential cmake fonts-droid
sudo apt-get install libsdl2-dev libboost-system-dev libboost-filesystem-dev libboost-date-time-dev libboost-locale-dev libfreeimage-dev libfreetype6-dev libeigen3-dev libcec-dev libcurl4-openssl-dev libasound2-dev libgl1-mesa-dev build-essential cmake fonts-droid
```

Then, generate and build the Makefile with CMake:
```bash
cd YourEmulationStationDirectory
cmake .
mkdir build && cd build
cmake ..
make
```

**On the Raspberry Pi:**

Short build instructions for Raspberry Pi 2:
```bash
cd YourEmulationStationDirectory
mkdir build && cd build
cmake -DCMAKE_CXX_COMPILER=g++-4.7 -DFREETYPE_INCLUDE_DIRS=/usr/include/freetype2 ..
make
```

Complete Raspberry Pi build instructions at [emulationstation.org](http://emulationstation.org/gettingstarted.html#install_rpi_standalone).

**On Windows:**
Expand All @@ -85,7 +94,9 @@ Complete Raspberry Pi build instructions at [emulationstation.org](http://emulat

[cURL](http://curl.haxx.se/download.html) (you'll need to compile or get the pre-compiled DLL version)

(Remember to copy necessary .DLLs into the same folder as the executable: probably FreeImage.dll, freetype6.dll, SDL2.dll, libcurl.dll, and zlib1.dll. Exact list depends on if you built your libraries in "static" mode or not.)
[libCEC](http://packages.pulse-eight.net/)

(Remember to copy necessary .DLLs into the same folder as the executable: probably FreeImage.dll, freetype6.dll, SDL2.dll, libcurl.dll, libcec.dll, and zlib1.dll. Exact list depends on if you built your libraries in "static" mode or not.)

[CMake](http://www.cmake.org/cmake/resources/software.html) (this is used for generating the Visual Studio project)

Expand Down
38 changes: 22 additions & 16 deletions es-app/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,29 +315,35 @@ int main(int argc, char* argv[])

int lastTime = SDL_GetTicks();
bool running = true;
Uint32 CecEventType = InputManager::getInstance()->getCecEventType();

while(running)
{
SDL_Event event;
while(SDL_PollEvent(&event))
{
switch(event.type)
if(CecEventType != ((Uint32)-1) && event.type == CecEventType)
{
case SDL_JOYHATMOTION:
case SDL_JOYBUTTONDOWN:
case SDL_JOYBUTTONUP:
case SDL_KEYDOWN:
case SDL_KEYUP:
case SDL_JOYAXISMOTION:
case SDL_TEXTINPUT:
case SDL_TEXTEDITING:
case SDL_JOYDEVICEADDED:
case SDL_JOYDEVICEREMOVED:
InputManager::getInstance()->parseEvent(event, &window);
break;
case SDL_QUIT:
running = false;
break;
InputManager::getInstance()->parseEvent(event, &window);
}else{
switch(event.type)
{
case SDL_JOYHATMOTION:
case SDL_JOYBUTTONDOWN:
case SDL_JOYBUTTONUP:
case SDL_KEYDOWN:
case SDL_KEYUP:
case SDL_JOYAXISMOTION:
case SDL_TEXTINPUT:
case SDL_TEXTEDITING:
case SDL_JOYDEVICEADDED:
case SDL_JOYDEVICEREMOVED:
InputManager::getInstance()->parseEvent(event, &window);
break;
case SDL_QUIT:
running = false;
break;
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions es-core/src/InputConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ std::string inputTypeToString(InputType type)
return "axis";
case TYPE_BUTTON:
return "button";
case TYPE_CEC:
return "cec_key";
case TYPE_HAT:
return "hat";
case TYPE_KEY:
Expand All @@ -32,6 +34,8 @@ InputType stringToInputType(const std::string& type)
return TYPE_AXIS;
if(type == "button")
return TYPE_BUTTON;
if(type == "cec_key")
return TYPE_CEC;
if(type == "hat")
return TYPE_HAT;
if(type == "key")
Expand Down
Loading