Renamed things named after BeOS to be named after Haiku instead.
authorRyan C. Gordon <icculus@icculus.org>
Thu, 14 Nov 2013 11:51:24 -0500
changeset 79816d538bc1b395
parent 7980 3122e7af0bf5
child 7983 eed9fd44234c
Renamed things named after BeOS to be named after Haiku instead.
CMakeLists.txt
cmake/sdlchecks.cmake
configure
configure.in
include/SDL_config.h.cmake
include/SDL_config.h.in
include/SDL_platform.h
include/SDL_thread.h
src/SDL.c
src/audio/SDL_audio.c
src/audio/baudio/SDL_beaudio.cc
src/audio/baudio/SDL_beaudio.h
src/audio/haiku/SDL_haikuaudio.cc
src/audio/haiku/SDL_haikuaudio.h
src/events/SDL_sysevents.h
src/filesystem/beos/SDL_sysfilesystem.cc
src/filesystem/haiku/SDL_sysfilesystem.cc
src/joystick/beos/SDL_bejoystick.cc
src/joystick/haiku/SDL_haikujoystick.cc
src/loadso/beos/SDL_sysloadso.c
src/loadso/haiku/SDL_sysloadso.c
src/main/beos/SDL_BApp.h
src/main/beos/SDL_BeApp.cc
src/main/beos/SDL_BeApp.h
src/main/haiku/SDL_BApp.h
src/main/haiku/SDL_BeApp.cc
src/main/haiku/SDL_BeApp.h
src/power/SDL_power.c
src/power/beos/SDL_syspower.c
src/power/haiku/SDL_syspower.c
src/timer/beos/SDL_systimer.c
src/timer/haiku/SDL_systimer.c
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/bwindow/SDL_BWin.h
src/video/bwindow/SDL_bclipboard.cc
src/video/bwindow/SDL_bclipboard.h
src/video/bwindow/SDL_bevents.cc
src/video/bwindow/SDL_bevents.h
src/video/bwindow/SDL_bframebuffer.cc
src/video/bwindow/SDL_bframebuffer.h
src/video/bwindow/SDL_bkeyboard.cc
src/video/bwindow/SDL_bkeyboard.h
src/video/bwindow/SDL_bmodes.cc
src/video/bwindow/SDL_bmodes.h
src/video/bwindow/SDL_bopengl.cc
src/video/bwindow/SDL_bopengl.h
src/video/bwindow/SDL_bvideo.cc
src/video/bwindow/SDL_bvideo.h
src/video/bwindow/SDL_bwindow.cc
src/video/bwindow/SDL_bwindow.h
src/video/haiku/SDL_BWin.h
src/video/haiku/SDL_bclipboard.cc
src/video/haiku/SDL_bclipboard.h
src/video/haiku/SDL_bevents.cc
src/video/haiku/SDL_bevents.h
src/video/haiku/SDL_bframebuffer.cc
src/video/haiku/SDL_bframebuffer.h
src/video/haiku/SDL_bkeyboard.cc
src/video/haiku/SDL_bkeyboard.h
src/video/haiku/SDL_bmodes.cc
src/video/haiku/SDL_bmodes.h
src/video/haiku/SDL_bopengl.cc
src/video/haiku/SDL_bopengl.h
src/video/haiku/SDL_bvideo.cc
src/video/haiku/SDL_bvideo.h
src/video/haiku/SDL_bwindow.cc
src/video/haiku/SDL_bwindow.h
test/configure
test/configure.in
visualtest/configure
visualtest/configure.in
     1.1 --- a/CMakeLists.txt	Thu Nov 14 10:19:07 2013 -0300
     1.2 +++ b/CMakeLists.txt	Thu Nov 14 11:51:24 2013 -0500
     1.3 @@ -95,8 +95,10 @@
     1.4      set(MACOSX TRUE)
     1.5    endif()
     1.6    # TODO: iOS?
     1.7 -elseif(CMAKE_SYSTEM_NAME MATCHES "Haiku.*|BeOS.*")
     1.8 -  set(BEOS TRUE)
     1.9 +elseif(CMAKE_SYSTEM_NAME MATCHES "BeOS.*")
    1.10 +  message_error("BeOS support has been removed as of SDL 2.0.2.")
    1.11 +elseif(CMAKE_SYSTEM_NAME MATCHES "Haiku.*")
    1.12 +  set(HAIKU TRUE)
    1.13  endif()
    1.14  
    1.15  # Don't mistake osx for unix
    1.16 @@ -308,9 +310,9 @@
    1.17  
    1.18    check_c_compiler_flag(-Wall HAVE_GCC_WALL)
    1.19    if(HAVE_GCC_WALL)
    1.20 -    if(CMAKE_SYSTEM_NAME MATCHES "Haiku|BeOS")
    1.21 +    if(HAIKU)
    1.22        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-multichar")
    1.23 -    endif(CMAKE_SYSTEM_NAME MATCHES "Haiku|BeOS")
    1.24 +    endif(HAIKU)
    1.25    endif(HAVE_GCC_WALL)
    1.26  endif(USE_GCC)
    1.27  
    1.28 @@ -991,15 +993,15 @@
    1.29    endif(SDL_VIDEO)
    1.30  
    1.31    CheckPTHREAD()
    1.32 -elseif(BEOS)
    1.33 +elseif(HAIKU)
    1.34    if(SDL_VIDEO)
    1.35 -    set(SDL_VIDEO_DRIVER_BWINDOW 1)
    1.36 -    file(GLOB BWINDOW_SOURCES ${SDL2_SOURCE_DIR}/src/video/bwindow/*.c)
    1.37 -    set(SOURCE_FILES ${SOURCE_FILES} ${BWINDOW_SOURCES})
    1.38 +    set(SDL_VIDEO_DRIVER_HAIKU 1)
    1.39 +    file(GLOB HAIKUVIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/haiku/*.c)
    1.40 +    set(SOURCE_FILES ${SOURCE_FILES} ${HAIKUVIDEO_SOURCES})
    1.41      set(HAVE_SDL_VIDEO TRUE)
    1.42  
    1.43 -    set(SDL_FILESYSTEM_BEOS 1)
    1.44 -    file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/beos/*.cc)
    1.45 +    set(SDL_FILESYSTEM_HAIKU 1)
    1.46 +    file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/haiku/*.cc)
    1.47      set(SOURCE_FILES ${SOURCE_FILES} ${FILESYSTEM_SOURCES})
    1.48      set(HAVE_SDL_FILESYSTEM TRUE)
    1.49  
     2.1 --- a/cmake/sdlchecks.cmake	Thu Nov 14 10:19:07 2013 -0300
     2.2 +++ b/cmake/sdlchecks.cmake	Thu Nov 14 11:51:24 2013 -0500
     2.3 @@ -638,7 +638,7 @@
     2.4      elseif(HPUX)
     2.5        set(PTHREAD_CFLAGS "-D_REENTRANT")
     2.6        set(PTHREAD_LDFLAGS "-L/usr/lib -pthread")
     2.7 -    elseif(BEOS)
     2.8 +    elseif(HAIKU)
     2.9        set(PTHREAD_CFLAGS "-D_REENTRANT")
    2.10        set(PTHREAD_LDFLAGS "")
    2.11      else()
     3.1 --- a/configure	Thu Nov 14 10:19:07 2013 -0300
     3.2 +++ b/configure	Thu Nov 14 11:51:24 2013 -0500
     3.3 @@ -15950,7 +15950,7 @@
     3.4      fi
     3.5  fi
     3.6  
     3.7 -# Actually this doesn't work on OpenBSD and BeOS
     3.8 +# Actually this doesn't work on OpenBSD
     3.9  #AC_MSG_CHECKING(for linker option --no-undefined)
    3.10  #have_no_undefined=no
    3.11  #save_LDFLAGS="$LDFLAGS"
    3.12 @@ -18598,7 +18598,7 @@
    3.13  $as_echo_n "checking for necessary GCC -Wno-multichar option... " >&6; }
    3.14          need_gcc_Wno_multichar=no
    3.15          case "$host" in
    3.16 -            *-*-beos* | *-*-haiku*)
    3.17 +            *-*-haiku*)
    3.18                  need_gcc_Wno_multichar=yes
    3.19                  ;;
    3.20          esac
    3.21 @@ -20124,13 +20124,13 @@
    3.22      fi
    3.23  }
    3.24  
    3.25 -CheckBWINDOW()
    3.26 +CheckHaikuVideo()
    3.27  {
    3.28      if test x$enable_video = xyes; then
    3.29  
    3.30 -$as_echo "#define SDL_VIDEO_DRIVER_BWINDOW 1" >>confdefs.h
    3.31 -
    3.32 -        SOURCES="$SOURCES $srcdir/src/video/bwindow/*.cc"
    3.33 +$as_echo "#define SDL_VIDEO_DRIVER_HAIKU 1" >>confdefs.h
    3.34 +
    3.35 +        SOURCES="$SOURCES $srcdir/src/video/haiku/*.cc"
    3.36          have_video=yes
    3.37      fi
    3.38  }
    3.39 @@ -20680,14 +20680,14 @@
    3.40      fi
    3.41  }
    3.42  
    3.43 -CheckBeGL()
    3.44 +CheckHaikuGL()
    3.45  {
    3.46      if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
    3.47  
    3.48  $as_echo "#define SDL_VIDEO_OPENGL 1" >>confdefs.h
    3.49  
    3.50  
    3.51 -$as_echo "#define SDL_VIDEO_OPENGL_BGL 1" >>confdefs.h
    3.52 +$as_echo "#define SDL_VIDEO_OPENGL_HAIKU 1" >>confdefs.h
    3.53  
    3.54  
    3.55  $as_echo "#define SDL_VIDEO_RENDER_OGL 1" >>confdefs.h
    3.56 @@ -22399,66 +22399,72 @@
    3.57          fi
    3.58          ;;
    3.59  
    3.60 +        *-*-beos*)
    3.61 +        as_fn_error $? "
    3.62 +*** BeOS support has been removed as of SDL 2.0.2.
    3.63 +        " "$LINENO" 5
    3.64 +        ;;
    3.65  
    3.66      *-*-haiku*)
    3.67 -        ARCH=beos
    3.68 +        ARCH=haiku
    3.69          ac_default_prefix=/boot/common
    3.70          CheckDummyVideo
    3.71          CheckDiskAudio
    3.72          CheckDummyAudio
    3.73 -        CheckBWINDOW
    3.74 -        CheckBeGL
    3.75 +        CheckHaikuVideo
    3.76 +        CheckHaikuGL
    3.77          CheckPTHREAD
    3.78 +
    3.79          # Set up files for the audio library
    3.80          if test x$enable_audio = xyes; then
    3.81  
    3.82 -$as_echo "#define SDL_AUDIO_DRIVER_BEOSAUDIO 1" >>confdefs.h
    3.83 -
    3.84 -            SOURCES="$SOURCES $srcdir/src/audio/baudio/*.cc"
    3.85 +$as_echo "#define SDL_AUDIO_DRIVER_HAIKU 1" >>confdefs.h
    3.86 +
    3.87 +            SOURCES="$SOURCES $srcdir/src/audio/haiku/*.cc"
    3.88              have_audio=yes
    3.89          fi
    3.90          # Set up files for the joystick library
    3.91          if test x$enable_joystick = xyes; then
    3.92  
    3.93 -$as_echo "#define SDL_JOYSTICK_BEOS 1" >>confdefs.h
    3.94 -
    3.95 -            SOURCES="$SOURCES $srcdir/src/joystick/beos/*.cc"
    3.96 +$as_echo "#define SDL_JOYSTICK_HAIKU 1" >>confdefs.h
    3.97 +
    3.98 +            SOURCES="$SOURCES $srcdir/src/joystick/haiku/*.cc"
    3.99              have_joystick=yes
   3.100          fi
   3.101          # Set up files for the timer library
   3.102          if test x$enable_timers = xyes; then
   3.103  
   3.104 -$as_echo "#define SDL_TIMER_BEOS 1" >>confdefs.h
   3.105 -
   3.106 -            SOURCES="$SOURCES $srcdir/src/timer/beos/*.c"
   3.107 +$as_echo "#define SDL_TIMER_HAIKU 1" >>confdefs.h
   3.108 +
   3.109 +            SOURCES="$SOURCES $srcdir/src/timer/haiku/*.c"
   3.110              have_timers=yes
   3.111          fi
   3.112          # Set up files for the shared object loading library
   3.113          if test x$enable_loadso = xyes; then
   3.114  
   3.115 -$as_echo "#define SDL_LOADSO_BEOS 1" >>confdefs.h
   3.116 -
   3.117 -            SOURCES="$SOURCES $srcdir/src/loadso/beos/*.c"
   3.118 +$as_echo "#define SDL_LOADSO_HAIKU 1" >>confdefs.h
   3.119 +
   3.120 +            SOURCES="$SOURCES $srcdir/src/loadso/haiku/*.c"
   3.121              have_loadso=yes
   3.122          fi
   3.123          # Set up files for the system power library
   3.124          if test x$enable_power = xyes; then
   3.125  
   3.126 -$as_echo "#define SDL_POWER_BEOS 1" >>confdefs.h
   3.127 -
   3.128 -            SOURCES="$SOURCES $srcdir/src/power/beos/*.c"
   3.129 +$as_echo "#define SDL_POWER_HAIKU 1" >>confdefs.h
   3.130 +
   3.131 +            SOURCES="$SOURCES $srcdir/src/power/haiku/*.c"
   3.132              have_power=yes
   3.133          fi
   3.134          # Set up files for the system filesystem library
   3.135          if test x$enable_filesystem = xyes; then
   3.136  
   3.137 -$as_echo "#define SDL_FILESYSTEM_BEOS 1" >>confdefs.h
   3.138 -
   3.139 -            SOURCES="$SOURCES $srcdir/src/filesystem/beos/*.cc"
   3.140 +$as_echo "#define SDL_FILESYSTEM_HAIKU 1" >>confdefs.h
   3.141 +
   3.142 +            SOURCES="$SOURCES $srcdir/src/filesystem/haiku/*.cc"
   3.143              have_filesystem=yes
   3.144          fi
   3.145          # The BeOS platform requires special setup.
   3.146 -        SOURCES="$srcdir/src/main/beos/*.cc $SOURCES"
   3.147 +        SOURCES="$srcdir/src/main/haiku/*.cc $SOURCES"
   3.148          EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lroot -lbe -lmedia -lgame -ldevice -ltextencoding"
   3.149          ;;
   3.150      arm*-apple-darwin*)
     4.1 --- a/configure.in	Thu Nov 14 10:19:07 2013 -0300
     4.2 +++ b/configure.in	Thu Nov 14 11:51:24 2013 -0500
     4.3 @@ -204,7 +204,7 @@
     4.4      fi
     4.5  fi
     4.6  
     4.7 -# Actually this doesn't work on OpenBSD and BeOS
     4.8 +# Actually this doesn't work on OpenBSD
     4.9  #AC_MSG_CHECKING(for linker option --no-undefined)
    4.10  #have_no_undefined=no
    4.11  #save_LDFLAGS="$LDFLAGS"
    4.12 @@ -1097,7 +1097,7 @@
    4.13          AC_MSG_CHECKING(for necessary GCC -Wno-multichar option)
    4.14          need_gcc_Wno_multichar=no
    4.15          case "$host" in
    4.16 -            *-*-beos* | *-*-haiku*)
    4.17 +            *-*-haiku*)
    4.18                  need_gcc_Wno_multichar=yes
    4.19                  ;;
    4.20          esac
    4.21 @@ -1474,12 +1474,12 @@
    4.22      fi
    4.23  }
    4.24  
    4.25 -dnl Set up the BWindow video driver if enabled
    4.26 -CheckBWINDOW()
    4.27 +dnl Set up the Haiku video driver if enabled
    4.28 +CheckHaikuVideo()
    4.29  {
    4.30      if test x$enable_video = xyes; then
    4.31 -        AC_DEFINE(SDL_VIDEO_DRIVER_BWINDOW, 1, [ ])
    4.32 -        SOURCES="$SOURCES $srcdir/src/video/bwindow/*.cc"
    4.33 +        AC_DEFINE(SDL_VIDEO_DRIVER_HAIKU, 1, [ ])
    4.34 +        SOURCES="$SOURCES $srcdir/src/video/haiku/*.cc"
    4.35          have_video=yes
    4.36      fi
    4.37  }
    4.38 @@ -1743,12 +1743,12 @@
    4.39      fi
    4.40  }
    4.41  
    4.42 -dnl Check for BeOS OpenGL
    4.43 -CheckBeGL()
    4.44 +dnl Check for Haiku OpenGL
    4.45 +CheckHaikuGL()
    4.46  {
    4.47      if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
    4.48          AC_DEFINE(SDL_VIDEO_OPENGL, 1, [ ])
    4.49 -        AC_DEFINE(SDL_VIDEO_OPENGL_BGL, 1, [ ])
    4.50 +        AC_DEFINE(SDL_VIDEO_OPENGL_HAIKU, 1, [ ])
    4.51          AC_DEFINE(SDL_VIDEO_RENDER_OGL, 1, [ ])
    4.52          EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGL"
    4.53      fi
    4.54 @@ -2619,55 +2619,60 @@
    4.55          ;;
    4.56  
    4.57      dnl BeOS support removed after SDL 2.0.1. Haiku still works.  --ryan.
    4.58 -    dnl *-*-beos*)
    4.59 +    *-*-beos*)
    4.60 +        AC_MSG_ERROR([
    4.61 +*** BeOS support has been removed as of SDL 2.0.2.
    4.62 +        ])
    4.63 +        ;;
    4.64  
    4.65      *-*-haiku*)
    4.66 -        ARCH=beos
    4.67 +        ARCH=haiku
    4.68          ac_default_prefix=/boot/common
    4.69          CheckDummyVideo
    4.70          CheckDiskAudio
    4.71          CheckDummyAudio
    4.72 -        CheckBWINDOW
    4.73 -        CheckBeGL
    4.74 +        CheckHaikuVideo
    4.75 +        CheckHaikuGL
    4.76          CheckPTHREAD
    4.77 +
    4.78          # Set up files for the audio library
    4.79          if test x$enable_audio = xyes; then
    4.80 -            AC_DEFINE(SDL_AUDIO_DRIVER_BEOSAUDIO, 1, [ ])
    4.81 -            SOURCES="$SOURCES $srcdir/src/audio/baudio/*.cc"
    4.82 +            AC_DEFINE(SDL_AUDIO_DRIVER_HAIKU, 1, [ ])
    4.83 +            SOURCES="$SOURCES $srcdir/src/audio/haiku/*.cc"
    4.84              have_audio=yes
    4.85          fi
    4.86          # Set up files for the joystick library
    4.87          if test x$enable_joystick = xyes; then
    4.88 -            AC_DEFINE(SDL_JOYSTICK_BEOS, 1, [ ])
    4.89 -            SOURCES="$SOURCES $srcdir/src/joystick/beos/*.cc"
    4.90 +            AC_DEFINE(SDL_JOYSTICK_HAIKU, 1, [ ])
    4.91 +            SOURCES="$SOURCES $srcdir/src/joystick/haiku/*.cc"
    4.92              have_joystick=yes
    4.93          fi
    4.94          # Set up files for the timer library
    4.95          if test x$enable_timers = xyes; then
    4.96 -            AC_DEFINE(SDL_TIMER_BEOS, 1, [ ])
    4.97 -            SOURCES="$SOURCES $srcdir/src/timer/beos/*.c"
    4.98 +            AC_DEFINE(SDL_TIMER_HAIKU, 1, [ ])
    4.99 +            SOURCES="$SOURCES $srcdir/src/timer/haiku/*.c"
   4.100              have_timers=yes
   4.101          fi
   4.102          # Set up files for the shared object loading library
   4.103          if test x$enable_loadso = xyes; then
   4.104 -            AC_DEFINE(SDL_LOADSO_BEOS, 1, [ ])
   4.105 -            SOURCES="$SOURCES $srcdir/src/loadso/beos/*.c"
   4.106 +            AC_DEFINE(SDL_LOADSO_HAIKU, 1, [ ])
   4.107 +            SOURCES="$SOURCES $srcdir/src/loadso/haiku/*.c"
   4.108              have_loadso=yes
   4.109          fi
   4.110          # Set up files for the system power library
   4.111          if test x$enable_power = xyes; then
   4.112 -            AC_DEFINE(SDL_POWER_BEOS, 1, [ ])
   4.113 -            SOURCES="$SOURCES $srcdir/src/power/beos/*.c"
   4.114 +            AC_DEFINE(SDL_POWER_HAIKU, 1, [ ])
   4.115 +            SOURCES="$SOURCES $srcdir/src/power/haiku/*.c"
   4.116              have_power=yes
   4.117          fi
   4.118          # Set up files for the system filesystem library
   4.119          if test x$enable_filesystem = xyes; then
   4.120 -            AC_DEFINE(SDL_FILESYSTEM_BEOS, 1, [ ])
   4.121 -            SOURCES="$SOURCES $srcdir/src/filesystem/beos/*.cc"
   4.122 +            AC_DEFINE(SDL_FILESYSTEM_HAIKU, 1, [ ])
   4.123 +            SOURCES="$SOURCES $srcdir/src/filesystem/haiku/*.cc"
   4.124              have_filesystem=yes
   4.125          fi
   4.126 -        # The BeOS platform requires special setup.
   4.127 -        SOURCES="$srcdir/src/main/beos/*.cc $SOURCES"
   4.128 +        # The Haiku platform requires special setup.
   4.129 +        SOURCES="$srcdir/src/main/haiku/*.cc $SOURCES"
   4.130          EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lroot -lbe -lmedia -lgame -ldevice -ltextencoding"
   4.131          ;;
   4.132      arm*-apple-darwin*)
     5.1 --- a/include/SDL_config.h.cmake	Thu Nov 14 10:19:07 2013 -0300
     5.2 +++ b/include/SDL_config.h.cmake	Thu Nov 14 11:51:24 2013 -0500
     5.3 @@ -191,7 +191,7 @@
     5.4  #cmakedefine SDL_AUDIO_DRIVER_ARTS_DYNAMIC @SDL_AUDIO_DRIVER_ARTS_DYNAMIC@
     5.5  #cmakedefine SDL_AUDIO_DRIVER_PULSEAUDIO @SDL_AUDIO_DRIVER_PULSEAUDIO@
     5.6  #cmakedefine SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC @SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC@
     5.7 -#cmakedefine SDL_AUDIO_DRIVER_BEOSAUDIO @SDL_AUDIO_DRIVER_BEOSAUDIO@
     5.8 +#cmakedefine SDL_AUDIO_DRIVER_HAIKU @SDL_AUDIO_DRIVER_HAIKU@
     5.9  #cmakedefine SDL_AUDIO_DRIVER_BSD @SDL_AUDIO_DRIVER_BSD@
    5.10  #cmakedefine SDL_AUDIO_DRIVER_COREAUDIO @SDL_AUDIO_DRIVER_COREAUDIO@
    5.11  #cmakedefine SDL_AUDIO_DRIVER_DISK @SDL_AUDIO_DRIVER_DISK@
    5.12 @@ -216,7 +216,7 @@
    5.13  /* Enable various input drivers */
    5.14  #cmakedefine SDL_INPUT_LINUXEV @SDL_INPUT_LINUXEV@
    5.15  #cmakedefine SDL_INPUT_TSLIB @SDL_INPUT_TSLIB@
    5.16 -#cmakedefine SDL_JOYSTICK_BEOS @SDL_JOYSTICK_BEOS@
    5.17 +#cmakedefine SDL_JOYSTICK_HAIKU @SDL_JOYSTICK_HAIKU@
    5.18  #cmakedefine SDL_JOYSTICK_DINPUT @SDL_JOYSTICK_DINPUT@
    5.19  #cmakedefine SDL_JOYSTICK_DUMMY @SDL_JOYSTICK_DUMMY@
    5.20  #cmakedefine SDL_JOYSTICK_IOKIT @SDL_JOYSTICK_IOKIT@
    5.21 @@ -230,7 +230,7 @@
    5.22  #cmakedefine SDL_HAPTIC_DINPUT @SDL_HAPTIC_DINPUT@
    5.23  
    5.24  /* Enable various shared object loading systems */
    5.25 -#cmakedefine SDL_LOADSO_BEOS @SDL_LOADSO_BEOS@
    5.26 +#cmakedefine SDL_LOADSO_HAIKU @SDL_LOADSO_HAIKU@
    5.27  #cmakedefine SDL_LOADSO_DLOPEN @SDL_LOADSO_DLOPEN@
    5.28  #cmakedefine SDL_LOADSO_DUMMY @SDL_LOADSO_DUMMY@
    5.29  #cmakedefine SDL_LOADSO_LDG @SDL_LOADSO_LDG@
    5.30 @@ -243,14 +243,14 @@
    5.31  #cmakedefine SDL_THREAD_WINDOWS @SDL_THREAD_WINDOWS@
    5.32  
    5.33  /* Enable various timer systems */
    5.34 -#cmakedefine SDL_TIMER_BEOS @SDL_TIMER_BEOS@
    5.35 +#cmakedefine SDL_TIMER_HAIKU @SDL_TIMER_HAIKU@
    5.36  #cmakedefine SDL_TIMER_DUMMY @SDL_TIMER_DUMMY@
    5.37  #cmakedefine SDL_TIMER_UNIX @SDL_TIMER_UNIX@
    5.38  #cmakedefine SDL_TIMER_WINDOWS @SDL_TIMER_WINDOWS@
    5.39  #cmakedefine SDL_TIMER_WINCE @SDL_TIMER_WINCE@
    5.40  
    5.41  /* Enable various video drivers */
    5.42 -#cmakedefine SDL_VIDEO_DRIVER_BWINDOW @SDL_VIDEO_DRIVER_BWINDOW@
    5.43 +#cmakedefine SDL_VIDEO_DRIVER_HAIKU @SDL_VIDEO_DRIVER_HAIKU@
    5.44  #cmakedefine SDL_VIDEO_DRIVER_COCOA @SDL_VIDEO_DRIVER_COCOA@
    5.45  #cmakedefine SDL_VIDEO_DRIVER_DIRECTFB @SDL_VIDEO_DRIVER_DIRECTFB@
    5.46  #cmakedefine SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC @SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC@
    5.47 @@ -300,11 +300,11 @@
    5.48  #cmakedefine SDL_POWER_LINUX @SDL_POWER_LINUX@
    5.49  #cmakedefine SDL_POWER_WINDOWS @SDL_POWER_WINDOWS@
    5.50  #cmakedefine SDL_POWER_MACOSX @SDL_POWER_MACOSX@
    5.51 -#cmakedefine SDL_POWER_BEOS @SDL_POWER_BEOS@
    5.52 +#cmakedefine SDL_POWER_HAIKU @SDL_POWER_HAIKU@
    5.53  #cmakedefine SDL_POWER_HARDWIRED @SDL_POWER_HARDWIRED@
    5.54  
    5.55  /* Enable system filesystem support */
    5.56 -#cmakedefine SDL_FILESYSTEM_BEOS @SDL_FILESYSTEM_BEOS@
    5.57 +#cmakedefine SDL_FILESYSTEM_HAIKU @SDL_FILESYSTEM_HAIKU@
    5.58  #cmakedefine SDL_FILESYSTEM_COCOA @SDL_FILESYSTEM_COCOA@
    5.59  #cmakedefine SDL_FILESYSTEM_DUMMY @SDL_FILESYSTEM_DUMMY@
    5.60  #cmakedefine SDL_FILESYSTEM_UNIX @SDL_FILESYSTEM_UNIX@
     6.1 --- a/include/SDL_config.h.in	Thu Nov 14 10:19:07 2013 -0300
     6.2 +++ b/include/SDL_config.h.in	Thu Nov 14 11:51:24 2013 -0500
     6.3 @@ -193,7 +193,7 @@
     6.4  #undef SDL_AUDIO_DRIVER_ARTS_DYNAMIC
     6.5  #undef SDL_AUDIO_DRIVER_PULSEAUDIO
     6.6  #undef SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC
     6.7 -#undef SDL_AUDIO_DRIVER_BEOSAUDIO
     6.8 +#undef SDL_AUDIO_DRIVER_HAIKU
     6.9  #undef SDL_AUDIO_DRIVER_BSD
    6.10  #undef SDL_AUDIO_DRIVER_COREAUDIO
    6.11  #undef SDL_AUDIO_DRIVER_DISK
    6.12 @@ -219,7 +219,7 @@
    6.13  #undef SDL_INPUT_LINUXEV
    6.14  #undef SDL_INPUT_LINUXKD
    6.15  #undef SDL_INPUT_TSLIB
    6.16 -#undef SDL_JOYSTICK_BEOS
    6.17 +#undef SDL_JOYSTICK_HAIKU
    6.18  #undef SDL_JOYSTICK_DINPUT
    6.19  #undef SDL_JOYSTICK_DUMMY
    6.20  #undef SDL_JOYSTICK_IOKIT
    6.21 @@ -233,7 +233,7 @@
    6.22  #undef SDL_HAPTIC_DINPUT
    6.23  
    6.24  /* Enable various shared object loading systems */
    6.25 -#undef SDL_LOADSO_BEOS
    6.26 +#undef SDL_LOADSO_HAIKU
    6.27  #undef SDL_LOADSO_DLOPEN
    6.28  #undef SDL_LOADSO_DUMMY
    6.29  #undef SDL_LOADSO_LDG
    6.30 @@ -246,13 +246,13 @@
    6.31  #undef SDL_THREAD_WINDOWS
    6.32  
    6.33  /* Enable various timer systems */
    6.34 -#undef SDL_TIMER_BEOS
    6.35 +#undef SDL_TIMER_HAIKU
    6.36  #undef SDL_TIMER_DUMMY
    6.37  #undef SDL_TIMER_UNIX
    6.38  #undef SDL_TIMER_WINDOWS
    6.39  
    6.40  /* Enable various video drivers */
    6.41 -#undef SDL_VIDEO_DRIVER_BWINDOW
    6.42 +#undef SDL_VIDEO_DRIVER_HAIKU
    6.43  #undef SDL_VIDEO_DRIVER_COCOA
    6.44  #undef SDL_VIDEO_DRIVER_DIRECTFB
    6.45  #undef SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC
    6.46 @@ -303,11 +303,11 @@
    6.47  #undef SDL_POWER_LINUX
    6.48  #undef SDL_POWER_WINDOWS
    6.49  #undef SDL_POWER_MACOSX
    6.50 -#undef SDL_POWER_BEOS
    6.51 +#undef SDL_POWER_HAIKU
    6.52  #undef SDL_POWER_HARDWIRED
    6.53  
    6.54  /* Enable system filesystem support */
    6.55 -#undef SDL_FILESYSTEM_BEOS
    6.56 +#undef SDL_FILESYSTEM_HAIKU
    6.57  #undef SDL_FILESYSTEM_COCOA
    6.58  #undef SDL_FILESYSTEM_DUMMY
    6.59  #undef SDL_FILESYSTEM_UNIX
     7.1 --- a/include/SDL_platform.h	Thu Nov 14 10:19:07 2013 -0300
     7.2 +++ b/include/SDL_platform.h	Thu Nov 14 11:51:24 2013 -0500
     7.3 @@ -32,10 +32,6 @@
     7.4  #undef __AIX__
     7.5  #define __AIX__     1
     7.6  #endif
     7.7 -#if defined(__BEOS__)
     7.8 -#undef __BEOS__
     7.9 -#define __BEOS__    1
    7.10 -#endif
    7.11  #if defined(__HAIKU__)
    7.12  #undef __HAIKU__
    7.13  #define __HAIKU__   1
     8.1 --- a/include/SDL_thread.h	Thu Nov 14 10:19:07 2013 -0300
     8.2 +++ b/include/SDL_thread.h	Thu Nov 14 11:51:24 2013 -0500
     8.3 @@ -119,7 +119,7 @@
     8.4   *  Create a thread.
     8.5   *
     8.6   *   Thread naming is a little complicated: Most systems have very small
     8.7 - *    limits for the string length (BeOS has 32 bytes, Linux currently has 16,
     8.8 + *    limits for the string length (Haiku has 32 bytes, Linux currently has 16,
     8.9   *    Visual C++ 6.0 has nine!), and possibly other arbitrary rules. You'll
    8.10   *    have to see what happens with your system's debugger. The name should be
    8.11   *    UTF-8 (but using the naming limits of C identifiers is a better bet).
     9.1 --- a/src/SDL.c	Thu Nov 14 10:19:07 2013 -0300
     9.2 +++ b/src/SDL.c	Thu Nov 14 11:51:24 2013 -0500
     9.3 @@ -396,8 +396,6 @@
     9.4      return "AIX";
     9.5  #elif __ANDROID__
     9.6      return "Android";
     9.7 -#elif __BEOS__
     9.8 -    return "BeOS";
     9.9  #elif __BSDI__
    9.10      return "BSDI";
    9.11  #elif __DREAMCAST__
    10.1 --- a/src/audio/SDL_audio.c	Thu Nov 14 10:19:07 2013 -0300
    10.2 +++ b/src/audio/SDL_audio.c	Thu Nov 14 11:51:24 2013 -0500
    10.3 @@ -56,7 +56,7 @@
    10.4  extern AudioBootStrap DSOUND_bootstrap;
    10.5  extern AudioBootStrap WINMM_bootstrap;
    10.6  extern AudioBootStrap PAUDIO_bootstrap;
    10.7 -extern AudioBootStrap BEOSAUDIO_bootstrap;
    10.8 +extern AudioBootStrap HAIKUAUDIO_bootstrap;
    10.9  extern AudioBootStrap COREAUDIO_bootstrap;
   10.10  extern AudioBootStrap SNDMGR_bootstrap;
   10.11  extern AudioBootStrap DISKAUD_bootstrap;
   10.12 @@ -113,8 +113,8 @@
   10.13  #if SDL_AUDIO_DRIVER_PAUDIO
   10.14      &PAUDIO_bootstrap,
   10.15  #endif
   10.16 -#if SDL_AUDIO_DRIVER_BEOSAUDIO
   10.17 -    &BEOSAUDIO_bootstrap,
   10.18 +#if SDL_AUDIO_DRIVER_HAIKU
   10.19 +    &HAIKUAUDIO_bootstrap,
   10.20  #endif
   10.21  #if SDL_AUDIO_DRIVER_COREAUDIO
   10.22      &COREAUDIO_bootstrap,
    11.1 --- a/src/audio/baudio/SDL_beaudio.cc	Thu Nov 14 10:19:07 2013 -0300
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,240 +0,0 @@
    11.4 -/*
    11.5 -  Simple DirectMedia Layer
    11.6 -  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    11.7 -
    11.8 -  This software is provided 'as-is', without any express or implied
    11.9 -  warranty.  In no event will the authors be held liable for any damages
   11.10 -  arising from the use of this software.
   11.11 -
   11.12 -  Permission is granted to anyone to use this software for any purpose,
   11.13 -  including commercial applications, and to alter it and redistribute it
   11.14 -  freely, subject to the following restrictions:
   11.15 -
   11.16 -  1. The origin of this software must not be misrepresented; you must not
   11.17 -     claim that you wrote the original software. If you use this software
   11.18 -     in a product, an acknowledgment in the product documentation would be
   11.19 -     appreciated but is not required.
   11.20 -  2. Altered source versions must be plainly marked as such, and must not be
   11.21 -     misrepresented as being the original software.
   11.22 -  3. This notice may not be removed or altered from any source distribution.
   11.23 -*/
   11.24 -#include "SDL_config.h"
   11.25 -
   11.26 -#if SDL_AUDIO_DRIVER_BEOSAUDIO
   11.27 -
   11.28 -/* Allow access to the audio stream on BeOS */
   11.29 -
   11.30 -#include <SoundPlayer.h>
   11.31 -#include <signal.h>
   11.32 -
   11.33 -#include "../../main/beos/SDL_BeApp.h"
   11.34 -
   11.35 -extern "C"
   11.36 -{
   11.37 -
   11.38 -#include "SDL_audio.h"
   11.39 -#include "../SDL_audio_c.h"
   11.40 -#include "../SDL_sysaudio.h"
   11.41 -#include "SDL_beaudio.h"
   11.42 -
   11.43 -}
   11.44 -
   11.45 -
   11.46 -/* !!! FIXME: have the callback call the higher level to avoid code dupe. */
   11.47 -/* The BeOS callback for handling the audio buffer */
   11.48 -static void
   11.49 -FillSound(void *device, void *stream, size_t len,
   11.50 -          const media_raw_audio_format & format)
   11.51 -{
   11.52 -    SDL_AudioDevice *audio = (SDL_AudioDevice *) device;
   11.53 -
   11.54 -    /* Only do soemthing if audio is enabled */
   11.55 -    if (!audio->enabled)
   11.56 -        return;
   11.57 -
   11.58 -    if (!audio->paused) {
   11.59 -        if (audio->convert.needed) {
   11.60 -            SDL_LockMutex(audio->mixer_lock);
   11.61 -            (*audio->spec.callback) (audio->spec.userdata,
   11.62 -                                     (Uint8 *) audio->convert.buf,
   11.63 -                                     audio->convert.len);
   11.64 -            SDL_UnlockMutex(audio->mixer_lock);
   11.65 -            SDL_ConvertAudio(&audio->convert);
   11.66 -            SDL_memcpy(stream, audio->convert.buf, audio->convert.len_cvt);
   11.67 -        } else {
   11.68 -            SDL_LockMutex(audio->mixer_lock);
   11.69 -            (*audio->spec.callback) (audio->spec.userdata,
   11.70 -                                     (Uint8 *) stream, len);
   11.71 -            SDL_UnlockMutex(audio->mixer_lock);
   11.72 -        }
   11.73 -    }
   11.74 -}
   11.75 -
   11.76 -static void
   11.77 -BEOSAUDIO_CloseDevice(_THIS)
   11.78 -{
   11.79 -    if (_this->hidden != NULL) {
   11.80 -        if (_this->hidden->audio_obj) {
   11.81 -            _this->hidden->audio_obj->Stop();
   11.82 -            delete _this->hidden->audio_obj;
   11.83 -            _this->hidden->audio_obj = NULL;
   11.84 -        }
   11.85 -
   11.86 -        delete _this->hidden;
   11.87 -        _this->hidden = NULL;
   11.88 -    }
   11.89 -}
   11.90 -
   11.91 -
   11.92 -static const int sig_list[] = {
   11.93 -    SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGALRM, SIGTERM, SIGWINCH, 0
   11.94 -};
   11.95 -
   11.96 -static inline void
   11.97 -MaskSignals(sigset_t * omask)
   11.98 -{
   11.99 -    sigset_t mask;
  11.100 -    int i;
  11.101 -
  11.102 -    sigemptyset(&mask);
  11.103 -    for (i = 0; sig_list[i]; ++i) {
  11.104 -        sigaddset(&mask, sig_list[i]);
  11.105 -    }
  11.106 -    sigprocmask(SIG_BLOCK, &mask, omask);
  11.107 -}
  11.108 -
  11.109 -static inline void
  11.110 -UnmaskSignals(sigset_t * omask)
  11.111 -{
  11.112 -    sigprocmask(SIG_SETMASK, omask, NULL);
  11.113 -}
  11.114 -
  11.115 -
  11.116 -static int
  11.117 -BEOSAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
  11.118 -{
  11.119 -    int valid_datatype = 0;
  11.120 -    media_raw_audio_format format;
  11.121 -    SDL_AudioFormat test_format = SDL_FirstAudioFormat(_this->spec.format);
  11.122 -
  11.123 -    /* Initialize all variables that we clean on shutdown */
  11.124 -    _this->hidden = new SDL_PrivateAudioData;
  11.125 -    if (_this->hidden == NULL) {
  11.126 -        return SDL_OutOfMemory();
  11.127 -    }
  11.128 -    SDL_memset(_this->hidden, 0, (sizeof *_this->hidden));
  11.129 -
  11.130 -    /* Parse the audio format and fill the Be raw audio format */
  11.131 -    SDL_memset(&format, '\0', sizeof(media_raw_audio_format));
  11.132 -    format.byte_order = B_MEDIA_LITTLE_ENDIAN;
  11.133 -    format.frame_rate = (float) _this->spec.freq;
  11.134 -    format.channel_count = _this->spec.channels;        /* !!! FIXME: support > 2? */
  11.135 -    while ((!valid_datatype) && (test_format)) {
  11.136 -        valid_datatype = 1;
  11.137 -        _this->spec.format = test_format;
  11.138 -        switch (test_format) {
  11.139 -        case AUDIO_S8:
  11.140 -            format.format = media_raw_audio_format::B_AUDIO_CHAR;
  11.141 -            break;
  11.142 -
  11.143 -        case AUDIO_U8:
  11.144 -            format.format = media_raw_audio_format::B_AUDIO_UCHAR;
  11.145 -            break;
  11.146 -
  11.147 -        case AUDIO_S16LSB:
  11.148 -            format.format = media_raw_audio_format::B_AUDIO_SHORT;
  11.149 -            break;
  11.150 -
  11.151 -        case AUDIO_S16MSB:
  11.152 -            format.format = media_raw_audio_format::B_AUDIO_SHORT;
  11.153 -            format.byte_order = B_MEDIA_BIG_ENDIAN;
  11.154 -            break;
  11.155 -
  11.156 -        case AUDIO_S32LSB:
  11.157 -            format.format = media_raw_audio_format::B_AUDIO_INT;
  11.158 -            break;
  11.159 -
  11.160 -        case AUDIO_S32MSB:
  11.161 -            format.format = media_raw_audio_format::B_AUDIO_INT;
  11.162 -            format.byte_order = B_MEDIA_BIG_ENDIAN;
  11.163 -            break;
  11.164 -
  11.165 -        case AUDIO_F32LSB:
  11.166 -            format.format = media_raw_audio_format::B_AUDIO_FLOAT;
  11.167 -            break;
  11.168 -
  11.169 -        case AUDIO_F32MSB:
  11.170 -            format.format = media_raw_audio_format::B_AUDIO_FLOAT;
  11.171 -            format.byte_order = B_MEDIA_BIG_ENDIAN;
  11.172 -            break;
  11.173 -
  11.174 -        default:
  11.175 -            valid_datatype = 0;
  11.176 -            test_format = SDL_NextAudioFormat();
  11.177 -            break;
  11.178 -        }
  11.179 -    }
  11.180 -
  11.181 -    if (!valid_datatype) {      /* shouldn't happen, but just in case... */
  11.182 -        BEOSAUDIO_CloseDevice(_this);
  11.183 -        return SDL_SetError("Unsupported audio format");
  11.184 -    }
  11.185 -
  11.186 -    /* Calculate the final parameters for this audio specification */
  11.187 -    SDL_CalculateAudioSpec(&_this->spec);
  11.188 -
  11.189 -    format.buffer_size = _this->spec.size;
  11.190 -
  11.191 -    /* Subscribe to the audio stream (creates a new thread) */
  11.192 -    sigset_t omask;
  11.193 -    MaskSignals(&omask);
  11.194 -    _this->hidden->audio_obj = new BSoundPlayer(&format, "SDL Audio",
  11.195 -                                                FillSound, NULL, _this);
  11.196 -    UnmaskSignals(&omask);
  11.197 -
  11.198 -    if (_this->hidden->audio_obj->Start() == B_NO_ERROR) {
  11.199 -        _this->hidden->audio_obj->SetHasData(true);
  11.200 -    } else {
  11.201 -        BEOSAUDIO_CloseDevice(_this);
  11.202 -        return SDL_SetError("Unable to start Be audio");
  11.203 -    }
  11.204 -
  11.205 -    /* We're running! */
  11.206 -    return 0;
  11.207 -}
  11.208 -
  11.209 -static void
  11.210 -BEOSAUDIO_Deinitialize(void)
  11.211 -{
  11.212 -    SDL_QuitBeApp();
  11.213 -}
  11.214 -
  11.215 -static int
  11.216 -BEOSAUDIO_Init(SDL_AudioDriverImpl * impl)
  11.217 -{
  11.218 -    /* Initialize the Be Application, if it's not already started */
  11.219 -    if (SDL_InitBeApp() < 0) {
  11.220 -        return 0;
  11.221 -    }
  11.222 -
  11.223 -    /* Set the function pointers */
  11.224 -    impl->OpenDevice = BEOSAUDIO_OpenDevice;
  11.225 -    impl->CloseDevice = BEOSAUDIO_CloseDevice;
  11.226 -    impl->Deinitialize = BEOSAUDIO_Deinitialize;
  11.227 -    impl->ProvidesOwnCallbackThread = 1;
  11.228 -    impl->OnlyHasDefaultOutputDevice = 1;
  11.229 -
  11.230 -    return 1;   /* this audio target is available. */
  11.231 -}
  11.232 -
  11.233 -extern "C"
  11.234 -{
  11.235 -    extern AudioBootStrap BEOSAUDIO_bootstrap;
  11.236 -}
  11.237 -AudioBootStrap BEOSAUDIO_bootstrap = {
  11.238 -    "baudio", "BeOS BSoundPlayer", BEOSAUDIO_Init, 0
  11.239 -};
  11.240 -
  11.241 -#endif /* SDL_AUDIO_DRIVER_BEOSAUDIO */
  11.242 -
  11.243 -/* vi: set ts=4 sw=4 expandtab: */
    12.1 --- a/src/audio/baudio/SDL_beaudio.h	Thu Nov 14 10:19:07 2013 -0300
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,38 +0,0 @@
    12.4 -/*
    12.5 -  Simple DirectMedia Layer
    12.6 -  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    12.7 -
    12.8 -  This software is provided 'as-is', without any express or implied
    12.9 -  warranty.  In no event will the authors be held liable for any damages
   12.10 -  arising from the use of this software.
   12.11 -
   12.12 -  Permission is granted to anyone to use this software for any purpose,
   12.13 -  including commercial applications, and to alter it and redistribute it
   12.14 -  freely, subject to the following restrictions:
   12.15 -
   12.16 -  1. The origin of this software must not be misrepresented; you must not
   12.17 -     claim that you wrote the original software. If you use this software
   12.18 -     in a product, an acknowledgment in the product documentation would be
   12.19 -     appreciated but is not required.
   12.20 -  2. Altered source versions must be plainly marked as such, and must not be
   12.21 -     misrepresented as being the original software.
   12.22 -  3. This notice may not be removed or altered from any source distribution.
   12.23 -*/
   12.24 -#include "SDL_config.h"
   12.25 -
   12.26 -#ifndef _SDL_beaudio_h
   12.27 -#define _SDL_beaudio_h
   12.28 -
   12.29 -#include "../SDL_sysaudio.h"
   12.30 -
   12.31 -/* Hidden "this" pointer for the audio functions */
   12.32 -#define _THIS   SDL_AudioDevice *_this
   12.33 -
   12.34 -struct SDL_PrivateAudioData
   12.35 -{
   12.36 -    BSoundPlayer *audio_obj;
   12.37 -};
   12.38 -
   12.39 -#endif /* _SDL_beaudio_h */
   12.40 -
   12.41 -/* vi: set ts=4 sw=4 expandtab: */
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/src/audio/haiku/SDL_haikuaudio.cc	Thu Nov 14 11:51:24 2013 -0500
    13.3 @@ -0,0 +1,240 @@
    13.4 +/*
    13.5 +  Simple DirectMedia Layer
    13.6 +  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    13.7 +
    13.8 +  This software is provided 'as-is', without any express or implied
    13.9 +  warranty.  In no event will the authors be held liable for any damages
   13.10 +  arising from the use of this software.
   13.11 +
   13.12 +  Permission is granted to anyone to use this software for any purpose,
   13.13 +  including commercial applications, and to alter it and redistribute it
   13.14 +  freely, subject to the following restrictions:
   13.15 +
   13.16 +  1. The origin of this software must not be misrepresented; you must not
   13.17 +     claim that you wrote the original software. If you use this software
   13.18 +     in a product, an acknowledgment in the product documentation would be
   13.19 +     appreciated but is not required.
   13.20 +  2. Altered source versions must be plainly marked as such, and must not be
   13.21 +     misrepresented as being the original software.
   13.22 +  3. This notice may not be removed or altered from any source distribution.
   13.23 +*/
   13.24 +#include "SDL_config.h"
   13.25 +
   13.26 +#if SDL_AUDIO_DRIVER_HAIKU
   13.27 +
   13.28 +/* Allow access to the audio stream on Haiku */
   13.29 +
   13.30 +#include <SoundPlayer.h>
   13.31 +#include <signal.h>
   13.32 +
   13.33 +#include "../../main/haiku/SDL_BeApp.h"
   13.34 +
   13.35 +extern "C"
   13.36 +{
   13.37 +
   13.38 +#include "SDL_audio.h"
   13.39 +#include "../SDL_audio_c.h"
   13.40 +#include "../SDL_sysaudio.h"
   13.41 +#include "SDL_haikuaudio.h"
   13.42 +
   13.43 +}
   13.44 +
   13.45 +
   13.46 +/* !!! FIXME: have the callback call the higher level to avoid code dupe. */
   13.47 +/* The Haiku callback for handling the audio buffer */
   13.48 +static void
   13.49 +FillSound(void *device, void *stream, size_t len,
   13.50 +          const media_raw_audio_format & format)
   13.51 +{
   13.52 +    SDL_AudioDevice *audio = (SDL_AudioDevice *) device;
   13.53 +
   13.54 +    /* Only do soemthing if audio is enabled */
   13.55 +    if (!audio->enabled)
   13.56 +        return;
   13.57 +
   13.58 +    if (!audio->paused) {
   13.59 +        if (audio->convert.needed) {
   13.60 +            SDL_LockMutex(audio->mixer_lock);
   13.61 +            (*audio->spec.callback) (audio->spec.userdata,
   13.62 +                                     (Uint8 *) audio->convert.buf,
   13.63 +                                     audio->convert.len);
   13.64 +            SDL_UnlockMutex(audio->mixer_lock);
   13.65 +            SDL_ConvertAudio(&audio->convert);
   13.66 +            SDL_memcpy(stream, audio->convert.buf, audio->convert.len_cvt);
   13.67 +        } else {
   13.68 +            SDL_LockMutex(audio->mixer_lock);
   13.69 +            (*audio->spec.callback) (audio->spec.userdata,
   13.70 +                                     (Uint8 *) stream, len);
   13.71 +            SDL_UnlockMutex(audio->mixer_lock);
   13.72 +        }
   13.73 +    }
   13.74 +}
   13.75 +
   13.76 +static void
   13.77 +HAIKUAUDIO_CloseDevice(_THIS)
   13.78 +{
   13.79 +    if (_this->hidden != NULL) {
   13.80 +        if (_this->hidden->audio_obj) {
   13.81 +            _this->hidden->audio_obj->Stop();
   13.82 +            delete _this->hidden->audio_obj;
   13.83 +            _this->hidden->audio_obj = NULL;
   13.84 +        }
   13.85 +
   13.86 +        delete _this->hidden;
   13.87 +        _this->hidden = NULL;
   13.88 +    }
   13.89 +}
   13.90 +
   13.91 +
   13.92 +static const int sig_list[] = {
   13.93 +    SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGALRM, SIGTERM, SIGWINCH, 0
   13.94 +};
   13.95 +
   13.96 +static inline void
   13.97 +MaskSignals(sigset_t * omask)
   13.98 +{
   13.99 +    sigset_t mask;
  13.100 +    int i;
  13.101 +
  13.102 +    sigemptyset(&mask);
  13.103 +    for (i = 0; sig_list[i]; ++i) {
  13.104 +        sigaddset(&mask, sig_list[i]);
  13.105 +    }
  13.106 +    sigprocmask(SIG_BLOCK, &mask, omask);
  13.107 +}
  13.108 +
  13.109 +static inline void
  13.110 +UnmaskSignals(sigset_t * omask)
  13.111 +{
  13.112 +    sigprocmask(SIG_SETMASK, omask, NULL);
  13.113 +}
  13.114 +
  13.115 +
  13.116 +static int
  13.117 +HAIKUAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
  13.118 +{
  13.119 +    int valid_datatype = 0;
  13.120 +    media_raw_audio_format format;
  13.121 +    SDL_AudioFormat test_format = SDL_FirstAudioFormat(_this->spec.format);
  13.122 +
  13.123 +    /* Initialize all variables that we clean on shutdown */
  13.124 +    _this->hidden = new SDL_PrivateAudioData;
  13.125 +    if (_this->hidden == NULL) {
  13.126 +        return SDL_OutOfMemory();
  13.127 +    }
  13.128 +    SDL_memset(_this->hidden, 0, (sizeof *_this->hidden));
  13.129 +
  13.130 +    /* Parse the audio format and fill the Be raw audio format */
  13.131 +    SDL_memset(&format, '\0', sizeof(media_raw_audio_format));
  13.132 +    format.byte_order = B_MEDIA_LITTLE_ENDIAN;
  13.133 +    format.frame_rate = (float) _this->spec.freq;
  13.134 +    format.channel_count = _this->spec.channels;        /* !!! FIXME: support > 2? */
  13.135 +    while ((!valid_datatype) && (test_format)) {
  13.136 +        valid_datatype = 1;
  13.137 +        _this->spec.format = test_format;
  13.138 +        switch (test_format) {
  13.139 +        case AUDIO_S8:
  13.140 +            format.format = media_raw_audio_format::B_AUDIO_CHAR;
  13.141 +            break;
  13.142 +
  13.143 +        case AUDIO_U8:
  13.144 +            format.format = media_raw_audio_format::B_AUDIO_UCHAR;
  13.145 +            break;
  13.146 +
  13.147 +        case AUDIO_S16LSB:
  13.148 +            format.format = media_raw_audio_format::B_AUDIO_SHORT;
  13.149 +            break;
  13.150 +
  13.151 +        case AUDIO_S16MSB:
  13.152 +            format.format = media_raw_audio_format::B_AUDIO_SHORT;
  13.153 +            format.byte_order = B_MEDIA_BIG_ENDIAN;
  13.154 +            break;
  13.155 +
  13.156 +        case AUDIO_S32LSB:
  13.157 +            format.format = media_raw_audio_format::B_AUDIO_INT;
  13.158 +            break;
  13.159 +
  13.160 +        case AUDIO_S32MSB:
  13.161 +            format.format = media_raw_audio_format::B_AUDIO_INT;
  13.162 +            format.byte_order = B_MEDIA_BIG_ENDIAN;
  13.163 +            break;
  13.164 +
  13.165 +        case AUDIO_F32LSB:
  13.166 +            format.format = media_raw_audio_format::B_AUDIO_FLOAT;
  13.167 +            break;
  13.168 +
  13.169 +        case AUDIO_F32MSB:
  13.170 +            format.format = media_raw_audio_format::B_AUDIO_FLOAT;
  13.171 +            format.byte_order = B_MEDIA_BIG_ENDIAN;
  13.172 +            break;
  13.173 +
  13.174 +        default:
  13.175 +            valid_datatype = 0;
  13.176 +            test_format = SDL_NextAudioFormat();
  13.177 +            break;
  13.178 +        }
  13.179 +    }
  13.180 +
  13.181 +    if (!valid_datatype) {      /* shouldn't happen, but just in case... */
  13.182 +        HAIKUAUDIO_CloseDevice(_this);
  13.183 +        return SDL_SetError("Unsupported audio format");
  13.184 +    }
  13.185 +
  13.186 +    /* Calculate the final parameters for this audio specification */
  13.187 +    SDL_CalculateAudioSpec(&_this->spec);
  13.188 +
  13.189 +    format.buffer_size = _this->spec.size;
  13.190 +
  13.191 +    /* Subscribe to the audio stream (creates a new thread) */
  13.192 +    sigset_t omask;
  13.193 +    MaskSignals(&omask);
  13.194 +    _this->hidden->audio_obj = new BSoundPlayer(&format, "SDL Audio",
  13.195 +                                                FillSound, NULL, _this);
  13.196 +    UnmaskSignals(&omask);
  13.197 +
  13.198 +    if (_this->hidden->audio_obj->Start() == B_NO_ERROR) {
  13.199 +        _this->hidden->audio_obj->SetHasData(true);
  13.200 +    } else {
  13.201 +        HAIKUAUDIO_CloseDevice(_this);
  13.202 +        return SDL_SetError("Unable to start Be audio");
  13.203 +    }
  13.204 +
  13.205 +    /* We're running! */
  13.206 +    return 0;
  13.207 +}
  13.208 +
  13.209 +static void
  13.210 +HAIKUAUDIO_Deinitialize(void)
  13.211 +{
  13.212 +    SDL_QuitBeApp();
  13.213 +}
  13.214 +
  13.215 +static int
  13.216 +HAIKUAUDIO_Init(SDL_AudioDriverImpl * impl)
  13.217 +{
  13.218 +    /* Initialize the Be Application, if it's not already started */
  13.219 +    if (SDL_InitBeApp() < 0) {
  13.220 +        return 0;
  13.221 +    }
  13.222 +
  13.223 +    /* Set the function pointers */
  13.224 +    impl->OpenDevice = HAIKUAUDIO_OpenDevice;
  13.225 +    impl->CloseDevice = HAIKUAUDIO_CloseDevice;
  13.226 +    impl->Deinitialize = HAIKUAUDIO_Deinitialize;
  13.227 +    impl->ProvidesOwnCallbackThread = 1;
  13.228 +    impl->OnlyHasDefaultOutputDevice = 1;
  13.229 +
  13.230 +    return 1;   /* this audio target is available. */
  13.231 +}
  13.232 +
  13.233 +extern "C"
  13.234 +{
  13.235 +    extern AudioBootStrap HAIKUAUDIO_bootstrap;
  13.236 +}
  13.237 +AudioBootStrap HAIKUAUDIO_bootstrap = {
  13.238 +    "haiku", "Haiku BSoundPlayer", HAIKUAUDIO_Init, 0
  13.239 +};
  13.240 +
  13.241 +#endif /* SDL_AUDIO_DRIVER_HAIKU */
  13.242 +
  13.243 +/* vi: set ts=4 sw=4 expandtab: */
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/src/audio/haiku/SDL_haikuaudio.h	Thu Nov 14 11:51:24 2013 -0500
    14.3 @@ -0,0 +1,38 @@
    14.4 +/*
    14.5 +  Simple DirectMedia Layer
    14.6 +  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    14.7 +
    14.8 +  This software is provided 'as-is', without any express or implied
    14.9 +  warranty.  In no event will the authors be held liable for any damages
   14.10 +  arising from the use of this software.
   14.11 +
   14.12 +  Permission is granted to anyone to use this software for any purpose,
   14.13 +  including commercial applications, and to alter it and redistribute it
   14.14 +  freely, subject to the following restrictions:
   14.15 +
   14.16 +  1. The origin of this software must not be misrepresented; you must not
   14.17 +     claim that you wrote the original software. If you use this software
   14.18 +     in a product, an acknowledgment in the product documentation would be
   14.19 +     appreciated but is not required.
   14.20 +  2. Altered source versions must be plainly marked as such, and must not be
   14.21 +     misrepresented as being the original software.
   14.22 +  3. This notice may not be removed or altered from any source distribution.
   14.23 +*/
   14.24 +#include "SDL_config.h"
   14.25 +
   14.26 +#ifndef _SDL_beaudio_h
   14.27 +#define _SDL_beaudio_h
   14.28 +
   14.29 +#include "../SDL_sysaudio.h"
   14.30 +
   14.31 +/* Hidden "this" pointer for the audio functions */
   14.32 +#define _THIS   SDL_AudioDevice *_this
   14.33 +
   14.34 +struct SDL_PrivateAudioData
   14.35 +{
   14.36 +    BSoundPlayer *audio_obj;
   14.37 +};
   14.38 +
   14.39 +#endif /* _SDL_beaudio_h */
   14.40 +
   14.41 +/* vi: set ts=4 sw=4 expandtab: */
    15.1 --- a/src/events/SDL_sysevents.h	Thu Nov 14 10:19:07 2013 -0300
    15.2 +++ b/src/events/SDL_sysevents.h	Thu Nov 14 11:51:24 2013 -0500
    15.3 @@ -24,8 +24,8 @@
    15.4  
    15.5  /* Useful functions and variables from SDL_sysevents.c */
    15.6  
    15.7 -#if defined(__BEOS__) || defined(__HAIKU__) 
    15.8 -/* The Be and Haiku event loops run in a separate thread */
    15.9 +#if defined(__HAIKU__)
   15.10 +/* The Haiku event loops run in a separate thread */
   15.11  #define MUST_THREAD_EVENTS
   15.12  #endif
   15.13  
    16.1 --- a/src/filesystem/beos/SDL_sysfilesystem.cc	Thu Nov 14 10:19:07 2013 -0300
    16.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.3 @@ -1,93 +0,0 @@
    16.4 -/*
    16.5 -  Simple DirectMedia Layer
    16.6 -  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    16.7 -
    16.8 -  This software is provided 'as-is', without any express or implied
    16.9 -  warranty.  In no event will the authors be held liable for any damages
   16.10 -  arising from the use of this software.
   16.11 -
   16.12 -  Permission is granted to anyone to use this software for any purpose,
   16.13 -  including commercial applications, and to alter it and redistribute it
   16.14 -  freely, subject to the following restrictions:
   16.15 -
   16.16 -  1. The origin of this software must not be misrepresented; you must not
   16.17 -     claim that you wrote the original software. If you use this software
   16.18 -     in a product, an acknowledgment in the product documentation would be
   16.19 -     appreciated but is not required.
   16.20 -  2. Altered source versions must be plainly marked as such, and must not be
   16.21 -     misrepresented as being the original software.
   16.22 -  3. This notice may not be removed or altered from any source distribution.
   16.23 -*/
   16.24 -#include "SDL_config.h"
   16.25 -
   16.26 -#ifdef SDL_FILESYSTEM_BEOS
   16.27 -
   16.28 -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
   16.29 -/* System dependent filesystem routines                                */
   16.30 -
   16.31 -#include <os/kernel/image.h>
   16.32 -#include <os/storage/Directory.h>
   16.33 -#include <os/storage/Entry.h>
   16.34 -#include <os/storage/Path.h>
   16.35 -
   16.36 -#include "SDL_error.h"
   16.37 -#include "SDL_stdinc.h"
   16.38 -#include "SDL_assert.h"
   16.39 -#include "SDL_filesystem.h"
   16.40 -
   16.41 -char *
   16.42 -SDL_GetBasePath(void)
   16.43 -{
   16.44 -    image_info info;
   16.45 -    int32 cookie = 0;
   16.46 -
   16.47 -    while (get_next_image_info(0, &cookie, &info) == B_OK) {
   16.48 -        if (info.type == B_APP_IMAGE) {
   16.49 -            break;
   16.50 -        }
   16.51 -    }
   16.52 -
   16.53 -    BEntry entry(info.name, true);
   16.54 -    BPath path;
   16.55 -    status_t rc = entry.GetPath(&path);  /* (path) now has binary's path. */
   16.56 -    SDL_assert(rc == B_OK);
   16.57 -    rc = path.GetParent(&path); /* chop filename, keep directory. */
   16.58 -    SDL_assert(rc == B_OK);
   16.59 -    const char *str = path.Path();
   16.60 -    SDL_assert(str != NULL);
   16.61 -
   16.62 -    const size_t len = SDL_strlen(str);
   16.63 -    char *retval = (char *) SDL_malloc(len + 2);
   16.64 -    if (!retval) {
   16.65 -        SDL_OutOfMemory();
   16.66 -        return NULL;
   16.67 -    }
   16.68 -
   16.69 -    SDL_memcpy(retval, str, len);
   16.70 -    retval[len] = '/';
   16.71 -    retval[len+1] = '\0';
   16.72 -    return retval;
   16.73 -}
   16.74 -
   16.75 -
   16.76 -char *
   16.77 -SDL_GetPrefPath(const char *org, const char *app)
   16.78 -{
   16.79 -    // !!! FIXME: is there a better way to do this?
   16.80 -    const char *home = SDL_getenv("HOME");
   16.81 -    const char *append = "config/settings/";
   16.82 -    const size_t len = SDL_strlen(home) + SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3;
   16.83 -    char *retval = (char *) SDL_malloc(len);
   16.84 -    if (!retval) {
   16.85 -        SDL_OutOfMemory();
   16.86 -    } else {
   16.87 -        SDL_snprintf(retval, len, "%s%s%s/%s/", home, append, org, app);
   16.88 -        create_directory(retval, 0700);  // BeOS api: creates missing dirs
   16.89 -    }
   16.90 -
   16.91 -    return retval;
   16.92 -}
   16.93 -
   16.94 -#endif /* SDL_FILESYSTEM_BEOS */
   16.95 -
   16.96 -/* vi: set ts=4 sw=4 expandtab: */
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/src/filesystem/haiku/SDL_sysfilesystem.cc	Thu Nov 14 11:51:24 2013 -0500
    17.3 @@ -0,0 +1,93 @@
    17.4 +/*
    17.5 +  Simple DirectMedia Layer
    17.6 +  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    17.7 +
    17.8 +  This software is provided 'as-is', without any express or implied
    17.9 +  warranty.  In no event will the authors be held liable for any damages
   17.10 +  arising from the use of this software.
   17.11 +
   17.12 +  Permission is granted to anyone to use this software for any purpose,
   17.13 +  including commercial applications, and to alter it and redistribute it
   17.14 +  freely, subject to the following restrictions:
   17.15 +
   17.16 +  1. The origin of this software must not be misrepresented; you must not
   17.17 +     claim that you wrote the original software. If you use this software
   17.18 +     in a product, an acknowledgment in the product documentation would be
   17.19 +     appreciated but is not required.
   17.20 +  2. Altered source versions must be plainly marked as such, and must not be
   17.21 +     misrepresented as being the original software.
   17.22 +  3. This notice may not be removed or altered from any source distribution.
   17.23 +*/
   17.24 +#include "SDL_config.h"
   17.25 +
   17.26 +#ifdef SDL_FILESYSTEM_HAIKU
   17.27 +
   17.28 +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
   17.29 +/* System dependent filesystem routines                                */
   17.30 +
   17.31 +#include <os/kernel/image.h>
   17.32 +#include <os/storage/Directory.h>
   17.33 +#include <os/storage/Entry.h>
   17.34 +#include <os/storage/Path.h>
   17.35 +
   17.36 +#include "SDL_error.h"
   17.37 +#include "SDL_stdinc.h"
   17.38 +#include "SDL_assert.h"
   17.39 +#include "SDL_filesystem.h"
   17.40 +
   17.41 +char *
   17.42 +SDL_GetBasePath(void)
   17.43 +{
   17.44 +    image_info info;
   17.45 +    int32 cookie = 0;
   17.46 +
   17.47 +    while (get_next_image_info(0, &cookie, &info) == B_OK) {
   17.48 +        if (info.type == B_APP_IMAGE) {
   17.49 +            break;
   17.50 +        }
   17.51 +    }
   17.52 +
   17.53 +    BEntry entry(info.name, true);
   17.54 +    BPath path;
   17.55 +    status_t rc = entry.GetPath(&path);  /* (path) now has binary's path. */
   17.56 +    SDL_assert(rc == B_OK);
   17.57 +    rc = path.GetParent(&path); /* chop filename, keep directory. */
   17.58 +    SDL_assert(rc == B_OK);
   17.59 +    const char *str = path.Path();
   17.60 +    SDL_assert(str != NULL);
   17.61 +
   17.62 +    const size_t len = SDL_strlen(str);
   17.63 +    char *retval = (char *) SDL_malloc(len + 2);
   17.64 +    if (!retval) {
   17.65 +        SDL_OutOfMemory();
   17.66 +        return NULL;
   17.67 +    }
   17.68 +
   17.69 +    SDL_memcpy(retval, str, len);
   17.70 +    retval[len] = '/';
   17.71 +    retval[len+1] = '\0';
   17.72 +    return retval;
   17.73 +}
   17.74 +
   17.75 +
   17.76 +char *
   17.77 +SDL_GetPrefPath(const char *org, const char *app)
   17.78 +{
   17.79 +    // !!! FIXME: is there a better way to do this?
   17.80 +    const char *home = SDL_getenv("HOME");
   17.81 +    const char *append = "config/settings/";
   17.82 +    const size_t len = SDL_strlen(home) + SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3;
   17.83 +    char *retval = (char *) SDL_malloc(len);
   17.84 +    if (!retval) {
   17.85 +        SDL_OutOfMemory();
   17.86 +    } else {
   17.87 +        SDL_snprintf(retval, len, "%s%s%s/%s/", home, append, org, app);
   17.88 +        create_directory(retval, 0700);  // Haiku api: creates missing dirs
   17.89 +    }
   17.90 +
   17.91 +    return retval;
   17.92 +}
   17.93 +
   17.94 +#endif /* SDL_FILESYSTEM_HAIKU */
   17.95 +
   17.96 +/* vi: set ts=4 sw=4 expandtab: */
    18.1 --- a/src/joystick/beos/SDL_bejoystick.cc	Thu Nov 14 10:19:07 2013 -0300
    18.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.3 @@ -1,280 +0,0 @@
    18.4 -/*
    18.5 -  Simple DirectMedia Layer
    18.6 -  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    18.7 -
    18.8 -  This software is provided 'as-is', without any express or implied
    18.9 -  warranty.  In no event will the authors be held liable for any damages
   18.10 -  arising from the use of this software.
   18.11 -
   18.12 -  Permission is granted to anyone to use this software for any purpose,
   18.13 -  including commercial applications, and to alter it and redistribute it
   18.14 -  freely, subject to the following restrictions:
   18.15 -
   18.16 -  1. The origin of this software must not be misrepresented; you must not
   18.17 -     claim that you wrote the original software. If you use this software
   18.18 -     in a product, an acknowledgment in the product documentation would be
   18.19 -     appreciated but is not required.
   18.20 -  2. Altered source versions must be plainly marked as such, and must not be
   18.21 -     misrepresented as being the original software.
   18.22 -  3. This notice may not be removed or altered from any source distribution.
   18.23 -*/
   18.24 -#include "SDL_config.h"
   18.25 -
   18.26 -#ifdef SDL_JOYSTICK_BEOS
   18.27 -
   18.28 -/* This is the system specific header for the SDL joystick API */
   18.29 -
   18.30 -#include <be/support/String.h>
   18.31 -#include <be/device/Joystick.h>
   18.32 -
   18.33 -extern "C"
   18.34 -{
   18.35 -
   18.36 -#include "SDL_joystick.h"
   18.37 -#include "../SDL_sysjoystick.h"
   18.38 -#include "../SDL_joystick_c.h"
   18.39 -
   18.40 -
   18.41 -/* The maximum number of joysticks we'll detect */
   18.42 -#define MAX_JOYSTICKS	16
   18.43 -
   18.44 -/* A list of available joysticks */
   18.45 -    static char *SDL_joyport[MAX_JOYSTICKS];
   18.46 -    static char *SDL_joyname[MAX_JOYSTICKS];
   18.47 -
   18.48 -/* The private structure used to keep track of a joystick */
   18.49 -    struct joystick_hwdata
   18.50 -    {
   18.51 -        BJoystick *stick;
   18.52 -        uint8 *new_hats;
   18.53 -        int16 *new_axes;
   18.54 -    };
   18.55 -
   18.56 -    static int SDL_SYS_numjoysticks = 0;
   18.57 -
   18.58 -/* Function to scan the system for joysticks.
   18.59 - * This function should set SDL_numjoysticks to the number of available
   18.60 - * joysticks.  Joystick 0 should be the system default joystick.
   18.61 - * It should return 0, or -1 on an unrecoverable fatal error.
   18.62 - */
   18.63 -    int SDL_SYS_JoystickInit(void)
   18.64 -    {
   18.65 -        BJoystick joystick;
   18.66 -        int i;
   18.67 -        int32 nports;
   18.68 -        char name[B_OS_NAME_LENGTH];
   18.69 -
   18.70 -        /* Search for attached joysticks */
   18.71 -          nports = joystick.CountDevices();
   18.72 -          SDL_SYS_numjoysticks = 0;
   18.73 -          SDL_memset(SDL_joyport, 0, (sizeof SDL_joyport));
   18.74 -          SDL_memset(SDL_joyname, 0, (sizeof SDL_joyname));
   18.75 -        for (i = 0; (SDL_SYS_numjoysticks < MAX_JOYSTICKS) && (i < nports); ++i)
   18.76 -        {
   18.77 -            if (joystick.GetDeviceName(i, name) == B_OK) {
   18.78 -                if (joystick.Open(name) != B_ERROR) {
   18.79 -                    BString stick_name;
   18.80 -                      joystick.GetControllerName(&stick_name);
   18.81 -                      SDL_joyport[SDL_SYS_numjoysticks] = strdup(name);
   18.82 -                      SDL_joyname[SDL_SYS_numjoysticks] = strdup(stick_name.String());
   18.83 -                      SDL_SYS_numjoysticks++;
   18.84 -                      joystick.Close();
   18.85 -                }
   18.86 -            }
   18.87 -        }
   18.88 -        return (SDL_SYS_numjoysticks);
   18.89 -    }
   18.90 -
   18.91 -    int SDL_SYS_NumJoysticks()
   18.92 -    {
   18.93 -        return SDL_SYS_numjoysticks;
   18.94 -    }
   18.95 -
   18.96 -    void SDL_SYS_JoystickDetect()
   18.97 -    {
   18.98 -    }
   18.99 -
  18.100 -    SDL_bool SDL_SYS_JoystickNeedsPolling()
  18.101 -    {
  18.102 -        return SDL_FALSE;
  18.103 -    }
  18.104 -
  18.105 -/* Function to get the device-dependent name of a joystick */
  18.106 -    const char *SDL_SYS_JoystickNameForDeviceIndex(int device_index)
  18.107 -    {
  18.108 -        return SDL_joyname[device_index];
  18.109 -    }
  18.110 -
  18.111 -/* Function to perform the mapping from device index to the instance id for this index */
  18.112 -    SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index)
  18.113 -    {
  18.114 -        return device_index;
  18.115 -    }
  18.116 -
  18.117 -/* Function to open a joystick for use.
  18.118 -   The joystick to open is specified by the index field of the joystick.
  18.119 -   This should fill the nbuttons and naxes fields of the joystick structure.
  18.120 -   It returns 0, or -1 if there is an error.
  18.121 - */
  18.122 -    int SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
  18.123 -    {
  18.124 -        BJoystick *stick;
  18.125 -
  18.126 -        /* Create the joystick data structure */
  18.127 -        joystick->instance_id = device_index;
  18.128 -        joystick->hwdata = (struct joystick_hwdata *)
  18.129 -            SDL_malloc(sizeof(*joystick->hwdata));
  18.130 -        if (joystick->hwdata == NULL) {
  18.131 -            return SDL_OutOfMemory();
  18.132 -        }
  18.133 -        SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
  18.134 -        stick = new BJoystick;
  18.135 -        joystick->hwdata->stick = stick;
  18.136 -
  18.137 -        /* Open the requested joystick for use */
  18.138 -        if (stick->Open(SDL_joyport[device_index]) == B_ERROR) {
  18.139 -            SDL_SYS_JoystickClose(joystick);
  18.140 -            return SDL_SetError("Unable to open joystick");
  18.141 -        }
  18.142 -
  18.143 -        /* Set the joystick to calibrated mode */
  18.144 -        stick->EnableCalibration();
  18.145 -
  18.146 -        /* Get the number of buttons, hats, and axes on the joystick */
  18.147 -        joystick->nbuttons = stick->CountButtons();
  18.148 -        joystick->naxes = stick->CountAxes();
  18.149 -        joystick->nhats = stick->CountHats();
  18.150 -
  18.151 -        joystick->hwdata->new_axes = (int16 *)
  18.152 -            SDL_malloc(joystick->naxes * sizeof(int16));
  18.153 -        joystick->hwdata->new_hats = (uint8 *)
  18.154 -            SDL_malloc(joystick->nhats * sizeof(uint8));
  18.155 -        if (!joystick->hwdata->new_hats || !joystick->hwdata->new_axes) {
  18.156 -            SDL_SYS_JoystickClose(joystick);
  18.157 -            return SDL_OutOfMemory();
  18.158 -        }
  18.159 -
  18.160 -        /* We're done! */
  18.161 -        return (0);
  18.162 -    }
  18.163 -
  18.164 -/* Function to determine is this joystick is attached to the system right now */
  18.165 -    SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
  18.166 -    {
  18.167 -        return SDL_TRUE;
  18.168 -    }
  18.169 -
  18.170 -/* Function to update the state of a joystick - called as a device poll.
  18.171 - * This function shouldn't update the joystick structure directly,
  18.172 - * but instead should call SDL_PrivateJoystick*() to deliver events
  18.173 - * and update joystick device state.
  18.174 - */
  18.175 -    void SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
  18.176 -    {
  18.177 -        static const Uint8 hat_map[9] = {
  18.178 -            SDL_HAT_CENTERED,
  18.179 -            SDL_HAT_UP,
  18.180 -            SDL_HAT_RIGHTUP,
  18.181 -            SDL_HAT_RIGHT,
  18.182 -            SDL_HAT_RIGHTDOWN,
  18.183 -            SDL_HAT_DOWN,
  18.184 -            SDL_HAT_LEFTDOWN,
  18.185 -            SDL_HAT_LEFT,
  18.186 -            SDL_HAT_LEFTUP
  18.187 -        };
  18.188 -        const int JITTER = (32768 / 10);        /* 10% jitter threshold (ok?) */
  18.189 -
  18.190 -        BJoystick *stick;
  18.191 -        int i, change;
  18.192 -        int16 *axes;
  18.193 -        uint8 *hats;
  18.194 -        uint32 buttons;
  18.195 -
  18.196 -        /* Set up data pointers */
  18.197 -        stick = joystick->hwdata->stick;
  18.198 -        axes = joystick->hwdata->new_axes;
  18.199 -        hats = joystick->hwdata->new_hats;
  18.200 -
  18.201 -        /* Get the new joystick state */
  18.202 -        stick->Update();
  18.203 -        stick->GetAxisValues(axes);
  18.204 -        stick->GetHatValues(hats);
  18.205 -        buttons = stick->ButtonValues();
  18.206 -
  18.207 -        /* Generate axis motion events */
  18.208 -        for (i = 0; i < joystick->naxes; ++i) {
  18.209 -            change = ((int32) axes[i] - joystick->axes[i]);
  18.210 -            if ((change > JITTER) || (change < -JITTER)) {
  18.211 -                SDL_PrivateJoystickAxis(joystick, i, axes[i]);
  18.212 -            }
  18.213 -        }
  18.214 -
  18.215 -        /* Generate hat change events */
  18.216 -        for (i = 0; i < joystick->nhats; ++i) {
  18.217 -            if (hats[i] != joystick->hats[i]) {
  18.218 -                SDL_PrivateJoystickHat(joystick, i, hat_map[hats[i]]);
  18.219 -            }
  18.220 -        }
  18.221 -
  18.222 -        /* Generate button events */
  18.223 -        for (i = 0; i < joystick->nbuttons; ++i) {
  18.224 -            if ((buttons & 0x01) != joystick->buttons[i]) {
  18.225 -                SDL_PrivateJoystickButton(joystick, i, (buttons & 0x01));
  18.226 -            }
  18.227 -            buttons >>= 1;
  18.228 -        }
  18.229 -    }
  18.230 -
  18.231 -/* Function to close a joystick after use */
  18.232 -    void SDL_SYS_JoystickClose(SDL_Joystick * joystick)
  18.233 -    {
  18.234 -        if (joystick->hwdata) {
  18.235 -            joystick->hwdata->stick->Close();
  18.236 -            delete joystick->hwdata->stick;
  18.237 -            SDL_free(joystick->hwdata->new_hats);
  18.238 -            SDL_free(joystick->hwdata->new_axes);
  18.239 -            SDL_free(joystick->hwdata);
  18.240 -            joystick->hwdata = NULL;
  18.241 -        }
  18.242 -    }
  18.243 -
  18.244 -/* Function to perform any system-specific joystick related cleanup */
  18.245 -    void SDL_SYS_JoystickQuit(void)
  18.246 -    {
  18.247 -        int i;
  18.248 -
  18.249 -        for (i = 0; SDL_joyport[i]; ++i) {
  18.250 -            SDL_free(SDL_joyport[i]);
  18.251 -        }
  18.252 -        SDL_joyport[0] = NULL;
  18.253 -
  18.254 -        for (i = 0; SDL_joyname[i]; ++i) {
  18.255 -            SDL_free(SDL_joyname[i]);
  18.256 -        }
  18.257 -        SDL_joyname[0] = NULL;
  18.258 -    }
  18.259 -
  18.260 -    SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index )
  18.261 -    {
  18.262 -        SDL_JoystickGUID guid;
  18.263 -        /* the GUID is just the first 16 chars of the name for now */
  18.264 -        const char *name = SDL_SYS_JoystickNameForDeviceIndex( device_index );
  18.265 -        SDL_zero( guid );
  18.266 -        SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
  18.267 -        return guid;
  18.268 -    }
  18.269 -
  18.270 -    SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick)
  18.271 -    {
  18.272 -        SDL_JoystickGUID guid;
  18.273 -        /* the GUID is just the first 16 chars of the name for now */
  18.274 -        const char *name = joystick->name;
  18.275 -        SDL_zero( guid );
  18.276 -        SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
  18.277 -        return guid;
  18.278 -    }
  18.279 -
  18.280 -};                              // extern "C"
  18.281 -
  18.282 -#endif /* SDL_JOYSTICK_BEOS */
  18.283 -/* vi: set ts=4 sw=4 expandtab: */
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/src/joystick/haiku/SDL_haikujoystick.cc	Thu Nov 14 11:51:24 2013 -0500
    19.3 @@ -0,0 +1,281 @@
    19.4 +/*
    19.5 +  Simple DirectMedia Layer
    19.6 +  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    19.7 +
    19.8 +  This software is provided 'as-is', without any express or implied
    19.9 +  warranty.  In no event will the authors be held liable for any damages
   19.10 +  arising from the use of this software.
   19.11 +
   19.12 +  Permission is granted to anyone to use this software for any purpose,
   19.13 +  including commercial applications, and to alter it and redistribute it
   19.14 +  freely, subject to the following restrictions:
   19.15 +
   19.16 +  1. The origin of this software must not be misrepresented; you must not
   19.17 +     claim that you wrote the original software. If you use this software
   19.18 +     in a product, an acknowledgment in the product documentation would be
   19.19 +     appreciated but is not required.
   19.20 +  2. Altered source versions must be plainly marked as such, and must not be
   19.21 +     misrepresented as being the original software.
   19.22 +  3. This notice may not be removed or altered from any source distribution.
   19.23 +*/
   19.24 +#include "SDL_config.h"
   19.25 +
   19.26 +#ifdef SDL_JOYSTICK_HAIKU
   19.27 +
   19.28 +/* This is the system specific header for the SDL joystick API */
   19.29 +
   19.30 +#include <os/support/String.h>
   19.31 +#include <os/device/Joystick.h>
   19.32 +
   19.33 +extern "C"
   19.34 +{
   19.35 +
   19.36 +#include "SDL_joystick.h"
   19.37 +#include "../SDL_sysjoystick.h"
   19.38 +#include "../SDL_joystick_c.h"
   19.39 +
   19.40 +
   19.41 +/* The maximum number of joysticks we'll detect */
   19.42 +#define MAX_JOYSTICKS	16
   19.43 +
   19.44 +/* A list of available joysticks */
   19.45 +    static char *SDL_joyport[MAX_JOYSTICKS];
   19.46 +    static char *SDL_joyname[MAX_JOYSTICKS];
   19.47 +
   19.48 +/* The private structure used to keep track of a joystick */
   19.49 +    struct joystick_hwdata
   19.50 +    {
   19.51 +        BJoystick *stick;
   19.52 +        uint8 *new_hats;
   19.53 +        int16 *new_axes;
   19.54 +    };
   19.55 +
   19.56 +    static int SDL_SYS_numjoysticks = 0;
   19.57 +
   19.58 +/* Function to scan the system for joysticks.
   19.59 + * This function should set SDL_numjoysticks to the number of available
   19.60 + * joysticks.  Joystick 0 should be the system default joystick.
   19.61 + * It should return 0, or -1 on an unrecoverable fatal error.
   19.62 + */
   19.63 +    int SDL_SYS_JoystickInit(void)
   19.64 +    {
   19.65 +        BJoystick joystick;
   19.66 +        int i;
   19.67 +        int32 nports;
   19.68 +        char name[B_OS_NAME_LENGTH];
   19.69 +
   19.70 +        /* Search for attached joysticks */
   19.71 +          nports = joystick.CountDevices();
   19.72 +          SDL_SYS_numjoysticks = 0;
   19.73 +          SDL_memset(SDL_joyport, 0, (sizeof SDL_joyport));
   19.74 +          SDL_memset(SDL_joyname, 0, (sizeof SDL_joyname));
   19.75 +        for (i = 0; (SDL_SYS_numjoysticks < MAX_JOYSTICKS) && (i < nports); ++i)
   19.76 +        {
   19.77 +            if (joystick.GetDeviceName(i, name) == B_OK) {
   19.78 +                if (joystick.Open(name) != B_ERROR) {
   19.79 +                    BString stick_name;
   19.80 +                      joystick.GetControllerName(&stick_name);
   19.81 +                      SDL_joyport[SDL_SYS_numjoysticks] = strdup(name);
   19.82 +                      SDL_joyname[SDL_SYS_numjoysticks] = strdup(stick_name.String());
   19.83 +                      SDL_SYS_numjoysticks++;
   19.84 +                      joystick.Close();
   19.85 +                }
   19.86 +            }
   19.87 +        }
   19.88 +        return (SDL_SYS_numjoysticks);
   19.89 +    }
   19.90 +
   19.91 +    int SDL_SYS_NumJoysticks()
   19.92 +    {
   19.93 +        return SDL_SYS_numjoysticks;
   19.94 +    }
   19.95 +
   19.96 +    void SDL_SYS_JoystickDetect()
   19.97 +    {
   19.98 +    }
   19.99 +
  19.100 +    SDL_bool SDL_SYS_JoystickNeedsPolling()
  19.101 +    {
  19.102 +        return SDL_FALSE;
  19.103 +    }
  19.104 +
  19.105 +/* Function to get the device-dependent name of a joystick */
  19.106 +    const char *SDL_SYS_JoystickNameForDeviceIndex(int device_index)
  19.107 +    {
  19.108 +        return SDL_joyname[device_index];
  19.109 +    }
  19.110 +
  19.111 +/* Function to perform the mapping from device index to the instance id for this index */
  19.112 +    SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index)
  19.113 +    {
  19.114 +        return device_index;
  19.115 +    }
  19.116 +
  19.117 +/* Function to open a joystick for use.
  19.118 +   The joystick to open is specified by the index field of the joystick.
  19.119 +   This should fill the nbuttons and naxes fields of the joystick structure.
  19.120 +   It returns 0, or -1 if there is an error.
  19.121 + */
  19.122 +    int SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index)
  19.123 +    {
  19.124 +        BJoystick *stick;
  19.125 +
  19.126 +        /* Create the joystick data structure */
  19.127 +        joystick->instance_id = device_index;
  19.128 +        joystick->hwdata = (struct joystick_hwdata *)
  19.129 +            SDL_malloc(sizeof(*joystick->hwdata));
  19.130 +        if (joystick->hwdata == NULL) {
  19.131 +            return SDL_OutOfMemory();
  19.132 +        }
  19.133 +        SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
  19.134 +        stick = new BJoystick;
  19.135 +        joystick->hwdata->stick = stick;
  19.136 +
  19.137 +        /* Open the requested joystick for use */
  19.138 +        if (stick->Open(SDL_joyport[device_index]) == B_ERROR) {
  19.139 +            SDL_SYS_JoystickClose(joystick);
  19.140 +            return SDL_SetError("Unable to open joystick");
  19.141 +        }
  19.142 +
  19.143 +        /* Set the joystick to calibrated mode */
  19.144 +        stick->EnableCalibration();
  19.145 +
  19.146 +        /* Get the number of buttons, hats, and axes on the joystick */
  19.147 +        joystick->nbuttons = stick->CountButtons();
  19.148 +        joystick->naxes = stick->CountAxes();
  19.149 +        joystick->nhats = stick->CountHats();
  19.150 +
  19.151 +        joystick->hwdata->new_axes = (int16 *)
  19.152 +            SDL_malloc(joystick->naxes * sizeof(int16));
  19.153 +        joystick->hwdata->new_hats = (uint8 *)
  19.154 +            SDL_malloc(joystick->nhats * sizeof(uint8));
  19.155 +        if (!joystick->hwdata->new_hats || !joystick->hwdata->new_axes) {
  19.156 +            SDL_SYS_JoystickClose(joystick);
  19.157 +            return SDL_OutOfMemory();
  19.158 +        }
  19.159 +
  19.160 +        /* We're done! */
  19.161 +        return (0);
  19.162 +    }
  19.163 +
  19.164 +/* Function to determine is this joystick is attached to the system right now */
  19.165 +    SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
  19.166 +    {
  19.167 +        return SDL_TRUE;
  19.168 +    }
  19.169 +
  19.170 +/* Function to update the state of a joystick - called as a device poll.
  19.171 + * This function shouldn't update the joystick structure directly,
  19.172 + * but instead should call SDL_PrivateJoystick*() to deliver events
  19.173 + * and update joystick device state.
  19.174 + */
  19.175 +    void SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
  19.176 +    {
  19.177 +        static const Uint8 hat_map[9] = {
  19.178 +            SDL_HAT_CENTERED,
  19.179 +            SDL_HAT_UP,
  19.180 +            SDL_HAT_RIGHTUP,
  19.181 +            SDL_HAT_RIGHT,
  19.182 +            SDL_HAT_RIGHTDOWN,
  19.183 +            SDL_HAT_DOWN,
  19.184 +            SDL_HAT_LEFTDOWN,
  19.185 +            SDL_HAT_LEFT,
  19.186 +            SDL_HAT_LEFTUP
  19.187 +        };
  19.188 +        const int JITTER = (32768 / 10);        /* 10% jitter threshold (ok?) */
  19.189 +
  19.190 +        BJoystick *stick;
  19.191 +        int i, change;
  19.192 +        int16 *axes;
  19.193 +        uint8 *hats;
  19.194 +        uint32 buttons;
  19.195 +
  19.196 +        /* Set up data pointers */
  19.197 +        stick = joystick->hwdata->stick;
  19.198 +        axes = joystick->hwdata->new_axes;
  19.199 +        hats = joystick->hwdata->new_hats;
  19.200 +
  19.201 +        /* Get the new joystick state */
  19.202 +        stick->Update();
  19.203 +        stick->GetAxisValues(axes);
  19.204 +        stick->GetHatValues(hats);
  19.205 +        buttons = stick->ButtonValues();
  19.206 +
  19.207 +        /* Generate axis motion events */
  19.208 +        for (i = 0; i < joystick->naxes; ++i) {
  19.209 +            change = ((int32) axes[i] - joystick->axes[i]);
  19.210 +            if ((change > JITTER) || (change < -JITTER)) {
  19.211 +                SDL_PrivateJoystickAxis(joystick, i, axes[i]);
  19.212 +            }
  19.213 +        }
  19.214 +
  19.215 +        /* Generate hat change events */
  19.216 +        for (i = 0; i < joystick->nhats; ++i) {
  19.217 +            if (hats[i] != joystick->hats[i]) {
  19.218 +                SDL_PrivateJoystickHat(joystick, i, hat_map[hats[i]]);
  19.219 +            }
  19.220 +        }
  19.221 +
  19.222 +        /* Generate button events */
  19.223 +        for (i = 0; i < joystick->nbuttons; ++i) {
  19.224 +            if ((buttons & 0x01) != joystick->buttons[i]) {
  19.225 +                SDL_PrivateJoystickButton(joystick, i, (buttons & 0x01));
  19.226 +            }
  19.227 +            buttons >>= 1;
  19.228 +        }
  19.229 +    }
  19.230 +
  19.231 +/* Function to close a joystick after use */
  19.232 +    void SDL_SYS_JoystickClose(SDL_Joystick * joystick)
  19.233 +    {
  19.234 +        if (joystick->hwdata) {
  19.235 +            joystick->hwdata->stick->Close();
  19.236 +            delete joystick->hwdata->stick;
  19.237 +            SDL_free(joystick->hwdata->new_hats);
  19.238 +            SDL_free(joystick->hwdata->new_axes);
  19.239 +            SDL_free(joystick->hwdata);
  19.240 +            joystick->hwdata = NULL;
  19.241 +        }
  19.242 +    }
  19.243 +
  19.244 +/* Function to perform any system-specific joystick related cleanup */
  19.245 +    void SDL_SYS_JoystickQuit(void)
  19.246 +    {
  19.247 +        int i;
  19.248 +
  19.249 +        for (i = 0; SDL_joyport[i]; ++i) {
  19.250 +            SDL_free(SDL_joyport[i]);
  19.251 +        }
  19.252 +        SDL_joyport[0] = NULL;
  19.253 +
  19.254 +        for (i = 0; SDL_joyname[i]; ++i) {
  19.255 +            SDL_free(SDL_joyname[i]);
  19.256 +        }
  19.257 +        SDL_joyname[0] = NULL;
  19.258 +    }
  19.259 +
  19.260 +    SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID( int device_index )
  19.261 +    {
  19.262 +        SDL_JoystickGUID guid;
  19.263 +        /* the GUID is just the first 16 chars of the name for now */
  19.264 +        const char *name = SDL_SYS_JoystickNameForDeviceIndex( device_index );
  19.265 +        SDL_zero( guid );
  19.266 +        SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
  19.267 +        return guid;
  19.268 +    }
  19.269 +
  19.270 +    SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick)
  19.271 +    {
  19.272 +        SDL_JoystickGUID guid;
  19.273 +        /* the GUID is just the first 16 chars of the name for now */
  19.274 +        const char *name = joystick->name;
  19.275 +        SDL_zero( guid );
  19.276 +        SDL_memcpy( &guid, name, SDL_min( sizeof(guid), SDL_strlen( name ) ) );
  19.277 +        return guid;
  19.278 +    }
  19.279 +
  19.280 +};                              // extern "C"
  19.281 +
  19.282 +#endif /* SDL_JOYSTICK_HAIKU */
  19.283 +
  19.284 +/* vi: set ts=4 sw=4 expandtab: */
    20.1 --- a/src/loadso/beos/SDL_sysloadso.c	Thu Nov 14 10:19:07 2013 -0300
    20.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.3 @@ -1,71 +0,0 @@
    20.4 -/*
    20.5 -  Simple DirectMedia Layer
    20.6 -  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    20.7 -
    20.8 -  This software is provided 'as-is', without any express or implied
    20.9 -  warranty.  In no event will the authors be held liable for any damages
   20.10 -  arising from the use of this software.
   20.11 -
   20.12 -  Permission is granted to anyone to use this software for any purpose,
   20.13 -  including commercial applications, and to alter it and redistribute it
   20.14 -  freely, subject to the following restrictions:
   20.15 -
   20.16 -  1. The origin of this software must not be misrepresented; you must not
   20.17 -     claim that you wrote the original software. If you use this software
   20.18 -     in a product, an acknowledgment in the product documentation would be
   20.19 -     appreciated but is not required.
   20.20 -  2. Altered source versions must be plainly marked as such, and must not be
   20.21 -     misrepresented as being the original software.
   20.22 -  3. This notice may not be removed or altered from any source distribution.
   20.23 -*/
   20.24 -#include "SDL_config.h"
   20.25 -
   20.26 -#ifdef SDL_LOADSO_BEOS
   20.27 -
   20.28 -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
   20.29 -/* System dependent library loading routines                           */
   20.30 -
   20.31 -#include <stdio.h>
   20.32 -#include <be/kernel/image.h>
   20.33 -
   20.34 -#include "SDL_loadso.h"
   20.35 -
   20.36 -void *
   20.37 -SDL_LoadObject(const char *sofile)
   20.38 -{
   20.39 -    void *handle = NULL;
   20.40 -    image_id library_id = load_add_on(sofile);
   20.41 -    if (library_id < 0) {
   20.42 -        SDL_SetError(strerror((int) library_id));
   20.43 -    } else {
   20.44 -        handle = (void *) (library_id);
   20.45 -    }
   20.46 -    return (handle);
   20.47 -}
   20.48 -
   20.49 -void *
   20.50 -SDL_LoadFunction(void *handle, const char *name)
   20.51 -{
   20.52 -    void *sym = NULL;
   20.53 -    image_id library_id = (image_id) handle;
   20.54 -    status_t rc =
   20.55 -        get_image_symbol(library_id, name, B_SYMBOL_TYPE_TEXT, &sym);
   20.56 -    if (rc != B_NO_ERROR) {
   20.57 -        SDL_SetError(strerror(rc));
   20.58 -    }
   20.59 -    return (sym);
   20.60 -}
   20.61 -
   20.62 -void
   20.63 -SDL_UnloadObject(void *handle)
   20.64 -{
   20.65 -    image_id library_id;
   20.66 -    if (handle != NULL) {
   20.67 -        library_id = (image_id) handle;
   20.68 -        unload_add_on(library_id);
   20.69 -    }
   20.70 -}
   20.71 -
   20.72 -#endif /* SDL_LOADSO_BEOS */
   20.73 -
   20.74 -/* vi: set ts=4 sw=4 expandtab: */
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/src/loadso/haiku/SDL_sysloadso.c	Thu Nov 14 11:51:24 2013 -0500
    21.3 @@ -0,0 +1,71 @@
    21.4 +/*
    21.5 +  Simple DirectMedia Layer
    21.6 +  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    21.7 +
    21.8 +  This software is provided 'as-is', without any express or implied
    21.9 +  warranty.  In no event will the authors be held liable for any damages
   21.10 +  arising from the use of this software.
   21.11 +
   21.12 +  Permission is granted to anyone to use this software for any purpose,
   21.13 +  including commercial applications, and to alter it and redistribute it
   21.14 +  freely, subject to the following restrictions:
   21.15 +
   21.16 +  1. The origin of this software must not be misrepresented; you must not
   21.17 +     claim that you wrote the original software. If you use this software
   21.18 +     in a product, an acknowledgment in the product documentation would be
   21.19 +     appreciated but is not required.
   21.20 +  2. Altered source versions must be plainly marked as such, and must not be
   21.21 +     misrepresented as being the original software.
   21.22 +  3. This notice may not be removed or altered from any source distribution.
   21.23 +*/
   21.24 +#include "SDL_config.h"
   21.25 +
   21.26 +#ifdef SDL_LOADSO_HAIKU
   21.27 +
   21.28 +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
   21.29 +/* System dependent library loading routines                           */
   21.30 +
   21.31 +#include <stdio.h>
   21.32 +#include <os/kernel/image.h>
   21.33 +
   21.34 +#include "SDL_loadso.h"
   21.35 +
   21.36 +void *
   21.37 +SDL_LoadObject(const char *sofile)
   21.38 +{
   21.39 +    void *handle = NULL;
   21.40 +    image_id library_id = load_add_on(sofile);
   21.41 +    if (library_id < 0) {
   21.42 +        SDL_SetError(strerror((int) library_id));
   21.43 +    } else {
   21.44 +        handle = (void *) (library_id);
   21.45 +    }
   21.46 +    return (handle);
   21.47 +}
   21.48 +
   21.49 +void *
   21.50 +SDL_LoadFunction(void *handle, const char *name)
   21.51 +{
   21.52 +    void *sym = NULL;
   21.53 +    image_id library_id = (image_id) handle;
   21.54 +    status_t rc =
   21.55 +        get_image_symbol(library_id, name, B_SYMBOL_TYPE_TEXT, &sym);
   21.56 +    if (rc != B_NO_ERROR) {
   21.57 +        SDL_SetError(strerror(rc));
   21.58 +    }
   21.59 +    return (sym);
   21.60 +}
   21.61 +
   21.62 +void
   21.63 +SDL_UnloadObject(void *handle)
   21.64 +{
   21.65 +    image_id library_id;
   21.66 +    if (handle != NULL) {
   21.67 +        library_id = (image_id) handle;
   21.68 +        unload_add_on(library_id);
   21.69 +    }
   21.70 +}
   21.71 +
   21.72 +#endif /* SDL_LOADSO_HAIKU */
   21.73 +
   21.74 +/* vi: set ts=4 sw=4 expandtab: */
    22.1 --- a/src/main/beos/SDL_BApp.h	Thu Nov 14 10:19:07 2013 -0300
    22.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.3 @@ -1,380 +0,0 @@
    22.4 -/*
    22.5 -  Simple DirectMedia Layer
    22.6 -  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    22.7 -
    22.8 -  This software is provided 'as-is', without any express or implied
    22.9 -  warranty.  In no event will the authors be held liable for any damages
   22.10 -  arising from the use of this software.
   22.11 -
   22.12 -  Permission is granted to anyone to use this software for any purpose,
   22.13 -  including commercial applications, and to alter it and redistribute it
   22.14 -  freely, subject to the following restrictions:
   22.15 -
   22.16 -  1. The origin of this software must not be misrepresented; you must not
   22.17 -     claim that you wrote the original software. If you use this software
   22.18 -     in a product, an acknowledgment in the product documentation would be
   22.19 -     appreciated but is not required.
   22.20 -  2. Altered source versions must be plainly marked as such, and must not be
   22.21 -     misrepresented as being the original software.
   22.22 -  3. This notice may not be removed or altered from any source distribution.
   22.23 -*/
   22.24 -#ifndef SDL_BAPP_H
   22.25 -#define SDL_BAPP_H
   22.26 -
   22.27 -#include <InterfaceKit.h>
   22.28 -#include <OpenGLKit.h>
   22.29 -
   22.30 -#include "../../video/bwindow/SDL_bkeyboard.h"
   22.31 -
   22.32 -
   22.33 -#ifdef __cplusplus
   22.34 -extern "C" {
   22.35 -#endif
   22.36 -
   22.37 -#include "SDL_config.h"
   22.38 -
   22.39 -#include "SDL_video.h"
   22.40 -
   22.41 -/* Local includes */
   22.42 -#include "../../events/SDL_events_c.h"
   22.43 -#include "../../video/bwindow/SDL_bkeyboard.h"
   22.44 -#include "../../video/bwindow/SDL_bframebuffer.h"
   22.45 -
   22.46 -#ifdef __cplusplus
   22.47 -}
   22.48 -#endif
   22.49 -
   22.50 -#include <vector>
   22.51 -
   22.52 -
   22.53 -
   22.54 -
   22.55 -/* Forward declarations */
   22.56 -class SDL_BWin;
   22.57 -
   22.58 -/* Message constants */
   22.59 -enum ToSDL {
   22.60 -    /* Intercepted by BWindow on its way to BView */
   22.61 -    BAPP_MOUSE_MOVED,
   22.62 -    BAPP_MOUSE_BUTTON,
   22.63 -    BAPP_MOUSE_WHEEL,
   22.64 -    BAPP_KEY,
   22.65 -    BAPP_REPAINT,           /* from _UPDATE_ */
   22.66 -    /* From BWindow */
   22.67 -    BAPP_MAXIMIZE,          /* from B_ZOOM */
   22.68 -    BAPP_MINIMIZE,
   22.69 -    BAPP_RESTORE,           /* TODO: IMPLEMENT! */
   22.70 -    BAPP_SHOW,
   22.71 -    BAPP_HIDE,
   22.72 -    BAPP_MOUSE_FOCUS,       /* caused by MOUSE_MOVE */
   22.73 -    BAPP_KEYBOARD_FOCUS,    /* from WINDOW_ACTIVATED */
   22.74 -    BAPP_WINDOW_CLOSE_REQUESTED,
   22.75 -    BAPP_WINDOW_MOVED,
   22.76 -    BAPP_WINDOW_RESIZED,
   22.77 -    BAPP_SCREEN_CHANGED
   22.78 -};
   22.79 -
   22.80 -
   22.81 -
   22.82 -/* Create a descendant of BApplication */
   22.83 -class SDL_BApp : public BApplication {
   22.84 -public:
   22.85 -    SDL_BApp(const char* signature) :
   22.86 -        BApplication(signature) {
   22.87 -        _current_context = NULL;
   22.88 -    }
   22.89 -
   22.90 -
   22.91 -    virtual ~SDL_BApp() {
   22.92 -    }
   22.93 -
   22.94 -
   22.95 -
   22.96 -        /* Event-handling functions */
   22.97 -    virtual void MessageReceived(BMessage* message) {
   22.98 -        /* Sort out SDL-related messages */
   22.99 -        switch ( message->what ) {
  22.100 -        case BAPP_MOUSE_MOVED:
  22.101 -            _HandleMouseMove(message);
  22.102 -            break;
  22.103 -
  22.104 -        case BAPP_MOUSE_BUTTON:
  22.105 -            _HandleMouseButton(message);
  22.106 -            break;
  22.107 -
  22.108 -        case BAPP_MOUSE_WHEEL:
  22.109 -            _HandleMouseWheel(message);
  22.110 -            break;
  22.111 -
  22.112 -        case BAPP_KEY:
  22.113 -            _HandleKey(message);
  22.114 -            break;
  22.115 -
  22.116 -        case BAPP_REPAINT:
  22.117 -            _HandleBasicWindowEvent(message, SDL_WINDOWEVENT_EXPOSED);
  22.118 -            break;
  22.119 -
  22.120 -        case BAPP_MAXIMIZE:
  22.121 -            _HandleBasicWindowEvent(message, SDL_WINDOWEVENT_MAXIMIZED);
  22.122 -            break;
  22.123 -
  22.124 -        case BAPP_MINIMIZE:
  22.125 -            _HandleBasicWindowEvent(message, SDL_WINDOWEVENT_MINIMIZED);
  22.126 -            break;
  22.127 -
  22.128 -        case BAPP_SHOW:
  22.129 -            _HandleBasicWindowEvent(message, SDL_WINDOWEVENT_SHOWN);
  22.130 -            break;
  22.131 -
  22.132 -        case BAPP_HIDE:
  22.133 -            _HandleBasicWindowEvent(message, SDL_WINDOWEVENT_HIDDEN);
  22.134 -            break;
  22.135 -
  22.136 -        case BAPP_MOUSE_FOCUS:
  22.137 -            _HandleMouseFocus(message);
  22.138 -            break;
  22.139 -
  22.140 -        case BAPP_KEYBOARD_FOCUS:
  22.141 -            _HandleKeyboardFocus(message);
  22.142 -            break;
  22.143 -
  22.144 -        case BAPP_WINDOW_CLOSE_REQUESTED:
  22.145 -            _HandleBasicWindowEvent(message, SDL_WINDOWEVENT_CLOSE);
  22.146 -            break;
  22.147 -
  22.148 -        case BAPP_WINDOW_MOVED:
  22.149 -            _HandleWindowMoved(message);
  22.150 -            break;
  22.151 -
  22.152 -        case BAPP_WINDOW_RESIZED:
  22.153 -            _HandleWindowResized(message);
  22.154 -            break;
  22.155 -
  22.156 -        case BAPP_SCREEN_CHANGED:
  22.157 -            /* TODO: Handle screen resize or workspace change */
  22.158 -            break;
  22.159 -
  22.160 -        default:
  22.161 -           BApplication::MessageReceived(message);
  22.162 -           break;
  22.163 -        }
  22.164 -    }
  22.165 -
  22.166 -    /* Window creation/destruction methods */
  22.167 -    int32 GetID(SDL_Window *win) {
  22.168 -        int32 i;
  22.169 -        for(i = 0; i < _GetNumWindowSlots(); ++i) {
  22.170 -            if( GetSDLWindow(i) == NULL ) {
  22.171 -                _SetSDLWindow(win, i);
  22.172 -                return i;
  22.173 -            }
  22.174 -        }
  22.175 -
  22.176 -        /* Expand the vector if all slots are full */
  22.177 -        if( i == _GetNumWindowSlots() ) {
  22.178 -            _PushBackWindow(win);
  22.179 -            return i;
  22.180 -        }
  22.181 -
  22.182 -        /* TODO: error handling */
  22.183 -        return 0;
  22.184 -    }
  22.185 -
  22.186 -    /* FIXME: Bad coding practice, but I can't include SDL_BWin.h here.  Is
  22.187 -       there another way to do this? */
  22.188 -    void ClearID(SDL_BWin *bwin); /* Defined in SDL_BeApp.cc */
  22.189 -
  22.190 -
  22.191 -    SDL_Window *GetSDLWindow(int32 winID) {
  22.192 -        return _window_map[winID];
  22.193 -    }
  22.194 -
  22.195 -    void SetCurrentContext(BGLView *newContext) {
  22.196 -        if(_current_context)
  22.197 -            _current_context->UnlockGL();
  22.198 -        _current_context = newContext;
  22.199 -        _current_context->LockGL();
  22.200 -    }
  22.201 -private:
  22.202 -    /* Event management */
  22.203 -    void _HandleBasicWindowEvent(BMessage *msg, int32 sdlEventType) {
  22.204 -        SDL_Window *win;
  22.205 -        int32 winID;
  22.206 -        if(
  22.207 -            !_GetWinID(msg, &winID)
  22.208 -        ) {
  22.209 -            return;
  22.210 -        }
  22.211 -        win = GetSDLWindow(winID);
  22.212 -        SDL_SendWindowEvent(win, sdlEventType, 0, 0);
  22.213 -    }
  22.214 -
  22.215 -    void _HandleMouseMove(BMessage *msg) {
  22.216 -        SDL_Window *win;
  22.217 -        int32 winID;
  22.218 -        int32 x = 0, y = 0;
  22.219 -        if(
  22.220 -            !_GetWinID(msg, &winID) ||
  22.221 -            msg->FindInt32("x", &x) != B_OK || /* x movement */
  22.222 -            msg->FindInt32("y", &y) != B_OK    /* y movement */
  22.223 -        ) {
  22.224 -            return;
  22.225 -        }
  22.226 -        win = GetSDLWindow(winID);
  22.227 -        SDL_SendMouseMotion(win, 0, 0, x, y);
  22.228 -
  22.229 -        /* Tell the application that the mouse passed over, redraw needed */
  22.230 -        BE_UpdateWindowFramebuffer(NULL,win,NULL,-1);
  22.231 -    }
  22.232 -
  22.233 -    void _HandleMouseButton(BMessage *msg) {
  22.234 -        SDL_Window *win;
  22.235 -        int32 winID;
  22.236 -        int32 button, state;    /* left/middle/right, pressed/released */
  22.237 -        if(
  22.238 -            !_GetWinID(msg, &winID) ||
  22.239 -            msg->FindInt32("button-id", &button) != B_OK ||
  22.240 -            msg->FindInt32("button-state", &state) != B_OK
  22.241 -        ) {
  22.242 -            return;
  22.243 -        }
  22.244 -        win = GetSDLWindow(winID);
  22.245 -        SDL_SendMouseButton(win, 0, state, button);
  22.246 -    }
  22.247 -
  22.248 -    void _HandleMouseWheel(BMessage *msg) {
  22.249 -        SDL_Window *win;
  22.250 -        int32 winID;
  22.251 -        int32 xTicks, yTicks;
  22.252 -        if(
  22.253 -            !_GetWinID(msg, &winID) ||
  22.254 -            msg->FindInt32("xticks", &xTicks) != B_OK ||
  22.255 -            msg->FindInt32("yticks", &yTicks) != B_OK
  22.256 -        ) {
  22.257 -            return;
  22.258 -        }
  22.259 -        win = GetSDLWindow(winID);
  22.260 -        SDL_SendMouseWheel(win, 0, xTicks, yTicks);
  22.261 -    }
  22.262 -
  22.263 -    void _HandleKey(BMessage *msg) {
  22.264 -        int32 scancode, state;  /* scancode, pressed/released */
  22.265 -        if(
  22.266 -            msg->FindInt32("key-state", &state) != B_OK ||
  22.267 -            msg->FindInt32("key-scancode", &scancode) != B_OK
  22.268 -        ) {
  22.269 -            return;
  22.270 -        }
  22.271 -
  22.272 -        /* Make sure this isn't a repeated event (key pressed and held) */
  22.273 -        if(state == SDL_PRESSED && BE_GetKeyState(scancode) == SDL_PRESSED) {
  22.274 -            return;
  22.275 -        }
  22.276 -        BE_SetKeyState(scancode, state);
  22.277 -        SDL_SendKeyboardKey(state, BE_GetScancodeFromBeKey(scancode));
  22.278 -    }
  22.279 -
  22.280 -    void _HandleMouseFocus(BMessage *msg) {
  22.281 -        SDL_Window *win;
  22.282 -        int32 winID;
  22.283 -        bool bSetFocus; /* If false, lose focus */
  22.284 -        if(
  22.285 -            !_GetWinID(msg, &winID) ||
  22.286 -            msg->FindBool("focusGained", &bSetFocus) != B_OK
  22.287 -        ) {
  22.288 -            return;
  22.289 -        }
  22.290 -        win = GetSDLWindow(winID);
  22.291 -        if(bSetFocus) {
  22.292 -            SDL_SetMouseFocus(win);
  22.293 -        } else if(SDL_GetMouseFocus() == win) {
  22.294 -            /* Only lose all focus if this window was the current focus */
  22.295 -            SDL_SetMouseFocus(NULL);
  22.296 -        }
  22.297 -    }
  22.298 -
  22.299 -    void _HandleKeyboardFocus(BMessage *msg) {
  22.300 -        SDL_Window *win;
  22.301 -        int32 winID;
  22.302 -        bool bSetFocus; /* If false, lose focus */
  22.303 -        if(
  22.304 -            !_GetWinID(msg, &winID) ||
  22.305 -            msg->FindBool("focusGained", &bSetFocus) != B_OK
  22.306 -        ) {
  22.307 -            return;
  22.308 -        }
  22.309 -        win = GetSDLWindow(winID);
  22.310 -        if(bSetFocus) {
  22.311 -            SDL_SetKeyboardFocus(win);
  22.312 -        } else if(SDL_GetKeyboardFocus() == win) {
  22.313 -            /* Only lose all focus if this window was the current focus */
  22.314 -            SDL_SetKeyboardFocus(NULL);
  22.315 -        }
  22.316 -    }
  22.317 -
  22.318 -    void _HandleWindowMoved(BMessage *msg) {
  22.319 -        SDL_Window *win;
  22.320 -        int32 winID;
  22.321 -        int32 xPos, yPos;
  22.322 -        /* Get the window id and new x/y position of the window */
  22.323 -        if(
  22.324 -            !_GetWinID(msg, &winID) ||
  22.325 -            msg->FindInt32("window-x", &xPos) != B_OK ||
  22.326 -            msg->FindInt32("window-y", &yPos) != B_OK
  22.327 -        ) {
  22.328 -            return;
  22.329 -        }
  22.330 -        win = GetSDLWindow(winID);
  22.331 -        SDL_SendWindowEvent(win, SDL_WINDOWEVENT_MOVED, xPos, yPos);
  22.332 -    }
  22.333 -
  22.334 -    void _HandleWindowResized(BMessage *msg) {
  22.335 -        SDL_Window *win;
  22.336 -        int32 winID;
  22.337 -        int32 w, h;
  22.338 -        /* Get the window id ]and new x/y position of the window */
  22.339 -        if(
  22.340 -            !_GetWinID(msg, &winID) ||
  22.341 -            msg->FindInt32("window-w", &w) != B_OK ||
  22.342 -            msg->FindInt32("window-h", &h) != B_OK
  22.343 -        ) {
  22.344 -            return;
  22.345 -        }
  22.346 -        win = GetSDLWindow(winID);
  22.347 -        SDL_SendWindowEvent(win, SDL_WINDOWEVENT_RESIZED, w, h);
  22.348 -    }
  22.349 -
  22.350 -    bool _GetWinID(BMessage *msg, int32 *winID) {
  22.351 -        return msg->FindInt32("window-id", winID) == B_OK;
  22.352 -    }
  22.353 -
  22.354 -
  22.355 -
  22.356 -    /* Vector functions: Wraps vector stuff in case we need to change
  22.357 -       implementation */
  22.358 -    void _SetSDLWindow(SDL_Window *win, int32 winID) {
  22.359 -        _window_map[winID] = win;
  22.360 -    }
  22.361 -
  22.362 -    int32 _GetNumWindowSlots() {
  22.363 -        return _window_map.size();
  22.364 -    }
  22.365 -
  22.366 -
  22.367 -    void _PopBackWindow() {
  22.368 -        _window_map.pop_back();
  22.369 -    }
  22.370 -
  22.371 -    void _PushBackWindow(SDL_Window *win) {
  22.372 -        _window_map.push_back(win);
  22.373 -    }
  22.374 -
  22.375 -
  22.376 -    /* Members */
  22.377 -    std::vector<SDL_Window*> _window_map; /* Keeps track of SDL_Windows by index-id */
  22.378 -
  22.379 -    display_mode *_saved_mode;
  22.380 -    BGLView      *_current_context;
  22.381 -};
  22.382 -
  22.383 -#endif
    23.1 --- a/src/main/beos/SDL_BeApp.cc	Thu Nov 14 10:19:07 2013 -0300
    23.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.3 @@ -1,136 +0,0 @@
    23.4 -/*
    23.5 -  Simple DirectMedia Layer
    23.6 -  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    23.7 -
    23.8 -  This software is provided 'as-is', without any express or implied
    23.9 -  warranty.  In no event will the authors be held liable for any damages
   23.10 -  arising from the use of this software.
   23.11 -
   23.12 -  Permission is granted to anyone to use this software for any purpose,
   23.13 -  including commercial applications, and to alter it and redistribute it
   23.14 -  freely, subject to the following restrictions:
   23.15 -
   23.16 -  1. The origin of this software must not be misrepresented; you must not
   23.17 -     claim that you wrote the original software. If you use this software
   23.18 -     in a product, an acknowledgment in the product documentation would be
   23.19 -     appreciated but is not required.
   23.20 -  2. Altered source versions must be plainly marked as such, and must not be
   23.21 -     misrepresented as being the original software.
   23.22 -  3. This notice may not be removed or altered from any source distribution.
   23.23 -*/
   23.24 -#include "SDL_config.h"
   23.25 -
   23.26 -#if defined(__BEOS__) || defined(__HAIKU__)
   23.27 -
   23.28 -/* Handle the BeApp specific portions of the application */
   23.29 -
   23.30 -#include <AppKit.h>
   23.31 -#include <storage/Path.h>
   23.32 -#include <storage/Entry.h>
   23.33 -#include <unistd.h>
   23.34 -
   23.35 -#include "SDL_BApp.h"	/* SDL_BApp class definition */
   23.36 -#include "SDL_BeApp.h"
   23.37 -#include "SDL_thread.h"
   23.38 -#include "SDL_timer.h"
   23.39 -#include "SDL_error.h"
   23.40 -
   23.41 -#include "../../video/bwindow/SDL_BWin.h"
   23.42 -
   23.43 -#ifdef __cplusplus
   23.44 -extern "C" {
   23.45 -#endif
   23.46 -/* Flag to tell whether or not the Be application is active or not */
   23.47 -int SDL_BeAppActive = 0;
   23.48 -static SDL_Thread *SDL_AppThread = NULL;
   23.49 -
   23.50 -static int
   23.51 -StartBeApp(void *unused)
   23.52 -{
   23.53 -    BApplication *App;
   23.54 -
   23.55 -    App = new SDL_BApp("application/x-SDL-executable");
   23.56 -
   23.57 -    App->Run();
   23.58 -    delete App;
   23.59 -    return (0);
   23.60 -}
   23.61 -
   23.62 -/* Initialize the Be Application, if it's not already started */
   23.63 -int
   23.64 -SDL_InitBeApp(void)
   23.65 -{
   23.66 -    /* Create the BApplication that handles appserver interaction */
   23.67 -    if (SDL_BeAppActive <= 0) {
   23.68 -        SDL_AppThread = SDL_CreateThread(StartBeApp, "SDLApplication", NULL);
   23.69 -        if (SDL_AppThread == NULL) {
   23.70 -            return SDL_SetError("Couldn't create BApplication thread");
   23.71 -        }
   23.72 -
   23.73 -        /* Change working to directory to that of executable */
   23.74 -        app_info info;
   23.75 -        if (B_OK == be_app->GetAppInfo(&info)) {
   23.76 -            entry_ref ref = info.ref;
   23.77 -            BEntry entry;
   23.78 -            if (B_OK == entry.SetTo(&ref)) {
   23.79 -                BPath path;
   23.80 -                if (B_OK == path.SetTo(&entry)) {
   23.81 -                    if (B_OK == path.GetParent(&path)) {
   23.82 -                        chdir(path.Path());
   23.83 -                    }
   23.84 -                }
   23.85 -            }
   23.86 -        }
   23.87 -
   23.88 -        do {
   23.89 -            SDL_Delay(10);
   23.90 -        } while ((be_app == NULL) || be_app->IsLaunching());
   23.91 -
   23.92 -        /* Mark the application active */
   23.93 -        SDL_BeAppActive = 0;
   23.94 -    }
   23.95 -
   23.96 -    /* Increment the application reference count */
   23.97 -    ++SDL_BeAppActive;
   23.98 -
   23.99 -    /* The app is running, and we're ready to go */
  23.100 -    return (0);
  23.101 -}
  23.102 -
  23.103 -/* Quit the Be Application, if there's nothing left to do */
  23.104 -void
  23.105 -SDL_QuitBeApp(void)
  23.106 -{
  23.107 -    /* Decrement the application reference count */
  23.108 -    --SDL_BeAppActive;
  23.109 -
  23.110 -    /* If the reference count reached zero, clean up the app */
  23.111 -    if (SDL_BeAppActive == 0) {
  23.112 -        if (SDL_AppThread != NULL) {
  23.113 -            if (be_app != NULL) {       /* Not tested */
  23.114 -                be_app->PostMessage(B_QUIT_REQUESTED);
  23.115 -            }
  23.116 -            SDL_WaitThread(SDL_AppThread, NULL);
  23.117 -            SDL_AppThread = NULL;
  23.118 -        }
  23.119 -        /* be_app should now be NULL since be_app has quit */
  23.120 -    }
  23.121 -}
  23.122 -
  23.123 -#ifdef __cplusplus
  23.124 -}
  23.125 -#endif
  23.126 -
  23.127 -/* SDL_BApp functions */
  23.128 -void SDL_BApp::ClearID(SDL_BWin *bwin) {
  23.129 -	_SetSDLWindow(NULL, bwin->GetID());
  23.130 -	int32 i = _GetNumWindowSlots() - 1;
  23.131 -	while(i >= 0 && GetSDLWindow(i) == NULL) {
  23.132 -		_PopBackWindow();
  23.133 -		--i;
  23.134 -	}
  23.135 -}
  23.136 -
  23.137 -#endif /* __BEOS__ */
  23.138 -
  23.139 -/* vi: set ts=4 sw=4 expandtab: */
    24.1 --- a/src/main/beos/SDL_BeApp.h	Thu Nov 14 10:19:07 2013 -0300
    24.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.3 @@ -1,41 +0,0 @@
    24.4 -/*
    24.5 -  Simple DirectMedia Layer
    24.6 -  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    24.7 -
    24.8 -  This software is provided 'as-is', without any express or implied
    24.9 -  warranty.  In no event will the authors be held liable for any damages
   24.10 -  arising from the use of this software.
   24.11 -
   24.12 -  Permission is granted to anyone to use this software for any purpose,
   24.13 -  including commercial applications, and to alter it and redistribute it
   24.14 -  freely, subject to the following restrictions:
   24.15 -
   24.16 -  1. The origin of this software must not be misrepresented; you must not
   24.17 -     claim that you wrote the original software. If you use this software
   24.18 -     in a product, an acknowledgment in the product documentation would be
   24.19 -     appreciated but is not required.
   24.20 -  2. Altered source versions must be plainly marked as such, and must not be
   24.21 -     misrepresented as being the original software.
   24.22 -  3. This notice may not be removed or altered from any source distribution.
   24.23 -*/
   24.24 -#include "SDL_config.h"
   24.25 -
   24.26 -
   24.27 -#ifdef __cplusplus
   24.28 -extern "C" {
   24.29 -#endif
   24.30 -/* Handle the BeApp specific portions of the application */
   24.31 -
   24.32 -/* Initialize the Be Application, if it's not already started */
   24.33 -extern int SDL_InitBeApp(void);
   24.34 -
   24.35 -/* Quit the Be Application, if there's nothing left to do */
   24.36 -extern void SDL_QuitBeApp(void);
   24.37 -
   24.38 -/* Flag to tell whether the app is active or not */
   24.39 -extern int SDL_BeAppActive;
   24.40 -/* vi: set ts=4 sw=4 expandtab: */
   24.41 -
   24.42 -#ifdef __cplusplus
   24.43 -}
   24.44 -#endif
    25.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.2 +++ b/src/main/haiku/SDL_BApp.h	Thu Nov 14 11:51:24 2013 -0500
    25.3 @@ -0,0 +1,380 @@
    25.4 +/*
    25.5 +  Simple DirectMedia Layer
    25.6 +  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    25.7 +
    25.8 +  This software is provided 'as-is', without any express or implied
    25.9 +  warranty.  In no event will the authors be held liable for any damages
   25.10 +  arising from the use of this software.
   25.11 +
   25.12 +  Permission is granted to anyone to use this software for any purpose,
   25.13 +  including commercial applications, and to alter it and redistribute it
   25.14 +  freely, subject to the following restrictions:
   25.15 +
   25.16 +  1. The origin of this software must not be misrepresented; you must not
   25.17 +     claim that you wrote the original software. If you use this software
   25.18 +     in a product, an acknowledgment in the product documentation would be
   25.19 +     appreciated but is not required.
   25.20 +  2. Altered source versions must be plainly marked as such, and must not be
   25.21 +     misrepresented as being the original software.
   25.22 +  3. This notice may not be removed or altered from any source distribution.
   25.23 +*/
   25.24 +#ifndef SDL_BAPP_H
   25.25 +#define SDL_BAPP_H
   25.26 +
   25.27 +#include <InterfaceKit.h>
   25.28 +#include <OpenGLKit.h>
   25.29 +
   25.30 +#include "../../video/haiku/SDL_bkeyboard.h"
   25.31 +
   25.32 +
   25.33 +#ifdef __cplusplus
   25.34 +extern "C" {
   25.35 +#endif
   25.36 +
   25.37 +#include "SDL_config.h"
   25.38 +
   25.39 +#include "SDL_video.h"
   25.40 +
   25.41 +/* Local includes */
   25.42 +#include "../../events/SDL_events_c.h"
   25.43 +#include "../../video/haiku/SDL_bkeyboard.h"
   25.44 +#include "../../video/haiku/SDL_bframebuffer.h"
   25.45 +
   25.46 +#ifdef __cplusplus
   25.47 +}
   25.48 +#endif
   25.49 +
   25.50 +#include <vector>
   25.51 +
   25.52 +
   25.53 +
   25.54 +
   25.55 +/* Forward declarations */
   25.56 +class SDL_BWin;
   25.57 +
   25.58 +/* Message constants */
   25.59 +enum ToSDL {
   25.60 +    /* Intercepted by BWindow on its way to BView */
   25.61 +    BAPP_MOUSE_MOVED,
   25.62 +    BAPP_MOUSE_BUTTON,
   25.63 +    BAPP_MOUSE_WHEEL,
   25.64 +    BAPP_KEY,
   25.65 +    BAPP_REPAINT,           /* from _UPDATE_ */
   25.66 +    /* From BWindow */
   25.67 +    BAPP_MAXIMIZE,          /* from B_ZOOM */
   25.68 +    BAPP_MINIMIZE,
   25.69 +    BAPP_RESTORE,           /* TODO: IMPLEMENT! */
   25.70 +    BAPP_SHOW,
   25.71 +    BAPP_HIDE,
   25.72 +    BAPP_MOUSE_FOCUS,       /* caused by MOUSE_MOVE */
   25.73 +    BAPP_KEYBOARD_FOCUS,    /* from WINDOW_ACTIVATED */
   25.74 +    BAPP_WINDOW_CLOSE_REQUESTED,
   25.75 +    BAPP_WINDOW_MOVED,
   25.76 +    BAPP_WINDOW_RESIZED,
   25.77 +    BAPP_SCREEN_CHANGED
   25.78 +};
   25.79 +
   25.80 +
   25.81 +
   25.82 +/* Create a descendant of BApplication */
   25.83 +class SDL_BApp : public BApplication {
   25.84 +public:
   25.85 +    SDL_BApp(const char* signature) :
   25.86 +        BApplication(signature) {
   25.87 +        _current_context = NULL;
   25.88 +    }
   25.89 +
   25.90 +
   25.91 +    virtual ~SDL_BApp() {
   25.92 +    }
   25.93 +
   25.94 +
   25.95 +
   25.96 +        /* Event-handling functions */
   25.97 +    virtual void MessageReceived(BMessage* message) {
   25.98 +        /* Sort out SDL-related messages */
   25.99 +        switch ( message->what ) {
  25.100 +        case BAPP_MOUSE_MOVED:
  25.101 +            _HandleMouseMove(message);
  25.102 +            break;
  25.103 +
  25.104 +        case BAPP_MOUSE_BUTTON:
  25.105 +            _HandleMouseButton(message);
  25.106 +            break;
  25.107 +
  25.108 +        case BAPP_MOUSE_WHEEL:
  25.109 +            _HandleMouseWheel(message);
  25.110 +            break;
  25.111 +
  25.112 +        case BAPP_KEY:
  25.113 +            _HandleKey(message);
  25.114 +            break;
  25.115 +
  25.116 +        case BAPP_REPAINT:
  25.117 +            _HandleBasicWindowEvent(message, SDL_WINDOWEVENT_EXPOSED);
  25.118 +            break;
  25.119 +
  25.120 +        case BAPP_MAXIMIZE:
  25.121 +            _HandleBasicWindowEvent(message, SDL_WINDOWEVENT_MAXIMIZED);
  25.122 +            break;
  25.123 +
  25.124 +        case BAPP_MINIMIZE:
  25.125 +            _HandleBasicWindowEvent(message, SDL_WINDOWEVENT_MINIMIZED);
  25.126 +            break;
  25.127 +
  25.128 +        case BAPP_SHOW:
  25.129 +            _HandleBasicWindowEvent(message, SDL_WINDOWEVENT_SHOWN);
  25.130 +            break;
  25.131 +
  25.132 +        case BAPP_HIDE:
  25.133 +            _HandleBasicWindowEvent(message, SDL_WINDOWEVENT_HIDDEN);
  25.134 +            break;
  25.135 +
  25.136 +        case BAPP_MOUSE_FOCUS:
  25.137 +            _HandleMouseFocus(message);
  25.138 +            break;
  25.139 +
  25.140 +        case BAPP_KEYBOARD_FOCUS:
  25.141 +            _HandleKeyboardFocus(message);
  25.142 +            break;
  25.143 +
  25.144 +        case BAPP_WINDOW_CLOSE_REQUESTED:
  25.145 +            _HandleBasicWindowEvent(message, SDL_WINDOWEVENT_CLOSE);
  25.146 +            break;
  25.147 +
  25.148 +        case BAPP_WINDOW_MOVED:
  25.149 +            _HandleWindowMoved(message);
  25.150 +            break;
  25.151 +
  25.152 +        case BAPP_WINDOW_RESIZED:
  25.153 +            _HandleWindowResized(message);
  25.154 +            break;
  25.155 +
  25.156 +        case BAPP_SCREEN_CHANGED:
  25.157 +            /* TODO: Handle screen resize or workspace change */
  25.158 +            break;
  25.159 +
  25.160 +        default:
  25.161 +           BApplication::MessageReceived(message);
  25.162 +           break;
  25.163 +        }
  25.164 +    }
  25.165 +
  25.166 +    /* Window creation/destruction methods */
  25.167 +    int32 GetID(SDL_Window *win) {
  25.168 +        int32 i;
  25.169 +        for(i = 0; i < _GetNumWindowSlots(); ++i) {
  25.170 +            if( GetSDLWindow(i) == NULL ) {
  25.171 +                _SetSDLWindow(win, i);
  25.172 +                return i;
  25.173 +            }
  25.174 +        }
  25.175 +
  25.176 +        /* Expand the vector if all slots are full */
  25.177 +        if( i == _GetNumWindowSlots() ) {
  25.178 +            _PushBackWindow(win);
  25.179 +            return i;
  25.180 +        }
  25.181 +
  25.182 +        /* TODO: error handling */
  25.183 +        return 0;
  25.184 +    }
  25.185 +
  25.186 +    /* FIXME: Bad coding practice, but I can't include SDL_BWin.h here.  Is
  25.187 +       there another way to do this? */
  25.188 +    void ClearID(SDL_BWin *bwin); /* Defined in SDL_BeApp.cc */
  25.189 +
  25.190 +
  25.191 +    SDL_Window *GetSDLWindow(int32 winID) {
  25.192 +        return _window_map[winID];
  25.193 +    }
  25.194 +
  25.195 +    void SetCurrentContext(BGLView *newContext) {
  25.196 +        if(_current_context)
  25.197 +            _current_context->UnlockGL();
  25.198 +        _current_context = newContext;
  25.199 +        _current_context->LockGL();
  25.200 +    }
  25.201 +private:
  25.202 +    /* Event management */
  25.203 +    void _HandleBasicWindowEvent(BMessage *msg, int32 sdlEventType) {
  25.204 +        SDL_Window *win;
  25.205 +        int32 winID;
  25.206 +        if(
  25.207 +            !_GetWinID(msg, &winID)
  25.208 +        ) {
  25.209 +            return;
  25.210 +        }
  25.211 +        win = GetSDLWindow(winID);
  25.212 +        SDL_SendWindowEvent(win, sdlEventType, 0, 0);
  25.213 +    }
  25.214 +
  25.215 +    void _HandleMouseMove(BMessage *msg) {
  25.216 +        SDL_Window *win;
  25.217 +        int32 winID;
  25.218 +        int32 x = 0, y = 0;
  25.219 +        if(
  25.220 +            !_GetWinID(msg, &winID) ||
  25.221 +            msg->FindInt32("x", &x) != B_OK || /* x movement */
  25.222 +            msg->FindInt32("y", &y) != B_OK    /* y movement */
  25.223 +        ) {
  25.224 +            return;
  25.225 +        }
  25.226 +        win = GetSDLWindow(winID);
  25.227 +        SDL_SendMouseMotion(win, 0, 0, x, y);
  25.228 +
  25.229 +        /* Tell the application that the mouse passed over, redraw needed */
  25.230 +        BE_UpdateWindowFramebuffer(NULL,win,NULL,-1);
  25.231 +    }
  25.232 +
  25.233 +    void _HandleMouseButton(BMessage *msg) {
  25.234 +        SDL_Window *win;
  25.235 +        int32 winID;
  25.236 +        int32 button, state;    /* left/middle/right, pressed/released */
  25.237 +        if(
  25.238 +            !_GetWinID(msg, &winID) ||
  25.239 +            msg->FindInt32("button-id", &button) != B_OK ||
  25.240 +            msg->FindInt32("button-state", &state) != B_OK
  25.241 +        ) {
  25.242 +            return;
  25.243 +        }
  25.244 +        win = GetSDLWindow(winID);
  25.245 +        SDL_SendMouseButton(win, 0, state, button);
  25.246 +    }
  25.247 +
  25.248 +    void _HandleMouseWheel(BMessage *msg) {
  25.249 +        SDL_Window *win;
  25.250 +        int32 winID;
  25.251 +        int32 xTicks, yTicks;
  25.252 +        if(
  25.253 +            !_GetWinID(msg, &winID) ||
  25.254 +            msg->FindInt32("xticks", &xTicks) != B_OK ||
  25.255 +            msg->FindInt32("yticks", &yTicks) != B_OK
  25.256 +        ) {
  25.257 +            return;
  25.258 +        }
  25.259 +        win = GetSDLWindow(winID);
  25.260 +        SDL_SendMouseWheel(win, 0, xTicks, yTicks);
  25.261 +    }
  25.262 +
  25.263 +    void _HandleKey(BMessage *msg) {
  25.264 +        int32 scancode, state;  /* scancode, pressed/released */
  25.265 +        if(
  25.266 +            msg->FindInt32("key-state", &state) != B_OK ||
  25.267 +            msg->FindInt32("key-scancode", &scancode) != B_OK
  25.268 +        ) {
  25.269 +            return;
  25.270 +        }
  25.271 +
  25.272 +        /* Make sure this isn't a repeated event (key pressed and held) */
  25.273 +        if(state == SDL_PRESSED && BE_GetKeyState(scancode) == SDL_PRESSED) {
  25.274 +            return;
  25.275 +        }
  25.276 +        BE_SetKeyState(scancode, state);
  25.277 +        SDL_SendKeyboardKey(state, BE_GetScancodeFromBeKey(scancode));
  25.278 +    }
  25.279 +
  25.280 +    void _HandleMouseFocus(BMessage *msg) {
  25.281 +        SDL_Window *win;
  25.282 +        int32 winID;
  25.283 +        bool bSetFocus; /* If false, lose focus */
  25.284 +        if(
  25.285 +            !_GetWinID(msg, &winID) ||
  25.286 +            msg->FindBool("focusGained", &bSetFocus) != B_OK
  25.287 +        ) {
  25.288 +            return;
  25.289 +        }
  25.290 +        win = GetSDLWindow(winID);
  25.291 +        if(bSetFocus) {
  25.292 +            SDL_SetMouseFocus(win);
  25.293 +        } else if(SDL_GetMouseFocus() == win) {
  25.294 +            /* Only lose all focus if this window was the current focus */
  25.295 +            SDL_SetMouseFocus(NULL);
  25.296 +        }
  25.297 +    }
  25.298 +
  25.299 +    void _HandleKeyboardFocus(BMessage *msg) {
  25.300 +        SDL_Window *win;
  25.301 +        int32 winID;
  25.302 +        bool bSetFocus; /* If false, lose focus */
  25.303 +        if(
  25.304 +            !_GetWinID(msg, &winID) ||
  25.305 +            msg->FindBool("focusGained", &bSetFocus) != B_OK
  25.306 +        ) {
  25.307 +            return;
  25.308 +        }
  25.309 +        win = GetSDLWindow(winID);
  25.310 +        if(bSetFocus) {
  25.311 +            SDL_SetKeyboardFocus(win);
  25.312 +        } else if(SDL_GetKeyboardFocus() == win) {
  25.313 +            /* Only lose all focus if this window was the current focus */
  25.314 +            SDL_SetKeyboardFocus(NULL);
  25.315 +        }
  25.316 +    }
  25.317 +
  25.318 +    void _HandleWindowMoved(BMessage *msg) {
  25.319 +        SDL_Window *win;
  25.320 +        int32 winID;
  25.321 +        int32 xPos, yPos;
  25.322 +        /* Get the window id and new x/y position of the window */
  25.323 +        if(
  25.324 +            !_GetWinID(msg, &winID) ||
  25.325 +            msg->FindInt32("window-x", &xPos) != B_OK ||
  25.326 +            msg->FindInt32("window-y", &yPos) != B_OK
  25.327 +        ) {
  25.328 +            return;
  25.329 +        }
  25.330 +        win = GetSDLWindow(winID);
  25.331 +        SDL_SendWindowEvent(win, SDL_WINDOWEVENT_MOVED, xPos, yPos);
  25.332 +    }
  25.333 +
  25.334 +    void _HandleWindowResized(BMessage *msg) {
  25.335 +        SDL_Window *win;
  25.336 +        int32 winID;
  25.337 +        int32 w, h;
  25.338 +        /* Get the window id ]and new x/y position of the window */
  25.339 +        if(
  25.340 +            !_GetWinID(msg, &winID) ||
  25.341 +            msg->FindInt32("window-w", &w) != B_OK ||
  25.342 +            msg->FindInt32("window-h", &h) != B_OK
  25.343 +        ) {
  25.344 +            return;
  25.345 +        }
  25.346 +        win = GetSDLWindow(winID);
  25.347 +        SDL_SendWindowEvent(win, SDL_WINDOWEVENT_RESIZED, w, h);
  25.348 +    }
  25.349 +
  25.350 +    bool _GetWinID(BMessage *msg, int32 *winID) {
  25.351 +        return msg->FindInt32("window-id", winID) == B_OK;
  25.352 +    }
  25.353 +
  25.354 +
  25.355 +
  25.356 +    /* Vector functions: Wraps vector stuff in case we need to change
  25.357 +       implementation */
  25.358 +    void _SetSDLWindow(SDL_Window *win, int32 winID) {
  25.359 +        _window_map[winID] = win;
  25.360 +    }
  25.361 +
  25.362 +    int32 _GetNumWindowSlots() {
  25.363 +        return _window_map.size();
  25.364 +    }
  25.365 +
  25.366 +
  25.367 +    void _PopBackWindow() {
  25.368 +        _window_map.pop_back();
  25.369 +    }
  25.370 +
  25.371 +    void _PushBackWindow(SDL_Window *win) {
  25.372 +        _window_map.push_back(win);
  25.373 +    }
  25.374 +
  25.375 +
  25.376 +    /* Members */
  25.377 +    std::vector<SDL_Window*> _window_map; /* Keeps track of SDL_Windows by index-id */
  25.378 +
  25.379 +    display_mode *_saved_mode;
  25.380 +    BGLView      *_current_context;
  25.381 +};
  25.382 +
  25.383 +#endif
    26.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.2 +++ b/src/main/haiku/SDL_BeApp.cc	Thu Nov 14 11:51:24 2013 -0500
    26.3 @@ -0,0 +1,136 @@
    26.4 +/*
    26.5 +  Simple DirectMedia Layer
    26.6 +  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    26.7 +
    26.8 +  This software is provided 'as-is', without any express or implied
    26.9 +  warranty.  In no event will the authors be held liable for any damages
   26.10 +  arising from the use of this software.
   26.11 +
   26.12 +  Permission is granted to anyone to use this software for any purpose,
   26.13 +  including commercial applications, and to alter it and redistribute it
   26.14 +  freely, subject to the following restrictions:
   26.15 +
   26.16 +  1. The origin of this software must not be misrepresented; you must not
   26.17 +     claim that you wrote the original software. If you use this software
   26.18 +     in a product, an acknowledgment in the product documentation would be
   26.19 +     appreciated but is not required.
   26.20 +  2. Altered source versions must be plainly marked as such, and must not be
   26.21 +     misrepresented as being the original software.
   26.22 +  3. This notice may not be removed or altered from any source distribution.
   26.23 +*/
   26.24 +#include "SDL_config.h"
   26.25 +
   26.26 +#if defined(__HAIKU__)
   26.27 +
   26.28 +/* Handle the BeApp specific portions of the application */
   26.29 +
   26.30 +#include <AppKit.h>
   26.31 +#include <storage/Path.h>
   26.32 +#include <storage/Entry.h>
   26.33 +#include <unistd.h>
   26.34 +
   26.35 +#include "SDL_BApp.h"	/* SDL_BApp class definition */
   26.36 +#include "SDL_BeApp.h"
   26.37 +#include "SDL_thread.h"
   26.38 +#include "SDL_timer.h"
   26.39 +#include "SDL_error.h"
   26.40 +
   26.41 +#include "../../video/haiku/SDL_BWin.h"
   26.42 +
   26.43 +#ifdef __cplusplus
   26.44 +extern "C" {
   26.45 +#endif
   26.46 +/* Flag to tell whether or not the Be application is active or not */
   26.47 +int SDL_BeAppActive = 0;
   26.48 +static SDL_Thread *SDL_AppThread = NULL;
   26.49 +
   26.50 +static int
   26.51 +StartBeApp(void *unused)
   26.52 +{
   26.53 +    BApplication *App;
   26.54 +
   26.55 +    App = new SDL_BApp("application/x-SDL-executable");
   26.56 +
   26.57 +    App->Run();
   26.58 +    delete App;
   26.59 +    return (0);
   26.60 +}
   26.61 +
   26.62 +/* Initialize the Be Application, if it's not already started */
   26.63 +int
   26.64 +SDL_InitBeApp(void)
   26.65 +{
   26.66 +    /* Create the BApplication that handles appserver interaction */
   26.67 +    if (SDL_BeAppActive <= 0) {
   26.68 +        SDL_AppThread = SDL_CreateThread(StartBeApp, "SDLApplication", NULL);
   26.69 +        if (SDL_AppThread == NULL) {
   26.70 +            return SDL_SetError("Couldn't create BApplication thread");
   26.71 +        }
   26.72 +
   26.73 +        /* Change working to directory to that of executable */
   26.74 +        app_info info;
   26.75 +        if (B_OK == be_app->GetAppInfo(&info)) {
   26.76 +            entry_ref ref = info.ref;
   26.77 +            BEntry entry;
   26.78 +            if (B_OK == entry.SetTo(&ref)) {
   26.79 +                BPath path;
   26.80 +                if (B_OK == path.SetTo(&entry)) {
   26.81 +                    if (B_OK == path.GetParent(&path)) {
   26.82 +                        chdir(path.Path());
   26.83 +                    }
   26.84 +                }
   26.85 +            }
   26.86 +        }
   26.87 +
   26.88 +        do {
   26.89 +            SDL_Delay(10);
   26.90 +        } while ((be_app == NULL) || be_app->IsLaunching());
   26.91 +
   26.92 +        /* Mark the application active */
   26.93 +        SDL_BeAppActive = 0;
   26.94 +    }
   26.95 +
   26.96 +    /* Increment the application reference count */
   26.97 +    ++SDL_BeAppActive;
   26.98 +
   26.99 +    /* The app is running, and we're ready to go */
  26.100 +    return (0);
  26.101 +}
  26.102 +
  26.103 +/* Quit the Be Application, if there's nothing left to do */
  26.104 +void
  26.105 +SDL_QuitBeApp(void)
  26.106 +{
  26.107 +    /* Decrement the application reference count */
  26.108 +    --SDL_BeAppActive;
  26.109 +
  26.110 +    /* If the reference count reached zero, clean up the app */
  26.111 +    if (SDL_BeAppActive == 0) {
  26.112 +        if (SDL_AppThread != NULL) {
  26.113 +            if (be_app != NULL) {       /* Not tested */
  26.114 +                be_app->PostMessage(B_QUIT_REQUESTED);
  26.115 +            }
  26.116 +            SDL_WaitThread(SDL_AppThread, NULL);
  26.117 +            SDL_AppThread = NULL;
  26.118 +        }
  26.119 +        /* be_app should now be NULL since be_app has quit */
  26.120 +    }
  26.121 +}
  26.122 +
  26.123 +#ifdef __cplusplus
  26.124 +}
  26.125 +#endif
  26.126 +
  26.127 +/* SDL_BApp functions */
  26.128 +void SDL_BApp::ClearID(SDL_BWin *bwin) {
  26.129 +	_SetSDLWindow(NULL, bwin->GetID());
  26.130 +	int32 i = _GetNumWindowSlots() - 1;
  26.131 +	while(i >= 0 && GetSDLWindow(i) == NULL) {
  26.132 +		_PopBackWindow();
  26.133 +		--i;
  26.134 +	}
  26.135 +}
  26.136 +
  26.137 +#endif /* __HAIKU__ */
  26.138 +
  26.139 +/* vi: set ts=4 sw=4 expandtab: */
    27.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.2 +++ b/src/main/haiku/SDL_BeApp.h	Thu Nov 14 11:51:24 2013 -0500
    27.3 @@ -0,0 +1,41 @@
    27.4 +/*
    27.5 +  Simple DirectMedia Layer
    27.6 +  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    27.7 +
    27.8 +  This software is provided 'as-is', without any express or implied
    27.9 +  warranty.  In no event will the authors be held liable for any damages
   27.10 +  arising from the use of this software.
   27.11 +
   27.12 +  Permission is granted to anyone to use this software for any purpose,
   27.13 +  including commercial applications, and to alter it and redistribute it
   27.14 +  freely, subject to the following restrictions:
   27.15 +
   27.16 +  1. The origin of this software must not be misrepresented; you must not
   27.17 +     claim that you wrote the original software. If you use this software
   27.18 +     in a product, an acknowledgment in the product documentation would be
   27.19 +     appreciated but is not required.
   27.20 +  2. Altered source versions must be plainly marked as such, and must not be
   27.21 +     misrepresented as being the original software.
   27.22 +  3. This notice may not be removed or altered from any source distribution.
   27.23 +*/
   27.24 +#include "SDL_config.h"
   27.25 +
   27.26 +
   27.27 +#ifdef __cplusplus
   27.28 +extern "C" {
   27.29 +#endif
   27.30 +/* Handle the BeApp specific portions of the application */
   27.31 +
   27.32 +/* Initialize the Be Application, if it's not already started */
   27.33 +extern int SDL_InitBeApp(void);
   27.34 +
   27.35 +/* Quit the Be Application, if there's nothing left to do */
   27.36 +extern void SDL_QuitBeApp(void);
   27.37 +
   27.38 +/* Flag to tell whether the app is active or not */
   27.39 +extern int SDL_BeAppActive;
   27.40 +/* vi: set ts=4 sw=4 expandtab: */
   27.41 +
   27.42 +#ifdef __cplusplus
   27.43 +}
   27.44 +#endif
    28.1 --- a/src/power/SDL_power.c	Thu Nov 14 10:19:07 2013 -0300
    28.2 +++ b/src/power/SDL_power.c	Thu Nov 14 11:51:24 2013 -0500
    28.3 @@ -33,7 +33,7 @@
    28.4  SDL_bool SDL_GetPowerInfo_Linux_proc_apm(SDL_PowerState *, int *, int *);
    28.5  SDL_bool SDL_GetPowerInfo_Windows(SDL_PowerState *, int *, int *);
    28.6  SDL_bool SDL_GetPowerInfo_MacOSX(SDL_PowerState *, int *, int *);
    28.7 -SDL_bool SDL_GetPowerInfo_BeOS(SDL_PowerState *, int *, int *);
    28.8 +SDL_bool SDL_GetPowerInfo_Haiku(SDL_PowerState *, int *, int *);
    28.9  SDL_bool SDL_GetPowerInfo_UIKit(SDL_PowerState *, int *, int *);
   28.10  SDL_bool SDL_GetPowerInfo_Android(SDL_PowerState *, int *, int *);
   28.11  SDL_bool SDL_GetPowerInfo_PSP(SDL_PowerState *, int *, int *);
   28.12 @@ -68,8 +68,8 @@
   28.13  #ifdef SDL_POWER_MACOSX         /* handles Mac OS X, Darwin. */
   28.14      SDL_GetPowerInfo_MacOSX,
   28.15  #endif
   28.16 -#ifdef SDL_POWER_BEOS           /* handles BeOS, Zeta, with euc.jp apm driver. */
   28.17 -    SDL_GetPowerInfo_BeOS,
   28.18 +#ifdef SDL_POWER_HAIKU          /* with BeOS euc.jp apm driver. Does this work on Haiku? */
   28.19 +    SDL_GetPowerInfo_Haiku,
   28.20  #endif
   28.21  #ifdef SDL_POWER_ANDROID        /* handles Android. */
   28.22      SDL_GetPowerInfo_Android,
    29.1 --- a/src/power/beos/SDL_syspower.c	Thu Nov 14 10:19:07 2013 -0300
    29.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.3 @@ -1,125 +0,0 @@
    29.4 -/*
    29.5 -  Simple DirectMedia Layer
    29.6 -  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    29.7 -
    29.8 -  This software is provided 'as-is', without any express or implied
    29.9 -  warranty.  In no event will the authors be held liable for any damages
   29.10 -  arising from the use of this software.
   29.11 -
   29.12 -  Permission is granted to anyone to use this software for any purpose,
   29.13 -  including commercial applications, and to alter it and redistribute it
   29.14 -  freely, subject to the following restrictions:
   29.15 -
   29.16 -  1. The origin of this software must not be misrepresented; you must not
   29.17 -     claim that you wrote the original software. If you use this software
   29.18 -     in a product, an acknowledgment in the product documentation would be
   29.19 -     appreciated but is not required.
   29.20 -  2. Altered source versions must be plainly marked as such, and must not be
   29.21 -     misrepresented as being the original software.
   29.22 -  3. This notice may not be removed or altered from any source distribution.
   29.23 -*/
   29.24 -#include "SDL_config.h"
   29.25 -
   29.26 -#ifndef SDL_POWER_DISABLED
   29.27 -#if SDL_POWER_BEOS
   29.28 -
   29.29 -#include <stdio.h>
   29.30 -#include <stdlib.h>
   29.31 -#include <unistd.h>
   29.32 -#include <fcntl.h>
   29.33 -#include <ctype.h>
   29.34 -#include <drivers/Drivers.h>
   29.35 -
   29.36 -/* These values are from apm.h ... */
   29.37 -#define APM_DEVICE_PATH "/dev/misc/apm"
   29.38 -#define APM_FUNC_OFFSET 0x5300
   29.39 -#define APM_FUNC_GET_POWER_STATUS 10
   29.40 -#define APM_DEVICE_ALL 1
   29.41 -#define APM_BIOS_CALL (B_DEVICE_OP_CODES_END + 3)
   29.42 -
   29.43 -#include "SDL_power.h"
   29.44 -
   29.45 -SDL_bool
   29.46 -SDL_GetPowerInfo_BeOS(SDL_PowerState * state, int *seconds, int *percent)
   29.47 -{
   29.48 -    const int fd = open("/dev/misc/apm", O_RDONLY);
   29.49 -    SDL_bool need_details = SDL_FALSE;
   29.50 -    uint16 regs[6];
   29.51 -    uint8 ac_status;
   29.52 -    uint8 battery_status;
   29.53 -    uint8 battery_flags;
   29.54 -    uint8 battery_life;
   29.55 -    uint32 battery_time;
   29.56 -    int rc;
   29.57 -
   29.58 -    if (fd == -1) {
   29.59 -        return SDL_FALSE;       /* maybe some other method will work? */
   29.60 -    }
   29.61 -
   29.62 -    memset(regs, '\0', sizeof(regs));
   29.63 -    regs[0] = APM_FUNC_OFFSET + APM_FUNC_GET_POWER_STATUS;
   29.64 -    regs[1] = APM_DEVICE_ALL;
   29.65 -    rc = ioctl(fd, APM_BIOS_CALL, regs);
   29.66 -    close(fd);
   29.67 -
   29.68 -    if (rc < 0) {
   29.69 -        return SDL_FALSE;
   29.70 -    }
   29.71 -
   29.72 -    ac_status = regs[1] >> 8;
   29.73 -    battery_status = regs[1] & 0xFF;
   29.74 -    battery_flags = regs[2] >> 8;
   29.75 -    battery_life = regs[2] & 0xFF;
   29.76 -    battery_time = (uint32) regs[3];
   29.77 -
   29.78 -    /* in theory, _something_ should be set in battery_flags, right? */
   29.79 -    if (battery_flags == 0x00) {        /* older APM BIOS? Less fields. */
   29.80 -        battery_time = 0xFFFF;
   29.81 -        if (battery_status == 0xFF) {
   29.82 -            battery_flags = 0xFF;
   29.83 -        } else {
   29.84 -            battery_flags = (1 << battery_status);
   29.85 -        }
   29.86 -    }
   29.87 -
   29.88 -    if ((battery_time != 0xFFFF) && (battery_time & (1 << 15))) {
   29.89 -        /* time is in minutes, not seconds */
   29.90 -        battery_time = (battery_time & 0x7FFF) * 60;
   29.91 -    }
   29.92 -
   29.93 -    if (battery_flags == 0xFF) {        /* unknown state */
   29.94 -        *state = SDL_POWERSTATE_UNKNOWN;
   29.95 -    } else if (battery_flags & (1 << 7)) {      /* no battery */
   29.96 -        *state = SDL_POWERSTATE_NO_BATTERY;
   29.97 -    } else if (battery_flags & (1 << 3)) {      /* charging */
   29.98 -        *state = SDL_POWERSTATE_CHARGING;
   29.99 -        need_details = SDL_TRUE;
  29.100 -    } else if (ac_status == 1) {
  29.101 -        *state = SDL_POWERSTATE_CHARGED;        /* on AC, not charging. */
  29.102 -        need_details = SDL_TRUE;
  29.103 -    } else {
  29.104 -        *state = SDL_POWERSTATE_ON_BATTERY;     /* not on AC. */
  29.105 -        need_details = SDL_TRUE;
  29.106 -    }
  29.107 -
  29.108 -    *percent = -1;
  29.109 -    *seconds = -1;
  29.110 -    if (need_details) {
  29.111 -        const int pct = (int) battery_life;
  29.112 -        const int secs = (int) battery_time;
  29.113 -
  29.114 -        if (pct != 255) {       /* 255 == unknown */
  29.115 -            *percent = (pct > 100) ? 100 : pct; /* clamp between 0%, 100% */
  29.116 -        }
  29.117 -        if (secs != 0xFFFF) {   /* 0xFFFF == unknown */
  29.118 -            *seconds = secs;
  29.119 -        }
  29.120 -    }
  29.121 -
  29.122 -    return SDL_TRUE;            /* the definitive answer if APM driver replied. */
  29.123 -}
  29.124 -
  29.125 -#endif /* SDL_POWER_BEOS */
  29.126 -#endif /* SDL_POWER_DISABLED */
  29.127 -
  29.128 -/* vi: set ts=4 sw=4 expandtab: */
    30.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.2 +++ b/src/power/haiku/SDL_syspower.c	Thu Nov 14 11:51:24 2013 -0500
    30.3 @@ -0,0 +1,126 @@
    30.4 +/*
    30.5 +  Simple DirectMedia Layer
    30.6 +  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    30.7 +
    30.8 +  This software is provided 'as-is', without any express or implied
    30.9 +  warranty.  In no event will the authors be held liable for any damages
   30.10 +  arising from the use of this software.
   30.11 +
   30.12 +  Permission is granted to anyone to use this software for any purpose,
   30.13 +  including commercial applications, and to alter it and redistribute it
   30.14 +  freely, subject to the following restrictions:
   30.15 +
   30.16 +  1. The origin of this software must not be misrepresented; you must not
   30.17 +     claim that you wrote the original software. If you use this software
   30.18 +     in a product, an acknowledgment in the product documentation would be
   30.19 +     appreciated but is not required.
   30.20 +  2. Altered source versions must be plainly marked as such, and must not be
   30.21 +     misrepresented as being the original software.
   30.22 +  3. This notice may not be removed or altered from any source distribution.
   30.23 +*/
   30.24 +#include "SDL_config.h"
   30.25 +
   30.26 +/* !!! FIXME: does this thing even work on Haiku? */
   30.27 +#ifndef SDL_POWER_DISABLED
   30.28 +#if SDL_POWER_HAIKU
   30.29 +
   30.30 +#include <stdio.h>
   30.31 +#include <stdlib.h>
   30.32 +#include <unistd.h>
   30.33 +#include <fcntl.h>
   30.34 +#include <ctype.h>
   30.35 +#include <drivers/Drivers.h>
   30.36 +
   30.37 +/* These values are from apm.h ... */
   30.38 +#define APM_DEVICE_PATH "/dev/misc/apm"
   30.39 +#define APM_FUNC_OFFSET 0x5300
   30.40 +#define APM_FUNC_GET_POWER_STATUS 10
   30.41 +#define APM_DEVICE_ALL 1
   30.42 +#define APM_BIOS_CALL (B_DEVICE_OP_CODES_END + 3)
   30.43 +
   30.44 +#include "SDL_power.h"
   30.45 +
   30.46 +SDL_bool
   30.47 +SDL_GetPowerInfo_Haiku(SDL_PowerState * state, int *seconds, int *percent)
   30.48 +{
   30.49 +    const int fd = open("/dev/misc/apm", O_RDONLY);
   30.50 +    SDL_bool need_details = SDL_FALSE;
   30.51 +    uint16 regs[6];
   30.52 +    uint8 ac_status;
   30.53 +    uint8 battery_status;
   30.54 +    uint8 battery_flags;
   30.55 +    uint8 battery_life;
   30.56 +    uint32 battery_time;
   30.57 +    int rc;
   30.58 +
   30.59 +    if (fd == -1) {
   30.60 +        return SDL_FALSE;       /* maybe some other method will work? */
   30.61 +    }
   30.62 +
   30.63 +    memset(regs, '\0', sizeof(regs));
   30.64 +    regs[0] = APM_FUNC_OFFSET + APM_FUNC_GET_POWER_STATUS;
   30.65 +    regs[1] = APM_DEVICE_ALL;
   30.66 +    rc = ioctl(fd, APM_BIOS_CALL, regs);
   30.67 +    close(fd);
   30.68 +
   30.69 +    if (rc < 0) {
   30.70 +        return SDL_FALSE;
   30.71 +    }
   30.72 +
   30.73 +    ac_status = regs[1] >> 8;
   30.74 +    battery_status = regs[1] & 0xFF;
   30.75 +    battery_flags = regs[2] >> 8;
   30.76 +    battery_life = regs[2] & 0xFF;
   30.77 +    battery_time = (uint32) regs[3];
   30.78 +
   30.79 +    /* in theory, _something_ should be set in battery_flags, right? */
   30.80 +    if (battery_flags == 0x00) {        /* older APM BIOS? Less fields. */
   30.81 +        battery_time = 0xFFFF;
   30.82 +        if (battery_status == 0xFF) {
   30.83 +            battery_flags = 0xFF;
   30.84 +        } else {
   30.85 +            battery_flags = (1 << battery_status);
   30.86 +        }
   30.87 +    }
   30.88 +
   30.89 +    if ((battery_time != 0xFFFF) && (battery_time & (1 << 15))) {
   30.90 +        /* time is in minutes, not seconds */
   30.91 +        battery_time = (battery_time & 0x7FFF) * 60;
   30.92 +    }
   30.93 +
   30.94 +    if (battery_flags == 0xFF) {        /* unknown state */
   30.95 +        *state = SDL_POWERSTATE_UNKNOWN;
   30.96 +    } else if (battery_flags & (1 << 7)) {      /* no battery */
   30.97 +        *state = SDL_POWERSTATE_NO_BATTERY;
   30.98 +    } else if (battery_flags & (1 << 3)) {      /* charging */
   30.99 +        *state = SDL_POWERSTATE_CHARGING;
  30.100 +        need_details = SDL_TRUE;
  30.101 +    } else if (ac_status == 1) {
  30.102 +        *state = SDL_POWERSTATE_CHARGED;        /* on AC, not charging. */
  30.103 +        need_details = SDL_TRUE;
  30.104 +    } else {
  30.105 +        *state = SDL_POWERSTATE_ON_BATTERY;     /* not on AC. */
  30.106 +        need_details = SDL_TRUE;
  30.107 +    }
  30.108 +
  30.109 +    *percent = -1;
  30.110 +    *seconds = -1;
  30.111 +    if (need_details) {
  30.112 +        const int pct = (int) battery_life;
  30.113 +        const int secs = (int) battery_time;
  30.114 +
  30.115 +        if (pct != 255) {       /* 255 == unknown */
  30.116 +            *percent = (pct > 100) ? 100 : pct; /* clamp between 0%, 100% */
  30.117 +        }
  30.118 +        if (secs != 0xFFFF) {   /* 0xFFFF == unknown */
  30.119 +            *seconds = secs;
  30.120 +        }
  30.121 +    }
  30.122 +
  30.123 +    return SDL_TRUE;            /* the definitive answer if APM driver replied. */
  30.124 +}
  30.125 +
  30.126 +#endif /* SDL_POWER_HAIKU */
  30.127 +#endif /* SDL_POWER_DISABLED */
  30.128 +
  30.129 +/* vi: set ts=4 sw=4 expandtab: */
    31.1 --- a/src/timer/beos/SDL_systimer.c	Thu Nov 14 10:19:07 2013 -0300
    31.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.3 @@ -1,74 +0,0 @@
    31.4 -/*
    31.5 -  Simple DirectMedia Layer
    31.6 -  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    31.7 -
    31.8 -  This software is provided 'as-is', without any express or implied
    31.9 -  warranty.  In no event will the authors be held liable for any damages
   31.10 -  arising from the use of this software.
   31.11 -
   31.12 -  Permission is granted to anyone to use this software for any purpose,
   31.13 -  including commercial applications, and to alter it and redistribute it
   31.14 -  freely, subject to the following restrictions:
   31.15 -
   31.16 -  1. The origin of this software must not be misrepresented; you must not
   31.17 -     claim that you wrote the original software. If you use this software
   31.18 -     in a product, an acknowledgment in the product documentation would be
   31.19 -     appreciated but is not required.
   31.20 -  2. Altered source versions must be plainly marked as such, and must not be
   31.21 -     misrepresented as being the original software.
   31.22 -  3. This notice may not be removed or altered from any source distribution.
   31.23 -*/
   31.24 -#include "SDL_config.h"
   31.25 -
   31.26 -#ifdef SDL_TIMER_BEOS
   31.27 -
   31.28 -#include <be/kernel/OS.h>
   31.29 -
   31.30 -#include "SDL_timer.h"
   31.31 -
   31.32 -static bigtime_t start;
   31.33 -static SDL_bool ticks_started = SDL_FALSE;
   31.34 -
   31.35 -void
   31.36 -SDL_InitTicks(void)
   31.37 -{
   31.38 -    if (ticks_started) {
   31.39 -        return;
   31.40 -    }
   31.41 -    ticks_started = SDL_TRUE;
   31.42 -
   31.43 -    /* Set first ticks value */
   31.44 -    start = system_time();
   31.45 -}
   31.46 -
   31.47 -Uint32
   31.48 -SDL_GetTicks(void)
   31.49 -{
   31.50 -    if (!ticks_started) {
   31.51 -        SDL_InitTicks();
   31.52 -    }
   31.53 -
   31.54 -    return ((system_time() - start) / 1000);
   31.55 -}
   31.56 -
   31.57 -Uint64
   31.58 -SDL_GetPerformanceCounter(void)
   31.59 -{
   31.60 -    return system_time();
   31.61 -}
   31.62 -
   31.63 -Uint64
   31.64 -SDL_GetPerformanceFrequency(void)
   31.65 -{
   31.66 -    return 1000000;
   31.67 -}
   31.68 -
   31.69 -void
   31.70 -SDL_Delay(Uint32 ms)
   31.71 -{
   31.72 -    snooze(ms * 1000);
   31.73 -}
   31.74 -
   31.75 -#endif /* SDL_TIMER_BEOS */
   31.76 -
   31.77 -/* vi: set ts=4 sw=4 expandtab: */
    32.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.2 +++ b/src/timer/haiku/SDL_systimer.c	Thu Nov 14 11:51:24 2013 -0500
    32.3 @@ -0,0 +1,74 @@
    32.4 +/*
    32.5 +  Simple DirectMedia Layer
    32.6 +  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    32.7 +
    32.8 +  This software is provided 'as-is', without any express or implied
    32.9 +  warranty.  In no event will the authors be held liable for any damages
   32.10 +  arising from the use of this software.
   32.11 +
   32.12 +  Permission is granted to anyone to use this software for any purpose,
   32.13 +  including commercial applications, and to alter it and redistribute it
   32.14 +  freely, subject to the following restrictions:
   32.15 +
   32.16 +  1. The origin of this software must not be misrepresented; you must not
   32.17 +     claim that you wrote the original software. If you use this software
   32.18 +     in a product, an acknowledgment in the product documentation would be
   32.19 +     appreciated but is not required.
   32.20 +  2. Altered source versions must be plainly marked as such, and must not be
   32.21 +     misrepresented as being the original software.
   32.22 +  3. This notice may not be removed or altered from any source distribution.
   32.23 +*/
   32.24 +#include "SDL_config.h"
   32.25 +
   32.26 +#ifdef SDL_TIMER_HAIKU
   32.27 +
   32.28 +#include <os/kernel/OS.h>
   32.29 +
   32.30 +#include "SDL_timer.h"
   32.31 +
   32.32 +static bigtime_t start;
   32.33 +static SDL_bool ticks_started = SDL_FALSE;
   32.34 +
   32.35 +void
   32.36 +SDL_InitTicks(void)
   32.37 +{
   32.38 +    if (ticks_started) {
   32.39 +        return;
   32.40 +    }
   32.41 +    ticks_started = SDL_TRUE;
   32.42 +
   32.43 +    /* Set first ticks value */
   32.44 +    start = system_time();
   32.45 +}
   32.46 +
   32.47 +Uint32
   32.48 +SDL_GetTicks(void)
   32.49 +{
   32.50 +    if (!ticks_started) {
   32.51 +        SDL_InitTicks();
   32.52 +    }
   32.53 +
   32.54 +    return ((system_time() - start) / 1000);
   32.55 +}
   32.56 +
   32.57 +Uint64
   32.58 +SDL_GetPerformanceCounter(void)
   32.59 +{
   32.60 +    return system_time();
   32.61 +}
   32.62 +
   32.63 +Uint64
   32.64 +SDL_GetPerformanceFrequency(void)
   32.65 +{
   32.66 +    return 1000000;
   32.67 +}
   32.68 +
   32.69 +void
   32.70 +SDL_Delay(Uint32 ms)
   32.71 +{
   32.72 +    snooze(ms * 1000);
   32.73 +}
   32.74 +
   32.75 +#endif /* SDL_TIMER_HAIKU */
   32.76 +
   32.77 +/* vi: set ts=4 sw=4 expandtab: */
    33.1 --- a/src/video/SDL_sysvideo.h	Thu Nov 14 10:19:07 2013 -0300
    33.2 +++ b/src/video/SDL_sysvideo.h	Thu Nov 14 11:51:24 2013 -0500
    33.3 @@ -348,8 +348,8 @@
    33.4  #if SDL_VIDEO_DRIVER_WINDOWS
    33.5  extern VideoBootStrap WINDOWS_bootstrap;
    33.6  #endif
    33.7 -#if SDL_VIDEO_DRIVER_BWINDOW
    33.8 -extern VideoBootStrap BWINDOW_bootstrap;
    33.9 +#if SDL_VIDEO_DRIVER_HAIKU
   33.10 +extern VideoBootStrap HAIKU_bootstrap;
   33.11  #endif
   33.12  #if SDL_VIDEO_DRIVER_PANDORA
   33.13  extern VideoBootStrap PND_bootstrap;
    34.1 --- a/src/video/SDL_video.c	Thu Nov 14 10:19:07 2013 -0300
    34.2 +++ b/src/video/SDL_video.c	Thu Nov 14 11:51:24 2013 -0500
    34.3 @@ -65,8 +65,8 @@
    34.4  #if SDL_VIDEO_DRIVER_WINDOWS
    34.5      &WINDOWS_bootstrap,
    34.6  #endif
    34.7 -#if SDL_VIDEO_DRIVER_BWINDOW
    34.8 -    &BWINDOW_bootstrap,
    34.9 +#if SDL_VIDEO_DRIVER_HAIKU
   34.10 +    &HAIKU_bootstrap,
   34.11  #endif
   34.12  #if SDL_VIDEO_DRIVER_PANDORA
   34.13      &PND_bootstrap,
    35.1 --- a/src/video/bwindow/SDL_BWin.h	Thu Nov 14 10:19:07 2013 -0300
    35.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    35.3 @@ -1,636 +0,0 @@
    35.4 -/*
    35.5 -  Simple DirectMedia Layer
    35.6 -  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    35.7 -
    35.8 -  This software is provided 'as-is', without any express or implied
    35.9 -  warranty.  In no event will the authors be held liable for any damages
   35.10 -  arising from the use of this software.
   35.11 -
   35.12 -  Permission is granted to anyone to use this software for any purpose,
   35.13 -  including commercial applications, and to alter it and redistribute it
   35.14 -  freely, subject to the following restrictions:
   35.15 -
   35.16 -  1. The origin of this software must not be misrepresented; you must not
   35.17 -     claim that you wrote the original software. If you use this software
   35.18 -     in a product, an acknowledgment in the product documentation would be
   35.19 -     appreciated but is not required.
   35.20 -  2. Altered source versions must be plainly marked as such, and must not be
   35.21 -     misrepresented as being the original software.
   35.22 -  3. This notice may not be removed or altered from any source distribution.
   35.23 -*/
   35.24 -
   35.25 -#ifndef _SDL_BWin_h
   35.26 -#define _SDL_BWin_h
   35.27 -
   35.28 -#ifdef __cplusplus
   35.29 -extern "C" {
   35.30 -#endif
   35.31 -
   35.32 -#include "SDL_config.h"
   35.33 -#include "SDL.h"
   35.34 -#include "SDL_syswm.h"
   35.35 -#include "SDL_bframebuffer.h"
   35.36 -
   35.37 -#ifdef __cplusplus
   35.38 -}
   35.39 -#endif
   35.40 -
   35.41 -#include <stdio.h>
   35.42 -#include <AppKit.h>
   35.43 -#include <InterfaceKit.h>
   35.44 -#include <be/game/DirectWindow.h>
   35.45 -#if SDL_VIDEO_OPENGL
   35.46 -#include <be/opengl/GLView.h>
   35.47 -#endif
   35.48 -#include "SDL_events.h"
   35.49 -#include "../../main/beos/SDL_BApp.h"
   35.50 -
   35.51 -
   35.52 -enum WinCommands {
   35.53 -    BWIN_MOVE_WINDOW,
   35.54 -    BWIN_RESIZE_WINDOW,
   35.55 -    BWIN_SHOW_WINDOW,
   35.56 -    BWIN_HIDE_WINDOW,
   35.57 -    BWIN_MAXIMIZE_WINDOW,
   35.58 -    BWIN_MINIMIZE_WINDOW,
   35.59 -    BWIN_RESTORE_WINDOW,
   35.60 -    BWIN_SET_TITLE,
   35.61 -    BWIN_SET_BORDERED,
   35.62 -    BWIN_FULLSCREEN
   35.63 -};
   35.64 -
   35.65 -
   35.66 -class SDL_BWin:public BDirectWindow
   35.67 -{
   35.68 -  public:
   35.69 -    /* Constructor/Destructor */
   35.70 -    SDL_BWin(BRect bounds, window_look look, uint32 flags)
   35.71 -        : BDirectWindow(bounds, "Untitled", look, B_NORMAL_WINDOW_FEEL, flags)
   35.72 -    {
   35.73 -        _last_buttons = 0;
   35.74 -
   35.75 -#if SDL_VIDEO_OPENGL
   35.76 -        _SDL_GLView = NULL;
   35.77 -#endif
   35.78 -        _shown = false;
   35.79 -        _inhibit_resize = false;
   35.80 -        _mouse_focused = false;
   35.81 -        _prev_frame = NULL;
   35.82 -
   35.83 -        /* Handle framebuffer stuff */
   35.84 -        _connected = _connection_disabled = false;
   35.85 -        _buffer_created = _buffer_dirty = false;
   35.86 -        _trash_window_buffer = false;
   35.87 -        _buffer_locker = new BLocker();
   35.88 -        _bitmap = NULL;
   35.89 -#ifdef DRAWTHREAD
   35.90 -        _draw_thread_id = spawn_thread(BE_DrawThread, "drawing_thread",
   35.91 -                            B_NORMAL_PRIORITY, (void*) this);
   35.92 -        resume_thread(_draw_thread_id);
   35.93 -#endif
   35.94 -    }
   35.95 -
   35.96 -    virtual ~ SDL_BWin()
   35.97 -    {
   35.98 -        Lock();
   35.99 -        _connection_disabled = true;
  35.100 -        int32 result;
  35.101 -
  35.102 -#if SDL_VIDEO_OPENGL
  35.103 -        if (_SDL_GLView) {
  35.104 -            _SDL_GLView->UnlockGL();
  35.105 -            RemoveChild(_SDL_GLView);   /* Why was this outside the if
  35.106 -                                            statement before? */
  35.107 -        }
  35.108 -
  35.109 -#endif
  35.110 -        Unlock();
  35.111 -#if SDL_VIDEO_OPENGL
  35.112 -        if (_SDL_GLView) {
  35.113 -            delete _SDL_GLView;
  35.114 -        }
  35.115 -#endif
  35.116 -
  35.117 -        /* Clean up framebuffer stuff */
  35.118 -        _buffer_locker->Lock();
  35.119 -#ifdef DRAWTHREAD
  35.120 -        wait_for_thread(_draw_thread_id, &result);
  35.121 -#endif
  35.122 -        free(_clips);
  35.123 -        delete _buffer_locker;
  35.124 -    }
  35.125 -
  35.126 -
  35.127 -    /* * * * * OpenGL functionality * * * * */
  35.128 -#if SDL_VIDEO_OPENGL
  35.129 -    virtual BGLView *CreateGLView(Uint32 gl_flags) {
  35.130 -        Lock();
  35.131 -        if (_SDL_GLView == NULL) {
  35.132 -            _SDL_GLView = new BGLView(Bounds(), "SDL GLView",
  35.133 -                                     B_FOLLOW_ALL_SIDES,
  35.134 -                                     (B_WILL_DRAW | B_FRAME_EVENTS),
  35.135 -                                     gl_flags);
  35.136 -        }
  35.137 -        AddChild(_SDL_GLView);
  35.138 -        _SDL_GLView->EnableDirectMode(true);
  35.139 -        _SDL_GLView->LockGL();  /* "New" GLViews are created */
  35.140 -        Unlock();
  35.141 -        return (_SDL_GLView);
  35.142 -    }
  35.143 -
  35.144 -    virtual void RemoveGLView() {
  35.145 -        Lock();
  35.146 -        if(_SDL_GLView) {
  35.147 -            _SDL_GLView->UnlockGL();
  35.148 -            RemoveChild(_SDL_GLView);
  35.149 -        }
  35.150 -        Unlock();
  35.151 -    }
  35.152 -
  35.153 -    virtual void SwapBuffers(void) {
  35.154 -        _SDL_GLView->UnlockGL();
  35.155 -        _SDL_GLView->LockGL();
  35.156 -        _SDL_GLView->SwapBuffers();
  35.157 -    }
  35.158 -#endif
  35.159 -
  35.160 -    /* * * * * Framebuffering* * * * */
  35.161 -    virtual void DirectConnected(direct_buffer_info *info) {
  35.162 -        if(!_connected && _connection_disabled) {
  35.163 -            return;
  35.164 -        }
  35.165 -
  35.166 -        /* Determine if the pixel buffer is usable after this update */
  35.167 -        _trash_window_buffer =      _trash_window_buffer
  35.168 -                                || ((info->buffer_state & B_BUFFER_RESIZED)
  35.169 -                                || (info->buffer_state & B_BUFFER_RESET)
  35.170 -                                || (info->driver_state == B_MODE_CHANGED));
  35.171 -        LockBuffer();
  35.172 -
  35.173 -        switch(info->buffer_state & B_DIRECT_MODE_MASK) {
  35.174 -        case B_DIRECT_START:
  35.175 -            _connected = true;
  35.176 -
  35.177 -        case B_DIRECT_MODIFY:
  35.178 -            if(_clips) {
  35.179 -                free(_clips);
  35.180 -                _clips = NULL;
  35.181 -            }
  35.182 -
  35.183 -            _num_clips = info->clip_list_count;
  35.184 -            _clips = (clipping_rect *)malloc(_num_clips*sizeof(clipping_rect));
  35.185 -            if(_clips) {
  35.186 -                memcpy(_clips, info->clip_list,
  35.187 -                    _num_clips*sizeof(clipping_rect));
  35.188 -
  35.189 -                _bits = (uint8*) info->bits;
  35.190 -                _row_bytes = info->bytes_per_row;
  35.191 -                _bounds = info->window_bounds;
  35.192 -                _bytes_per_px = info->bits_per_pixel / 8;
  35.193 -                _buffer_dirty = true;
  35.194 -            }
  35.195 -            break;
  35.196 -
  35.197 -        case B_DIRECT_STOP:
  35.198 -            _connected = false;
  35.199 -            break;
  35.200 -        }
  35.201 -#if SDL_VIDEO_OPENGL
  35.202 -        if(_SDL_GLView) {
  35.203 -            _SDL_GLView->DirectConnected(info);
  35.204 -        }
  35.205 -#endif
  35.206 -
  35.207 -
  35.208 -        /* Call the base object directconnected */
  35.209 -        BDirectWindow::DirectConnected(info);
  35.210 -
  35.211 -        UnlockBuffer();
  35.212 -
  35.213 -    }
  35.214 -
  35.215 -
  35.216 -
  35.217 -
  35.218 -    /* * * * * Event sending * * * * */
  35.219 -    /* Hook functions */
  35.220 -    virtual void FrameMoved(BPoint origin) {
  35.221 -        /* Post a message to the BApp so that it can handle the window event */
  35.222 -        BMessage msg(BAPP_WINDOW_MOVED);
  35.223 -        msg.AddInt32("window-x", (int)origin.x);
  35.224 -        msg.AddInt32("window-y", (int)origin.y);
  35.225 -        _PostWindowEvent(msg);
  35.226 -
  35.227 -        /* Perform normal hook operations */
  35.228 -        BDirectWindow::FrameMoved(origin);
  35.229 -    }
  35.230 -
  35.231 -    virtual void FrameResized(float width, float height) {
  35.232 -        /* Post a message to the BApp so that it can handle the window event */
  35.233 -        BMessage msg(BAPP_WINDOW_RESIZED);
  35.234 -
  35.235 -        msg.AddInt32("window-w", (int)width + 1);
  35.236 -        msg.AddInt32("window-h", (int)height + 1);
  35.237 -        _PostWindowEvent(msg);
  35.238 -
  35.239 -        /* Perform normal hook operations */
  35.240 -        BDirectWindow::FrameResized(width, height);
  35.241 -    }
  35.242 -
  35.243 -    virtual bool QuitRequested() {
  35.244 -        BMessage msg(BAPP_WINDOW_CLOSE_REQUESTED);
  35.245 -        _PostWindowEvent(msg);
  35.246 -
  35.247 -        /* We won't allow a quit unless asked by DestroyWindow() */
  35.248 -        return false;
  35.249 -    }
  35.250 -
  35.251 -    virtual void WindowActivated(bool active) {
  35.252 -        BMessage msg(BAPP_KEYBOARD_FOCUS);  /* Mouse focus sold separately */
  35.253 -        _PostWindowEvent(msg);
  35.254 -    }
  35.255 -
  35.256 -    virtual void Zoom(BPoint origin,
  35.257 -                float width,
  35.258 -                float height) {
  35.259 -        BMessage msg(BAPP_MAXIMIZE);    /* Closest thing to maximization Haiku has */
  35.260 -        _PostWindowEvent(msg);
  35.261 -
  35.262 -        /* Before the window zooms, record its size */
  35.263 -        if( !_prev_frame )
  35.264 -            _prev_frame = new BRect(Frame());
  35.265 -
  35.266 -        /* Perform normal hook operations */
  35.267 -        BDirectWindow::Zoom(origin, width, height);
  35.268 -    }
  35.269 -
  35.270 -    /* Member functions */
  35.271 -    virtual void Show() {
  35.272 -        while(IsHidden()) {
  35.273 -            BDirectWindow::Show();
  35.274 -        }
  35.275 -        _shown = true;
  35.276 -
  35.277 -        BMessage msg(BAPP_SHOW);
  35.278 -        _PostWindowEvent(msg);
  35.279 -    }
  35.280 -
  35.281 -    virtual void Hide() {
  35.282 -        BDirectWindow::Hide();
  35.283 -        _shown = false;
  35.284 -
  35.285 -        BMessage msg(BAPP_HIDE);
  35.286 -        _PostWindowEvent(msg);
  35.287 -    }
  35.288 -
  35.289 -    virtual void Minimize(bool minimize) {
  35.290 -        BDirectWindow::Minimize(minimize);
  35.291 -        int32 minState = (minimize ? BAPP_MINIMIZE : BAPP_RESTORE);
  35.292 -
  35.293 -        BMessage msg(minState);
  35.294 -        _PostWindowEvent(msg);
  35.295 -    }
  35.296 -
  35.297 -
  35.298 -    /* BView message interruption */
  35.299 -    virtual void DispatchMessage(BMessage * msg, BHandler * target)
  35.300 -    {
  35.301 -        BPoint where;   /* Used by mouse moved */
  35.302 -        int32 buttons;  /* Used for mouse button events */
  35.303 -        int32 key;      /* Used for key events */
  35.304 -
  35.305 -        switch (msg->what) {
  35.306 -        case B_MOUSE_MOVED:
  35.307 -            int32 transit;
  35.308 -            if (msg->FindPoint("where", &where) == B_OK
  35.309 -                && msg->FindInt32("be:transit", &transit) == B_OK) {
  35.310 -                _MouseMotionEvent(where, transit);
  35.311 -            }
  35.312 -
  35.313 -            /* FIXME: Apparently a button press/release event might be dropped
  35.314 -               if made before before a different button is released.  Does
  35.315 -               B_MOUSE_MOVED have the data needed to check if a mouse button
  35.316 -               state has changed? */
  35.317 -            if (msg->FindInt32("buttons", &buttons) == B_OK) {
  35.318 -                _MouseButtonEvent(buttons);
  35.319 -            }
  35.320 -            break;
  35.321 -
  35.322 -        case B_MOUSE_DOWN:
  35.323 -        case B_MOUSE_UP:
  35.324 -            /* _MouseButtonEvent() detects any and all buttons that may have
  35.325 -               changed state, as well as that button's new state */
  35.326 -            if (msg->FindInt32("buttons", &buttons) == B_OK) {
  35.327 -                _MouseButtonEvent(buttons);
  35.328 -            }
  35.329 -            break;
  35.330 -
  35.331 -        case B_MOUSE_WHEEL_CHANGED:
  35.332 -            float x, y;
  35.333 -            if (msg->FindFloat("be:wheel_delta_x", &x) == B_OK
  35.334 -                && msg->FindFloat("be:wheel_delta_y", &y) == B_OK) {
  35.335 -                    _MouseWheelEvent((int)x, (int)y);
  35.336 -            }
  35.337 -            break;
  35.338 -
  35.339 -        case B_KEY_DOWN:
  35.340 -        case B_UNMAPPED_KEY_DOWN:      /* modifier keys are unmapped */
  35.341 -            if (msg->FindInt32("key", &key) == B_OK) {
  35.342 -                _KeyEvent((SDL_Scancode)key, SDL_PRESSED);
  35.343 -            }
  35.344 -            break;
  35.345 -
  35.346 -        case B_KEY_UP:
  35.347 -        case B_UNMAPPED_KEY_UP:        /* modifier keys are unmapped */
  35.348 -            if (msg->FindInt32("key", &key) == B_OK) {
  35.349 -                _KeyEvent(key, SDL_RELEASED);
  35.350 -            }
  35.351 -            break;
  35.352 -
  35.353 -        default:
  35.354 -            /* move it after switch{} so it's always handled
  35.355 -               that way we keep BeOS feautures like:
  35.356 -               - CTRL+Q to close window (and other shortcuts)
  35.357 -               - PrintScreen to make screenshot into /boot/home
  35.358 -               - etc.. */
  35.359 -            /* BDirectWindow::DispatchMessage(msg, target); */
  35.360 -            break;
  35.361 -        }
  35.362 -
  35.363 -        BDirectWindow::DispatchMessage(msg, target);
  35.364 -    }
  35.365 -
  35.366 -    /* Handle command messages */
  35.367 -    virtual void MessageReceived(BMessage* message) {
  35.368 -        switch (message->what) {
  35.369 -            /* Handle commands from SDL */
  35.370 -            case BWIN_SET_TITLE:
  35.371 -                _SetTitle(message);
  35.372 -                break;
  35.373 -            case BWIN_MOVE_WINDOW:
  35.374 -                _MoveTo(message);
  35.375 -                break;
  35.376 -            case BWIN_RESIZE_WINDOW:
  35.377 -                _ResizeTo(message);
  35.378 -                break;
  35.379 -            case BWIN_SET_BORDERED:
  35.380 -                _SetBordered(message);
  35.381 -                break;
  35.382 -            case BWIN_SHOW_WINDOW:
  35.383 -                Show();
  35.384 -                break;
  35.385 -            case BWIN_HIDE_WINDOW:
  35.386 -                Hide();
  35.387 -                break;
  35.388 -            case BWIN_MAXIMIZE_WINDOW:
  35.389 -                BWindow::Zoom();
  35.390 -                break;
  35.391 -            case BWIN_MINIMIZE_WINDOW:
  35.392 -                Minimize(true);
  35.393 -                break;
  35.394 -            case BWIN_RESTORE_WINDOW:
  35.395 -                _Restore();
  35.396 -                break;
  35.397 -            case BWIN_FULLSCREEN:
  35.398 -                _SetFullScreen(message);
  35.399 -                break;
  35.400 -            default:
  35.401 -                /* Perform normal message handling */
  35.402 -                BDirectWindow::MessageReceived(message);
  35.403 -                break;
  35.404 -        }
  35.405 -
  35.406 -    }
  35.407 -
  35.408 -
  35.409 -
  35.410 -    /* Accessor methods */
  35.411 -    bool IsShown() { return _shown; }
  35.412 -    int32 GetID() { return _id; }
  35.413 -    uint32 GetRowBytes() { return _row_bytes; }
  35.414 -    int32 GetFbX() { return _bounds.left; }
  35.415 -    int32 GetFbY() { return _bounds.top; }
  35.416 -    bool ConnectionEnabled() { return !_connection_disabled; }
  35.417 -    bool Connected() { return _connected; }
  35.418 -    clipping_rect *GetClips() { return _clips; }
  35.419 -    int32 GetNumClips() { return _num_clips; }
  35.420 -    uint8* GetBufferPx() { return _bits; }
  35.421 -    int32 GetBytesPerPx() { return _bytes_per_px; }
  35.422 -    bool CanTrashWindowBuffer() { return _trash_window_buffer; }
  35.423 -    bool BufferExists() { return _buffer_created; }
  35.424 -    bool BufferIsDirty() { return _buffer_dirty; }
  35.425 -    BBitmap *GetBitmap() { return _bitmap; }
  35.426 -#if SDL_VIDEO_OPENGL
  35.427 -    BGLView *GetGLView() { return _SDL_GLView; }
  35.428 -#endif
  35.429 -
  35.430 -    /* Setter methods */
  35.431 -    void SetID(int32 id) { _id = id; }
  35.432 -    void SetBufferExists(bool bufferExists) { _buffer_created = bufferExists; }
  35.433 -    void LockBuffer() { _buffer_locker->Lock(); }
  35.434 -    void UnlockBuffer() { _buffer_locker->Unlock(); }
  35.435 -    void SetBufferDirty(bool bufferDirty) { _buffer_dirty = bufferDirty; }
  35.436 -    void SetTrashBuffer(bool trash) { _trash_window_buffer = trash;     }
  35.437 -    void SetBitmap(BBitmap *bitmap) { _bitmap = bitmap; }
  35.438 -
  35.439 -
  35.440 -private:
  35.441 -    /* Event redirection */
  35.442 -    void _MouseMotionEvent(BPoint &where, int32 transit) {
  35.443 -        if(transit == B_EXITED_VIEW) {
  35.444 -            /* Change mouse focus */
  35.445 -            if(_mouse_focused) {
  35.446 -                _MouseFocusEvent(false);
  35.447 -            }
  35.448 -        } else {
  35.449 -            /* Change mouse focus */
  35.450 -            if (!_mouse_focused) {
  35.451 -                _MouseFocusEvent(true);
  35.452 -            }
  35.453 -            BMessage msg(BAPP_MOUSE_MOVED);
  35.454 -            msg.AddInt32("x", (int)where.x);
  35.455 -            msg.AddInt32("y", (int)where.y);
  35.456 -
  35.457 -            _PostWindowEvent(msg);
  35.458 -        }
  35.459 -    }
  35.460 -
  35.461 -    void _MouseFocusEvent(bool focusGained) {
  35.462 -        _mouse_focused = focusGained;
  35.463 -        BMessage msg(BAPP_MOUSE_FOCUS);
  35.464 -        msg.AddBool("focusGained", focusGained);
  35.465 -        _PostWindowEvent(msg);
  35.466 -
  35.467 -/* FIXME: Why were these here?
  35.468 - if false: be_app->SetCursor(B_HAND_CURSOR);
  35.469 - if true:  SDL_SetCursor(NULL); */
  35.470 -    }
  35.471 -
  35.472 -    void _MouseButtonEvent(int32 buttons) {
  35.473 -        int32 buttonStateChange = buttons ^ _last_buttons;
  35.474 -
  35.475 -        /* Make sure at least one button has changed state */
  35.476 -        if( !(buttonStateChange) ) {
  35.477 -            return;
  35.478 -        }
  35.479 -
  35.480 -        /* Add any mouse button events */
  35.481 -        if(buttonStateChange & B_PRIMARY_MOUSE_BUTTON) {
  35.482 -            _SendMouseButton(SDL_BUTTON_LEFT, buttons &
  35.483 -                B_PRIMARY_MOUSE_BUTTON);
  35.484 -        }
  35.485 -        if(buttonStateChange & B_SECONDARY_MOUSE_BUTTON) {
  35.486 -            _SendMouseButton(SDL_BUTTON_RIGHT, buttons &
  35.487 -                B_PRIMARY_MOUSE_BUTTON);
  35.488 -        }
  35.489 -        if(buttonStateChange & B_TERTIARY_MOUSE_BUTTON) {
  35.490 -            _SendMouseButton(SDL_BUTTON_MIDDLE, buttons &
  35.491 -                B_PRIMARY_MOUSE_BUTTON);
  35.492 -        }
  35.493 -
  35.494 -        _last_buttons = buttons;
  35.495 -    }
  35.496 -
  35.497 -    void _SendMouseButton(int32 button, int32 state) {
  35.498 -        BMessage msg(BAPP_MOUSE_BUTTON);
  35.499 -        msg.AddInt32("button-id", button);
  35.500 -        msg.AddInt32("button-state", state);
  35.501 -        _PostWindowEvent(msg);
  35.502 -    }
  35.503 -
  35.504 -    void _MouseWheelEvent(int32 x, int32 y) {
  35.505 -        /* Create a message to pass along to the BeApp thread */
  35.506 -        BMessage msg(BAPP_MOUSE_WHEEL);
  35.507 -        msg.AddInt32("xticks", x);
  35.508 -        msg.AddInt32("yticks", y);
  35.509 -        _PostWindowEvent(msg);
  35.510 -    }
  35.511 -
  35.512 -    void _KeyEvent(int32 keyCode, int32 keyState) {
  35.513 -        /* Create a message to pass along to the BeApp thread */
  35.514 -        BMessage msg(BAPP_KEY);
  35.515 -        msg.AddInt32("key-state", keyState);
  35.516 -        msg.AddInt32("key-scancode", keyCode);
  35.517 -        be_app->PostMessage(&msg);
  35.518 -        /* Apparently SDL only uses the scancode */
  35.519 -    }
  35.520 -
  35.521 -    void _RepaintEvent() {
  35.522 -        /* Force a repaint: Call the SDL exposed event */
  35.523 -        BMessage msg(BAPP_REPAINT);
  35.524 -        _PostWindowEvent(msg);
  35.525 -    }
  35.526 -    void _PostWindowEvent(BMessage &msg) {
  35.527 -        msg.AddInt32("window-id", _id);
  35.528 -        be_app->PostMessage(&msg);
  35.529 -    }
  35.530 -
  35.531 -    /* Command methods (functions called upon by SDL) */
  35.532 -    void _SetTitle(BMessage *msg) {
  35.533 -        const char *title;
  35.534 -        if(
  35.535 -            msg->FindString("window-title", &title) != B_OK
  35.536 -        ) {
  35.537 -            return;
  35.538 -        }
  35.539 -        SetTitle(title);
  35.540 -    }
  35.541 -
  35.542 -    void _MoveTo(BMessage *msg) {
  35.543 -        int32 x, y;
  35.544 -        if(
  35.545 -            msg->FindInt32("window-x", &x) != B_OK ||
  35.546 -            msg->FindInt32("window-y", &y) != B_OK
  35.547 -        ) {
  35.548 -            return;
  35.549 -        }
  35.550 -        MoveTo(x, y);
  35.551 -    }
  35.552 -
  35.553 -    void _ResizeTo(BMessage *msg) {
  35.554 -        int32 w, h;
  35.555 -        if(
  35.556 -            msg->FindInt32("window-w", &w) != B_OK ||
  35.557 -            msg->FindInt32("window-h", &h) != B_OK
  35.558 -        ) {
  35.559 -            return;
  35.560 -        }
  35.561 -        ResizeTo(w, h);
  35.562 -    }
  35.563 -
  35.564 -    void _SetBordered(BMessage *msg) {
  35.565 -        bool bEnabled;
  35.566 -        if(msg->FindBool("window-border", &bEnabled) != B_OK) {
  35.567 -            return;
  35.568 -        }
  35.569 -        SetLook(bEnabled ? B_BORDERED_WINDOW_LOOK : B_NO_BORDER_WINDOW_LOOK);
  35.570 -    }
  35.571 -
  35.572 -    void _Restore() {
  35.573 -        if(IsMinimized()) {
  35.574 -            Minimize(false);
  35.575 -        } else if(IsHidden()) {
  35.576 -            Show();
  35.577 -        } else if(_prev_frame != NULL) {    /* Zoomed */
  35.578 -            MoveTo(_prev_frame->left, _prev_frame->top);
  35.579 -            ResizeTo(_prev_frame->Width(), _prev_frame->Height());
  35.580 -        }
  35.581 -    }
  35.582 -
  35.583 -    void _SetFullScreen(BMessage *msg) {
  35.584 -        bool fullscreen;
  35.585 -        if(
  35.586 -            msg->FindBool("fullscreen", &fullscreen) != B_OK
  35.587 -        ) {
  35.588 -            return;
  35.589 -        }
  35.590 -        SetFullScreen(fullscreen);
  35.591 -    }
  35.592 -
  35.593 -    /* Members */
  35.594 -#if SDL_VIDEO_OPENGL
  35.595 -    BGLView * _SDL_GLView;
  35.596 -#endif
  35.597 -
  35.598 -    int32 _last_buttons;
  35.599 -    int32 _id;  /* Window id used by SDL_BApp */
  35.600 -    bool  _mouse_focused;       /* Does this window have mouse focus? */
  35.601 -    bool  _shown;
  35.602 -    bool  _inhibit_resize;
  35.603 -
  35.604 -    BRect *_prev_frame; /* Previous position and size of the window */
  35.605 -
  35.606 -    /* Framebuffer members */
  35.607 -    bool            _connected,
  35.608 -                    _connection_disabled,
  35.609 -                    _buffer_created,
  35.610 -                    _buffer_dirty,
  35.611 -                    _trash_window_buffer;
  35.612 -    uint8          *_bits;
  35.613 -    uint32          _row_bytes;
  35.614 -    clipping_rect   _bounds;
  35.615 -    BLocker        *_buffer_locker;
  35.616 -    clipping_rect  *_clips;
  35.617 -    int32           _num_clips;
  35.618 -    int32           _bytes_per_px;
  35.619 -    thread_id       _draw_thread_id;
  35.620 -
  35.621 -    BBitmap        *_bitmap;
  35.622 -};
  35.623 -
  35.624 -
  35.625 -/* FIXME:
  35.626 - * An explanation of framebuffer flags.
  35.627 - *
  35.628 - * _connected -           Original variable used to let the drawing thread know
  35.629 - *                         when changes are being made to the other framebuffer
  35.630 - *                         members.
  35.631 - * _connection_disabled - Used to signal to the drawing thread that the window
  35.632 - *                         is closing, and the thread should exit.
  35.633 - * _buffer_created -      True if the current buffer is valid
  35.634 - * _buffer_dirty -        True if the window should be redrawn.
  35.635 - * _trash_window_buffer - True if the window buffer needs to be trashed partway
  35.636 - *                         through a draw cycle.  Occurs when the previous
  35.637 - *                         buffer provided by DirectConnected() is invalidated.
  35.638 - */
  35.639 -#endif
    36.1 --- a/src/video/bwindow/SDL_bclipboard.cc	Thu Nov 14 10:19:07 2013 -0300
    36.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    36.3 @@ -1,95 +0,0 @@
    36.4 -/*
    36.5 -  Simple DirectMedia Layer
    36.6 -  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    36.7 -
    36.8 -  This software is provided 'as-is', without any express or implied
    36.9 -  warranty.  In no event will the authors be held liable for any damages
   36.10 -  arising from the use of this software.
   36.11 -
   36.12 -  Permission is granted to anyone to use this software for any purpose,
   36.13 -  including commercial applications, and to alter it and redistribute it
   36.14 -  freely, subject to the following restrictions:
   36.15 -
   36.16 -  1. The origin of this software must not be misrepresented; you must not
   36.17 -     claim that you wrote the original software. If you use this software
   36.18 -     in a product, an acknowledgment in the product documentation would be
   36.19 -     appreciated but is not required.
   36.20 -  2. Altered source versions must be plainly marked as such, and must not be
   36.21 -     misrepresented as being the original software.
   36.22 -  3. This notice may not be removed or altered from any source distribution.
   36.23 -*/
   36.24 -#include "SDL_config.h"
   36.25 -
   36.26 -#if SDL_VIDEO_DRIVER_BWINDOW
   36.27 -
   36.28 -/* BWindow based framebuffer implementation */
   36.29 -
   36.30 -#include <unistd.h>
   36.31 -#include <TypeConstants.h>
   36.32 -
   36.33 -#include "SDL_BWin.h"
   36.34 -#include "SDL_timer.h"
   36.35 -#include "../SDL_sysvideo.h"
   36.36 -
   36.37 -#ifdef __cplusplus
   36.38 -extern "C" {
   36.39 -#endif
   36.40 -
   36.41 -int BE_SetClipboardText(_THIS, const char *text) {
   36.42 -	BMessage *clip = NULL;
   36.43 -	if(be_clipboard->Lock()) {
   36.44 -		be_clipboard->Clear();
   36.45 -		if((clip = be_clipboard->Data())) {
   36.46 -			/* Presumably the string of characters is ascii-format */
   36.47 -			ssize_t asciiLength = 0;
   36.48 -			for(; text[asciiLength] != 0; ++asciiLength) {}
   36.49 -			clip->AddData("text/plain", B_MIME_TYPE, &text, asciiLength);
   36.50 -			be_clipboard->Commit();
   36.51 -		}
   36.52 -		be_clipboard->Unlock();
   36.53 -	}
   36.54 -	return 0;
   36.55 -}
   36.56 -
   36.57 -char *BE_GetClipboardText(_THIS) {
   36.58 -	BMessage *clip = NULL;
   36.59 -	const char *text = NULL;	
   36.60 -	ssize_t length;
   36.61 -	char *result;
   36.62 -	if(be_clipboard->Lock()) {
   36.63 -		if((clip = be_clipboard->Data())) {
   36.64 -			/* Presumably the string of characters is ascii-format */
   36.65 -			clip->FindData("text/plain", B_MIME_TYPE, (const void**)&text,
   36.66 -				&length);
   36.67 -		} else {
   36.68 -			be_clipboard->Unlock();
   36.69 -		}
   36.70 -		be_clipboard->Unlock();
   36.71 -	} 
   36.72 -	
   36.73 -	if (!text) {
   36.74 -		result = SDL_strdup("");
   36.75 -	} else {
   36.76 -		/* Copy the data and pass on to SDL */
   36.77 -		result = (char*)SDL_calloc(1, sizeof(char*)*length);
   36.78 -		SDL_strlcpy(result, text, length);
   36.79 -	}
   36.80 -	
   36.81 -	return result;
   36.82 -}
   36.83 -
   36.84 -SDL_bool BE_HasClipboardText(_THIS) {
   36.85 -	SDL_bool result = SDL_FALSE;
   36.86 -	char *text = BE_GetClipboardText(_this);
   36.87 -	if (text) {
   36.88 -		result = text[0] != '\0' ? SDL_TRUE : SDL_FALSE;
   36.89 -		SDL_free(text);
   36.90 -	} 
   36.91 -	return result;
   36.92 -}
   36.93 -
   36.94 -#ifdef __cplusplus
   36.95 -}
   36.96 -#endif
   36.97 -
   36.98 -#endif /* SDL_VIDEO_DRIVER_BWINDOW */
    37.1 --- a/src/video/bwindow/SDL_bclipboard.h	Thu Nov 14 10:19:07 2013 -0300
    37.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    37.3 @@ -1,31 +0,0 @@
    37.4 -/*
    37.5 -  Simple DirectMedia Layer
    37.6 -  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    37.7 -
    37.8 -  This software is provided 'as-is', without any express or implied
    37.9 -  warranty.  In no event will the authors be held liable for any damages
   37.10 -  arising from the use of this software.
   37.11 -
   37.12 -  Permission is granted to anyone to use this software for any purpose,
   37.13 -  including commercial applications, and to alter it and redistribute it
   37.14 -  freely, subject to the following restrictions:
   37.15 -
   37.16 -  1. The origin of this software must not be misrepresented; you must not
   37.17 -     claim that you wrote the original software. If you use this software
   37.18 -     in a product, an acknowledgment in the product documentation would be
   37.19 -     appreciated but is not required.
   37.20 -  2. Altered source versions must be plainly marked as such, and must not be
   37.21 -     misrepresented as being the original software.
   37.22 -  3. This notice may not be removed or altered from any source distribution.
   37.23 -*/
   37.24 -
   37.25 -#include "SDL_config.h"
   37.26 -
   37.27 -#ifndef SDL_BCLIPBOARD_H
   37.28 -#define SDL_BCLIPBOARD_H
   37.29 -
   37.30 -extern int BE_SetClipboardText(_THIS, const char *text);
   37.31 -extern char *BE_GetClipboardText(_THIS);
   37.32 -extern SDL_bool BE_HasClipboardText(_THIS);
   37.33 -
   37.34 -#endif
    38.1 --- a/src/video/bwindow/SDL_bevents.cc	Thu Nov 14 10:19:07 2013 -0300
    38.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    38.3 @@ -1,39 +0,0 @@
    38.4 -/*
    38.5 -  Simple DirectMedia Layer
    38.6 -  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    38.7 -
    38.8 -  This software is provided 'as-is', without any express or implied
    38.9 -  warranty.  In no event will the authors be held liable for any damages
   38.10 -  arising from the use of this software.
   38.11 -
   38.12 -  Permission is granted to anyone to use this software for any purpose,
   38.13 -  including commercial applications, and to alter it and redistribute it
   38.14 -  freely, subject to the following restrictions:
   38.15 -
   38.16 -  1. The origin of this software must not be misrepresented; you must not
   38.17 -     claim that you wrote the original software. If you use this software
   38.18 -     in a product, an acknowledgment in the product documentation would be
   38.19 -     appreciated but is not required.
   38.20 -  2. Altered source versions must be plainly marked as such, and must not be
   38.21 -     misrepresented as being the original software.
   38.22 -  3. This notice may not be removed or altered from any source distribution.
   38.23 -*/
   38.24 -#include "SDL_config.h"
   38.25 -
   38.26 -#if SDL_VIDEO_DRIVER_BWINDOW
   38.27 -
   38.28 -#include "SDL_bevents.h"
   38.29 -
   38.30 -#ifdef __cplusplus
   38.31 -extern "C" {
   38.32 -#endif
   38.33 -
   38.34 -void BE_PumpEvents(_THIS) {
   38.35 -	/* Since the event thread is its own thread, this isn't really necessary */
   38.36 -}
   38.37 -
   38.38 -#ifdef __cplusplus
   38.39 -}
   38.40 -#endif
   38.41 -
   38.42 -#endif /* SDL_VIDEO_DRIVER_BWINDOW */
    39.1 --- a/src/video/bwindow/SDL_bevents.h	Thu Nov 14 10:19:07 2013 -0300
    39.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    39.3 @@ -1,37 +0,0 @@
    39.4 -/*
    39.5 -  Simple DirectMedia Layer
    39.6 -  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    39.7 -
    39.8 -  This software is provided 'as-is', without any express or implied
    39.9 -  warranty.  In no event will the authors be held liable for any damages
   39.10 -  arising from the use of this software.
   39.11 -
   39.12 -  Permission is granted to anyone to use this software for any purpose,
   39.13 -  including commercial applications, and to alter it and redistribute it
   39.14 -  freely, subject to the following restrictions:
   39.15 -
   39.16 -  1. The origin of this software must not be misrepresented; you must not
   39.17 -     claim that you wrote the original software. If you use this software
   39.18 -     in a product, an acknowledgment in the product documentation would be
   39.19 -     appreciated but is not required.
   39.20 -  2. Altered source versions must be plainly marked as such, and must not be
   39.21 -     misrepresented as being the original software.
   39.22 -  3. This notice may not be removed or altered from any source distribution.
   39.23 -*/
   39.24 -
   39.25 -#ifndef SDL_BEVENTS_H
   39.26 -#define SDL_BEVENTS_H
   39.27 -
   39.28 -#include "../SDL_sysvideo.h"
   39.29 -
   39.30 -#ifdef __cplusplus
   39.31 -extern "C" {
   39.32 -#endif
   39.33 -
   39.34 -extern void BE_PumpEvents(_THIS);
   39.35 -
   39.36 -#ifdef __cplusplus
   39.37 -}
   39.38 -#endif
   39.39 -
   39.40 -#endif
    40.1 --- a/src/video/bwindow/SDL_bframebuffer.cc	Thu Nov 14 10:19:07 2013 -0300
    40.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    40.3 @@ -1,254 +0,0 @@
    40.4 -/*
    40.5 -  Simple DirectMedia Layer
    40.6 -  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    40.7 -
    40.8 -  This software is provided 'as-is', without any express or implied
    40.9 -  warranty.  In no event will the authors be held liable for any damages
   40.10 -  arising from the use of this software.
   40.11 -
   40.12 -  Permission is granted to anyone to use this software for any purpose,
   40.13 -  including commercial applications, and to alter it and redistribute it
   40.14 -  freely, subject to the following restrictions:
   40.15 -
   40.16 -  1. The origin of this software must not be misrepresented; you must not
   40.17 -     claim that you wrote the original software. If you use this software
   40.18 -     in a product, an acknowledgment in the product documentation would be
   40.19 -     appreciated but is not required.
   40.20 -  2. Altered source versions must be plainly marked as such, and must not be
   40.21 -     misrepresented as being the original software.
   40.22 -  3. This notice may not be removed or altered from any source distribution.
   40.23 -*/
   40.24 -#include "SDL_config.h"
   40.25 -
   40.26 -#if SDL_VIDEO_DRIVER_BWINDOW
   40.27 -
   40.28 -#include "SDL_bframebuffer.h"
   40.29 -
   40.30 -#include <AppKit.h>
   40.31 -#include <InterfaceKit.h>
   40.32 -#include "SDL_bmodes.h"
   40.33 -#include "SDL_BWin.h"
   40.34 -
   40.35 -#include "../../main/beos/SDL_BApp.h"
   40.36 -
   40.37 -#ifdef __cplusplus
   40.38 -extern "C" {
   40.39 -#endif
   40.40 -
   40.41 -int32 BE_UpdateOnce(SDL_Window *window);
   40.42 -
   40.43 -static SDL_INLINE SDL_BWin *_ToBeWin(SDL_Window *window) {
   40.44 -	return ((SDL_BWin*)(window->driverdata));
   40.45 -}
   40.46 -
   40.47 -static SDL_INLINE SDL_BApp *_GetBeApp() {
   40.48 -	return ((SDL_BApp*)be_app);
   40.49 -}
   40.50 -
   40.51 -int BE_CreateWindowFramebuffer(_THIS, SDL_Window * window,
   40.52 -                                       Uint32 * format,
   40.53 -                                       void ** pixels, int *pitch) {
   40.54 -	SDL_BWin *bwin = _ToBeWin(window);
   40.55 -	BScreen bscreen;
   40.56 -	if(!bscreen.IsValid()) {
   40.57 -		return -1;
   40.58 -	}
   40.59 -
   40.60 -	while(!bwin->Connected()) { snooze(100); }
   40.61 -	
   40.62 -	/* Make sure we have exclusive access to frame buffer data */
   40.63 -	bwin->LockBuffer();
   40.64 -
   40.65 -	/* format */
   40.66 -	display_mode bmode;
   40.67 -	bscreen.GetMode(&bmode);
   40.68 -	int32 bpp = BE_ColorSpaceToBitsPerPixel(bmode.space);
   40.69 -	*format = BE_BPPToSDLPxFormat(bpp);
   40.70 -
   40.71 -	/* Create the new bitmap object */
   40.72 -	BBitmap *bitmap = bwin->GetBitmap();
   40.73 -
   40.74 -	if(bitmap) {
   40.75 -		delete bitmap;
   40.76 -	}
   40.77 -	bitmap = new BBitmap(bwin->Bounds(), (color_space)bmode.space,
   40.78 -			false,	/* Views not accepted */
   40.79 -			true);	/* Contiguous memory required */
   40.80 -			
   40.81 -	if(bitmap->InitCheck() != B_OK) {
   40.82 -		return SDL_SetError("Could not initialize back buffer!\n");
   40.83 -	}
   40.84 -
   40.85 -
   40.86 -	bwin->SetBitmap(bitmap);
   40.87 -	
   40.88 -	/* Set the pixel pointer */
   40.89 -	*pixels = bitmap->Bits();
   40.90 -
   40.91 -	/* pitch = width of window, in bytes */
   40.92 -	*pitch = bitmap->BytesPerRow();
   40.93 -
   40.94 -	bwin->SetBufferExists(true);
   40.95 -	bwin->SetTrashBuffer(false);
   40.96 -	bwin->UnlockBuffer();
   40.97 -	return 0;
   40.98 -}
   40.99 -
  40.100 -
  40.101 -
  40.102 -int BE_UpdateWindowFramebuffer(_THIS, SDL_Window * window,
  40.103 -                                      const SDL_Rect * rects, int numrects) {
  40.104 -	if(!window)
  40.105 -		return 0;
  40.106 -
  40.107 -	SDL_BWin *bwin = _ToBeWin(window);
  40.108 -
  40.109 -#ifdef DRAWTHREAD	
  40.110 -	bwin->LockBuffer();
  40.111 -	bwin->SetBufferDirty(true);
  40.112 -	bwin->UnlockBuffer();
  40.113 -#else
  40.114 -	bwin->SetBufferDirty(true);
  40.115 -	BE_UpdateOnce(window);
  40.116 -#endif
  40.117 -
  40.118 -	return 0;
  40.119 -}
  40.120 -
  40.121 -int32 BE_DrawThread(void *data) {
  40.122 -	SDL_BWin *bwin = (SDL_BWin*)data;
  40.123 -	
  40.124 -	BScreen bscreen;
  40.125 -	if(!bscreen.IsValid()) {
  40.126 -		return -1;
  40.127 -	}
  40.128 -
  40.129 -	while(bwin->ConnectionEnabled()) {
  40.130 -		if( bwin->Connected() && bwin->BufferExists() && bwin->BufferIsDirty() ) {
  40.131 -			bwin->LockBuffer();
  40.132 -			BBitmap *bitmap = NULL;
  40.133 -			bitmap = bwin->GetBitmap();
  40.134 -			int32 windowPitch = bitmap->BytesPerRow();
  40.135 -			int32 bufferPitch = bwin->GetRowBytes();
  40.136 -			uint8 *windowpx;
  40.137 -			uint8 *bufferpx;
  40.138 -
  40.139 -			int32 BPP = bwin->GetBytesPerPx();
  40.140 -			int32 windowSub = bwin->GetFbX() * BPP +
  40.141 -						  bwin->GetFbY() * windowPitch;
  40.142 -			clipping_rect *clips = bwin->GetClips();
  40.143 -			int32 numClips = bwin->GetNumClips();
  40.144 -			int i, y;
  40.145 -
  40.146 -			/* Blit each clipping rectangle */
  40.147 -			bscreen.WaitForRetrace();
  40.148 -			for(i = 0; i < numClips; ++i) {
  40.149 -				clipping_rect rc = clips[i];
  40.150 -				/* Get addresses of the start of each clipping rectangle */
  40.151 -				int32 width = clips[i].right - clips[i].left + 1;
  40.152 -				int32 height = clips[i].bottom - clips[i].top + 1;
  40.153 -				bufferpx = bwin->GetBufferPx() + 
  40.154 -					clips[i].top * bufferPitch + clips[i].left * BPP;
  40.155 -				windowpx = (uint8*)bitmap->Bits() + 
  40.156 -					clips[i].top * windowPitch + clips[i].left * BPP -
  40.157 -					windowSub;
  40.158 -
  40.159 -				/* Copy each row of pixels from the window buffer into the frame
  40.160 -				   buffer */
  40.161 -				for(y = 0; y < height; ++y)
  40.162 -				{
  40.163 -
  40.164 -					if(bwin->CanTrashWindowBuffer()) {
  40.165 -						goto escape;	/* Break out before the buffer is killed */
  40.166 -					}
  40.167 -
  40.168 -					memcpy(bufferpx, windowpx, width * BPP);
  40.169 -					bufferpx += bufferPitch;
  40.170 -					windowpx += windowPitch;
  40.171 -				}
  40.172 -			}
  40.173 -
  40.174 -			bwin->SetBufferDirty(false);
  40.175 -escape:
  40.176 -			bwin->UnlockBuffer();
  40.177 -		} else {
  40.178 -			snooze(16000);
  40.179 -		}
  40.180 -	}
  40.181 -	
  40.182 -	return B_OK;
  40.183 -}
  40.184 -
  40.185 -void BE_DestroyWindowFramebuffer(_THIS, SDL_Window * window) {
  40.186 -	SDL_BWin *bwin = _ToBeWin(window);
  40.187 -	
  40.188 -	bwin->LockBuffer();
  40.189 -	
  40.190 -	/* Free and clear the window buffer */
  40.191 -	BBitmap *bitmap = bwin->GetBitmap();
  40.192 -	delete bitmap;
  40.193 -	bwin->SetBitmap(NULL);
  40.194 -	bwin->SetBufferExists(false);
  40.195 -	bwin->UnlockBuffer();
  40.196 -}
  40.197 -
  40.198 -
  40.199 -/*
  40.200 - * TODO:
  40.201 - * This was written to test if certain errors were caused by threading issues.
  40.202 - * The specific issues have since become rare enough that they may have been
  40.203 - * solved, but I doubt it- they were pretty sporadic before now.
  40.204 - */
  40.205 -int32 BE_UpdateOnce(SDL_Window *window) {
  40.206 -	SDL_BWin *bwin = _ToBeWin(window);
  40.207 -	BScreen bscreen;
  40.208 -	if(!bscreen.IsValid()) {
  40.209 -		return -1;
  40.210 -	}
  40.211 -
  40.212 -	if(bwin->ConnectionEnabled() && bwin->Connected()) {
  40.213 -		bwin->LockBuffer();
  40.214 -		int32 windowPitch = window->surface->pitch;
  40.215 -		int32 bufferPitch = bwin->GetRowBytes();
  40.216 -		uint8 *windowpx;
  40.217 -		uint8 *bufferpx;
  40.218 -
  40.219 -		int32 BPP = bwin->GetBytesPerPx();
  40.220 -		uint8 *windowBaseAddress = (uint8*)window->surface->pixels;
  40.221 -		int32 windowSub = bwin->GetFbX() * BPP +
  40.222 -						  bwin->GetFbY() * windowPitch;
  40.223 -		clipping_rect *clips = bwin->GetClips();
  40.224 -		int32 numClips = bwin->GetNumClips();
  40.225 -		int i, y;
  40.226 -
  40.227 -		/* Blit each clipping rectangle */
  40.228 -		bscreen.WaitForRetrace();
  40.229 -		for(i = 0; i < numClips; ++i) {
  40.230 -			clipping_rect rc = clips[i];
  40.231 -			/* Get addresses of the start of each clipping rectangle */
  40.232 -			int32 width = clips[i].right - clips[i].left + 1;
  40.233 -			int32 height = clips[i].bottom - clips[i].top + 1;
  40.234 -			bufferpx = bwin->GetBufferPx() + 
  40.235 -				clips[i].top * bufferPitch + clips[i].left * BPP;
  40.236 -			windowpx = windowBaseAddress + 
  40.237 -				clips[i].top * windowPitch + clips[i].left * BPP - windowSub;
  40.238 -
  40.239 -			/* Copy each row of pixels from the window buffer into the frame
  40.240 -			   buffer */
  40.241 -			for(y = 0; y < height; ++y)
  40.242 -			{
  40.243 -				memcpy(bufferpx, windowpx, width * BPP);
  40.244 -				bufferpx += bufferPitch;
  40.245 -				windowpx += windowPitch;
  40.246 -			}
  40.247 -		}
  40.248 -		bwin->UnlockBuffer();
  40.249 -	}
  40.250 -	return 0;
  40.251 -}
  40.252 -
  40.253 -#ifdef __cplusplus
  40.254 -}
  40.255 -#endif
  40.256 -
  40.257 -#endif /* SDL_VIDEO_DRIVER_BWINDOW */
    41.1 --- a/src/video/bwindow/SDL_bframebuffer.h	Thu Nov 14 10:19:07 2013 -0300
    41.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    41.3 @@ -1,45 +0,0 @@
    41.4 -/*
    41.5 -  Simple DirectMedia Layer
    41.6 -  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    41.7 -
    41.8 -  This software is provided 'as-is', without any express or implied
    41.9 -  warranty.  In no event will the authors be held liable for any damages
   41.10 -  arising from the use of this software.
   41.11 -
   41.12 -  Permission is granted to anyone to use this software for any purpose,
   41.13 -  including commercial applications, and to alter it and redistribute it
   41.14 -  freely, subject to the following restrictions:
   41.15 -
   41.16 -  1. The origin of this software must not be misrepresented; you must not
   41.17 -     claim that you wrote the original software. If you use this software
   41.18 -     in a product, an acknowledgment in the product documentation would be
   41.19 -     appreciated but is not required.
   41.20 -  2. Altered source versions must be plainly marked as such, and must not be
   41.21 -     misrepresented as being the original software.
   41.22 -  3. This notice may not be removed or altered from any source distribution.
   41.23 -*/
   41.24 -
   41.25 -#ifndef SDL_BFRAMEBUFFER_H
   41.26 -#define SDL_BFRAMEBUFFER_H
   41.27 -#include <SupportDefs.h>
   41.28 -#ifdef __cplusplus
   41.29 -extern "C" {
   41.30 -#endif
   41.31 -
   41.32 -#define DRAWTHREAD
   41.33 -
   41.34 -#include "../SDL_sysvideo.h"
   41.35 -
   41.36 -extern int BE_CreateWindowFramebuffer(_THIS, SDL_Window * window,
   41.37 -                                       Uint32 * format,
   41.38 -                                       void ** pixels, int *pitch);
   41.39 -extern int BE_UpdateWindowFramebuffer(_THIS, SDL_Window * window,
   41.40 -                                       const SDL_Rect * rects, int numrects);
   41.41 -extern void BE_DestroyWindowFramebuffer(_THIS, SDL_Window * window);
   41.42 -extern int32 BE_DrawThread(void *data);
   41.43 -
   41.44 -#ifdef __cplusplus
   41.45 -}
   41.46 -#endif
   41.47 -
   41.48 -#endif
    42.1 --- a/src/video/bwindow/SDL_bkeyboard.cc	Thu Nov 14 10:19:07 2013 -0300
    42.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    42.3 @@ -1,188 +0,0 @@
    42.4 -/*
    42.5 -  Simple DirectMedia Layer
    42.6 -  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    42.7 -
    42.8 -  This software is provided 'as-is', without any express or implied
    42.9 -  warranty.  In no event will the authors be held liable for any damages
   42.10 -  arising from the use of this software.
   42.11 -
   42.12 -  Permission is granted to anyone to use this software for any purpose,
   42.13 -  including commercial applications, and to alter it and redistribute it
   42.14 -  freely, subject to the following restrictions:
   42.15 -
   42.16 -  1. The origin of this software must not be misrepresented; you must not
   42.17 -     claim that you wrote the original software. If you use this software
   42.18 -     in a product, an acknowledgment in the product documentation would be
   42.19 -     appreciated but is not required.
   42.20 -  2. Altered source versions must be plainly marked as such, and must not be
   42.21 -     misrepresented as being the original software.
   42.22 -  3. This notice may not be removed or altered from any source distribution.
   42.23 -*/
   42.24 -#include "SDL_config.h"
   42.25 -
   42.26 -#if SDL_VIDEO_DRIVER_BWINDOW
   42.27 -
   42.28 -#include <SupportDefs.h>
   42.29 -#include <support/UTF8.h>
   42.30 -
   42.31 -#ifdef __cplusplus
   42.32 -extern "C" {
   42.33 -#endif
   42.34 -
   42.35 -#include "SDL_events.h"
   42.36 -#include "SDL_keycode.h"
   42.37 -
   42.38 -#include "SDL_bkeyboard.h"
   42.39 -
   42.40 -
   42.41 -#define KEYMAP_SIZE 128
   42.42 -
   42.43 -
   42.44 -static SDL_Scancode keymap[KEYMAP_SIZE];
   42.45 -static int8 keystate[KEYMAP_SIZE];
   42.46 -
   42.47 -void BE_InitOSKeymap() {
   42.48 -		for( uint i = 0; i < SDL_TABLESIZE(keymap); ++i ) {
   42.49 -			keymap[i] = SDL_SCANCODE_UNKNOWN;
   42.50 -		}
   42.51 -
   42.52 -		for( uint i = 0; i < KEYMAP_SIZE; ++i ) {
   42.53 -			keystate[i] = SDL_RELEASED;
   42.54 -		}
   42.55 -
   42.56 -		keymap[0x01]		= SDL_GetScancodeFromKey(SDLK_ESCAPE);
   42.57 -		keymap[B_F1_KEY]	= SDL_GetScancodeFromKey(SDLK_F1);
   42.58 -		keymap[B_F2_KEY]	= SDL_GetScancodeFromKey(SDLK_F2);
   42.59 -		keymap[B_F3_KEY]	= SDL_GetScancodeFromKey(SDLK_F3);
   42.60 -		keymap[B_F4_KEY]	= SDL_GetScancodeFromKey(SDLK_F4);
   42.61 -		keymap[B_F5_KEY]	= SDL_GetScancodeFromKey(SDLK_F5);
   42.62 -		keymap[B_F6_KEY]	= SDL_GetScancodeFromKey(SDLK_F6);
   42.63 -		keymap[B_F7_KEY]	= SDL_GetScancodeFromKey(SDLK_F7);
   42.64 -		keymap[B_F8_KEY]	= SDL_GetScancodeFromKey(SDLK_F8);
   42.65 -		keymap[B_F9_KEY]	= SDL_GetScancodeFromKey(SDLK_F9);
   42.66 -		keymap[B_F10_KEY]	= SDL_GetScancodeFromKey(SDLK_F10);
   42.67 -		keymap[B_F11_KEY]	= SDL_GetScancodeFromKey(SDLK_F11);
   42.68 -		keymap[B_F12_KEY]	= SDL_GetScancodeFromKey(SDLK_F12);
   42.69 -		keymap[B_PRINT_KEY]	= SDL_GetScancodeFromKey(SDLK_PRINTSCREEN);
   42.70 -		keymap[B_SCROLL_KEY]	= SDL_GetScancodeFromKey(SDLK_SCROLLLOCK);
   42.71 -		keymap[B_PAUSE_KEY]	= SDL_GetScancodeFromKey(SDLK_PAUSE);
   42.72 -		keymap[0x11]		= SDL_GetScancodeFromKey(SDLK_BACKQUOTE);
   42.73 -		keymap[0x12]		= SDL_GetScancodeFromKey(SDLK_1);
   42.74 -		keymap[0x13]		= SDL_GetScancodeFromKey(SDLK_2);
   42.75 -		keymap[0x14]		= SDL_GetScancodeFromKey(SDLK_3);
   42.76 -		keymap[0x15]		= SDL_GetScancodeFromKey(SDLK_4);
   42.77 -		keymap[0x16]		= SDL_GetScancodeFromKey(SDLK_5);
   42.78 -		keymap[0x17]		= SDL_GetScancodeFromKey(SDLK_6);
   42.79 -		keymap[0x18]		= SDL_GetScancodeFromKey(SDLK_7);
   42.80 -		keymap[0x19]		= SDL_GetScancodeFromKey(SDLK_8);
   42.81 -		keymap[0x1a]		= SDL_GetScancodeFromKey(SDLK_9);
   42.82 -		keymap[0x1b]		= SDL_GetScancodeFromKey(SDLK_0);
   42.83 -		keymap[0x1c]		= SDL_GetScancodeFromKey(SDLK_MINUS);
   42.84 -		keymap[0x1d]		= SDL_GetScancodeFromKey(SDLK_EQUALS);
   42.85 -		keymap[0x1e]		= SDL_GetScancodeFromKey(SDLK_BACKSPACE);
   42.86 -		keymap[0x1f]		= SDL_GetScancodeFromKey(SDLK_INSERT);
   42.87 -		keymap[0x20]		= SDL_GetScancodeFromKey(SDLK_HOME);
   42.88 -		keymap[0x21]		= SDL_GetScancodeFromKey(SDLK_PAGEUP);
   42.89 -		keymap[0x22]		= SDL_GetScancodeFromKey(SDLK_NUMLOCKCLEAR);
   42.90 -		keymap[0x23]		= SDL_GetScancodeFromKey(SDLK_KP_DIVIDE);
   42.91 -		keymap[0x24]		= SDL_GetScancodeFromKey(SDLK_KP_MULTIPLY);
   42.92 -		keymap[0x25]		= SDL_GetScancodeFromKey(SDLK_KP_MINUS);
   42.93 -		keymap[0x26]		= SDL_GetScancodeFromKey(SDLK_TAB);
   42.94 -		keymap[0x27]		= SDL_GetScancodeFromKey(SDLK_q);
   42.95 -		keymap[0x28]		= SDL_GetScancodeFromKey(SDLK_w);
   42.96 -		keymap[0x29]		= SDL_GetScancodeFromKey(SDLK_e);
   42.97 -		keymap[0x2a]		= SDL_GetScancodeFromKey(SDLK_r);
   42.98 -		keymap[0x2b]		= SDL_GetScancodeFromKey(SDLK_t);
   42.99 -		keymap[0x2c]		= SDL_GetScancodeFromKey(SDLK_y);
  42.100 -		keymap[0x2d]		= SDL_GetScancodeFromKey(SDLK_u);
  42.101 -		keymap[0x2e]		= SDL_GetScancodeFromKey(SDLK_i);
  42.102 -		keymap[0x2f]		= SDL_GetScancodeFromKey(SDLK_o);
  42.103 -		keymap[0x30]		= SDL_GetScancodeFromKey(SDLK_p);
  42.104 -		keymap[0x31]		= SDL_GetScancodeFromKey(SDLK_LEFTBRACKET);
  42.105 -		keymap[0x32]		= SDL_GetScancodeFromKey(SDLK_RIGHTBRACKET);
  42.106 -		keymap[0x33]		= SDL_GetScancodeFromKey(SDLK_BACKSLASH);
  42.107 -		keymap[0x34]		= SDL_GetScancodeFromKey(SDLK_DELETE);
  42.108 -		keymap[0x35]		= SDL_GetScancodeFromKey(SDLK_END);
  42.109 -		keymap[0x36]		= SDL_GetScancodeFromKey(SDLK_PAGEDOWN);
  42.110 -		keymap[0x37]		= SDL_GetScancodeFromKey(SDLK_KP_7);
  42.111 -		keymap[0x38]		= SDL_GetScancodeFromKey(SDLK_KP_8);
  42.112 -		keymap[0x39]		= SDL_GetScancodeFromKey(SDLK_KP_9);
  42.113 -		keymap[0x3a]		= SDL_GetScancodeFromKey(SDLK_KP_PLUS);
  42.114 -		keymap[0x3b]		= SDL_GetScancodeFromKey(SDLK_CAPSLOCK);
  42.115 -		keymap[0x3c]		= SDL_GetScancodeFromKey(SDLK_a);
  42.116 -		keymap[0x3d]		= SDL_GetScancodeFromKey(SDLK_s);
  42.117 -		keymap[0x3e]		= SDL_GetScancodeFromKey(SDLK_d);
  42.118 -		keymap[0x3f]		= SDL_GetScancodeFromKey(SDLK_f);
  42.119 -		keymap[0x40]		= SDL_GetScancodeFromKey(SDLK_g);
  42.120 -		keymap[0x41]		= SDL_GetScancodeFromKey(SDLK_h);
  42.121 -		keymap[0x42]		= SDL_GetScancodeFromKey(SDLK_j);
  42.122 -		keymap[0x43]		= SDL_GetScancodeFromKey(SDLK_k);
  42.123 -		keymap[0x44]		= SDL_GetScancodeFromKey(SDLK_l);
  42.124 -		keymap[0x45]		= SDL_GetScancodeFromKey(SDLK_SEMICOLON);
  42.125 -		keymap[0x46]		= SDL_GetScancodeFromKey(SDLK_QUOTE);
  42.126 -		keymap[0x47]		= SDL_GetScancodeFromKey(SDLK_RETURN);
  42.127 -		keymap[0x48]		= SDL_GetScancodeFromKey(SDLK_KP_4);
  42.128 -		keymap[0x49]		= SDL_GetScancodeFromKey(SDLK_KP_5);
  42.129 -		keymap[0x4a]		= SDL_GetScancodeFromKey(SDLK_KP_6);
  42.130 -		keymap[0x4b]		= SDL_GetScancodeFromKey(SDLK_LSHIFT);
  42.131 -		keymap[0x4c]		= SDL_GetScancodeFromKey(SDLK_z);
  42.132 -		keymap[0x4d]		= SDL_GetScancodeFromKey(SDLK_x);
  42.133 -		keymap[0x4e]		= SDL_GetScancodeFromKey(SDLK_c);
  42.134 -		keymap[0x4f]		= SDL_GetScancodeFromKey(SDLK_v);
  42.135 -		keymap[0x50]		= SDL_GetScancodeFromKey(SDLK_b);
  42.136 -		keymap[0x51]		= SDL_GetScancodeFromKey(SDLK_n);
  42.137 -		keymap[0x52]		= SDL_GetScancodeFromKey(SDLK_m);
  42.138 -		keymap[0x53]		= SDL_GetScancodeFromKey(SDLK_COMMA);
  42.139 -		keymap[0x54]		= SDL_GetScancodeFromKey(SDLK_PERIOD);
  42.140 -		keymap[0x55]		= SDL_GetScancodeFromKey(SDLK_SLASH);
  42.141 -		keymap[0x56]		= SDL_GetScancodeFromKey(SDLK_RSHIFT);
  42.142 -		keymap[0x57]		= SDL_GetScancodeFromKey(SDLK_UP);
  42.143 -		keymap[0x58]		= SDL_GetScancodeFromKey(SDLK_KP_1);
  42.144 -		keymap[0x59]		= SDL_GetScancodeFromKey(SDLK_KP_2);
  42.145 -		keymap[0x5a]		= SDL_GetScancodeFromKey(SDLK_KP_3);
  42.146 -		keymap[0x5b]		= SDL_GetScancodeFromKey(SDLK_KP_ENTER);
  42.147 -		keymap[0x5c]		= SDL_GetScancodeFromKey(SDLK_LCTRL);
  42.148 -		keymap[0x5d]		= SDL_GetScancodeFromKey(SDLK_LALT);
  42.149 -		keymap[0x5e]		= SDL_GetScancodeFromKey(SDLK_SPACE);
  42.150 -		keymap[0x5f]		= SDL_GetScancodeFromKey(SDLK_RALT);
  42.151 -		keymap[0x60]		= SDL_GetScancodeFromKey(SDLK_RCTRL);
  42.152 -		keymap[0x61]		= SDL_GetScancodeFromKey(SDLK_LEFT);
  42.153 -		keymap[0x62]		= SDL_GetScancodeFromKey(SDLK_DOWN);
  42.154 -		keymap[0x63]		= SDL_GetScancodeFromKey(SDLK_RIGHT);
  42.155 -		keymap[0x64]		= SDL_GetScancodeFromKey(SDLK_KP_0);
  42.156 -		keymap[0x65]		= SDL_GetScancodeFromKey(SDLK_KP_PERIOD);
  42.157 -		keymap[0x66]		= SDL_GetScancodeFromKey(SDLK_LGUI);
  42.158 -		keymap[0x67]		= SDL_GetScancodeFromKey(SDLK_RGUI);
  42.159 -		keymap[0x68]		= SDL_GetScancodeFromKey(SDLK_MENU);
  42.160 -		keymap[0x69]		= SDL_GetScancodeFromKey(SDLK_2); /* SDLK_EURO */
  42.161 -		keymap[0x6a]		= SDL_GetScancodeFromKey(SDLK_KP_EQUALS);
  42.162 -		keymap[0x6b]		= SDL_GetScancodeFromKey(SDLK_POWER);
  42.163 -}
  42.164 -
  42.165 -SDL_Scancode BE_GetScancodeFromBeKey(int32 bkey) {
  42.166 -	if(bkey > 0 && bkey < (int32)SDL_TABLESIZE(keymap)) {
  42.167 -		return keymap[bkey];
  42.168 -	} else {
  42.169 -		return SDL_SCANCODE_UNKNOWN;
  42.170 -	}
  42.171 -}
  42.172 -
  42.173 -int8 BE_GetKeyState(int32 bkey) {
  42.174 -	if(bkey > 0 && bkey < KEYMAP_SIZE) {
  42.175 -		return keystate[bkey];
  42.176 -	} else {
  42.177 -		return SDL_RELEASED;
  42.178 -	}
  42.179 -}
  42.180 -
  42.181 -void BE_SetKeyState(int32 bkey, int8 state) {
  42.182 -	if(bkey > 0 && bkey < KEYMAP_SIZE) {
  42.183 -		keystate[bkey] = state;
  42.184 -	}
  42.185 -}
  42.186 -
  42.187 -#ifdef __cplusplus
  42.188 -}
  42.189 -#endif
  42.190 -
  42.191 -#endif /* SDL_VIDEO_DRIVER_BWINDOW */
    43.1 --- a/src/video/bwindow/SDL_bkeyboard.h	Thu Nov 14 10:19:07 2013 -0300
    43.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    43.3 @@ -1,42 +0,0 @@
    43.4 -/*
    43.5 -  Simple DirectMedia Layer
    43.6 -  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    43.7 -
    43.8 -  This software is provided 'as-is', without any express or implied
    43.9 -  warranty.  In no event will the authors be held liable for any damages
   43.10 -  arising from the use of this software.
   43.11 -
   43.12 -  Permission is granted to anyone to use this software for any purpose,
   43.13 -  including commercial applications, and to alter it and redistribute it
   43.14 -  freely, subject to the following restrictions:
   43.15 -
   43.16 -  1. The origin of this software must not be misrepresented; you must not
   43.17 -     claim that you wrote the original software. If you use this software
   43.18 -     in a product, an acknowledgment in the product documentation would be
   43.19 -     appreciated but is not required.
   43.20 -  2. Altered source versions must be plainly marked as such, and must not be
   43.21 -     misrepresented as being the original software.
   43.22 -  3. This notice may not be removed or altered from any source distribution.
   43.23 -*/
   43.24 -
   43.25 -#ifndef SDL_BKEYBOARD_H
   43.26 -#define SDL_BKEYBOARD_H
   43.27 -
   43.28 -#include <SupportDefs.h>
   43.29 -
   43.30 -#ifdef __cplusplus
   43.31 -extern "C" {
   43.32 -#endif
   43.33 -
   43.34 -#include "../../../include/SDL_keyboard.h"
   43.35 -
   43.36 -extern void BE_InitOSKeymap();
   43.37 -extern SDL_Scancode BE_GetScancodeFromBeKey(int32 bkey);
   43.38 -extern int8 BE_GetKeyState(int32 bkey);
   43.39 -extern void BE_SetKeyState(int32 bkey, int8 state);
   43.40 -
   43.41 -#ifdef __cplusplus
   43.42 -}
   43.43 -#endif
   43.44 -
   43.45 -#endif
    44.1 --- a/src/video/bwindow/SDL_bmodes.cc	Thu Nov 14 10:19:07 2013 -0300
    44.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    44.3 @@ -1,331 +0,0 @@
    44.4 -/*
    44.5 -  Simple DirectMedia Layer
    44.6 -  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    44.7 -
    44.8 -  This software is provided 'as-is', without any express or implied
    44.9 -  warranty.  In no event will the authors be held liable for any damages
   44.10 -  arising from the use of this software.
   44.11 -
   44.12 -  Permission is granted to anyone to use this software for any purpose,
   44.13 -  including commercial applications, and to alter it and redistribute it
   44.14 -  freely, subject to the following restrictions:
   44.15 -
   44.16 -  1. The origin of this software must not be misrepresented; you must not
   44.17 -     claim that you wrote the original software. If you use this software
   44.18 -     in a product, an acknowledgment in the product documentation would be
   44.19 -     appreciated but is not required.
   44.20 -  2. Altered source versions must be plainly marked as such, and must not be
   44.21 -     misrepresented as being the original software.
   44.22 -  3. This notice may not be removed or altered from any source distribution.
   44.23 -*/
   44.24 -#include "SDL_config.h"
   44.25 -
   44.26 -#if SDL_VIDEO_DRIVER_BWINDOW
   44.27 -
   44.28 -#include <AppKit.h>
   44.29 -#include <InterfaceKit.h>
   44.30 -#include "SDL_bmodes.h"
   44.31 -#include "SDL_BWin.h"
   44.32 -
   44.33 -#if SDL_VIDEO_OPENGL
   44.34 -#include "SDL_bopengl.h"
   44.35 -#endif
   44.36 -
   44.37 -#include "../../main/beos/SDL_BApp.h"
   44.38 -
   44.39 -#ifdef __cplusplus
   44.40 -extern "C" {
   44.41 -#endif
   44.42 -
   44.43 -
   44.44 -#define WRAP_BMODE 1 /* FIXME: Some debate as to whether this is necessary */
   44.45 -
   44.46 -#if WRAP_BMODE
   44.47 -/* This wrapper is here so that the driverdata can be freed without freeing
   44.48 -   the display_mode structure */
   44.49 -typedef struct SDL_DisplayModeData {
   44.50 -	display_mode *bmode;
   44.51 -};
   44.52 -#endif
   44.53 -
   44.54 -static SDL_INLINE SDL_BWin *_ToBeWin(SDL_Window *window) {
   44.55 -	return ((SDL_BWin*)(window->driverdata));
   44.56 -}
   44.57 -
   44.58 -static SDL_INLINE SDL_BApp *_GetBeApp() {
   44.59 -	return ((SDL_BApp*)be_app);
   44.60 -}
   44.61 -
   44.62 -static SDL_INLINE display_mode * _ExtractBMode(SDL_DisplayMode *mode) {
   44.63 -#if WRAP_BMODE
   44.64 -	return ((SDL_DisplayModeData*)mode->driverdata)->bmode;
   44.65 -#else
   44.66 -	return (display_mode*)(mode->driverdata);
   44.67 -#endif
   44.68 -}
   44.69 -
   44.70 -/* Copied from haiku/trunk/src/preferences/screen/ScreenMode.cpp */
   44.71 -static float get_refresh_rate(display_mode &mode) {
   44.72 -	return float(mode.timing.pixel_clock * 1000)
   44.73 -		/ float(mode.timing.h_total * mode.timing.v_total);
   44.74 -}
   44.75 -
   44.76 -
   44.77 -#if 0
   44.78 -/* TODO:
   44.79 - * This is a useful debugging tool.  Uncomment and insert into code as needed.
   44.80 - */
   44.81 -void _SpoutModeData(display_mode *bmode) {
   44.82 -	printf("BMode:\n");
   44.83 -	printf("\tw,h = (%i,%i)\n", bmode->virtual_width, bmode->virtual_height);
   44.84 -	printf("\th,v = (%i,%i)\n", bmode->h_display_start, 
   44.85 -			bmode->v_display_start);
   44.86 -	if(bmode->flags) {
   44.87 -		printf("\tFlags:\n");
   44.88 -		if(bmode->flags & B_SCROLL) {
   44.89 -			printf("\t\tB_SCROLL\n");
   44.90 -		}
   44.91 -		if(bmode->flags & B_8_BIT_DAC) {
   44.92 -			printf("\t\tB_8_BIT_DAC\n");
   44.93 -		}
   44.94 -		if(bmode->flags & B_HARDWARE_CURSOR) {
   44.95 -			printf("\t\tB_HARDWARE_CURSOR\n");
   44.96 -		}
   44.97 -		if(bmode->flags & B_PARALLEL_ACCESS) {
   44.98 -			printf("\t\tB_PARALLEL_ACCESS\n");
   44.99 -		}
  44.100 -		if(bmode->flags & B_DPMS) {
  44.101 -			printf("\t\tB_DPMS\n");
  44.102 -		}
  44.103 -		if(bmode->flags & B_IO_FB_NA) {
  44.104 -			printf("\t\tB_IO_FB_NA\n");
  44.105 -		}
  44.106 -	}
  44.107 -	printf("\tTiming:\n");
  44.108 -	printf("\t\tpx clock: %i\n", bmode->timing.pixel_clock);
  44.109 -	printf("\t\th - display: %i sync start: %i sync end: %i total: %i\n",
  44.110 -		bmode->timing.h_display, bmode->timing.h_sync_start,
  44.111 -		bmode->timing.h_sync_end, bmode->timing.h_total);
  44.112 -	printf("\t\tv - display: %i sync start: %i sync end: %i total: %i\n",
  44.113 -		bmode->timing.v_display, bmode->timing.v_sync_start,
  44.114 -		bmode->timing.v_sync_end, bmode->timing.v_total);
  44.115 -	if(bmode->timing.flags) {
  44.116 -		printf("\t\tFlags:\n");
  44.117 -		if(bmode->timing.flags & B_BLANK_PEDESTAL) {
  44.118 -			printf("\t\t\tB_BLANK_PEDESTAL\n");
  44.119 -		}
  44.120 -		if(bmode->timing.flags & B_TIMING_INTERLACED) {
  44.121 -			printf("\t\t\tB_TIMING_INTERLACED\n");
  44.122 -		}
  44.123 -		if(bmode->timing.flags & B_POSITIVE_HSYNC) {
  44.124 -			printf("\t\t\tB_POSITIVE_HSYNC\n");
  44.125 -		}
  44.126 -		if(bmode->timing.flags & B_POSITIVE_VSYNC) {
  44.127 -			printf("\t\t\tB_POSITIVE_VSYNC\n");
  44.128 -		}
  44.129 -		if(bmode->timing.flags & B_SYNC_ON_GREEN) {
  44.130 -			printf("\t\t\tB_SYNC_ON_GREEN\n");
  44.131 -		}
  44.132 -	}
  44.133 -}
  44.134 -#endif
  44.135 -
  44.136 -
  44.137 -
  44.138 -int32 BE_ColorSpaceToBitsPerPixel(uint32 colorspace)
  44.139 -{
  44.140 -	int bitsperpixel;
  44.141 -
  44.142 -	bitsperpixel = 0;
  44.143 -	switch (colorspace) {
  44.144 -	    case B_CMAP8:
  44.145 -		bitsperpixel = 8;
  44.146 -		break;
  44.147 -	    case B_RGB15:
  44.148 -	    case B_RGBA15:
  44.149 -	    case B_RGB15_BIG:
  44.150 -	    case B_RGBA15_BIG:
  44.151 -		bitsperpixel = 15;
  44.152 -		break;
  44.153 -	    case B_RGB16:
  44.154 -	    case B_RGB16_BIG:
  44.155 -		bitsperpixel = 16;
  44.156 -		break;
  44.157 -	    case B_RGB32:
  44.158 -	    case B_RGBA32:
  44.159 -	    case B_RGB32_BIG:
  44.160 -	    case B_RGBA32_BIG:
  44.161 -		bitsperpixel = 32;
  44.162 -		break;
  44.163 -	    default:
  44.164 -		break;
  44.165 -	}
  44.166 -	return(bitsperpixel);
  44.167 -}
  44.168 -
  44.169 -int32 BE_BPPToSDLPxFormat(int32 bpp) {
  44.170 -	/* Translation taken from SDL_windowsmodes.c */
  44.171 -	switch (bpp) {
  44.172 -	case 32:
  44.173 -		return SDL_PIXELFORMAT_RGB888;
  44.174 -		break;
  44.175 -	case 24:	/* May not be supported by Haiku */
  44.176 -		return SDL_PIXELFORMAT_RGB24;
  44.177 -		break;
  44.178 -	case 16:
  44.179 -		return SDL_PIXELFORMAT_RGB565;
  44.180 -		break;
  44.181 -	case 15:
  44.182 -		return SDL_PIXELFORMAT_RGB555;
  44.183 -		break;
  44.184 -	case 8:
  44.185 -		return SDL_PIXELFORMAT_INDEX8;
  44.186 -		break;
  44.187 -	case 4:		/* May not be supported by Haiku */
  44.188 -		return SDL_PIXELFORMAT_INDEX4LSB;
  44.189 -		break;
  44.190 -	}
  44.191 -
  44.192 -	/* May never get here, but safer and needed to shut up compiler */
  44.193 -	SDL_SetError("Invalid bpp value");
  44.194 -	return 0;       
  44.195 -}
  44.196 -
  44.197 -static void _BDisplayModeToSdlDisplayMode(display_mode *bmode,
  44.198 -		SDL_DisplayMode *mode) {
  44.199 -	mode->w = bmode->virtual_width;
  44.200 -	mode->h = bmode->virtual_height;
  44.201 -	mode->refresh_rate = (int)get_refresh_rate(*bmode);
  44.202 -
  44.203 -#if WRAP_BMODE
  44.204 -	SDL_DisplayModeData *data = (SDL_DisplayModeData*)SDL_calloc(1,
  44.205 -		sizeof(SDL_DisplayModeData));
  44.206 -	data->bmode = bmode;
  44.207 -	
  44.208 -	mode->driverdata = data;
  44.209 -
  44.210 -#else
  44.211 -
  44.212 -	mode->driverdata = bmode;
  44.213 -#endif
  44.214 -
  44.215 -	/* Set the format */
  44.216 -	int32 bpp = BE_ColorSpaceToBitsPerPixel(bmode->space);
  44.217 -	mode->format = BE_BPPToSDLPxFormat(bpp);
  44.218 -}
  44.219 -
  44.220 -/* Later, there may be more than one monitor available */
  44.221 -static void _AddDisplay(BScreen *screen) {
  44.222 -	SDL_VideoDisplay display;
  44.223 -	SDL_DisplayMode *mode = (SDL_DisplayMode*)SDL_calloc(1,
  44.224 -		sizeof(SDL_DisplayMode));
  44.225 -	display_mode *bmode = (display_mode*)SDL_calloc(1, sizeof(display_mode));
  44.226 -	screen->GetMode(bmode);
  44.227 -
  44.228 -	_BDisplayModeToSdlDisplayMode(bmode, mode);
  44.229 -	
  44.230 -	SDL_zero(display);
  44.231 -	display.desktop_mode = *mode;
  44.232 -	display.current_mode = *mode;
  44.233 -	
  44.234 -	SDL_AddVideoDisplay(&display);
  44.235 -}
  44.236 -
  44.237 -/*
  44.238 - * Functions called by SDL
  44.239 - */
  44.240 -
  44.241 -int BE_InitModes(_THIS) {
  44.242 -	BScreen screen;
  44.243 -
  44.244 -	/* TODO: When Haiku supports multiple display screens, call
  44.245 -	   _AddDisplayScreen() for each of them. */
  44.246 -	_AddDisplay(&screen);
  44.247 -	return 0;
  44.248 -}
  44.249 -
  44.250 -int BE_QuitModes(_THIS) {
  44.251 -	/* FIXME: Nothing really needs to be done here at the moment? */
  44.252 -	return 0;
  44.253 -}
  44.254 -
  44.255 -
  44.256 -int BE_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect) {
  44.257 -	BScreen bscreen;
  44.258 -	BRect rc = bscreen.Frame();
  44.259 -	rect->x = (int)rc.left;
  44.260 -	rect->y = (int)rc.top;
  44.261 -	rect->w = (int)rc.Width() + 1;
  44.262 -	rect->h = (int)rc.Height() + 1;
  44.263 -	return 0;
  44.264 -}
  44.265 -
  44.266 -void BE_GetDisplayModes(_THIS, SDL_VideoDisplay *display) {
  44.267 -	/* Get the current screen */
  44.268 -	BScreen bscreen;
  44.269 -
  44.270 -	/* Iterate through all of the modes */
  44.271 -	SDL_DisplayMode mode;
  44.272 -	display_mode this_bmode;
  44.273 -	display_mode *bmodes;
  44.274 -	uint32 count, i;
  44.275 -	
  44.276 -	/* Get graphics-hardware supported modes */
  44.277 -	bscreen.GetModeList(&bmodes, &count);
  44.278 -	bscreen.GetMode(&this_bmode);
  44.279 -	
  44.280 -	for(i = 0; i < count; ++i) {
  44.281 -		// FIXME: Apparently there are errors with colorspace changes
  44.282 -		if (bmodes[i].space == this_bmode.space) {
  44.283 -			_BDisplayModeToSdlDisplayMode(&bmodes[i], &mode);
  44.284 -			SDL_AddDisplayMode(display, &mode);
  44.285 -		}
  44.286 -	}
  44.287 -	free(bmodes);
  44.288 -}
  44.289 -
  44.290 -
  44.291 -int BE_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode){
  44.292 -	/* Get the current screen */
  44.293 -	BScreen bscreen;
  44.294 -	if(!bscreen.IsValid()) {
  44.295 -		printf(__FILE__": %d - ERROR: BAD SCREEN\n", __LINE__);
  44.296 -	}
  44.297 -
  44.298 -	/* Set the mode using the driver data */
  44.299 -	display_mode *bmode = _ExtractBMode(mode);
  44.300 -
  44.301 -
  44.302 -	/* FIXME: Is the first option always going to be the right one? */
  44.303 -	uint32 c = 0, i;
  44.304 -	display_mode *bmode_list;
  44.305 -	bscreen.GetModeList(&bmode_list, &c);
  44.306 -	for(i = 0; i < c; ++i) {
  44.307 -		if(	bmode_list[i].space == bmode->space &&
  44.308 -			bmode_list[i].virtual_width == bmode->virtual_width &&
  44.309 -			bmode_list[i].virtual_height == bmode->virtual_height ) {
  44.310 -				bmode = &bmode_list[i];
  44.311 -				break;
  44.312 -		}
  44.313 -	}
  44.314 -
  44.315 -	if(bscreen.SetMode(bmode) != B_OK) {
  44.316 -		return SDL_SetError("Bad video mode\n");
  44.317 -	}
  44.318 -	
  44.319 -	free(bmode_list);
  44.320 -	
  44.321 -#if SDL_VIDEO_OPENGL
  44.322 -	/* FIXME: Is there some way to reboot the OpenGL context?  This doesn't
  44.323 -	   help */
  44.324 -//	BE_GL_RebootContexts(_this);
  44.325 -#endif
  44.326 -
  44.327 -	return 0;
  44.328 -}
  44.329 -
  44.330 -#ifdef __cplusplus
  44.331 -}
  44.332 -#endif
  44.333 -
  44.334 -#endif /* SDL_VIDEO_DRIVER_BWINDOW */
    45.1 --- a/src/video/bwindow/SDL_bmodes.h	Thu Nov 14 10:19:07 2013 -0300
    45.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    45.3 @@ -1,46 +0,0 @@
    45.4 -/*
    45.5 -  Simple DirectMedia Layer
    45.6 -  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    45.7 -
    45.8 -  This software is provided 'as-is', without any express or implied
    45.9 -  warranty.  In no event will the authors be held liable for any damages
   45.10 -  arising from the use of this software.
   45.11 -
   45.12 -  Permission is granted to anyone to use this software for any purpose,
   45.13 -  including commercial applications, and to alter it and redistribute it
   45.14 -  freely, subject to the following restrictions:
   45.15 -
   45.16 -  1. The origin of this software must not be misrepresented; you must not
   45.17 -     claim that you wrote the original software. If you use this software
   45.18 -     in a product, an acknowledgment in the product documentation would be
   45.19 -     appreciated but is not required.
   45.20 -  2. Altered source versions must be plainly marked as such, and must not be
   45.21 -     misrepresented as being the original software.
   45.22 -  3. This notice may not be removed or altered from any source distribution.
   45.23 -*/
   45.24 -
   45.25 -#ifndef SDL_BMODES_H
   45.26 -#define SDL_BMODES_H
   45.27 -
   45.28 -#ifdef __cplusplus
   45.29 -extern "C" {
   45.30 -#endif
   45.31 -
   45.32 -#include "../SDL_sysvideo.h"
   45.33 -
   45.34 -extern int32 BE_ColorSpaceToBitsPerPixel(uint32 colorspace);
   45.35 -extern int32 BE_BPPToSDLPxFormat(int32 bpp);
   45.36 -
   45.37 -extern int BE_InitModes(_THIS);
   45.38 -extern int BE_QuitModes(_THIS);
   45.39 -extern int BE_GetDisplayBounds(_THIS, SDL_VideoDisplay *display,
   45.40 -    SDL_Rect *rect);
   45.41 -extern void BE_GetDisplayModes(_THIS, SDL_VideoDisplay *display);
   45.42 -extern int BE_SetDisplayMode(_THIS, SDL_VideoDisplay *display,
   45.43 -    SDL_DisplayMode *mode);
   45.44 -
   45.45 -#ifdef __cplusplus
   45.46 -}
   45.47 -#endif
   45.48 -
   45.49 -#endif
    46.1 --- a/src/video/bwindow/SDL_bopengl.cc	Thu Nov 14 10:19:07 2013 -0300
    46.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    46.3 @@ -1,219 +0,0 @@
    46.4 -/*
    46.5 -  Simple DirectMedia Layer
    46.6 -  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    46.7 -
    46.8 -  This software is provided 'as-is', without any express or implied
    46.9 -  warranty.  In no event will the authors be held liable for any damages
   46.10 -  arising from the use of this software.
   46.11 -
   46.12 -  Permission is granted to anyone to use this software for any purpose,
   46.13 -  including commercial applications, and to alter it and redistribute it
   46.14 -  freely, subject to the following restrictions:
   46.15 -
   46.16 -  1. The origin of this software must not be misrepresented; you must not
   46.17 -     claim that you wrote the original software. If you use this software
   46.18 -     in a product, an acknowledgment in the product documentation would be
   46.19 -     appreciated but is not required.
   46.20 -  2. Altered source versions must be plainly marked as such, and must not be
   46.21 -     misrepresented as being the original software.
   46.22 -  3. This notice may not be removed or altered from any source distribution.
   46.23 -*/
   46.24 -#include "SDL_config.h"
   46.25 -
   46.26 -#if SDL_VIDEO_DRIVER_BWINDOW
   46.27 -
   46.28 -#include "SDL_bopengl.h"
   46.29 -
   46.30 -#include <unistd.h>
   46.31 -#include <KernelKit.h>
   46.32 -#include <OpenGLKit.h>
   46.33 -#include "SDL_BWin.h"
   46.34 -#include "../../main/beos/SDL_BApp.h"
   46.35 -
   46.36 -#ifdef __cplusplus
   46.37 -extern "C" {
   46.38 -#endif
   46.39 -
   46.40 -
   46.41 -#define BGL_FLAGS BGL_RGB | BGL_DOUBLE
   46.42 -
   46.43 -static SDL_INLINE SDL_BWin *_ToBeWin(SDL_Window *window) {
   46.44 -	return ((SDL_BWin*)(window->driverdata));
   46.45 -}
   46.46 -
   46.47 -static SDL_INLINE SDL_BApp *_GetBeApp() {
   46.48 -	return ((SDL_BApp*)be_app);
   46.49 -}
   46.50 -
   46.51 -/* Passing a NULL path means load pointers from the application */
   46.52 -int BE_GL_LoadLibrary(_THIS, const char *path)
   46.53 -{
   46.54 -/* FIXME: Is this working correctly? */
   46.55 -	image_info info;
   46.56 -			int32 cookie = 0;
   46.57 -	while (get_next_image_info(0, &cookie, &info) == B_OK) {
   46.58 -		void *location = NULL;
   46.59 -		if( get_image_symbol(info.id, "glBegin", B_SYMBOL_TYPE_ANY,
   46.60 -				&location) == B_OK) {
   46.61 -
   46.62 -			_this->gl_config.dll_handle = (void *) info.id;
   46.63 -			_this->gl_config.driver_loaded = 1;
   46.64 -			SDL_strlcpy(_this->gl_config.driver_path, "libGL.so",
   46.65 -					SDL_arraysize(_this->gl_config.driver_path));
   46.66 -		}
   46.67 -	}
   46.68 -	return 0;
   46.69 -}
   46.70 -
   46.71 -void *BE_GL_GetProcAddress(_THIS, const char *proc)
   46.72 -{
   46.73 -	if (_this->gl_config.dll_handle != NULL) {
   46.74 -		void *location = NULL;
   46.75 -		status_t err;
   46.76 -		if ((err =
   46.77 -			get_image_symbol((image_id) _this->gl_config.dll_handle,
   46.78 -                              proc, B_SYMBOL_TYPE_ANY,
   46.79 -                              &location)) == B_OK) {
   46.80 -            return location;
   46.81 -        } else {
   46.82 -                SDL_SetError("Couldn't find OpenGL symbol");
   46.83 -                return NULL;
   46.84 -        }
   46.85 -	} else {
   46.86 -		SDL_SetError("OpenGL library not loaded");
   46.87 -		return NULL;
   46.88 -	}
   46.89 -}
   46.90 -
   46.91 -
   46.92 -
   46.93 -
   46.94 -void BE_GL_SwapWindow(_THIS, SDL_Window * window) {
   46.95 -    _ToBeWin(window)->SwapBuffers();
   46.96 -}
   46.97 -
   46.98 -int BE_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) {
   46.99 -	_GetBeApp()->SetCurrentContext(((SDL_BWin*)context)->GetGLView());
  46.100 -	return 0;
  46.101 -}
  46.102 -
  46.103 -
  46.104 -SDL_GLContext BE_GL_CreateContext(_THIS, SDL_Window * window) {
  46.105 -	/* FIXME: Not sure what flags should be included here; may want to have
  46.106 -	   most of them */
  46.107 -	SDL_BWin *bwin = _ToBeWin(window);
  46.108 -	bwin->CreateGLView(BGL_FLAGS);
  46.109 -	return (SDL_GLContext)(bwin);
  46.110 -}
  46.111 -
  46.112 -void BE_GL_DeleteContext(_THIS, SDL_GLContext context) {
  46.113 -	/* Currently, automatically unlocks the view */
  46.114 -	((SDL_BWin*)context)->RemoveGLView();
  46.115 -}
  46.116 -
  46.117 -
  46.118 -int BE_GL_SetSwapInterval(_THIS, int interval) {
  46.119 -	/* TODO: Implement this, if necessary? */
  46.120 -	return 0;
  46.121 -}
  46.122 -
  46.123 -int BE_GL_GetSwapInterval(_THIS) {
  46.124 -	/* TODO: Implement this, if necessary? */
  46.125 -	return 0;
  46.126 -}
  46.127 -
  46.128 -
  46.129 -void BE_GL_UnloadLibrary(_THIS) {
  46.130 -	/* TODO: Implement this, if necessary? */
  46.131 -}
  46.132 -
  46.133 -
  46.134 -/* FIXME: This function is meant to clear the OpenGL context when the video
  46.135 -   mode changes (see SDL_bmodes.cc), but it doesn't seem to help, and is not
  46.136 -   currently in use. */
  46.137 -void BE_GL_RebootContexts(_THIS) {
  46.138 -	SDL_Window *window = _this->windows;
  46.139 -	while(window) {
  46.140 -		SDL_BWin *bwin = _ToBeWin(window);
  46.141 -		if(bwin->GetGLView()) {
  46.142 -			bwin->LockLooper();
  46.143 -			bwin->RemoveGLView();
  46.144 -			bwin->CreateGLView(BGL_FLAGS);
  46.145 -			bwin->UnlockLooper();
  46.146 -		}
  46.147 -		window = window->next;
  46.148 -	}
  46.149 -}
  46.150 -
  46.151 -
  46.152 -#if 0 /* Functions from 1.2 that do not appear to be used in 1.3 */
  46.153 -
  46.154 -    int BE_GL_GetAttribute(_THIS, SDL_GLattr attrib, int *value)
  46.155 -    {
  46.156 -        /*
  46.157 -           FIXME? Right now BE_GL_GetAttribute shouldn't be called between glBegin() and glEnd() - it doesn't use "cached" values
  46.158 -         */
  46.159 -        switch (attrib) {
  46.160 -        case SDL_GL_RED_SIZE:
  46.161 -            glGetIntegerv(GL_RED_BITS, (GLint *) value);
  46.162 -            break;
  46.163 -        case SDL_GL_GREEN_SIZE:
  46.164 -            glGetIntegerv(GL_GREEN_BITS, (GLint *) value);
  46.165 -            break;
  46.166 -        case SDL_GL_BLUE_SIZE:
  46.167 -            glGetIntegerv(GL_BLUE_BITS, (GLint *) value);
  46.168 -            break;
  46.169 -        case SDL_GL_ALPHA_SIZE:
  46.170 -            glGetIntegerv(GL_ALPHA_BITS, (GLint *) value);
  46.171 -            break;
  46.172 -        case SDL_GL_DOUBLEBUFFER:
  46.173 -            glGetBooleanv(GL_DOUBLEBUFFER, (GLboolean *) value);
  46.174 -            break;
  46.175 -        case SDL_GL_BUFFER_SIZE:
  46.176 -            int v;
  46.177 -            glGetIntegerv(GL_RED_BITS, (GLint *) & v);
  46.178 -            *value = v;
  46.179 -            glGetIntegerv(GL_GREEN_BITS, (GLint *) & v);
  46.180 -            *value += v;
  46.181 -            glGetIntegerv(GL_BLUE_BITS, (GLint *) & v);
  46.182 -            *value += v;
  46.183 -            glGetIntegerv(GL_ALPHA_BITS, (GLint *) & v);
  46.184 -            *value += v;
  46.185 -            break;
  46.186 -        case SDL_GL_DEPTH_SIZE:
  46.187 -            glGetIntegerv(GL_DEPTH_BITS, (GLint *) value);      /* Mesa creates 16 only? r5 always 32 */
  46.188 -            break;
  46.189 -        case SDL_GL_STENCIL_SIZE:
  46.190 -            glGetIntegerv(GL_STENCIL_BITS, (GLint *) value);
  46.191 -            break;
  46.192 -        case SDL_GL_ACCUM_RED_SIZE:
  46.193 -            glGetIntegerv(GL_ACCUM_RED_BITS, (GLint *) value);
  46.194 -            break;
  46.195 -        case SDL_GL_ACCUM_GREEN_SIZE:
  46.196 -            glGetIntegerv(GL_ACCUM_GREEN_BITS, (GLint *) value);
  46.197 -            break;
  46.198 -        case SDL_GL_ACCUM_BLUE_SIZE:
  46.199 -            glGetIntegerv(GL_ACCUM_BLUE_BITS, (GLint *) value);
  46.200 -            break;
  46.201 -        case SDL_GL_ACCUM_ALPHA_SIZE:
  46.202 -            glGetIntegerv(GL_ACCUM_ALPHA_BITS, (GLint *) value);
  46.203 -            break;
  46.204 -        case SDL_GL_STEREO:
  46.205 -        case SDL_GL_MULTISAMPLEBUFFERS:
  46.206 -        case SDL_GL_MULTISAMPLESAMPLES:
  46.207 -        default:
  46.208 -            *value = 0;
  46.209 -            return (-1);
  46.210 -        }
  46.211 -        return 0;
  46.212 -    }
  46.213 -
  46.214 -#endif
  46.215 -
  46.216 -
  46.217 -
  46.218 -#ifdef __cplusplus
  46.219 -}
  46.220 -#endif
  46.221 -
  46.222 -#endif /* SDL_VIDEO_DRIVER_BWINDOW */
    47.1 --- a/src/video/bwindow/SDL_bopengl.h	Thu Nov 14 10:19:07 2013 -0300
    47.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    47.3 @@ -1,49 +0,0 @@
    47.4 -/*
    47.5 -  Simple DirectMedia Layer
    47.6 -  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    47.7 -
    47.8 -  This software is provided 'as-is', without any express or implied
    47.9 -  warranty.  In no event will the authors be held liable for any damages
   47.10 -  arising from the use of this software.
   47.11 -
   47.12 -  Permission is granted to anyone to use this software for any purpose,
   47.13 -  including commercial applications, and to alter it and redistribute it
   47.14 -  freely, subject to the following restrictions:
   47.15 -
   47.16 -  1. The origin of this software must not be misrepresented; you must not
   47.17 -     claim that you wrote the original software. If you use this software
   47.18 -     in a product, an acknowledgment in the product documentation would be
   47.19 -     appreciated but is not required.
   47.20 -  2. Altered source versions must be plainly marked as such, and must not be
   47.21 -     misrepresented as being the original software.
   47.22 -  3. This notice may not be removed or altered from any source distribution.
   47.23 -*/
   47.24 -
   47.25 -#ifndef SDL_BOPENGL_H
   47.26 -#define SDL_BOPENGL_H
   47.27 -
   47.28 -#ifdef __cplusplus
   47.29 -extern "C" {
   47.30 -#endif
   47.31 -
   47.32 -#include "../SDL_sysvideo.h"
   47.33 -
   47.34 -
   47.35 -extern int BE_GL_LoadLibrary(_THIS, const char *path);                  /* FIXME */
   47.36 -extern void *BE_GL_GetProcAddress(_THIS, const char *proc);             /* FIXME */
   47.37 -extern void BE_GL_UnloadLibrary(_THIS);                                 /* TODO */
   47.38 -extern int BE_GL_MakeCurrent(_THIS, SDL_Window * window,
   47.39 -                              SDL_GLContext context);
   47.40 -extern int BE_GL_SetSwapInterval(_THIS, int interval);                  /* TODO */
   47.41 -extern int BE_GL_GetSwapInterval(_THIS);                                /* TODO */
   47.42 -extern void BE_GL_SwapWindow(_THIS, SDL_Window * window);
   47.43 -extern SDL_GLContext BE_GL_CreateContext(_THIS, SDL_Window * window);
   47.44 -extern void BE_GL_DeleteContext(_THIS, SDL_GLContext context);
   47.45 -
   47.46 -extern void BE_GL_RebootContexts(_THIS);
   47.47 -
   47.48 -#ifdef __cplusplus
   47.49 -}
   47.50 -#endif
   47.51 -
   47.52 -#endif
    48.1 --- a/src/video/bwindow/SDL_bvideo.cc	Thu Nov 14 10:19:07 2013 -0300
    48.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    48.3 @@ -1,174 +0,0 @@
    48.4 -/*
    48.5 -  Simple DirectMedia Layer
    48.6 -  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    48.7 -
    48.8 -  This software is provided 'as-is', without any express or implied
    48.9 -  warranty.  In no event will the authors be held liable for any damages
   48.10 -  arising from the use of this software.
   48.11 -
   48.12 -  Permission is granted to anyone to use this software for any purpose,
   48.13 -  including commercial applications, and to alter it and redistribute it
   48.14 -  freely, subject to the following restrictions:
   48.15 -
   48.16 -  1. The origin of this software must not be misrepresented; you must not
   48.17 -     claim that you wrote the original software. If you use this software
   48.18 -     in a product, an acknowledgment in the product documentation would be
   48.19 -     appreciated but is not required.
   48.20 -  2. Altered source versions must be plainly marked as such, and must not be
   48.21 -     misrepresented as being the original software.
   48.22 -  3. This notice may not be removed or altered from any source distribution.
   48.23 -*/
   48.24 -#include "SDL_config.h"
   48.25 -
   48.26 -#if SDL_VIDEO_DRIVER_BWINDOW
   48.27 -
   48.28 -
   48.29 -#ifdef __cplusplus
   48.30 -extern "C" {
   48.31 -#endif
   48.32 -
   48.33 -#include "SDL_bkeyboard.h"
   48.34 -#include "SDL_bwindow.h"
   48.35 -#include "SDL_bclipboard.h"
   48.36 -#include "SDL_bvideo.h"
   48.37 -#include "SDL_bopengl.h"
   48.38 -#include "SDL_bmodes.h"
   48.39 -#include "SDL_bframebuffer.h"
   48.40 -#include "SDL_bevents.h"
   48.41 -
   48.42 -/* FIXME: Undefined functions */
   48.43 -//    #define BE_PumpEvents NULL
   48.44 -    #define BE_StartTextInput NULL
   48.45 -    #define BE_StopTextInput NULL
   48.46 -    #define BE_SetTextInputRect NULL
   48.47 -
   48.48 -//    #define BE_DeleteDevice NULL
   48.49 -
   48.50 -/* End undefined functions */
   48.51 -
   48.52 -static SDL_VideoDevice *
   48.53 -BE_CreateDevice(int devindex)
   48.54 -{
   48.55 -    SDL_VideoDevice *device;
   48.56 -    /*SDL_VideoData *data;*/
   48.57 -
   48.58 -    /* Initialize all variables that we clean on shutdown */
   48.59 -    device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
   48.60 -
   48.61 -    device->driverdata = NULL; /* FIXME: Is this the cause of some of the
   48.62 -    							  SDL_Quit() errors? */
   48.63 -
   48.64 -/* TODO: Figure out if any initialization needs to go here */
   48.65 -
   48.66 -    /* Set the function pointers */
   48.67 -    device->VideoInit = BE_VideoInit;
   48.68 -    device->VideoQuit = BE_VideoQuit;
   48.69 -    device->GetDisplayBounds = BE_GetDisplayBounds;
   48.70 -    device->GetDisplayModes = BE_GetDisplayModes;
   48.71 -    device->SetDisplayMode = BE_SetDisplayMode;
   48.72 -    device->PumpEvents = BE_PumpEvents;
   48.73 -
   48.74 -    device->CreateWindow = BE_CreateWindow;
   48.75 -    device->CreateWindowFrom = BE_CreateWindowFrom;
   48.76 -    device->SetWindowTitle = BE_SetWindowTitle;
   48.77 -    device->SetWindowIcon = BE_SetWindowIcon;
   48.78 -    device->SetWindowPosition = BE_SetWindowPosition;
   48.79 -    device->SetWindowSize = BE_SetWindowSize;
   48.80 -    device->ShowWindow = BE_ShowWindow;
   48.81 -    device->HideWindow = BE_HideWindow;
   48.82 -    device->RaiseWindow = BE_RaiseWindow;
   48.83 -    device->MaximizeWindow = BE_MaximizeWindow;
   48.84 -    device->MinimizeWindow = BE_MinimizeWindow;
   48.85 -    device->RestoreWindow = BE_RestoreWindow;
   48.86 -    device->SetWindowBordered = BE_SetWindowBordered;
   48.87 -    device->SetWindowFullscreen = BE_SetWindowFullscreen;
   48.88 -    device->SetWindowGammaRamp = BE_SetWindowGammaRamp;
   48.89 -    device->GetWindowGammaRamp = BE_GetWindowGammaRamp;
   48.90 -    device->SetWindowGrab = BE_SetWindowGrab;
   48.91 -    device->DestroyWindow = BE_DestroyWindow;
   48.92 -    device->GetWindowWMInfo = BE_GetWindowWMInfo;
   48.93 -    device->CreateWindowFramebuffer = BE_CreateWindowFramebuffer;
   48.94 -    device->UpdateWindowFramebuffer = BE_UpdateWindowFramebuffer;
   48.95 -    device->DestroyWindowFramebuffer = BE_DestroyWindowFramebuffer;
   48.96 -    
   48.97 -    device->shape_driver.CreateShaper = NULL;
   48.98 -    device->shape_driver.SetWindowShape = NULL;
   48.99 -    device->shape_driver.ResizeWindowShape = NULL;
  48.100 -
  48.101 -
  48.102 -    device->GL_LoadLibrary = BE_GL_LoadLibrary;
  48.103 -    device->GL_GetProcAddress = BE_GL_GetProcAddress;
  48.104 -    device->GL_UnloadLibrary = BE_GL_UnloadLibrary;
  48.105 -    device->GL_CreateContext = BE_GL_CreateContext;
  48.106 -    device->GL_MakeCurrent = BE_GL_MakeCurrent;
  48.107 -    device->GL_SetSwapInterval = BE_GL_SetSwapInterval;
  48.108 -    device->GL_GetSwapInterval = BE_GL_GetSwapInterval;
  48.109 -    device->GL_SwapWindow = BE_GL_SwapWindow;
  48.110 -    device->GL_DeleteContext = BE_GL_DeleteContext;
  48.111 -
  48.112 -    device->StartTextInput = BE_StartTextInput;
  48.113 -    device->StopTextInput = BE_StopTextInput;
  48.114 -    device->SetTextInputRect = BE_SetTextInputRect;
  48.115 -
  48.116 -    device->SetClipboardText = BE_SetClipboardText;
  48.117 -    device->GetClipboardText = BE_GetClipboardText;
  48.118 -    device->HasClipboardText = BE_HasClipboardText;
  48.119 -
  48.120 -    device->free = BE_DeleteDevice;
  48.121 -
  48.122 -    return device;
  48.123 -}
  48.124 -
  48.125 -VideoBootStrap BWINDOW_bootstrap = {
  48.126 -	"bwindow", "BDirectWindow graphics",
  48.127 -	BE_Available, BE_CreateDevice
  48.128 -};
  48.129 -
  48.130 -void BE_DeleteDevice(SDL_VideoDevice * device)
  48.131 -{
  48.132 -	SDL_free(device->driverdata);
  48.133 -	SDL_free(device);
  48.134 -}
  48.135 -
  48.136 -int BE_VideoInit(_THIS)
  48.137 -{
  48.138 -	/* Initialize the Be Application for appserver interaction */
  48.139 -	if (SDL_InitBeApp() < 0) {
  48.140 -		return -1;
  48.141 -	}
  48.142 -	
  48.143 -	/* Initialize video modes */
  48.144 -	BE_InitModes(_this);
  48.145 -
  48.146 -	/* Init the keymap */
  48.147 -	BE_InitOSKeymap();
  48.148 -	
  48.149 -	
  48.150 -#if SDL_VIDEO_OPENGL
  48.151 -        /* testgl application doesn't load library, just tries to load symbols */
  48.152 -        /* is it correct? if so we have to load library here */
  48.153 -    BE_GL_LoadLibrary(_this, NULL);
  48.154 -#endif
  48.155 -
  48.156 -        /* We're done! */
  48.157 -    return (0);
  48.158 -}
  48.159 -
  48.160 -int BE_Available(void)
  48.161 -{
  48.162 -    return (1);
  48.163 -}
  48.164 -
  48.165 -void BE_VideoQuit(_THIS)
  48.166 -{
  48.167 -
  48.168 -    BE_QuitModes(_this);
  48.169 -
  48.170 -    SDL_QuitBeApp();
  48.171 -}
  48.172 -
  48.173 -#ifdef __cplusplus
  48.174 -}
  48.175 -#endif
  48.176 -
  48.177 -#endif /* SDL_VIDEO_DRIVER_BWINDOW */
    49.1 --- a/src/video/bwindow/SDL_bvideo.h	Thu Nov 14 10:19:07 2013 -0300
    49.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    49.3 @@ -1,42 +0,0 @@
    49.4 -/*
    49.5 -  Simple DirectMedia Layer
    49.6 -  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    49.7 -
    49.8 -  This software is provided 'as-is', without any express or implied
    49.9 -  warranty.  In no event will the authors be held liable for any damages
   49.10 -  arising from the use of this software.
   49.11 -
   49.12 -  Permission is granted to anyone to use this software for any purpose,
   49.13 -  including commercial applications, and to alter it and redistribute it
   49.14 -  freely, subject to the following restrictions:
   49.15 -
   49.16 -  1. The origin of this software must not be misrepresented; you must not
   49.17 -     claim that you wrote the original software. If you use this software
   49.18 -     in a product, an acknowledgment in the product documentation would be
   49.19 -     appreciated but is not required.
   49.20 -  2. Altered source versions must be plainly marked as such, and must not be
   49.21 -     misrepresented as being the original software.
   49.22 -  3. This notice may not be removed or altered from any source distribution.
   49.23 -*/
   49.24 -
   49.25 -#ifndef BVIDEO_H
   49.26 -#define BVIDEO_H
   49.27 -
   49.28 -#ifdef __cplusplus
   49.29 -extern "C" {
   49.30 -#endif
   49.31 -
   49.32 -#include "../../main/beos/SDL_BeApp.h"
   49.33 -#include "../SDL_sysvideo.h"
   49.34 -
   49.35 -
   49.36 -extern void BE_VideoQuit(_THIS);
   49.37 -extern int BE_VideoInit(_THIS);
   49.38 -extern void BE_DeleteDevice(_THIS);
   49.39 -extern int BE_Available(void);
   49.40 -
   49.41 -#ifdef __cplusplus
   49.42 -}
   49.43 -#endif
   49.44 -
   49.45 -#endif
    50.1 --- a/src/video/bwindow/SDL_bwindow.cc	Thu Nov 14 10:19:07 2013 -0300
    50.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    50.3 @@ -1,223 +0,0 @@
    50.4 -/*
    50.5 -  Simple DirectMedia Layer
    50.6 -  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    50.7 -
    50.8 -  This software is provided 'as-is', without any express or implied
    50.9 -  warranty.  In no event will the authors be held liable for any damages
   50.10 -  arising from the use of this software.
   50.11 -
   50.12 -  Permission is granted to anyone to use this software for any purpose,
   50.13 -  including commercial applications, and to alter it and redistribute it
   50.14 -  freely, subject to the following restrictions:
   50.15 -
   50.16 -  1. The origin of this software must not be misrepresented; you must not
   50.17 -     claim that you wrote the original software. If you use this software
   50.18 -     in a product, an acknowledgment in the product documentation would be
   50.19 -     appreciated but is not required.
   50.20 -  2. Altered source versions must be plainly marked as such, and must not be
   50.21 -     misrepresented as being the original software.
   50.22 -  3. This notice may not be removed or altered from any source distribution.
   50.23 -*/
   50.24 -#include "SDL_config.h"
   50.25 -
   50.26 -#if SDL_VIDEO_DRIVER_BWINDOW
   50.27 -#include "../SDL_sysvideo.h"
   50.28 -
   50.29 -#include "SDL_BWin.h"
   50.30 -#include <new>
   50.31 -
   50.32 -/* Define a path to window's BWIN data */
   50.33 -#ifdef __cplusplus
   50.34 -extern "C" {
   50.35 -#endif
   50.36 -
   50.37 -static SDL_INLINE SDL_BWin *_ToBeWin(SDL_Window *window) {
   50.38 -	return ((SDL_BWin*)(window->driverdata));
   50.39 -}
   50.40 -
   50.41 -static SDL_INLINE SDL_BApp *_GetBeApp() {
   50.42 -	return ((SDL_BApp*)be_app);
   50.43 -}
   50.44 -
   50.45 -static int _InitWindow(_THIS, SDL_Window *window) {
   50.46 -	uint32 flags = 0;
   50.47 -	window_look look = B_BORDERED_WINDOW_LOOK;
   50.48 -
   50.49 -	BRect bounds(
   50.50 -        window->x,
   50.51 -        window->y,
   50.52 -        window->x + window->w - 1,	//BeWindows have an off-by-one px w/h thing
   50.53 -        window->y + window->h - 1
   50.54 -    );
   50.55 -    
   50.56 -    if(window->flags & SDL_WINDOW_FULLSCREEN) {
   50.57 -    	/* TODO: Add support for this flag */
   50.58 -    	printf(__FILE__": %d!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n",__LINE__);
   50.59 -    }
   50.60 -    if(window->flags & SDL_WINDOW_OPENGL) {
   50.61 -    	/* TODO: Add support for this flag */
   50.62 -    }
   50.63 -    if(!(window->flags & SDL_WINDOW_RESIZABLE)) {
   50.64 -    	flags |= B_NOT_RESIZABLE | B_NOT_ZOOMABLE;
   50.65 -    }
   50.66 -    if(window->flags & SDL_WINDOW_BORDERLESS) {
   50.67 -    	look = B_NO_BORDER_WINDOW_LOOK;
   50.68 -    }
   50.69 -
   50.70 -    SDL_BWin *bwin = new(std::nothrow) SDL_BWin(bounds, look, flags);
   50.71 -    if(bwin == NULL)
   50.72 -    	return ENOMEM;
   50.73 -
   50.74 -    window->driverdata = bwin;
   50.75 -    int32 winID = _GetBeApp()->GetID(window);
   50.76 -    bwin->SetID(winID);
   50.77 -
   50.78 -    return 0;
   50.79 -}
   50.80 -
   50.81 -int BE_CreateWindow(_THIS, SDL_Window *window) {
   50.82 -	if(_InitWindow(_this, window) == ENOMEM)
   50.83 -		return ENOMEM;
   50.84 -	
   50.85 -	/* Start window loop */
   50.86 -    _ToBeWin(window)->Show();
   50.87 -    return 0;
   50.88 -}
   50.89 -
   50.90 -int BE_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) {
   50.91 -
   50.92 -	SDL_BWin *otherBWin = (SDL_BWin*)data;
   50.93 -	if(!otherBWin->LockLooper())
   50.94 -		return -1;
   50.95 -	
   50.96 -	/* Create the new window and initialize its members */
   50.97 -	window->x = (int)otherBWin->Frame().left;
   50.98 -	window->y = (int)otherBWin->Frame().top;
   50.99 -	window->w = (int)otherBWin->Frame().Width();
  50.100 -	window->h = (int)otherBWin->Frame().Height();
  50.101 -	
  50.102 -	/* Set SDL flags */
  50.103 -	if(!(otherBWin->Flags() & B_NOT_RESIZABLE)) {
  50.104 -		window->flags |= SDL_WINDOW_RESIZABLE;
  50.105 -	}
  50.106 -	
  50.107 -	/* If we are out of memory, return the error code */
  50.108 -	if(_InitWindow(_this, window) == ENOMEM)
  50.109 -		return ENOMEM;
  50.110 -	
  50.111 -	/* TODO: Add any other SDL-supported window attributes here */
  50.112 -    _ToBeWin(window)->SetTitle(otherBWin->Title());
  50.113 -    
  50.114 -    /* Start window loop and unlock the other window */
  50.115 -    _ToBeWin(window)->Show();
  50.116 -    
  50.117 -    otherBWin->UnlockLooper();
  50.118 -    return 0;
  50.119 -}
  50.120 -
  50.121 -void BE_SetWindowTitle(_THIS, SDL_Window * window) {
  50.122 -	BMessage msg(BWIN_SET_TITLE);
  50.123 -	msg.AddString("window-title", window->title);
  50.124 -	_ToBeWin(window)->PostMessage(&msg);
  50.125 -}
  50.126 -
  50.127 -void BE_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) {
  50.128 -	/* FIXME: Icons not supported by BeOs/Haiku */
  50.129 -}
  50.130 -
  50.131 -void BE_SetWindowPosition(_THIS, SDL_Window * window) {
  50.132 -	BMessage msg(BWIN_MOVE_WINDOW);
  50.133 -	msg.AddInt32("window-x", window->x);
  50.134 -	msg.AddInt32("window-y", window->y);
  50.135 -	_ToBeWin(window)->PostMessage(&msg);
  50.136 -}
  50.137 -
  50.138 -void BE_SetWindowSize(_THIS, SDL_Window * window) {
  50.139 -	BMessage msg(BWIN_RESIZE_WINDOW);
  50.140 -	msg.AddInt32("window-w", window->w - 1);
  50.141 -	msg.AddInt32("window-h", window->h - 1);
  50.142 -	_ToBeWin(window)->PostMessage(&msg);
  50.143 -}
  50.144 -
  50.145 -void BE_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered) {
  50.146 -	BMessage msg(BWIN_SET_BORDERED);
  50.147 -	msg.AddBool("window-border", bordered != SDL_FALSE);
  50.148 -	_ToBeWin(window)->PostMessage(&msg);
  50.149 -}
  50.150 -
  50.151 -void BE_ShowWindow(_THIS, SDL_Window * window) {
  50.152 -	BMessage msg(BWIN_SHOW_WINDOW);
  50.153 -	_ToBeWin(window)->PostMessage(&msg);
  50.154 -}
  50.155 -
  50.156 -void BE_HideWindow(_THIS, SDL_Window * window) {
  50.157 -	BMessage msg(BWIN_HIDE_WINDOW);
  50.158 -	_ToBeWin(window)->PostMessage(&msg);
  50.159 -}
  50.160 -
  50.161 -void BE_RaiseWindow(_THIS, SDL_Window * window) {
  50.162 -	BMessage msg(BWIN_SHOW_WINDOW);	/* Activate this window and move to front */
  50.163 -	_ToBeWin(window)->PostMessage(&msg);
  50.164 -}
  50.165 -
  50.166 -void BE_MaximizeWindow(_THIS, SDL_Window * window) {
  50.167 -	BMessage msg(BWIN_MAXIMIZE_WINDOW);
  50.168 -	_ToBeWin(window)->PostMessage(&msg);
  50.169 -}
  50.170 -
  50.171 -void BE_MinimizeWindow(_THIS, SDL_Window * window) {
  50.172 -	BMessage msg(BWIN_MINIMIZE_WINDOW);
  50.173 -	_ToBeWin(window)->PostMessage(&msg);
  50.174 -}
  50.175 -
  50.176 -void BE_RestoreWindow(_THIS, SDL_Window * window) {
  50.177 -	BMessage msg(BWIN_RESTORE_WINDOW);
  50.178 -	_ToBeWin(window)->PostMessage(&msg);
  50.179 -}
  50.180 -
  50.181 -void BE_SetWindowFullscreen(_THIS, SDL_Window * window,
  50.182 -		SDL_VideoDisplay * display, SDL_bool fullscreen) {
  50.183 -	/* Haiku tracks all video display information */
  50.184 -	BMessage msg(BWIN_FULLSCREEN);
  50.185 -	msg.AddBool("fullscreen", fullscreen);
  50.186 -	_ToBeWin(window)->PostMessage(&msg);
  50.187 -	
  50.188 -}
  50.189 -
  50.190 -int BE_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp) {
  50.191 -	/* FIXME: Not BeOs/Haiku supported */
  50.192 -	return -1;
  50.193 -}
  50.194 -
  50.195 -int BE_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp) {
  50.196 -	/* FIXME: Not BeOs/Haiku supported */
  50.197 -	return -1;
  50.198 -}
  50.199 -
  50.200 -
  50.201 -void BE_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed) {
  50.202 -	/* TODO: Implement this! */
  50.203 -}
  50.204 -
  50.205 -void BE_DestroyWindow(_THIS, SDL_Window * window) {
  50.206 -	_ToBeWin(window)->LockLooper();	/* This MUST be locked */
  50.207 -	_GetBeApp()->ClearID(_ToBeWin(window));
  50.208 -	_ToBeWin(window)->Quit();
  50.209 -	window->driverdata = NULL;
  50.210 -}
  50.211 -
  50.212 -SDL_bool BE_GetWindowWMInfo(_THIS, SDL_Window * window,
  50.213 -                                    struct SDL_SysWMinfo *info) {
  50.214 -	/* FIXME: What is the point of this? What information should be included? */
  50.215 -	return SDL_FALSE;
  50.216 -}
  50.217 -
  50.218 -
  50.219 -
  50.220 -
  50.221 - 
  50.222 -#ifdef __cplusplus
  50.223 -}
  50.224 -#endif
  50.225 -
  50.226 -#endif /* SDL_VIDEO_DRIVER_BWINDOW */
    51.1 --- a/src/video/bwindow/SDL_bwindow.h	Thu Nov 14 10:19:07 2013 -0300
    51.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    51.3 @@ -1,53 +0,0 @@
    51.4 -/*
    51.5 -  Simple DirectMedia Layer
    51.6 -  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    51.7 -
    51.8 -  This software is provided 'as-is', without any express or implied
    51.9 -  warranty.  In no event will the authors be held liable for any damages
   51.10 -  arising from the use of this software.
   51.11 -
   51.12 -  Permission is granted to anyone to use this software for any purpose,
   51.13 -  including commercial applications, and to alter it and redistribute it
   51.14 -  freely, subject to the following restrictions:
   51.15 -
   51.16 -  1. The origin of this software must not be misrepresented; you must not
   51.17 -     claim that you wrote the original software. If you use this software
   51.18 -     in a product, an acknowledgment in the product documentation would be
   51.19 -     appreciated but is not required.
   51.20 -  2. Altered source versions must be plainly marked as such, and must not be
   51.21 -     misrepresented as being the original software.
   51.22 -  3. This notice may not be removed or altered from any source distribution.
   51.23 -*/
   51.24 -
   51.25 -#ifndef SDL_BWINDOW_H
   51.26 -#define SDL_BWINDOW_H
   51.27 -
   51.28 -
   51.29 -#include "../SDL_sysvideo.h"
   51.30 -
   51.31 -
   51.32 -extern int BE_CreateWindow(_THIS, SDL_Window *window);
   51.33 -extern int BE_CreateWindowFrom(_THIS, SDL_Window * window, const void *data);
   51.34 -extern void BE_SetWindowTitle(_THIS, SDL_Window * window);
   51.35 -extern void BE_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon);
   51.36 -extern void BE_SetWindowPosition(_THIS, SDL_Window * window);
   51.37 -extern void BE_SetWindowSize(_THIS, SDL_Window * window);
   51.38 -extern void BE_ShowWindow(_THIS, SDL_Window * window);
   51.39 -extern void BE_HideWindow(_THIS, SDL_Window * window);
   51.40 -extern void BE_RaiseWindow(_THIS, SDL_Window * window);
   51.41 -extern void BE_MaximizeWindow(_THIS, SDL_Window * window);
   51.42 -extern void BE_MinimizeWindow(_THIS, SDL_Window * window);
   51.43 -extern void BE_RestoreWindow(_THIS, SDL_Window * window);
   51.44 -extern void BE_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered);
   51.45 -extern void BE_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen);
   51.46 -extern int BE_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp);
   51.47 -extern int BE_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp);
   51.48 -extern void BE_SetWindowGrab(_THIS, SDL_Window * window, SDL_bool grabbed);
   51.49 -extern void BE_DestroyWindow(_THIS, SDL_Window * window);
   51.50 -extern SDL_bool BE_GetWindowWMInfo(_THIS, SDL_Window * window,
   51.51 -                                    struct SDL_SysWMinfo *info);
   51.52 -
   51.53 -
   51.54 -
   51.55 -#endif
   51.56 -
    52.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    52.2 +++ b/src/video/haiku/SDL_BWin.h	Thu Nov 14 11:51:24 2013 -0500
    52.3 @@ -0,0 +1,636 @@
    52.4 +/*
    52.5 +  Simple DirectMedia Layer
    52.6 +  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    52.7 +
    52.8 +  This software is provided 'as-is', without any express or implied
    52.9 +  warranty.  In no event will the authors be held liable for any damages
   52.10 +  arising from the use of this software.
   52.11 +
   52.12 +  Permission is granted to anyone to use this software for any purpose,
   52.13 +  including commercial applications, and to alter it and redistribute it
   52.14 +  freely, subject to the following restrictions:
   52.15 +
   52.16 +  1. The origin of this software must not be misrepresented; you must not
   52.17 +     claim that you wrote the original software. If you use this software
   52.18 +     in a product, an acknowledgment in the product documentation would be
   52.19 +     appreciated but is not required.
   52.20 +  2. Altered source versions must be plainly marked as such, and must not be
   52.21 +     misrepresented as being the original software.
   52.22 +  3. This notice may not be removed or altered from any source distribution.
   52.23 +*/
   52.24 +
   52.25 +#ifndef _SDL_BWin_h
   52.26 +#define _SDL_BWin_h
   52.27 +
   52.28 +#ifdef __cplusplus
   52.29 +extern "C" {
   52.30 +#endif
   52.31 +
   52.32 +#include "SDL_config.h"
   52.33 +#include "SDL.h"
   52.34 +#include "SDL_syswm.h"
   52.35 +#include "SDL_bframebuffer.h"
   52.36 +
   52.37 +#ifdef __cplusplus
   52.38 +}
   52.39 +#endif
   52.40 +
   52.41 +#include <stdio.h>
   52.42 +#include <AppKit.h>
   52.43 +#include <InterfaceKit.h>
   52.44 +#include <be/game/DirectWindow.h>
   52.45 +#if SDL_VIDEO_OPENGL
   52.46 +#include <be/opengl/GLView.h>
   52.47 +#endif
   52.48 +#include "SDL_events.h"
   52.49 +#include "../../main/haiku/SDL_BApp.h"
   52.50 +
   52.51 +
   52.52 +enum WinCommands {
   52.53 +    BWIN_MOVE_WINDOW,
   52.54 +    BWIN_RESIZE_WINDOW,
   52.55 +    BWIN_SHOW_WINDOW,
   52.56 +    BWIN_HIDE_WINDOW,
   52.57 +    BWIN_MAXIMIZE_WINDOW,
   52.58 +    BWIN_MINIMIZE_WINDOW,
   52.59 +    BWIN_RESTORE_WINDOW,
   52.60 +    BWIN_SET_TITLE,
   52.61 +    BWIN_SET_BORDERED,
   52.62 +    BWIN_FULLSCREEN
   52.63 +};
   52.64 +
   52.65 +
   52.66 +class SDL_BWin:public BDirectWindow
   52.67 +{
   52.68 +  public:
   52.69 +    /* Constructor/Destructor */
   52.70 +    SDL_BWin(BRect bounds, window_look look, uint32 flags)
   52.71 +        : BDirectWindow(bounds, "Untitled", look, B_NORMAL_WINDOW_FEEL, flags)
   52.72 +    {
   52.73 +        _last_buttons = 0;
   52.74 +
   52.75 +#if SDL_VIDEO_OPENGL
   52.76 +        _SDL_GLView = NULL;
   52.77 +#endif
   52.78 +        _shown = false;
   52.79 +        _inhibit_resize = false;
   52.80 +        _mouse_focused = false;
   52.81 +        _prev_frame = NULL;
   52.82 +
   52.83 +        /* Handle framebuffer stuff */
   52.84 +        _connected = _connection_disabled = false;
   52.85 +        _buffer_created = _buffer_dirty = false;
   52.86 +        _trash_window_buffer = false;
   52.87 +        _buffer_locker = new BLocker();
   52.88 +        _bitmap = NULL;
   52.89 +#ifdef DRAWTHREAD
   52.90 +        _draw_thread_id = spawn_thread(BE_DrawThread, "drawing_thread",
   52.91 +                            B_NORMAL_PRIORITY, (void*) this);
   52.92 +        resume_thread(_draw_thread_id);
   52.93 +#endif
   52.94 +    }
   52.95 +
   52.96 +    virtual ~ SDL_BWin()
   52.97 +    {
   52.98 +        Lock();
   52.99 +        _connection_disabled = true;
  52.100 +        int32 result;
  52.101 +
  52.102 +#if SDL_VIDEO_OPENGL
  52.103 +        if (_SDL_GLView) {
  52.104 +            _SDL_GLView->UnlockGL();
  52.105 +            RemoveChild(_SDL_GLView);   /* Why was this outside the if
  52.106 +                                            statement before? */
  52.107 +        }
  52.108 +
  52.109 +#endif
  52.110 +        Unlock();
  52.111 +#if SDL_VIDEO_OPENGL
  52.112 +        if (_SDL_GLView) {
  52.113 +            delete _SDL_GLView;
  52.114 +        }
  52.115 +#endif
  52.116 +
  52.117 +        /* Clean up framebuffer stuff */
  52.118 +        _buffer_locker->Lock();
  52.119 +#ifdef DRAWTHREAD
  52.120 +        wait_for_thread(_draw_thread_id, &result);
  52.121 +#endif
  52.122 +        free(_clips);
  52.123 +        delete _buffer_locker;
  52.124 +    }
  52.125 +
  52.126 +
  52.127 +    /* * * * * OpenGL functionality * * * * */
  52.128 +#if SDL_VIDEO_OPENGL
  52.129 +    virtual BGLView *CreateGLView(Uint32 gl_flags) {
  52.130 +        Lock();
  52.131 +        if (_SDL_GLView == NULL) {
  52.132 +            _SDL_GLView = new BGLView(Bounds(), "SDL GLView",
  52.133 +                                     B_FOLLOW_ALL_SIDES,
  52.134 +                                     (B_WILL_DRAW | B_FRAME_EVENTS),
  52.135 +                                     gl_flags);
  52.136 +        }
  52.137 +        AddChild(_SDL_GLView);
  52.138 +        _SDL_GLView->EnableDirectMode(true);
  52.139 +        _SDL_GLView->LockGL();  /* "New" GLViews are created */
  52.140 +        Unlock();
  52.141 +        return (_SDL_GLView);
  52.142 +    }
  52.143 +
  52.144 +    virtual void RemoveGLView() {
  52.145 +        Lock();
  52.146 +        if(_SDL_GLView) {
  52.147 +            _SDL_GLView->UnlockGL();
  52.148 +            RemoveChild(_SDL_GLView);
  52.149 +        }
  52.150 +        Unlock();
  52.151 +    }
  52.152 +
  52.153 +    virtual void SwapBuffers(void) {
  52.154 +        _SDL_GLView->UnlockGL();
  52.155 +        _SDL_GLView->LockGL();
  52.156 +        _SDL_GLView->SwapBuffers();
  52.157 +    }
  52.158 +#endif
  52.159 +
  52.160 +    /* * * * * Framebuffering* * * * */
  52.161 +    virtual void DirectConnected(direct_buffer_info *info) {
  52.162 +        if(!_connected && _connection_disabled) {
  52.163 +            return;
  52.164 +        }
  52.165 +
  52.166 +        /* Determine if the pixel buffer is usable after this update */
  52.167 +        _trash_window_buffer =      _trash_window_buffer
  52.168 +                                || ((info->buffer_state & B_BUFFER_RESIZED)
  52.169 +                                || (info->buffer_state & B_BUFFER_RESET)
  52.170 +                                || (info->driver_state == B_MODE_CHANGED));
  52.171 +        LockBuffer();
  52.172 +
  52.173 +        switch(info->buffer_state & B_DIRECT_MODE_MASK) {
  52.174 +        case B_DIRECT_START:
  52.175 +            _connected = true;
  52.176 +
  52.177 +        case B_DIRECT_MODIFY:
  52.178 +            if(_clips) {
  52.179 +                free(_clips);
  52.180 +                _clips = NULL;
  52.181 +            }
  52.182 +
  52.183 +            _num_clips = info->clip_list_count;
  52.184 +            _clips = (clipping_rect *)malloc(_num_clips*sizeof(clipping_rect));
  52.185 +            if(_clips) {
  52.186 +                memcpy(_clips, info->clip_list,
  52.187 +                    _num_clips*sizeof(clipping_rect));
  52.188 +
  52.189 +                _bits = (uint8*) info->bits;
  52.190 +                _row_bytes = info->bytes_per_row;
  52.191 +                _bounds = info->window_bounds;
  52.192 +                _bytes_per_px = info->bits_per_pixel / 8;
  52.193 +                _buffer_dirty = true;
  52.194 +            }
  52.195 +            break;
  52.196 +
  52.197 +        case B_DIRECT_STOP:
  52.198 +            _connected = false;
  52.199 +            break;
  52.200 +        }
  52.201 +#if SDL_VIDEO_OPENGL
  52.202 +        if(_SDL_GLView) {
  52.203 +            _SDL_GLView->DirectConnected(info);
  52.204 +        }
  52.205 +#endif
  52.206 +
  52.207 +
  52.208 +        /* Call the base object directconnected */
  52.209 +        BDirectWindow::DirectConnected(info);
  52.210 +
  52.211 +        UnlockBuffer();
  52.212 +
  52.213 +    }
  52.214 +
  52.215 +
  52.216 +
  52.217 +
  52.218 +    /* * * * * Event sending * * * * */
  52.219 +    /* Hook functions */
  52.220 +    virtual void FrameMoved(BPoint origin) {
  52.221 +        /* Post a message to the BApp so that it can handle the window event */
  52.222 +        BMessage msg(BAPP_WINDOW_MOVED);
  52.223 +        msg.AddInt32("window-x", (int)origin.x);
  52.224 +        msg.AddInt32("window-y", (int)origin.y);
  52.225 +        _PostWindowEvent(msg);
  52.226 +
  52.227 +        /* Perform normal hook operations */
  52.228 +        BDirectWindow::FrameMoved(origin);
  52.229 +    }
  52.230 +
  52.231 +    virtual void FrameResized(float width, float height) {
  52.232 +        /* Post a message to the BApp so that it can handle the window event */
  52.233 +        BMessage msg(BAPP_WINDOW_RESIZED);
  52.234 +
  52.235 +        msg.AddInt32("window-w", (int)width + 1);
  52.236 +        msg.AddInt32("window-h", (int)height + 1);
  52.237 +        _PostWindowEvent(msg);
  52.238 +
  52.239 +        /* Perform normal hook operations */
  52.240 +        BDirectWindow::FrameResized(width, height);
  52.241 +    }
  52.242 +
  52.243 +    virtual bool QuitRequested() {
  52.244 +        BMessage msg(BAPP_WINDOW_CLOSE_REQUESTED);
  52.245 +        _PostWindowEvent(msg);
  52.246 +
  52.247 +        /* We won't allow a quit unless asked by DestroyWindow() */
  52.248 +        return false;
  52.249 +    }
  52.250 +
  52.251 +    virtual void WindowActivated(bool active) {
  52.252 +        BMessage msg(BAPP_KEYBOARD_FOCUS);  /* Mouse focus sold separately */
  52.253 +        _PostWindowEvent(msg);
  52.254 +    }
  52.255 +
  52.256 +    virtual void Zoom(BPoint origin,
  52.257 +                float width,
  52.258 +                float height) {
  52.259 +        BMessage msg(BAPP_MAXIMIZE);    /* Closest thing to maximization Haiku has */
  52.260 +        _PostWindowEvent(msg);
  52.261 +
  52.262 +        /* Before the window zooms, record its size */
  52.263 +        if( !_prev_frame )
  52.264 +            _prev_frame = new BRect(Frame());
  52.265 +
  52.266 +        /* Perform normal hook operations */
  52.267 +        BDirectWindow::Zoom(origin, width, height);
  52.268 +    }
  52.269 +
  52.270 +    /* Member functions */
  52.271 +    virtual void Show() {
  52.272 +        while(IsHidden()) {
  52.273 +            BDirectWindow::Show();
  52.274 +        }
  52.275 +        _shown = true;
  52.276 +
  52.277 +        BMessage msg(BAPP_SHOW);
  52.278 +        _PostWindowEvent(msg);
  52.279 +    }
  52.280 +
  52.281 +    virtual void Hide() {
  52.282 +        BDirectWindow::Hide();
  52.283 +        _shown = false;
  52.284 +
  52.285 +        BMessage msg(BAPP_HIDE);
  52.286 +        _PostWindowEvent(msg);
  52.287 +    }
  52.288 +
  52.289 +    virtual void Minimize(bool minimize) {
  52.290 +        BDirectWindow::Minimize(minimize);
  52.291 +        int32 minState = (minimize ? BAPP_MINIMIZE : BAPP_RESTORE);
  52.292 +
  52.293 +        BMessage msg(minState);
  52.294 +        _PostWindowEvent(msg);
  52.295 +    }
  52.296 +
  52.297 +
  52.298 +    /* BView message interruption */
  52.299 +    virtual void DispatchMessage(BMessage * msg, BHandler * target)
  52.300 +    {
  52.301 +        BPoint where;   /* Used by mouse moved */
  52.302 +        int32 buttons;  /* Used for mouse button events */
  52.303 +        int32 key;      /* Used for key events */
  52.304 +
  52.305 +        switch (msg->what) {
  52.306 +        case B_MOUSE_MOVED:
  52.307 +            int32 transit;
  52.308 +            if (msg->FindPoint("where", &where) == B_OK
  52.309 +                && msg->FindInt32("be:transit", &transit) == B_OK) {
  52.310 +                _MouseMotionEvent(where, transit);
  52.311 +            }
  52.312 +
  52.313 +            /* FIXME: Apparently a button press/release event might be dropped
  52.314 +               if made before before a different button is released.  Does
  52.315 +               B_MOUSE_MOVED have the data needed to check if a mouse button
  52.316 +               state has changed? */
  52.317 +            if (msg->FindInt32("buttons", &buttons) == B_OK) {
  52.318 +                _MouseButtonEvent(buttons);
  52.319 +            }
  52.320 +            break;
  52.321 +
  52.322 +        case B_MOUSE_DOWN:
  52.323 +        case B_MOUSE_UP:
  52.324 +            /* _MouseButtonEvent() detects any and all buttons that may have
  52.325 +               changed state, as well as that button's new state */
  52.326 +            if (msg->FindInt32("buttons", &buttons) == B_OK) {
  52.327 +                _MouseButtonEvent(buttons);
  52.328 +            }
  52.329 +            break;
  52.330 +
  52.331 +        case B_MOUSE_WHEEL_CHANGED:
  52.332 +            float x, y;
  52.333 +            if (msg->FindFloat("be:wheel_delta_x", &x) == B_OK
  52.334 +                && msg->FindFloat("be:wheel_delta_y", &y) == B_OK) {
  52.335 +                    _MouseWheelEvent((int)x, (int)y);
  52.336 +            }
  52.337 +            break;
  52.338 +
  52.339 +        case B_KEY_DOWN:
  52.340 +        case B_UNMAPPED_KEY_DOWN:      /* modifier keys are unmapped */
  52.341 +            if (msg->FindInt32("key", &key) == B_OK) {
  52.342 +                _KeyEvent((SDL_Scancode)key, SDL_PRESSED);
  52.343 +            }
  52.344 +            break;
  52.345 +
  52.346 +        case B_KEY_UP:
  52.347 +        case B_UNMAPPED_KEY_UP:        /* modifier keys are unmapped */
  52.348 +            if (msg->FindInt32("key", &key) == B_OK) {
  52.349 +                _KeyEvent(key, SDL_RELEASED);
  52.350 +            }
  52.351 +            break;
  52.352 +
  52.353 +        default:
  52.354 +            /* move it after switch{} so it's always handled
  52.355 +               that way we keep Haiku features like:
  52.356 +               - CTRL+Q to close window (and other shortcuts)
  52.357 +               - PrintScreen to make screenshot into /boot/home
  52.358 +               - etc.. */
  52.359 +            /* BDirectWindow::DispatchMessage(msg, target); */
  52.360 +            break;
  52.361 +        }
  52.362 +
  52.363 +        BDirectWindow::DispatchMessage(msg, target);
  52.364 +    }
  52.365 +
  52.366 +    /* Handle command messages */
  52.367 +    virtual void MessageReceived(BMessage* message) {
  52.368 +        switch (message->what) {
  52.369 +            /* Handle commands from SDL */
  52.370 +            case BWIN_SET_TITLE:
  52.371 +                _SetTitle(message);
  52.372 +                break;
  52.373 +            case BWIN_MOVE_WINDOW:
  52.374 +                _MoveTo(message);
  52.375 +                break;
  52.376 +            case BWIN_RESIZE_WINDOW:
  52.377 +                _ResizeTo(message);
  52.378 +                break;
  52.379 +            case BWIN_SET_BORDERED:
  52.380 +                _SetBordered(message);
  52.381 +                break;
  52.382 +            case BWIN_SHOW_WINDOW:
  52.383 +                Show();
  52.384 +                break;
  52.385 +            case BWIN_HIDE_WINDOW:
  52.386 +                Hide();
  52.387 +                break;
  52.388 +            case BWIN_MAXIMIZE_WINDOW:
  52.389 +                BWindow::Zoom();
  52.390 +                break;
  52.391 +            case BWIN_MINIMIZE_WINDOW:
  52.392 +                Minimize(true);
  52.393 +                break;
  52.394 +            case BWIN_RESTORE_WINDOW:
  52.395 +                _Restore();
  52.396 +                break;
  52.397 +            case BWIN_FULLSCREEN:
  52.398 +                _SetFullScreen(message);
  52.399 +                break;
  52.400 +            default:
  52.401 +                /* Perform normal message handling */
  52.402 +                BDirectWindow::MessageReceived(message);
  52.403 +                break;
  52.404 +        }
  52.405 +
  52.406 +    }
  52.407 +
  52.408 +
  52.409 +
  52.410 +    /* Accessor methods */
  52.411 +    bool IsShown() { return _shown; }
  52.412 +    int32 GetID() { return _id; }
  52.413 +    uint32 GetRowBytes() { return _row_bytes; }
  52.414 +    int32 GetFbX() { return _bounds.left; }
  52.415 +    int32 GetFbY() { return _bounds.top; }
  52.416 +    bool ConnectionEnabled() { return !_connection_disabled; }
  52.417 +    bool Connected() { return _connected; }
  52.418 +    clipping_rect *GetClips() { return _clips; }
  52.419 +    int32 GetNumClips() { return _num_clips; }
  52.420 +    uint8* GetBufferPx() { return _bits; }
  52.421 +    int32 GetBytesPerPx() { return _bytes_per_px; }
  52.422 +    bool CanTrashWindowBuffer() { return _trash_window_buffer; }
  52.423 +    bool BufferExists() { return _buffer_created; }
  52.424 +    bool BufferIsDirty() { return _buffer_dirty; }
  52.425 +    BBitmap *GetBitmap() { return _bitmap; }
  52.426 +#if SDL_VIDEO_OPENGL
  52.427 +    BGLView *GetGLView() { return _SDL_GLView; }
  52.428 +#endif
  52.429 +
  52.430 +    /* Setter methods */
  52.431 +    void SetID(int32 id) { _id = id; }
  52.432 +    void SetBufferExists(bool bufferExists) { _buffer_created = bufferExists; }
  52.433 +    void LockBuffer() { _buffer_locker->Lock(); }
  52.434 +    void UnlockBuffer() { _buffer_locker->Unlock(); }
  52.435 +    void SetBufferDirty(bool bufferDirty) { _buffer_dirty = bufferDirty; }
  52.436 +    void SetTrashBuffer(bool trash) { _trash_window_buffer = trash;     }
  52.437 +    void SetBitmap(BBitmap *bitmap) { _bitmap = bitmap; }
  52.438 +
  52.439 +
  52.440 +private:
  52.441 +    /* Event redirection */
  52.442 +    void _MouseMotionEvent(BPoint &where, int32 transit) {
  52.443 +        if(transit == B_EXITED_VIEW) {
  52.444 +            /* Change mouse focus */
  52.445 +            if(_mouse_focused) {
  52.446 +                _MouseFocusEvent(false);
  52.447 +            }
  52.448 +        } else {
  52.449 +            /* Change mouse focus */
  52.450 +            if (!_mouse_focused) {
  52.451 +                _MouseFocusEvent(true);
  52.452 +            }
  52.453 +            BMessage msg(BAPP_MOUSE_MOVED);
  52.454 +            msg.AddInt32("x", (int)where.x);
  52.455 +            msg.AddInt32("y", (int)where.y);
  52.456 +
  52.457 +            _PostWindowEvent(msg);
  52.458 +        }
  52.459 +    }
  52.460 +
  52.461 +    void _MouseFocusEvent(bool focusGained) {
  52.462 +        _mouse_focused = focusGained;
  52.463 +        BMessage msg(BAPP_MOUSE_FOCUS);
  52.464 +        msg.AddBool("focusGained", focusGained);
  52.465 +        _PostWindowEvent(msg);
  52.466 +
  52.467 +/* FIXME: Why were these here?
  52.468 + if false: be_app->SetCursor(B_HAND_CURSOR);
  52.469 + if true:  SDL_SetCursor(NULL); */
  52.470 +    }
  52.471 +
  52.472 +    void _MouseButtonEvent(int32 buttons) {
  52.473 +        int32 buttonStateChange = buttons ^ _last_buttons;
  52.474 +
  52.475 +        /* Make sure at least one button has changed state */
  52.476 +        if( !(buttonStateChange) ) {
  52.477 +            return;
  52.478 +        }
  52.479 +
  52.480 +        /* Add any mouse button events */
  52.481 +        if(buttonStateChange & B_PRIMARY_MOUSE_BUTTON) {
  52.482 +            _SendMouseButton(SDL_BUTTON_LEFT, buttons &
  52.483 +                B_PRIMARY_MOUSE_BUTTON);
  52.484 +        }
  52.485 +        if(buttonStateChange & B_SECONDARY_MOUSE_BUTTON) {
  52.486 +            _SendMouseButton(SDL_BUTTON_RIGHT, buttons &
  52.487 +                B_PRIMARY_MOUSE_BUTTON);
  52.488 +        }
  52.489 +        if(buttonStateChange & B_TERTIARY_MOUSE_BUTTON) {
  52.490 +            _SendMouseButton(SDL_BUTTON_MIDDLE, buttons &
  52.491 +                B_PRIMARY_MOUSE_BUTTON);
  52.492 +        }
  52.493 +
  52.494 +        _last_buttons = buttons;
  52.495 +    }
  52.496 +
  52.497 +    void _SendMouseButton(int32 button, int32 state) {
  52.498 +        BMessage msg(BAPP_MOUSE_BUTTON);
  52.499 +        msg.AddInt32("button-id", button);
  52.500 +        msg.AddInt32("button-state", state);
  52.501 +        _PostWindowEvent(msg);
  52.502 +    }
  52.503 +
  52.504 +    void _MouseWheelEvent(int32 x, int32 y) {
  52.505 +        /* Create a message to pass along to the BeApp thread */
  52.506 +        BMessage msg(BAPP_MOUSE_WHEEL);
  52.507 +        msg.AddInt32("xticks", x);
  52.508 +        msg.AddInt32("yticks", y);
  52.509 +        _PostWindowEvent(msg);
  52.510 +    }
  52.511 +
  52.512 +    void _KeyEvent(int32 keyCode, int32 keyState) {
  52.513 +        /* Create a message to pass along to the BeApp thread */
  52.514 +        BMessage msg(BAPP_KEY);
  52.515 +        msg.AddInt32("key-state", keyState);
  52.516 +        msg.AddInt32("key-scancode", keyCode);
  52.517 +        be_app->PostMessage(&msg);
  52.518 +        /* Apparently SDL only uses the scancode */
  52.519 +    }
  52.520 +
  52.521 +    void _RepaintEvent() {
  52.522 +        /* Force a repaint: Call the SDL exposed event */
  52.523 +        BMessage msg(BAPP_REPAINT);
  52.524 +        _PostWindowEvent(msg);
  52.525 +    }
  52.526 +    void _PostWindowEvent(BMessage &msg) {
  52.527 +        msg.AddInt32("window-id", _id);
  52.528 +        be_app->PostMessage(&msg);
  52.529 +    }
  52.530 +
  52.531 +    /* Command methods (functions called upon by SDL) */
  52.532 +    void _SetTitle(BMessage *msg) {
  52.533 +        const char *title;
  52.534 +        if(
  52.535 +            msg->FindString("window-title", &title) != B_OK
  52.536 +        ) {
  52.537 +            return;
  52.538 +        }
  52.539 +        SetTitle(title);
  52.540 +    }
  52.541 +
  52.542 +    void _MoveTo(BMessage *msg) {
  52.543 +        int32 x, y;
  52.544 +        if(
  52.545 +            msg->FindInt32("window-x", &x) != B_OK ||
  52.546 +            msg->FindInt32("window-y", &y) != B_OK
  52.547 +        ) {
  52.548 +            return;
  52.549 +        }
  52.550 +        MoveTo(x, y);
  52.551 +    }
  52.552 +
  52.553 +    void _ResizeTo(BMessage *msg) {
  52.554 +        int32 w, h;
  52.555 +        if(
  52.556 +            msg->FindInt32("window-w", &w) != B_OK ||
  52.557 +            msg->FindInt32("window-h", &h) != B_OK
  52.558 +        ) {
  52.559 +            return;
  52.560 +        }
  52.561 +        ResizeTo(w, h);
  52.562 +    }
  52.563 +
  52.564 +    void _SetBordered(BMessage *msg) {
  52.565 +        bool bEnabled;
  52.566 +        if(msg->FindBool("window-border", &bEnabled) != B_OK) {
  52.567 +            return;
  52.568 +        }
  52.569 +        SetLook(bEnabled ? B_BORDERED_WINDOW_LOOK : B_NO_BORDER_WINDOW_LOOK);
  52.570 +    }
  52.571 +
  52.572 +    void _Restore() {
  52.573 +        if(IsMinimized()) {
  52.574 +            Minimize(false);
  52.575 +        } else if(IsHidden()) {
  52.576 +            Show();
  52.577 +        } else if(_prev_frame != NULL) {    /* Zoomed */
  52.578 +            MoveTo(_prev_frame->left, _prev_frame->top);
  52.579 +            ResizeTo(_prev_frame->Width(), _prev_frame->Height());
  52.580 +        }
  52.581 +    }
  52.582 +
  52.583 +    void _SetFullScreen(BMessage *msg) {
  52.584 +        bool fullscreen;
  52.585 +        if(
  52.586 +            msg->FindBool("fullscreen", &fullscreen) != B_OK
  52.587 +        ) {
  52.588 +            return;
  52.589 +        }
  52.590 +        SetFullScreen(fullscreen);
  52.591 +    }
  52.592 +
  52.593 +    /* Members */
  52.594 +#if SDL_VIDEO_OPENGL
  52.595 +    BGLView * _SDL_GLView;
  52.596 +#endif
  52.597 +
  52.598 +    int32 _last_buttons;
  52.599 +    int32 _id;  /* Window id used by SDL_BApp */
  52.600 +    bool  _mouse_focused;       /* Does this window have mouse focus? */
  52.601 +    bool  _shown;
  52.602 +    bool  _inhibit_resize;
  52.603 +
  52.604 +    BRect *_prev_frame; /* Previous position and size of the window */
  52.605 +
  52.606 +    /* Framebuffer members */
  52.607 +    bool            _connected,
  52.608 +                    _connection_disabled,
  52.609 +                    _buffer_created,
  52.610 +                    _buffer_dirty,
  52.611 +                    _trash_window_buffer;
  52.612 +    uint8          *_bits;
  52.613 +    uint32          _row_bytes;
  52.614 +    clipping_rect   _bounds;
  52.615 +    BLocker        *_buffer_locker;
  52.616 +    clipping_rect  *_clips;
  52.617 +    int32           _num_clips;
  52.618 +    int32           _bytes_per_px;
  52.619 +    thread_id       _draw_thread_id;
  52.620 +
  52.621 +    BBitmap        *_bitmap;
  52.622 +};
  52.623 +
  52.624 +
  52.625 +/* FIXME:
  52.626 + * An explanation of framebuffer flags.
  52.627 + *
  52.628 + * _connected -           Original variable used to let the drawing thread know
  52.629 + *                         when changes are being made to the other framebuffer
  52.630 + *                         members.
  52.631 + * _connection_disabled - Used to signal to the drawing thread that the window
  52.632 + *                         is closing, and the thread should exit.
  52.633 + * _buffer_created -      True if the current buffer is valid
  52.634 + * _buffer_dirty -        True if the window should be redrawn.
  52.635 + * _trash_window_buffer - True if the window buffer needs to be trashed partway
  52.636 + *                         through a draw cycle.  Occurs when the previous
  52.637 + *                         buffer provided by DirectConnected() is invalidated.
  52.638 + */
  52.639 +#endif
    53.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    53.2 +++ b/src/video/haiku/SDL_bclipboard.cc	Thu Nov 14 11:51:24 2013 -0500
    53.3 @@ -0,0 +1,95 @@
    53.4 +/*
    53.5 +  Simple DirectMedia Layer
    53.6 +  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    53.7 +
    53.8 +  This software is provided 'as-is', without any express or implied
    53.9 +  warranty.  In no event will the authors be held liable for any damages
   53.10 +  arising from the use of this software.
   53.11 +
   53.12 +  Permission is granted to anyone to use this software for any purpose,
   53.13 +  including commercial applications, and to alter it and redistribute it
   53.14 +  freely, subject to the following restrictions:
   53.15 +
   53.16 +  1. The origin of this software must not be misrepresented; you must not
   53.17 +     claim that you wrote the original software. If you use this software
   53.18 +     in a product, an acknowledgment in the product documentation would be
   53.19 +     appreciated but is not required.
   53.20 +  2. Altered source versions must be plainly marked as such, and must not be
   53.21 +     misrepresented as being the original software.
   53.22 +  3. This notice may not be removed or altered from any source distribution.
   53.23 +*/
   53.24 +#include "SDL_config.h"
   53.25 +
   53.26 +#if SDL_VIDEO_DRIVER_HAIKU
   53.27 +
   53.28 +/* BWindow based framebuffer implementation */
   53.29 +
   53.30 +#include <unistd.h>
   53.31 +#include <TypeConstants.h>
   53.32 +
   53.33 +#include "SDL_BWin.h"
   53.34 +#include "SDL_timer.h"
   53.35 +#include "../SDL_sysvideo.h"
   53.36 +
   53.37 +#ifdef __cplusplus
   53.38 +extern "C" {
   53.39 +#endif
   53.40 +
   53.41 +int BE_SetClipboardText(_THIS, const char *text) {
   53.42 +	BMessage *clip = NULL;
   53.43 +	if(be_clipboard->Lock()) {
   53.44 +		be_clipboard->Clear();
   53.45 +		if((clip = be_clipboard->Data())) {
   53.46 +			/* Presumably the string of characters is ascii-format */
   53.47 +			ssize_t asciiLength = 0;
   53.48 +			for(; text[asciiLength] != 0; ++asciiLength) {}
   53.49 +			clip->AddData("text/plain", B_MIME_TYPE, &text, asciiLength);
   53.50 +			be_clipboard->Commit();
   53.51 +		}
   53.52 +		be_clipboard->Unlock();
   53.53 +	}
   53.54 +	return 0;
   53.55 +}
   53.56 +
   53.57 +char *BE_GetClipboardText(_THIS) {
   53.58 +	BMessage *clip = NULL;
   53.59 +	const char *text = NULL;	
   53.60 +	ssize_t length;
   53.61 +	char *result;
   53.62 +	if(be_clipboard->Lock()) {
   53.63 +		if((clip = be_clipboard->Data())) {
   53.64 +			/* Presumably the string of characters is ascii-format */
   53.65 +			clip->FindData("text/plain", B_MIME_TYPE, (const void**)&text,
   53.66 +				&length);
   53.67 +		} else {
   53.68 +			be_clipboard->Unlock();
   53.69 +		}
   53.70 +		be_clipboard->Unlock();
   53.71 +	} 
   53.72 +	
   53.73 +	if (!text) {
   53.74 +		result = SDL_strdup("");
   53.75 +	} else {
   53.76 +		/* Copy the data and pass on to SDL */
   53.77 +		result = (char*)SDL_calloc(1, sizeof(char*)*length);
   53.78 +		SDL_strlcpy(result, text, length);
   53.79 +	}
   53.80 +	
   53.81 +	return result;
   53.82 +}
   53.83 +
   53.84 +SDL_bool BE_HasClipboardText(_THIS) {
   53.85 +	SDL_bool result = SDL_FALSE;
   53.86 +	char *text = BE_GetClipboardText(_this);
   53.87 +	if (text) {
   53.88 +		result = text[0] != '\0' ? SDL_TRUE : SDL_FALSE;
   53.89 +		SDL_free(text);
   53.90 +	} 
   53.91 +	return result;
   53.92 +}
   53.93 +
   53.94 +#ifdef __cplusplus
   53.95 +}
   53.96 +#endif
   53.97 +
   53.98 +#endif /* SDL_VIDEO_DRIVER_HAIKU */
    54.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    54.2 +++ b/src/video/haiku/SDL_bclipboard.h	Thu Nov 14 11:51:24 2013 -0500
    54.3 @@ -0,0 +1,31 @@
    54.4 +/*
    54.5 +  Simple DirectMedia Layer
    54.6 +  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    54.7 +
    54.8 +  This software is provided 'as-is', without any express or implied
    54.9 +  warranty.  In no event will the authors be held liable for any damages
   54.10 +  arising from the use of this software.
   54.11 +
   54.12 +  Permission is granted to anyone to use this software for any purpose,
   54.13 +  including commercial applications, and to alter it and redistribute it
   54.14 +  freely, subject to the following restrictions:
   54.15 +
   54.16 +  1. The origin of this software must not be misrepresented; you must not
   54.17 +     claim that you wrote the original software. If you use this software
   54.18 +     in a product, an acknowledgment in the product documentation would be
   54.19 +     appreciated but is not required.
   54.20 +  2. Altered source versions must be plainly marked as such, and must not be
   54.21 +     misrepresented as being the original software.
   54.22 +  3. This notice may not be removed or altered from any source distribution.
   54.23 +*/
   54.24 +
   54.25 +#include "SDL_config.h"
   54.26 +
   54.27 +#ifndef SDL_BCLIPBOARD_H
   54.28 +#define SDL_BCLIPBOARD_H
   54.29 +
   54.30 +extern int BE_SetClipboardText(_THIS, const char *text);
   54.31 +extern char *BE_GetClipboardText(_THIS);
   54.32 +extern SDL_bool BE_HasClipboardText(_THIS);
   54.33 +
   54.34 +#endif
    55.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    55.2 +++ b/src/video/haiku/SDL_bevents.cc	Thu Nov 14 11:51:24 2013 -0500
    55.3 @@ -0,0 +1,39 @@
    55.4 +/*
    55.5 +  Simple DirectMedia Layer
    55.6 +  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    55.7 +
    55.8 +  This software is provided 'as-is', without any express or implied
    55.9 +  warranty.  In no event will the authors be held liable for any damages
   55.10 +  arising from the use of this software.
   55.11 +
   55.12 +  Permission is granted to anyone to use this software for any purpose,
   55.13 +  including commercial applications, and to alter it and redistribute it
   55.14 +  freely, subject to the following restrictions:
   55.15 +
   55.16 +  1. The origin of this software must not be misrepresented; you must not
   55.17 +     claim that you wrote the original software. If you use this software
   55.18 +     in a product, an acknowledgment in the product documentation would be
   55.19 +     appreciated but is not required.
   55.20 +  2. Altered source versions must be plainly marked as such, and must not be
   55.21 +     misrepresented as being the original software.
   55.22 +  3. This notice may not be removed or altered from any source distribution.
   55.23 +*/
   55.24 +#include "SDL_config.h"
   55.25 +
   55.26 +#if SDL_VIDEO_DRIVER_HAIKU
   55.27 +
   55.28 +#include "SDL_bevents.h"
   55.29 +
   55.30 +#ifdef __cplusplus
   55.31 +extern "C" {
   55.32 +#endif
   55.33 +
   55.34 +void BE_PumpEvents(_THIS) {
   55.35 +	/* Since the event thread is its own thread, this isn't really necessary */
   55.36 +}
   55.37 +
   55.38 +#ifdef __cplusplus
   55.39 +}
   55.40 +#endif
   55.41 +
   55.42 +#endif /* SDL_VIDEO_DRIVER_HAIKU */
    56.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    56.2 +++ b/src/video/haiku/SDL_bevents.h	Thu Nov 14 11:51:24 2013 -0500
    56.3 @@ -0,0 +1,37 @@
    56.4 +/*
    56.5 +  Simple DirectMedia Layer
    56.6 +  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    56.7 +
    56.8 +  This software is provided 'as-is', without any express or implied
    56.9 +  warranty.  In no event will the authors be held liable for any damages
   56.10 +  arising from the use of this software.
   56.11 +
   56.12 +  Permission is granted to anyone to use this software for any purpose,
   56.13 +  including commercial applications, and to alter it and redistribute it
   56.14 +  freely, subject to the following restrictions:
   56.15 +
   56.16 +  1. The origin of this software must not be misrepresented; you must not
   56.17 +     claim that you wrote the original software. If you use this software
   56.18 +     in a product, an acknowledgment in the product documentation would be
   56.19 +     appreciated but is not required.
   56.20 +  2. Altered source versions must be plainly marked as such, and must not be
   56.21 +     misrepresented as being the original software.
   56.22 +  3. This notice may not be removed or altered from any source distribution.
   56.23 +*/
   56.24 +
   56.25 +#ifndef SDL_BEVENTS_H
   56.26 +#define SDL_BEVENTS_H
   56.27 +
   56.28 +#include "../SDL_sysvideo.h"
   56.29 +
   56.30 +#ifdef __cplusplus
   56.31 +extern "C" {
   56.32 +#endif
   56.33 +
   56.34 +extern void BE_PumpEvents(_THIS);
   56.35 +
   56.36 +#ifdef __cplusplus
   56.37 +}
   56.38 +#endif
   56.39 +
   56.40 +#endif
    57.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    57.2 +++ b/src/video/haiku/SDL_bframebuffer.cc	Thu Nov 14 11:51:24 2013 -0500
    57.3 @@ -0,0 +1,254 @@
    57.4 +/*
    57.5 +  Simple DirectMedia Layer
    57.6 +  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    57.7 +
    57.8 +  This software is provided 'as-is', without any express or implied
    57.9 +  warranty.  In no event will the authors be held liable for any damages
   57.10 +  arising from the use of this software.
   57.11 +
   57.12 +  Permission is granted to anyone to use this software for any purpose,
   57.13 +  including commercial applications, and to alter it and redistribute it
   57.14 +  freely, subject to the following restrictions:
   57.15 +
   57.16 +  1. The origin of this software must not be misrepresented; you must not
   57.17 +     claim that you wrote the original software. If you use this software
   57.18 +     in a product, an acknowledgment in the product documentation would be
   57.19 +     appreciated but is not required.
   57.20 +  2. Altered source versions must be plainly marked as such, and must not be
   57.21 +     misrepresented as being the original software.
   57.22 +  3. This notice may not be removed or altered from any source distribution.
   57.23 +*/
   57.24 +#include "SDL_config.h"
   57.25 +
   57.26 +#if SDL_VIDEO_DRIVER_HAIKU
   57.27 +
   57.28 +#include "SDL_bframebuffer.h"
   57.29 +
   57.30 +#include <AppKit.h>
   57.31 +#include <InterfaceKit.h>
   57.32 +#include "SDL_bmodes.h"
   57.33 +#include "SDL_BWin.h"
   57.34 +
   57.35 +#include "../../main/haiku/SDL_BApp.h"
   57.36 +
   57.37 +#ifdef __cplusplus
   57.38 +extern "C" {
   57.39 +#endif
   57.40 +
   57.41 +int32 BE_UpdateOnce(SDL_Window *window);
   57.42 +
   57.43 +static SDL_INLINE SDL_BWin *_ToBeWin(SDL_Window *window) {
   57.44 +	return ((SDL_BWin*)(window->driverdata));
   57.45 +}
   57.46 +
   57.47 +static SDL_INLINE SDL_BApp *_GetBeApp() {
   57.48 +	return ((SDL_BApp*)be_app);
   57.49 +}
   57.50 +
   57.51 +int BE_CreateWindowFramebuffer(_THIS, SDL_Window * window,
   57.52 +                                       Uint32 * format,
   57.53 +                                       void ** pixels, int *pitch) {
   57.54 +	SDL_BWin *bwin = _ToBeWin(window);
   57.55 +	BScreen bscreen;
   57.56 +	if(!bscreen.IsValid()) {
   57.57 +		return -1;
   57.58 +	}
   57.59 +
   57.60 +	while(!bwin->Connected()) { snooze(100); }
   57.61 +	
   57.62 +	/* Make sure we have exclusive access to frame buffer data */
   57.63 +	bwin->LockBuffer();
   57.64 +
   57.65 +	/* format */
   57.66 +	display_mode bmode;
   57.67 +	bscreen.GetMode(&bmode);
   57.68 +	int32 bpp = BE_ColorSpaceToBitsPerPixel(bmode.space);
   57.69 +	*format = BE_BPPToSDLPxFormat(bpp);
   57.70 +
   57.71 +	/* Create the new bitmap object */
   57.72 +	BBitmap *bitmap = bwin->GetBitmap();
   57.73 +
   57.74 +	if(bitmap) {
   57.75 +		delete bitmap;
   57.76 +	}
   57.77 +	bitmap = new BBitmap(bwin->Bounds(), (color_space)bmode.space,
   57.78 +			false,	/* Views not accepted */
   57.79 +			true);	/* Contiguous memory required */
   57.80 +			
   57.81 +	if(bitmap->InitCheck() != B_OK) {
   57.82 +		return SDL_SetError("Could not initialize back buffer!\n");
   57.83 +	}
   57.84 +
   57.85 +
   57.86 +	bwin->SetBitmap(bitmap);
   57.87 +	
   57.88 +	/* Set the pixel pointer */
   57.89 +	*pixels = bitmap->Bits();
   57.90 +
   57.91 +	/* pitch = width of window, in bytes */
   57.92 +	*pitch = bitmap->BytesPerRow();
   57.93 +
   57.94 +	bwin->SetBufferExists(true);
   57.95 +	bwin->SetTrashBuffer(false);
   57.96 +	bwin->UnlockBuffer();
   57.97 +	return 0;
   57.98 +}
   57.99 +
  57.100 +
  57.101 +
  57.102 +int BE_UpdateWindowFramebuffer(_THIS, SDL_Window * window,
  57.103 +                                      const SDL_Rect * rects, int numrects) {
  57.104 +	if(!window)
  57.105 +		return 0;
  57.106 +
  57.107 +	SDL_BWin *bwin = _ToBeWin(window);
  57.108 +
  57.109 +#ifdef DRAWTHREAD	
  57.110 +	bwin->LockBuffer();
  57.111 +	bwin->SetBufferDirty(true);
  57.112 +	bwin->UnlockBuffer();
  57.113 +#else
  57.114 +	bwin->SetBufferDirty(true);
  57.115 +	BE_UpdateOnce(window);
  57.116 +#endif
  57.117 +
  57.118 +	return 0;
  57.119 +}
  57.120 +
  57.121 +int32 BE_DrawThread(void *data) {
  57.122 +	SDL_BWin *bwin = (SDL_BWin*)data;
  57.123 +	
  57.124 +	BScreen bscreen;
  57.125 +	if(!bscreen.IsValid()) {
  57.126 +		return -1;
  57.127 +	}
  57.128 +
  57.129 +	while(bwin->ConnectionEnabled()) {
  57.130 +		if( bwin->Connected() && bwin->BufferExists() && bwin->BufferIsDirty() ) {
  57.131 +			bwin->LockBuffer();
  57.132 +			BBitmap *bitmap = NULL;
  57.133 +			bitmap = bwin->GetBitmap();
  57.134 +			int32 windowPitch = bitmap->BytesPerRow();
  57.135 +			int32 bufferPitch = bwin->GetRowBytes();
  57.136 +			uint8 *windowpx;
  57.137 +			uint8 *bufferpx;
  57.138 +
  57.139 +			int32 BPP = bwin->GetBytesPerPx();
  57.140 +			int32 windowSub = bwin->GetFbX() * BPP +
  57.141 +						  bwin->GetFbY() * windowPitch;
  57.142 +			clipping_rect *clips = bwin->GetClips();
  57.143 +			int32 numClips = bwin->GetNumClips();
  57.144 +			int i, y;
  57.145 +
  57.146 +			/* Blit each clipping rectangle */
  57.147 +			bscreen.WaitForRetrace();
  57.148 +			for(i = 0; i < numClips; ++i) {
  57.149 +				clipping_rect rc = clips[i];
  57.150 +				/* Get addresses of the start of each clipping rectangle */
  57.151 +				int32 width = clips[i].right - clips[i].left + 1;
  57.152 +				int32 height = clips[i].bottom - clips[i].top + 1;
  57.153 +				bufferpx = bwin->GetBufferPx() + 
  57.154 +					clips[i].top * bufferPitch + clips[i].left * BPP;
  57.155 +				windowpx = (uint8*)bitmap->Bits() + 
  57.156 +					clips[i].top * windowPitch + clips[i].left * BPP -
  57.157 +					windowSub;
  57.158 +
  57.159 +				/* Copy each row of pixels from the window buffer into the frame
  57.160 +				   buffer */
  57.161 +				for(y = 0; y < height; ++y)
  57.162 +				{
  57.163 +
  57.164 +					if(bwin->CanTrashWindowBuffer()) {
  57.165 +						goto escape;	/* Break out before the buffer is killed */
  57.166 +					}
  57.167 +
  57.168 +					memcpy(bufferpx, windowpx, width * BPP);
  57.169 +					bufferpx += bufferPitch;
  57.170 +					windowpx += windowPitch;
  57.171 +				}
  57.172 +			}
  57.173 +
  57.174 +			bwin->SetBufferDirty(false);
  57.175 +escape:
  57.176 +			bwin->UnlockBuffer();
  57.177 +		} else {
  57.178 +			snooze(16000);
  57.179 +		}
  57.180 +	}
  57.181 +	
  57.182 +	return B_OK;
  57.183 +}
  57.184 +
  57.185 +void BE_DestroyWindowFramebuffer(_THIS, SDL_Window * window) {
  57.186 +	SDL_BWin *bwin = _ToBeWin(window);
  57.187 +	
  57.188 +	bwin->LockBuffer();
  57.189 +	
  57.190 +	/* Free and clear the window buffer */
  57.191 +	BBitmap *bitmap = bwin->GetBitmap();
  57.192 +	delete bitmap;
  57.193 +	bwin->SetBitmap(NULL);
  57.194 +	bwin->SetBufferExists(false);
  57.195 +	bwin->UnlockBuffer();
  57.196 +}
  57.197 +
  57.198 +
  57.199 +/*
  57.200 + * TODO:
  57.201 + * This was written to test if certain errors were caused by threading issues.
  57.202 + * The specific issues have since become rare enough that they may have been
  57.203 + * solved, but I doubt it- they were pretty sporadic before now.
  57.204 + */
  57.205 +int32 BE_UpdateOnce(SDL_Window *window) {
  57.206 +	SDL_BWin *bwin = _ToBeWin(window);
  57.207 +	BScreen bscreen;
  57.208 +	if(!bscreen.IsValid()) {
  57.209 +		return -1;
  57.210 +	}
  57.211 +
  57.212 +	if(bwin->ConnectionEnabled() && bwin->Connected()) {
  57.213 +		bwin->LockBuffer();
  57.214 +		int32 windowPitch = window->surface->pitch;
  57.215 +		int32 bufferPitch = bwin->GetRowBytes();
  57.216 +		uint8 *windowpx;
  57.217 +		uint8 *bufferpx;
  57.218 +
  57.219 +		int32 BPP = bwin->GetBytesPerPx();
  57.220 +		uint8 *windowBaseAddress = (uint8*)window->surface->pixels;
  57.221 +		int32 windowSub = bwin->GetFbX() * BPP +
  57.222 +						  bwin->GetFbY() * windowPitch;
  57.223 +		clipping_rect *clips = bwin->GetClips();
  57.224 +		int32 numClips = bwin->GetNumClips();
  57.225 +		int i, y;
  57.226 +
  57.227 +		/* Blit each clipping rectangle */
  57.228 +		bscreen.WaitForRetrace();
  57.229 +		for(i = 0; i < numClips; ++i) {
  57.230 +			clipping_rect rc = clips[i];
  57.231 +			/* Get addresses of the start of each clipping rectangle */
  57.232 +			int32 width = clips[i].right - clips[i].left + 1;
  57.233 +			int32 height = clips[i].bottom - clips[i].top + 1;
  57.234 +			bufferpx = bwin->GetBufferPx() + 
  57.235 +				clips[i].top * bufferPitch + clips[i].left * BPP;
  57.236 +			windowpx = windowBaseAddress + 
  57.237 +				clips[i].top * windowPitch + clips[i].left * BPP - windowSub;
  57.238 +
  57.239 +			/* Copy each row of pixels from the window buffer into the frame
  57.240 +			   buffer */
  57.241 +			for(y = 0; y < height; ++y)
  57.242 +			{
  57.243 +				memcpy(bufferpx, windowpx, width * BPP);
  57.244 +				bufferpx += bufferPitch;
  57.245 +				windowpx += windowPitch;
  57.246 +			}
  57.247 +		}
  57.248 +		bwin->UnlockBuffer();
  57.249 +	}
  57.250 +	return 0;
  57.251 +}
  57.252 +
  57.253 +#ifdef __cplusplus
  57.254 +}
  57.255 +#endif
  57.256 +
  57.257 +#endif /* SDL_VIDEO_DRIVER_HAIKU */
    58.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    58.2 +++ b/src/video/haiku/SDL_bframebuffer.h	Thu Nov 14 11:51:24 2013 -0500
    58.3 @@ -0,0 +1,45 @@
    58.4 +/*
    58.5 +  Simple DirectMedia Layer
    58.6 +  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    58.7 +
    58.8 +  This software is provided 'as-is', without any express or implied
    58.9 +  warranty.  In no event will the authors be held liable for any damages
   58.10 +  arising from the use of this software.
   58.11 +
   58.12 +  Permission is granted to anyone to use this software for any purpose,
   58.13 +  including commercial applications, and to alter it and redistribute it
   58.14 +  freely, subject to the following restrictions:
   58.15 +
   58.16 +  1. The origin of this software must not be misrepresented; you must not
   58.17 +     claim that you wrote the original software. If you use this software
   58.18 +     in a product, an acknowledgment in the product documentation would be
   58.19 +     appreciated but is not required.
   58.20 +  2. Altered source versions must be plainly marked as such, and must not be
   58.21 +     misrepresented as being the original software.
   58.22 +  3. This notice may not be removed or altered from any source distribution.
   58.23 +*/
   58.24 +
   58.25 +#ifndef SDL_BFRAMEBUFFER_H
   58.26 +#define SDL_BFRAMEBUFFER_H
   58.27 +#include <SupportDefs.h>
   58.28 +#ifdef __cplusplus
   58.29 +extern "C" {
   58.30 +#endif
   58.31 +
   58.32 +#define DRAWTHREAD
   58.33 +
   58.34 +#include "../SDL_sysvideo.h"
   58.35 +
   58.36 +extern int BE_CreateWindowFramebuffer(_THIS, SDL_Window * window,
   58.37 +                                       Uint32 * format,
   58.38 +                                       void ** pixels, int *pitch);
   58.39 +extern int BE_UpdateWindowFramebuffer(_THIS, SDL_Window * window,
   58.40 +                                       const SDL_Rect * rects, int numrects);
   58.41 +extern void BE_DestroyWindowFramebuffer(_THIS, SDL_Window * window);
   58.42 +extern int32 BE_DrawThread(void *data);
   58.43 +
   58.44 +#ifdef __cplusplus
   58.45 +}
   58.46 +#endif
   58.47 +
   58.48 +#endif
    59.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    59.2 +++ b/src/video/haiku/SDL_bkeyboard.cc	Thu Nov 14 11:51:24 2013 -0500
    59.3 @@ -0,0 +1,188 @@
    59.4 +/*
    59.5 +  Simple DirectMedia Layer
    59.6 +  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    59.7 +
    59.8 +  This software is provided 'as-is', without any express or implied
    59.9 +  warranty.  In no event will the authors be held liable for any damages
   59.10 +  arising from the use of this software.
   59.11 +
   59.12 +  Permission is granted to anyone to use this software for any purpose,
   59.13 +  including commercial applications, and to alter it and redistribute it
   59.14 +  freely, subject to the following restrictions:
   59.15 +
   59.16 +  1. The origin of this software must not be misrepresented; you must not
   59.17 +     claim that you wrote the original software. If you use this software
   59.18 +     in a product, an acknowledgment in the product documentation would be
   59.19 +     appreciated but is not required.
   59.20 +  2. Altered source versions must be plainly marked as such, and must not be
   59.21 +     misrepresented as being the original software.
   59.22 +  3. This notice may not be removed or altered from any source distribution.
   59.23 +*/
   59.24 +#include "SDL_config.h"
   59.25 +
   59.26 +#if SDL_VIDEO_DRIVER_HAIKU
   59.27 +
   59.28 +#include <SupportDefs.h>
   59.29 +#include <support/UTF8.h>
   59.30 +
   59.31 +#ifdef __cplusplus
   59.32 +extern "C" {
   59.33 +#endif
   59.34 +
   59.35 +#include "SDL_events.h"
   59.36 +#include "SDL_keycode.h"
   59.37 +
   59.38 +#include "SDL_bkeyboard.h"
   59.39 +
   59.40 +
   59.41 +#define KEYMAP_SIZE 128
   59.42 +
   59.43 +
   59.44 +static SDL_Scancode keymap[KEYMAP_SIZE];
   59.45 +static int8 keystate[KEYMAP_SIZE];
   59.46 +
   59.47 +void BE_InitOSKeymap() {
   59.48 +		for( uint i = 0; i < SDL_TABLESIZE(keymap); ++i ) {
   59.49 +			keymap[i] = SDL_SCANCODE_UNKNOWN;
   59.50 +		}
   59.51 +
   59.52 +		for( uint i = 0; i < KEYMAP_SIZE; ++i ) {
   59.53 +			keystate[i] = SDL_RELEASED;
   59.54 +		}
   59.55 +
   59.56 +		keymap[0x01]		= SDL_GetScancodeFromKey(SDLK_ESCAPE);
   59.57 +		keymap[B_F1_KEY]	= SDL_GetScancodeFromKey(SDLK_F1);
   59.58 +		keymap[B_F2_KEY]	= SDL_GetScancodeFromKey(SDLK_F2);
   59.59 +		keymap[B_F3_KEY]	= SDL_GetScancodeFromKey(SDLK_F3);
   59.60 +		keymap[B_F4_KEY]	= SDL_GetScancodeFromKey(SDLK_F4);
   59.61 +		keymap[B_F5_KEY]	= SDL_GetScancodeFromKey(SDLK_F5);
   59.62 +		keymap[B_F6_KEY]	= SDL_GetScancodeFromKey(SDLK_F6);
   59.63 +		keymap[B_F7_KEY]	= SDL_GetScancodeFromKey(SDLK_F7);
   59.64 +		keymap[B_F8_KEY]	= SDL_GetScancodeFromKey(SDLK_F8);
   59.65 +		keymap[B_F9_KEY]	= SDL_GetScancodeFromKey(SDLK_F9);
   59.66 +		keymap[B_F10_KEY]	= SDL_GetScancodeFromKey(SDLK_F10);
   59.67 +		keymap[B_F11_KEY]	= SDL_GetScancodeFromKey(SDLK_F11);
   59.68 +		keymap[B_F12_KEY]	= SDL_GetScancodeFromKey(SDLK_F12);
   59.69 +		keymap[B_PRINT_KEY]	= SDL_GetScancodeFromKey(SDLK_PRINTSCREEN);
   59.70 +		keymap[B_SCROLL_KEY]	= SDL_GetScancodeFromKey(SDLK_SCROLLLOCK);
   59.71 +		keymap[B_PAUSE_KEY]	= SDL_GetScancodeFromKey(SDLK_PAUSE);
   59.72 +		keymap[0x11]		= SDL_GetScancodeFromKey(SDLK_BACKQUOTE);
   59.73 +		keymap[0x12]		= SDL_GetScancodeFromKey(SDLK_1);
   59.74 +		keymap[0x13]		= SDL_GetScancodeFromKey(SDLK_2);
   59.75 +		keymap[0x14]		= SDL_GetScancodeFromKey(SDLK_3);
   59.76 +		keymap[0x15]		= SDL_GetScancodeFromKey(SDLK_4);
   59.77 +		keymap[0x16]		= SDL_GetScancodeFromKey(SDLK_5);
   59.78 +		keymap[0x17]		= SDL_GetScancodeFromKey(SDLK_6);
   59.79 +		keymap[0x18]		= SDL_GetScancodeFromKey(SDLK_7);
   59.80 +		keymap[0x19]		= SDL_GetScancodeFromKey(SDLK_8);
   59.81 +		keymap[0x1a]		= SDL_GetScancodeFromKey(SDLK_9);
   59.82 +		keymap[0x1b]		= SDL_GetScancodeFromKey(SDLK_0);
   59.83 +		keymap[0x1c]		= SDL_GetScancodeFromKey(SDLK_MINUS);
   59.84 +		keymap[0x1d]		= SDL_GetScancodeFromKey(SDLK_EQUALS);
   59.85 +		keymap[0x1e]		= SDL_GetScancodeFromKey(SDLK_BACKSPACE);
   59.86 +		keymap[0x1f]		= SDL_GetScancodeFromKey(SDLK_INSERT);
   59.87 +		keymap[0x20]		= SDL_GetScancodeFromKey(SDLK_HOME);
   59.88 +		keymap[0x21]		= SDL_GetScancodeFromKey(SDLK_PAGEUP);
   59.89 +		keymap[0x22]		= SDL_GetScancodeFromKey(SDLK_NUMLOCKCLEAR);
   59.90 +		keymap[0x23]		= SDL_GetScancodeFromKey(SDLK_KP_DIVIDE);
   59.91 +		keymap[0x24]		= SDL_GetScancodeFromKey(SDLK_KP_MULTIPLY);
   59.92 +		keymap[0x25]		= SDL_GetScancodeFromKey(SDLK_KP_MINUS);
   59.93 +		keymap[0x26]		= SDL_GetScancodeFromKey(SDLK_TAB);
   59.94 +		keymap[0x27]		= SDL_GetScancodeFromKey(SDLK_q);
   59.95 +		keymap[0x28]		= SDL_GetScancodeFromKey(SDLK_w);
   59.96 +		keymap[0x29]		= SDL_GetScancodeFromKey(SDLK_e);
   59.97 +		keymap[0x2a]		= SDL_GetScancodeFromKey(SDLK_r);
   59.98 +		keymap[0x2b]		= SDL_GetScancodeFromKey(SDLK_t);
   59.99 +		keymap[0x2c]		= SDL_GetScancodeFromKey(SDLK_y);
  59.100 +		keymap[0x2d]		= SDL_GetScancodeFromKey(SDLK_u);
  59.101 +		keymap[0x2e]		= SDL_GetScancodeFromKey(SDLK_i);
  59.102 +		keymap[0x2f]		= SDL_GetScancodeFromKey(SDLK_o);
  59.103 +		keymap[0x30]		= SDL_GetScancodeFromKey(SDLK_p);
  59.104 +		keymap[0x31]		= SDL_GetScancodeFromKey(SDLK_LEFTBRACKET);
  59.105 +		keymap[0x32]		= SDL_GetScancodeFromKey(SDLK_RIGHTBRACKET);
  59.106 +		keymap[0x33]		= SDL_GetScancodeFromKey(SDLK_BACKSLASH);
  59.107 +		keymap[0x34]		= SDL_GetScancodeFromKey(SDLK_DELETE);
  59.108 +		keymap[0x35]		= SDL_GetScancodeFromKey(SDLK_END);
  59.109 +		keymap[0x36]		= SDL_GetScancodeFromKey(SDLK_PAGEDOWN);
  59.110 +		keymap[0x37]		= SDL_GetScancodeFromKey(SDLK_KP_7);
  59.111 +		keymap[0x38]		= SDL_GetScancodeFromKey(SDLK_KP_8);
  59.112 +		keymap[0x39]		= SDL_GetScancodeFromKey(SDLK_KP_9);
  59.113 +		keymap[0x3a]		= SDL_GetScancodeFromKey(SDLK_KP_PLUS);
  59.114 +		keymap[0x3b]		= SDL_GetScancodeFromKey(SDLK_CAPSLOCK);
  59.115 +		keymap[0x3c]		= SDL_GetScancodeFromKey(SDLK_a);
  59.116 +		keymap[0x3d]		= SDL_GetScancodeFromKey(SDLK_s);
  59.117 +		keymap[0x3e]		= SDL_GetScancodeFromKey(SDLK_d);
  59.118 +		keymap[0x3f]		= SDL_GetScancodeFromKey(SDLK_f);
  59.119 +		keymap[0x40]		= SDL_GetScancodeFromKey(SDLK_g);
  59.120 +		keymap[0x41]		= SDL_GetScancodeFromKey(SDLK_h);
  59.121 +		keymap[0x42]		= SDL_GetScancodeFromKey(SDLK_j);
  59.122 +		keymap[0x43]		= SDL_GetScancodeFromKey(SDLK_k);
  59.123 +		keymap[0x44]		= SDL_GetScancodeFromKey(SDLK_l);
  59.124 +		keymap[0x45]		= SDL_GetScancodeFromKey(SDLK_SEMICOLON);
  59.125 +		keymap[0x46]		= SDL_GetScancodeFromKey(SDLK_QUOTE);
  59.126 +		keymap[0x47]		= SDL_GetScancodeFromKey(SDLK_RETURN);
  59.127 +		keymap[0x48]		= SDL_GetScancodeFromKey(SDLK_KP_4);
  59.128 +		keymap[0x49]		= SDL_GetScancodeFromKey(SDLK_KP_5);
  59.129 +		keymap[0x4a]		= SDL_GetScancodeFromKey(SDLK_KP_6);
  59.130 +		keymap[0x4b]		= SDL_GetScancodeFromKey(SDLK_LSHIFT);
  59.131 +		keymap[0x4c]		= SDL_GetScancodeFromKey(SDLK_z);
  59.132 +		keymap[0x4d]		= SDL_GetScancodeFromKey(SDLK_x);
  59.133 +		keymap[0x4e]		= SDL_GetScancodeFromKey(SDLK_c);
  59.134 +		keymap[0x4f]		= SDL_GetScancodeFromKey(SDLK_v);
  59.135 +		keymap[0x50]		= SDL_GetScancodeFromKey(SDLK_b);
  59.136 +		keymap[0x51]		= SDL_GetScancodeFromKey(SDLK_n);
  59.137 +		keymap[0x52]		= SDL_GetScancodeFromKey(SDLK_m);
  59.138 +		keymap[0x53]		= SDL_GetScancodeFromKey(SDLK_COMMA);
  59.139 +		keymap[0x54]		= SDL_GetScancodeFromKey(SDLK_PERIOD);
  59.140 +		keymap[0x55]		= SDL_GetScancodeFromKey(SDLK_SLASH);
  59.141 +		keymap[0x56]		= SDL_GetScancodeFromKey(SDLK_RSHIFT);
  59.142 +		keymap[0x57]		= SDL_GetScancodeFromKey(SDLK_UP);
  59.143 +		keymap[0x58]		= SDL_GetScancodeFromKey(SDLK_KP_1);
  59.144 +		keymap[0x59]		= SDL_GetScancodeFromKey(SDLK_KP_2);
  59.145 +		keymap[0x5a]		= SDL_GetScancodeFromKey(SDLK_KP_3);
  59.146 +		keymap[0x5b]		= SDL_GetScancodeFromKey(SDLK_KP_ENTER);
  59.147 +		keymap[0x5c]		= SDL_GetScancodeFromKey(SDLK_LCTRL);
  59.148 +		keymap[0x5d]		= SDL_GetScancodeFromKey(SDLK_LALT);
  59.149 +		keymap[0x5e]		= SDL_GetScancodeFromKey(SDLK_SPACE);
  59.150 +		keymap[0x5f]		= SDL_GetScancodeFromKey(SDLK_RALT);
  59.151 +		keymap[0x60]		= SDL_GetScancodeFromKey(SDLK_RCTRL);
  59.152 +		keymap[0x61]		= SDL_GetScancodeFromKey(SDLK_LEFT);
  59.153 +		keymap[0x62]		= SDL_GetScancodeFromKey(SDLK_DOWN);
  59.154 +		keymap[0x63]		= SDL_GetScancodeFromKey(SDLK_RIGHT);
  59.155 +		keymap[0x64]		= SDL_GetScancodeFromKey(SDLK_KP_0);
  59.156 +		keymap[0x65]		= SDL_GetScancodeFromKey(SDLK_KP_PERIOD);
  59.157 +		keymap[0x66]		= SDL_GetScancodeFromKey(SDLK_LGUI);
  59.158 +		keymap[0x67]		= SDL_GetScancodeFromKey(SDLK_RGUI);
  59.159 +		keymap[0x68]		= SDL_GetScancodeFromKey(SDLK_MENU);
  59.160 +		keymap[0x69]		= SDL_GetScancodeFromKey(SDLK_2); /* SDLK_EURO */
  59.161 +		keymap[0x6a]		= SDL_GetScancodeFromKey(SDLK_KP_EQUALS);
  59.162 +		keymap[0x6b]		= SDL_GetScancodeFromKey(SDLK_POWER);
  59.163 +}
  59.164 +
  59.165 +SDL_Scancode BE_GetScancodeFromBeKey(int32 bkey) {
  59.166 +	if(bkey > 0 && bkey < (int32)SDL_TABLESIZE(keymap)) {
  59.167 +		return keymap[bkey];
  59.168 +	} else {
  59.169 +		return SDL_SCANCODE_UNKNOWN;
  59.170 +	}
  59.171 +}
  59.172 +
  59.173 +int8 BE_GetKeyState(int32 bkey) {
  59.174 +	if(bkey > 0 && bkey < KEYMAP_SIZE) {
  59.175 +		return keystate[bkey];
  59.176 +	} else {
  59.177 +		return SDL_RELEASED;
  59.178 +	}
  59.179 +}
  59.180 +
  59.181 +void BE_SetKeyState(int32 bkey, int8 state) {
  59.182 +	if(bkey > 0 && bkey < KEYMAP_SIZE) {
  59.183 +		keystate[bkey] = state;
  59.184 +	}
  59.185 +}
  59.186 +
  59.187 +#ifdef __cplusplus
  59.188 +}
  59.189 +#endif
  59.190 +
  59.191 +#endif /* SDL_VIDEO_DRIVER_HAIKU */
    60.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    60.2 +++ b/src/video/haiku/SDL_bkeyboard.h	Thu Nov 14 11:51:24 2013 -0500
    60.3 @@ -0,0 +1,42 @@
    60.4 +/*
    60.5 +  Simple DirectMedia Layer
    60.6 +  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    60.7 +
    60.8 +  This software is provided 'as-is', without any express or implied
    60.9 +  warranty.  In no event will the authors be held liable for any damages
   60.10 +  arising from the use of this software.
   60.11 +
   60.12 +  Permission is granted to anyone to use this software for any purpose,
   60.13 +  including commercial applications, and to alter it and redistribute it
   60.14 +  freely, subject to the following restrictions:
   60.15 +
   60.16 +  1. The origin of this software must not be misrepresented; you must not
   60.17 +     claim that you wrote the original software. If you use this software
   60.18 +     in a product, an acknowledgment in the product documentation would be
   60.19 +     appreciated but is not required.
   60.20 +  2. Altered source versions must be plainly marked as such, and must not be
   60.21 +     misrepresented as being the original software.
   60.22 +  3. This notice may not be removed or altered from any source distribution.
   60.23 +*/
   60.24 +
   60.25 +#ifndef SDL_BKEYBOARD_H
   60.26 +#define SDL_BKEYBOARD_H
   60.27 +
   60.28 +#include <SupportDefs.h>
   60.29 +
   60.30 +#ifdef __cplusplus
   60.31 +extern "C" {
   60.32 +#endif
   60.33 +
   60.34 +#include "../../../include/SDL_keyboard.h"
   60.35 +
   60.36 +extern void BE_InitOSKeymap();
   60.37 +extern SDL_Scancode BE_GetScancodeFromBeKey(int32 bkey);
   60.38 +extern int8 BE_GetKeyState(int32 bkey);
   60.39 +extern void BE_SetKeyState(int32 bkey, int8 state);
   60.40 +
   60.41 +#ifdef __cplusplus
   60.42 +}
   60.43 +#endif
   60.44 +
   60.45 +#endif
    61.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    61.2 +++ b/src/video/haiku/SDL_bmodes.cc	Thu Nov 14 11:51:24 2013 -0500
    61.3 @@ -0,0 +1,331 @@
    61.4 +/*
    61.5 +  Simple DirectMedia Layer
    61.6 +  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    61.7 +
    61.8 +  This software is provided 'as-is', without any express or implied
    61.9 +  warranty.  In no event will the authors be held liable for any damages
   61.10 +  arising from the use of this software.
   61.11 +
   61.12 +  Permission is granted to anyone to use this software for any purpose,
   61.13 +  including commercial applications, and to alter it and redistribute it
   61.14 +  freely, subject to the following restrictions:
   61.15 +
   61.16 +  1. The origin of this software must not be misrepresented; you must not
   61.17 +     claim that you wrote the original software. If you use this software
   61.18 +     in a product, an acknowledgment in the product documentation would be
   61.19 +     appreciated but is not required.
   61.20 +  2. Altered source versions must be plainly marked as such, and must not be
   61.21 +     misrepresented as being the original software.
   61.22 +  3. This notice may not be removed or altered from any source distribution.
   61.23 +*/
   61.24 +#include "SDL_config.h"
   61.25 +
   61.26 +#if SDL_VIDEO_DRIVER_HAIKU
   61.27 +
   61.28 +#include <AppKit.h>
   61.29 +#include <InterfaceKit.h>
   61.30 +#include "SDL_bmodes.h"
   61.31 +#include "SDL_BWin.h"
   61.32 +
   61.33 +#if SDL_VIDEO_OPENGL
   61.34 +#include "SDL_bopengl.h"
   61.35 +#endif
   61.36 +
   61.37 +#include "../../main/haiku/SDL_BApp.h"
   61.38 +
   61.39 +#ifdef __cplusplus
   61.40 +extern "C" {
   61.41 +#endif
   61.42 +
   61.43 +
   61.44 +#define WRAP_BMODE 1 /* FIXME: Some debate as to whether this is necessary */
   61.45 +
   61.46 +#if WRAP_BMODE
   61.47 +/* This wrapper is here so that the driverdata can be freed without freeing
   61.48 +   the display_mode structure */
   61.49 +typedef struct SDL_DisplayModeData {
   61.50 +	display_mode *bmode;
   61.51 +};
   61.52 +#endif
   61.53 +
   61.54 +static SDL_INLINE SDL_BWin *_ToBeWin(SDL_Window *window) {
   61.55 +	return ((SDL_BWin*)(window->driverdata));
   61.56 +}
   61.57 +
   61.58 +static SDL_INLINE SDL_BApp *_GetBeApp() {
   61.59 +	return ((SDL_BApp*)be_app);
   61.60 +}
   61.61 +
   61.62 +static SDL_INLINE display_mode * _ExtractBMode(SDL_DisplayMode *mode) {
   61.63 +#if WRAP_BMODE
   61.64 +	return ((SDL_DisplayModeData*)mode->driverdata)->bmode;
   61.65 +#else
   61.66 +	return (display_mode*)(mode->driverdata);
   61.67 +#endif
   61.68 +}
   61.69 +
   61.70 +/* Copied from haiku/trunk/src/preferences/screen/ScreenMode.cpp */
   61.71 +static float get_refresh_rate(display_mode &mode) {
   61.72 +	return float(mode.timing.pixel_clock * 1000)
   61.73 +		/ float(mode.timing.h_total * mode.timing.v_total);
   61.74 +}
   61.75 +
   61.76 +
   61.77 +#if 0
   61.78 +/* TODO:
   61.79 + * This is a useful debugging tool.  Uncomment and insert into code as needed.
   61.80 + */
   61.81 +void _SpoutModeData(display_mode *bmode) {
   61.82 +	printf("BMode:\n");
   61.83 +	printf("\tw,h = (%i,%i)\n", bmode->virtual_width, bmode->virtual_height);
   61.84 +	printf("\th,v = (%i,%i)\n", bmode->h_display_start, 
   61.85 +			bmode->v_display_start);
   61.86 +	if(bmode->flags) {
   61.87 +		printf("\tFlags:\n");
   61.88 +		if(bmode->flags & B_SCROLL) {
   61.89 +			printf("\t\tB_SCROLL\n");
   61.90 +		}
   61.91 +		if(bmode->flags & B_8_BIT_DAC) {
   61.92 +			printf("\t\tB_8_BIT_DAC\n");
   61.93 +		}
   61.94 +		if(bmode->flags & B_HARDWARE_CURSOR) {
   61.95 +			printf("\t\tB_HARDWARE_CURSOR\n");
   61.96 +		}
   61.97 +		if(bmode->flags & B_PARALLEL_ACCESS) {
   61.98 +			printf("\t\tB_PARALLEL_ACCESS\n");
   61.99 +		}
  61.100 +		if(bmode->flags & B_DPMS) {
  61.101 +			printf("\t\tB_DPMS\n");
  61.102 +		}
  61.103 +		if(bmode->flags & B_IO_FB_NA) {
  61.104 +			printf("\t\tB_IO_FB_NA\n");
  61.105 +		}
  61.106 +	}
  61.107 +	printf("\tTiming:\n");
  61.108 +	printf("\t\tpx clock: %i\n", bmode->timing.pixel_clock);
  61.109 +	printf("\t\th - display: %i sync start: %i sync end: %i total: %i\n",
  61.110 +		bmode->timing.h_display, bmode->timing.h_sync_start,
  61.111 +		bmode->timing.h_sync_end, bmode->timing.h_total);
  61.112 +	printf("\t\tv - display: %i sync start: %i sync end: %i total: %i\n",
  61.113 +		bmode->timing.v_display, bmode->timing.v_sync_start,
  61.114 +		bmode->timing.v_sync_end, bmode->timing.v_total);
  61.115 +	if(bmode->timing.flags) {
  61.116 +		printf("\t\tFlags:\n");
  61.117 +		if(bmode->timing.flags & B_BLANK_PEDESTAL) {
  61.118 +			printf("\t\t\tB_BLANK_PEDESTAL\n");
  61.119 +		}
  61.120 +		if(bmode->timing.flags & B_TIMING_INTERLACED) {
  61.121 +			printf("\t\t\tB_TIMING_INTERLACED\n");
  61.122 +		}
  61.123 +		if(bmode->timing.flags & B_POSITIVE_HSYNC) {
  61.124 +			printf("\t\t\tB_POSITIVE_HSYNC\n");
  61.125 +		}
  61.126 +		if(bmode->timing.flags & B_POSITIVE_VSYNC) {
  61.127 +			printf("\t\t\tB_POSITIVE_VSYNC\n");
  61.128 +		}
  61.129 +		if(bmode->timing.flags & B_SYNC_ON_GREEN) {
  61.130 +			printf("\t\t\tB_SYNC_ON_GREEN\n");
  61.131 +		}
  61.132 +	}
  61.133 +}
  61.134 +#endif
  61.135 +
  61.136 +
  61.137 +
  61.138 +int32 BE_ColorSpaceToBitsPerPixel(uint32 colorspace)
  61.139 +{
  61.140 +	int bitsperpixel;
  61.141 +
  61.142 +	bitsperpixel = 0;
  61.143 +	switch (colorspace) {
  61.144 +	    case B_CMAP8:
  61.145 +		bitsperpixel = 8;
  61.146 +		break;
  61.147 +	    case B_RGB15:
  61.148 +	    case B_RGBA15:
  61.149 +	    case B_RGB15_BIG:
  61.150 +	    case B_RGBA15_BIG:
  61.151 +		bitsperpixel = 15;
  61.152 +		break;
  61.153 +	    case B_RGB16:
  61.154 +	    case B_RGB16_BIG:
  61.155 +		bitsperpixel = 16;
  61.156 +		break;
  61.157 +	    case B_RGB32:
  61.158 +	    case B_RGBA32:
  61.159 +	    case B_RGB32_BIG:
  61.160 +	    case B_RGBA32_BIG:
  61.161 +		bitsperpixel = 32;
  61.162 +		break;
  61.163 +	    default:
  61.164 +		break;
  61.165 +	}
  61.166 +	return(bitsperpixel);
  61.167 +}
  61.168 +
  61.169 +int32 BE_BPPToSDLPxFormat(int32 bpp) {
  61.170 +	/* Translation taken from SDL_windowsmodes.c */
  61.171 +	switch (bpp) {
  61.172 +	case 32:
  61.173 +		return SDL_PIXELFORMAT_RGB888;
  61.174 +		break;
  61.175 +	case 24:	/* May not be supported by Haiku */
  61.176 +		return SDL_PIXELFORMAT_RGB24;
  61.177 +		break;
  61.178 +	case 16:
  61.179 +		return SDL_PIXELFORMAT_RGB565;
  61.180 +		break;
  61.181 +	case 15:
  61.182 +		return SDL_PIXELFORMAT_RGB555;
  61.183 +		break;
  61.184 +	case 8:
  61.185 +		return SDL_PIXELFORMAT_INDEX8;
  61.186 +		break;
  61.187 +	case 4:		/* May not be supported by Haiku */
  61.188 +		return SDL_PIXELFORMAT_INDEX4LSB;
  61.189 +		break;
  61.190 +	}
  61.191 +
  61.192 +	/* May never get here, but safer and needed to shut up compiler */
  61.193 +	SDL_SetError("Invalid bpp value");
  61.194 +	return 0;       
  61.195 +}
  61.196 +
  61.197 +static void _BDisplayModeToSdlDisplayMode(display_mode *bmode,
  61.198 +		SDL_DisplayMode *mode) {
  61.199 +	mode->w = bmode->virtual_width;
  61.200 +	mode->h = bmode->virtual_height;
  61.201 +	mode->refresh_rate = (int)get_refresh_rate(*bmode);
  61.202 +
  61.203 +#if WRAP_BMODE
  61.204 +	SDL_DisplayModeData *data = (SDL_DisplayModeData*)SDL_calloc(1,
  61.205 +		sizeof(SDL_DisplayModeData));
  61.206 +	data->bmode = bmode;
  61.207 +	
  61.208 +	mode->driverdata = data;
  61.209 +
  61.210 +#else
  61.211 +
  61.212 +	mode->driverdata = bmode;
  61.213 +#endif
  61.214 +
  61.215 +	/* Set the format */
  61.216 +	int32 bpp = BE_ColorSpaceToBitsPerPixel(bmode->space);
  61.217 +	mode->format = BE_BPPToSDLPxFormat(bpp);
  61.218 +}
  61.219 +
  61.220 +/* Later, there may be more than one monitor available */
  61.221 +static void _AddDisplay(BScreen *screen) {
  61.222 +	SDL_VideoDisplay display;
  61.223 +	SDL_DisplayMode *mode = (SDL_DisplayMode*)SDL_calloc(1,
  61.224 +		sizeof(SDL_DisplayMode));
  61.225 +	display_mode *bmode = (display_mode*)SDL_calloc(1, sizeof(display_mode));
  61.226 +	screen->GetMode(bmode);
  61.227 +
  61.228 +	_BDisplayModeToSdlDisplayMode(bmode, mode);
  61.229 +	
  61.230 +	SDL_zero(display);
  61.231 +	display.desktop_mode = *mode;
  61.232 +	display.current_mode = *mode;
  61.233 +	
  61.234 +	SDL_AddVideoDisplay(&display);
  61.235 +}
  61.236 +
  61.237 +/*
  61.238 + * Functions called by SDL
  61.239 + */
  61.240 +
  61.241 +int BE_InitModes(_THIS) {
  61.242 +	BScreen screen;
  61.243 +
  61.244 +	/* TODO: When Haiku supports multiple display screens, call
  61.245 +	   _AddDisplayScreen() for each of them. */
  61.246 +	_AddDisplay(&screen);
  61.247 +	return 0;
  61.248 +}
  61.249 +
  61.250 +int BE_QuitModes(_THIS) {
  61.251 +	/* FIXME: Nothing really needs to be done here at the moment? */
  61.252 +	return 0;
  61.253 +}
  61.254 +
  61.255 +
  61.256 +int BE_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect) {
  61.257 +	BScreen bscreen;
  61.258 +	BRect rc = bscreen.Frame();
  61.259 +	rect->x = (int)rc.left;
  61.260 +	rect->y = (int)rc.top;
  61.261 +	rect->w = (int)rc.Width() + 1;
  61.262 +	rect->h = (int)rc.Height() + 1;
  61.263 +	return 0;
  61.264 +}
  61.265 +
  61.266 +void BE_GetDisplayModes(_THIS, SDL_VideoDisplay *display) {
  61.267 +	/* Get the current screen */
  61.268 +	BScreen bscreen;
  61.269 +
  61.270 +	/* Iterate through all of the modes */
  61.271 +	SDL_DisplayMode mode;
  61.272 +	display_mode this_bmode;
  61.273 +	display_mode *bmodes;
  61.274 +	uint32 count, i;
  61.275 +	
  61.276 +	/* Get graphics-hardware supported modes */
  61.277 +	bscreen.GetModeList(&bmodes, &count);
  61.278 +	bscreen.GetMode(&this_bmode);
  61.279 +	
  61.280 +	for(i = 0; i < count; ++i) {
  61.281 +		// FIXME: Apparently there are errors with colorspace changes
  61.282 +		if (bmodes[i].space == this_bmode.space) {
  61.283 +			_BDisplayModeToSdlDisplayMode(&bmodes[i], &mode);
  61.284 +			SDL_AddDisplayMode(display, &mode);
  61.285 +		}
  61.286 +	}
  61.287 +	free(bmodes);
  61.288 +}
  61.289 +
  61.290 +
  61.291 +int BE_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode){
  61.292 +	/* Get the current screen */
  61.293 +	BScreen bscreen;
  61.294 +	if(!bscreen.IsValid()) {
  61.295 +		printf(__FILE__": %d - ERROR: BAD SCREEN\n", __LINE__);
  61.296 +	}
  61.297 +
  61.298 +	/* Set the mode using the driver data */
  61.299 +	display_mode *bmode = _ExtractBMode(mode);
  61.300 +
  61.301 +
  61.302 +	/* FIXME: Is the first option always going to be the right one? */
  61.303 +	uint32 c = 0, i;
  61.304 +	display_mode *bmode_list;
  61.305 +	bscreen.GetModeList(&bmode_list, &c);
  61.306 +	for(i = 0; i < c; ++i) {
  61.307 +		if(	bmode_list[i].space == bmode->space &&
  61.308 +			bmode_list[i].virtual_width == bmode->virtual_width &&
  61.309 +			bmode_list[i].virtual_height == bmode->virtual_height ) {
  61.310 +				bmode = &bmode_list[i];
  61.311 +				break;
  61.312 +		}
  61.313 +	}
  61.314 +
  61.315 +	if(bscreen.SetMode(bmode) != B_OK) {
  61.316 +		return SDL_SetError("Bad video mode\n");
  61.317 +	}
  61.318 +	
  61.319 +	free(bmode_list);
  61.320 +	
  61.321 +#if SDL_VIDEO_OPENGL
  61.322 +	/* FIXME: Is there some way to reboot the OpenGL context?  This doesn't
  61.323 +	   help */
  61.324 +//	BE_GL_RebootContexts(_this);
  61.325 +#endif
  61.326 +
  61.327 +	return 0;
  61.328 +}
  61.329 +
  61.330 +#ifdef __cplusplus
  61.331 +}
  61.332 +#endif
  61.333 +
  61.334 +#endif /* SDL_VIDEO_DRIVER_HAIKU */
    62.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    62.2 +++ b/src/video/haiku/SDL_bmodes.h	Thu Nov 14 11:51:24 2013 -0500
    62.3 @@ -0,0 +1,46 @@
    62.4 +/*
    62.5 +  Simple DirectMedia Layer
    62.6 +  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    62.7 +
    62.8 +  This software is provided 'as-is', without any express or implied
    62.9 +  warranty.  In no event will the authors be held liable for any damages
   62.10 +  arising from the use of this software.
   62.11 +
   62.12 +  Permission is granted to anyone to use this software for any purpose,
   62.13 +  including commercial applications, and to alter it and redistribute it
   62.14 +  freely, subject to the following restrictions:
   62.15 +
   62.16 +  1. The origin of this software must not be misrepresented; you must not
   62.17 +     claim that you wrote the original software. If you use this software
   62.18 +     in a product, an acknowledgment in the product documentation would be
   62.19 +     appreciated but is not required.
   62.20 +  2. Altered source versions must be plainly marked as such, and must not be
   62.21 +     misrepresented as being the original software.
   62.22 +  3. This notice may not be removed or altered from any source distribution.
   62.23 +*/
   62.24 +
   62.25 +#ifndef SDL_BMODES_H
   62.26 +#define SDL_BMODES_H
   62.27 +
   62.28 +#ifdef __cplusplus
   62.29 +extern "C" {
   62.30 +#endif
   62.31 +
   62.32 +#include "../SDL_sysvideo.h"
   62.33 +
   62.34 +extern int32 BE_ColorSpaceToBitsPerPixel(uint32 colorspace);
   62.35 +extern int32 BE_BPPToSDLPxFormat(int32 bpp);
   62.36 +
   62.37 +extern int BE_InitModes(_THIS);
   62.38 +extern int BE_QuitModes(_THIS);
   62.39 +extern int BE_GetDisplayBounds(_THIS, SDL_VideoDisplay *display,
   62.40 +    SDL_Rect *rect);
   62.41 +extern void BE_GetDisplayModes(_THIS, SDL_VideoDisplay *display);
   62.42 +extern int BE_SetDisplayMode(_THIS, SDL_VideoDisplay *display,
   62.43 +    SDL_DisplayMode *mode);
   62.44 +
   62.45 +#ifdef __cplusplus
   62.46 +}
   62.47 +#endif
   62.48 +
   62.49 +#endif
    63.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    63.2 +++ b/src/video/haiku/SDL_bopengl.cc	Thu Nov 14 11:51:24 2013 -0500
    63.3 @@ -0,0 +1,219 @@
    63.4 +/*
    63.5 +  Simple DirectMedia Layer
    63.6 +  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
    63.7 +
    63.8 +  This software is provided 'as-is', without any express or implied
    63.9 +  warranty.  In no event will the authors be held liable for any damages
   63.10 +  arising from the use of this software.
   63.11 +
   63.12 +  Permission is granted to anyone to use this software for any purpose,
   63.13 +  including commercial applications, and to alter it and redistribute it
   63.14 +  freely, subject to the following restrictions:
   63.15 +
   63.16 +  1. The origin of this software must not be misrepresented; you must not
   63.17 +     claim that you wrote the original software. If you use this software
   63.18 +     in a product, an acknowledgment in the product documentation would be
   63.19 +     appreciated but is not required.
   63.20 +  2. Altered source versions must be plainly marked as such, and must not be
   63.21 +     misrepresented as being the original software.
   63.22 +  3. This notice may not be removed or altered from any source distribution.
   63.23 +*/
   63.24 +#include "SDL_config.h"
   63.25 +
   63.26 +#if SDL_VIDEO_DRIVER_HAIKU
   63.27 +
   63.28 +#include "SDL_bopengl.h"
   63.29 +
   63.30 +#include <unistd.h>
   63.31 +#include <KernelKit.h>
   63.32 +#include <OpenGLKit.h>
   63.33 +#include "SDL_BWin.h"
   63.34 +#include "../../main/haiku/SDL_BApp.h"
   63.35 +
   63.36 +#ifdef __cplusplus
   63.37 +extern "C" {
   63.38 +#endif
   63.39 +
   63.40 +
   63.41 +#define BGL_FLAGS BGL_RGB | BGL_DOUBLE
   63.42 +
   63.43 +static SDL_INLINE SDL_BWin *_ToBeWin(SDL_Window *window) {
   63.44 +	return ((SDL_BWin*)(window->driverdata));
   63.45 +}
   63.46 +
   63.47 +static SDL_INLINE SDL_BApp *_GetBeApp() {
   63.48 +	return ((SDL_BApp*)be_app);
   63.49 +}
   63.50 +
   63.51 +/* Passing a NULL path means load pointers from the application */
   63.52 +int BE_GL_LoadLibrary(_THIS, const char *path)
   63.53 +{
   63.54 +/* FIXME: Is this working correctly? */
   63.55 +	image_info info;
   63.56 +			int32 cookie = 0;
   63.57 +	while (get_next_image_info(0, &cookie, &info) == B_OK) {
   63.58 +		void *location = NULL;
   63.59 +		if( get_image_symbol(info.id, "glBegin", B_SYMBOL_TYPE_ANY,
   63.60 +				&location) == B_OK) {
   63.61 +
   63.62 +			_this->gl_config.dll_handle = (void *) info.id;