00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "Core/precomp.h"
00020
00021 #ifdef USE_FBDEV
00022
00023 #include "implementation_fbdev.h"
00024 #include "API/Display/Display/display.h"
00025 #include "Display/Display/FBDev/display_fbdev.h"
00026 #include "API/Display/Input/input.h"
00027
00028 #include "Display/Input/TTY/keyboard_tty.h"
00029 #include "Display/Input/X11/joystick_linux.h"
00030 #include "implementation.h"
00031
00032 bool CL_Implementation_FBDev::initialized = false;
00033 int CL_Implementation_FBDev::display_counter=0;
00034
00035 static CL_Implementation_FBDev impl_fbdev;
00036
00037 extern "C"
00038 {
00039 DL_PREFIX char* clan_module_identify()
00040 {
00041 return "Linux FBDEV target";
00042 }
00043
00044 DL_PREFIX char* clan_module_abbreviation()
00045 {
00046 return "fbdev";
00047 }
00048
00049 DL_PREFIX void clan_module_init()
00050 {
00051 impl_fbdev.add_display();
00052 }
00053 }
00054
00055 char *fbdev_identify()
00056 {
00057 return clan_module_identify();
00058 }
00059
00060 char *fbdev_abbreviation()
00061 {
00062 return clan_module_abbreviation();
00063 }
00064
00065 void fbdev_init()
00066 {
00067 clan_module_init();
00068 }
00069
00070 CL_Implementation_FBDev::~CL_Implementation_FBDev()
00071 {
00072 clean_up();
00073 }
00074
00075 bool CL_Implementation_FBDev::init()
00076 {
00077 if (initialized) return true;
00078
00079 return true;
00080 }
00081
00082 void CL_Implementation_FBDev::clean_up()
00083 {
00084 if (display_counter == 0) return;
00085
00086 display_counter--;
00087 if (display_counter>0) return;
00088 }
00089
00090 void CL_Implementation_FBDev::add_display()
00091 {
00092 if (init() == false)
00093 {
00094 std::cout << "ClanLib: Failed to open display. No FBDev display available." << std::endl;
00095 }
00096
00097 CL_FBDev_DisplayCard *card = new CL_FBDev_DisplayCard(display_counter);
00098
00099 CL_Display::cards.push_back(card);
00100
00101 CL_Input::keyboards.push_back(new CL_TTYKeyboard());
00102
00103
00104 #ifdef USE_JOY
00105 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0)
00106
00107 for (int i=0; i<8; i++)
00108 {
00109 CL_LinuxJoystick *joy = new CL_LinuxJoystick();
00110 if (joy->init(i))
00111 CL_Input::joysticks.push_back(joy);
00112 else
00113 delete joy;
00114 }
00115
00116 #endif
00117 #endif
00118
00119 display_counter++;
00120 }
00121
00122 #endif