All Classes Namespaces Files Functions Variables Enumerations Enumerator
libs/controller/SdlJoystickInit.cpp
Go to the documentation of this file.
00001 
00012 #ifdef HAVE_CONFIG_H
00013 #include "config.h"
00014 #endif
00015 #include "SdlJoystickInit.h"
00016 #include "SdlVideoInit.h"
00017 #include <SDL.h>
00018 
00019 using namespace qrk;
00020 
00021 
00025 struct SdlJoystickInit::pImpl : private SdlVideoInit
00026 {
00027   static bool initialized;
00028 
00029   static void joystickQuit(void) {
00030     SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
00031   }
00032 };
00033 
00034 bool SdlJoystickInit::pImpl::initialized = false;
00035 
00036 
00037 SdlJoystickInit::SdlJoystickInit(void) : pimpl(new pImpl)
00038 {
00039   if (pimpl->initialized == false) {
00040     if (SDL_InitSubSystem(SDL_INIT_JOYSTICK)) {
00041       // !!! LogManager へのメッセージ表示
00042       return;
00043     }
00044     SDL_InitSubSystem(SDL_INIT_VIDEO);
00045     atexit(pImpl::joystickQuit);
00046     SDL_JoystickEventState(SDL_ENABLE);
00047     pimpl->initialized = true;
00048   }
00049 }
00050 
00051 
00052 SdlJoystickInit::~SdlJoystickInit(void) {
00053 }