├── meta ├── icon.png ├── audio.wav ├── banner.png ├── logo.lz11 └── picopixel.ttf ├── romfs ├── kbd.png ├── chars.png ├── twistydn.png ├── twistyup.png └── background.png ├── LIBSDL ├── src │ ├── video │ │ ├── SDL_RLEaccel.c │ │ ├── default_cursor.h │ │ ├── n3ds │ │ │ ├── vshader_shbin.h │ │ │ ├── SDL_n3dsmouse_c.h │ │ │ ├── SDL_n3dsmouse.c │ │ │ ├── SDL_n3dsevents_c.h │ │ │ ├── vshader_shbin.s │ │ │ ├── SDL_n3dsvideo.h │ │ │ └── SDL_n3dsevents.c │ │ ├── SDL_leaks.h │ │ ├── SDL_stretch_c.h │ │ ├── SDL_RLEaccel_c.h │ │ ├── SDL_yuvfuncs.h │ │ ├── SDL_yuv_sw_c.h │ │ ├── SDL_pixels_c.h │ │ ├── SDL_cursor_c.h │ │ ├── SDL_yuv.c │ │ ├── math_private.h │ │ └── e_log.h │ ├── audio │ │ ├── SDL_mixer_MMX.c │ │ ├── SDL_mixer_MMX.h │ │ ├── SDL_audiomem.h │ │ ├── SDL_audiodev_c.h │ │ ├── SDL_audio_c.h │ │ ├── SDL_mixer_m68k.h │ │ ├── n3ds │ │ │ └── SDL_n3dsaudio.h │ │ ├── SDL_mixer_MMX_VC.h │ │ └── SDL_wave.h │ ├── main │ │ └── dummy │ │ │ └── SDL_dummy_main.c │ ├── timer │ │ ├── n3ds │ │ │ └── SDL_systimer.c │ │ ├── SDL_systimer.h │ │ └── SDL_timer_c.h │ ├── thread │ │ ├── generic │ │ │ └── SDL_systhread_c.h │ │ ├── n3ds │ │ │ ├── SDL_systhread_c.h │ │ │ ├── SDL_sysmutex_c.h │ │ │ ├── SDL_sysmutex.c │ │ │ ├── SDL_systhread.c │ │ │ ├── SDL_syssem.c │ │ │ └── SDL_syscond.c │ │ ├── SDL_systhread.h │ │ └── SDL_thread_c.h │ ├── SDL_fatal.h │ ├── cdrom │ │ ├── dummy │ │ │ └── SDL_syscdrom.c │ │ └── SDL_syscdrom.h │ ├── events │ │ ├── SDL_sysevents.h │ │ ├── SDL_expose.c │ │ ├── SDL_resize.c │ │ ├── SDL_active.c │ │ ├── SDL_events_c.h │ │ └── SDL_quit.c │ ├── joystick │ │ ├── SDL_joystick_c.h │ │ ├── SDL_sysjoystick.h │ │ └── n3ds │ │ │ └── SDL_sysjoystick.c │ ├── loadso │ │ └── dummy │ │ │ └── SDL_sysloadso.c │ ├── SDL_error_c.h │ ├── hermes │ │ └── HeadMMX.h │ └── SDL_fatal.c ├── include │ └── SDL │ │ ├── SDL_name.h │ │ ├── close_code.h │ │ ├── SDL_error.h │ │ ├── SDL_active.h │ │ ├── SDL_quit.h │ │ ├── SDL_cpuinfo.h │ │ ├── SDL_version.h │ │ ├── SDL_loadso.h │ │ ├── SDL_platform.h │ │ ├── SDL_main.h │ │ ├── SDL.h │ │ ├── SDL_keyboard.h │ │ ├── SDL_thread.h │ │ └── SDL_timer.h └── Makefile ├── README.md └── src ├── streamclient.h ├── mp3decoder.h ├── rfb ├── base64.h ├── sha-private.h ├── sasl.h ├── d3des.h ├── tls_none.c ├── sockets.h ├── rfbregion.h ├── tls.h ├── crypto.h ├── corre-c.h ├── rre-c.h ├── crypto_included.c ├── minilzo.h ├── hextile-c.h ├── threading.h └── listen.c ├── decoder.h ├── utilities.h ├── vjoy-udp-feeder-client.h ├── dsu-server.h ├── uibottom.h ├── mp3decoder.c └── utilities.c /meta/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/badda71/TinyVNC/HEAD/meta/icon.png -------------------------------------------------------------------------------- /romfs/kbd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/badda71/TinyVNC/HEAD/romfs/kbd.png -------------------------------------------------------------------------------- /meta/audio.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/badda71/TinyVNC/HEAD/meta/audio.wav -------------------------------------------------------------------------------- /meta/banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/badda71/TinyVNC/HEAD/meta/banner.png -------------------------------------------------------------------------------- /meta/logo.lz11: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/badda71/TinyVNC/HEAD/meta/logo.lz11 -------------------------------------------------------------------------------- /romfs/chars.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/badda71/TinyVNC/HEAD/romfs/chars.png -------------------------------------------------------------------------------- /meta/picopixel.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/badda71/TinyVNC/HEAD/meta/picopixel.ttf -------------------------------------------------------------------------------- /romfs/twistydn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/badda71/TinyVNC/HEAD/romfs/twistydn.png -------------------------------------------------------------------------------- /romfs/twistyup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/badda71/TinyVNC/HEAD/romfs/twistyup.png -------------------------------------------------------------------------------- /romfs/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/badda71/TinyVNC/HEAD/romfs/background.png -------------------------------------------------------------------------------- /LIBSDL/src/video/SDL_RLEaccel.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/badda71/TinyVNC/HEAD/LIBSDL/src/video/SDL_RLEaccel.c -------------------------------------------------------------------------------- /LIBSDL/src/audio/SDL_mixer_MMX.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/badda71/TinyVNC/HEAD/LIBSDL/src/audio/SDL_mixer_MMX.c -------------------------------------------------------------------------------- /LIBSDL/src/video/default_cursor.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/badda71/TinyVNC/HEAD/LIBSDL/src/video/default_cursor.h -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TinyVNC 2 | A VNC viewer for Nintendo 3DS 3 | 4 | https://gbatemp.net/threads/release-tinyvnc-vnc-viewer-for-nintendo-3ds.574242/ 5 | -------------------------------------------------------------------------------- /LIBSDL/src/video/n3ds/vshader_shbin.h: -------------------------------------------------------------------------------- 1 | extern const u8 vshader_shbin[]; 2 | extern const u8 vshader_shbin_end[]; 3 | extern const u32 vshader_shbin_size; 4 | -------------------------------------------------------------------------------- /LIBSDL/include/SDL/SDL_name.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef _SDLname_h_ 3 | #define _SDLname_h_ 4 | 5 | #if defined(__STDC__) || defined(__cplusplus) 6 | #define NeedFunctionPrototypes 1 7 | #endif 8 | 9 | #define SDL_NAME(X) SDL_##X 10 | 11 | #endif /* _SDLname_h_ */ 12 | -------------------------------------------------------------------------------- /LIBSDL/src/main/dummy/SDL_dummy_main.c: -------------------------------------------------------------------------------- 1 | 2 | /* Include the SDL main definition header */ 3 | #include "SDL_main.h" 4 | 5 | #ifdef main 6 | #undef main 7 | int main(int argc, char *argv[]) 8 | { 9 | return(SDL_main(argc, argv)); 10 | } 11 | #else 12 | /* Nothing to do on this platform */ 13 | #endif 14 | -------------------------------------------------------------------------------- /src/streamclient.h: -------------------------------------------------------------------------------- 1 | /* 2 | * TinyVNC - A VNC client for Nintendo 3DS 3 | * 4 | * streamclient.h - functions for handling audio streaming 5 | * 6 | * Copyright 2020 Sebastian Weber 7 | */ 8 | 9 | int start_stream(char *url, char *username, char *password); 10 | void stop_stream(); 11 | int run_stream(); 12 | -------------------------------------------------------------------------------- /src/mp3decoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * TinyVNC - A VNC client for Nintendo 3DS 3 | * 4 | * mp3decoder.h - functions for handling mp3 decoding 5 | * 6 | * Copyright 2020 Sebastian Weber 7 | */ 8 | 9 | #include "decoder.h" 10 | extern void mp3_create_decoder(audioDecoder* decoder); 11 | extern int mp3_checkmagic(char *magic); 12 | -------------------------------------------------------------------------------- /src/rfb/base64.h: -------------------------------------------------------------------------------- 1 | #ifndef _BASE64_H 2 | #define _BASE64_H 3 | 4 | extern int __b64_ntop(u_char const *src, size_t srclength, char *target, size_t targsize); 5 | extern int __b64_pton(char const *src, u_char *target, size_t targsize); 6 | 7 | #define rfbBase64NtoP __b64_ntop 8 | #define rfbBase64PtoN __b64_pton 9 | 10 | #endif /* _BASE64_H */ 11 | -------------------------------------------------------------------------------- /src/decoder.h: -------------------------------------------------------------------------------- 1 | #ifndef _DECODER_H 2 | #define _DECODER_H 3 | 4 | typedef struct { 5 | int (*init)(); 6 | int (*feed)(void *data, int size); 7 | int (*decode)(void **outdata, int *size); 8 | int (*info)(char **type, int *rate, int *channels, int *bitrate); 9 | int (*close)(); 10 | const char *(*errstr)(); 11 | int (*checkmagic)(char *buffer); 12 | } audioDecoder; 13 | 14 | #endif /* _DECODER_H */ 15 | 16 | /* magic types 17 | } magic2type[] = { 18 | { "\xFF\xFB", TYPE_MP3}, 19 | { "\xFF\xF3", TYPE_MP3}, 20 | { "\xFF\xF2", TYPE_MP3}, 21 | { "\xFF\xF1", TYPE_ACC}, 22 | { "\xFF\xF9", TYPE_ACC}, 23 | { "Oggs", TYPE_OPUS}, 24 | { NULL, 0} 25 | };*/ 26 | -------------------------------------------------------------------------------- /LIBSDL/src/audio/SDL_mixer_MMX.h: -------------------------------------------------------------------------------- 1 | /* 2 | headers for MMX assembler version of SDL_MixAudio 3 | Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr) 4 | This code is licensed under the LGPL (see COPYING for details) 5 | 6 | Assumes buffer size in bytes is a multiple of 16 7 | Assumes SDL_MIX_MAXVOLUME = 128 8 | */ 9 | #include "SDL_config.h" 10 | 11 | #if defined(SDL_BUGGY_MMX_MIXERS) /* buggy, so we're disabling them. --ryan. */ 12 | #if defined(__GNUC__) && defined(__i386__) && defined(SDL_ASSEMBLY_ROUTINES) 13 | void SDL_MixAudio_MMX_S16(char* ,char* ,unsigned int ,int ); 14 | void SDL_MixAudio_MMX_S8(char* ,char* ,unsigned int ,int ); 15 | #endif 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /LIBSDL/src/timer/n3ds/SDL_systimer.c: -------------------------------------------------------------------------------- 1 | #include "SDL_config.h" 2 | 3 | #include 4 | #include <3ds.h> 5 | #include 6 | 7 | 8 | #include "SDL_thread.h" 9 | #include "SDL_timer.h" 10 | #include "SDL_error.h" 11 | #include "../SDL_timer_c.h" 12 | 13 | static u64 g_startTicks; 14 | 15 | void SDL_StartTicks (void) { 16 | g_startTicks = svcGetSystemTick(); 17 | } 18 | 19 | Uint32 SDL_GetTicks (void) { 20 | u64 elapsed = svcGetSystemTick() - g_startTicks; 21 | return elapsed * 1000 / SYSCLOCK_ARM11; 22 | } 23 | 24 | void SDL_Delay (Uint32 ms) { 25 | svcSleepThread((u64)ms * 1000000ULL); 26 | } 27 | 28 | int SDL_SYS_TimerInit (void) { 29 | return 0; 30 | } 31 | 32 | void SDL_SYS_TimerQuit (void) { 33 | } 34 | 35 | int SDL_SYS_StartTimer (void) { 36 | SDL_SetError ("Timers not implemented on 3DS"); 37 | 38 | return -1; 39 | } 40 | 41 | void SDL_SYS_StopTimer (void) { 42 | } 43 | -------------------------------------------------------------------------------- /src/rfb/sha-private.h: -------------------------------------------------------------------------------- 1 | /************************ sha-private.h ************************/ 2 | /***************** See RFC 6234 for details. *******************/ 3 | #ifndef _SHA_PRIVATE__H 4 | #define _SHA_PRIVATE__H 5 | /* 6 | * These definitions are defined in FIPS 180-3, section 4.1. 7 | * Ch() and Maj() are defined identically in sections 4.1.1, 8 | * 4.1.2, and 4.1.3. 9 | * 10 | * The definitions used in FIPS 180-3 are as follows: 11 | */ 12 | 13 | #ifndef USE_MODIFIED_MACROS 14 | #define SHA_Ch(x,y,z) (((x) & (y)) ^ ((~(x)) & (z))) 15 | #define SHA_Maj(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) 16 | #else /* USE_MODIFIED_MACROS */ 17 | /* 18 | * The following definitions are equivalent and potentially faster. 19 | */ 20 | 21 | #define SHA_Ch(x, y, z) (((x) & ((y) ^ (z))) ^ (z)) 22 | #define SHA_Maj(x, y, z) (((x) & ((y) | (z))) | ((y) & (z))) 23 | 24 | #endif /* USE_MODIFIED_MACROS */ 25 | 26 | #define SHA_Parity(x, y, z) ((x) ^ (y) ^ (z)) 27 | 28 | #endif /* _SHA_PRIVATE__H */ 29 | 30 | -------------------------------------------------------------------------------- /LIBSDL/src/audio/SDL_audiomem.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | #include "SDL_config.h" 23 | 24 | #define SDL_AllocAudioMem SDL_malloc 25 | #define SDL_FreeAudioMem SDL_free 26 | -------------------------------------------------------------------------------- /LIBSDL/src/video/n3ds/SDL_n3dsmouse_c.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | #include "SDL_config.h" 23 | 24 | #include "SDL_n3dsvideo.h" 25 | 26 | /* Functions to be exported */ 27 | -------------------------------------------------------------------------------- /LIBSDL/src/thread/generic/SDL_systhread_c.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with this library; if not, write to the Free 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | #include "SDL_config.h" 23 | 24 | /* Stub until we implement threads on this platform */ 25 | typedef int SYS_ThreadHandle; 26 | -------------------------------------------------------------------------------- /LIBSDL/src/thread/n3ds/SDL_systhread_c.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #include <3ds.h> 23 | 24 | typedef Thread SYS_ThreadHandle; 25 | -------------------------------------------------------------------------------- /LIBSDL/src/SDL_fatal.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | #include "SDL_config.h" 23 | 24 | /* General fatal signal handling code for SDL */ 25 | 26 | extern void SDL_InstallParachute(void); 27 | extern void SDL_UninstallParachute(void); 28 | 29 | -------------------------------------------------------------------------------- /LIBSDL/src/audio/SDL_audiodev_c.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | #include "SDL_config.h" 23 | 24 | /* Open the audio device, storing the pathname in 'path' */ 25 | extern int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic); 26 | 27 | -------------------------------------------------------------------------------- /LIBSDL/src/video/SDL_leaks.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | #include "SDL_config.h" 23 | 24 | /* Define this if you want surface leak detection code enabled */ 25 | /*#define CHECK_LEAKS*/ 26 | 27 | /* Global variables used to check leaks in code using SDL */ 28 | 29 | #ifdef CHECK_LEAKS 30 | extern int surfaces_allocated; 31 | #endif 32 | -------------------------------------------------------------------------------- /LIBSDL/src/thread/n3ds/SDL_sysmutex_c.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | #include "SDL_config.h" 22 | 23 | #include "SDL_thread.h" 24 | #include "SDL_systhread_c.h" 25 | 26 | struct SDL_mutex 27 | { 28 | RecursiveLock rl; 29 | }; 30 | 31 | /* vi: set ts=4 sw=4 expandtab: */ 32 | -------------------------------------------------------------------------------- /LIBSDL/src/video/n3ds/SDL_n3dsmouse.c: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | #include "SDL_config.h" 23 | 24 | #include "SDL_mouse.h" 25 | #include "../../events/SDL_events_c.h" 26 | 27 | #include "SDL_n3dsmouse_c.h" 28 | 29 | 30 | /* The implementation dependent data for the window manager cursor */ 31 | struct WMcursor { 32 | int unused; 33 | }; 34 | -------------------------------------------------------------------------------- /LIBSDL/src/video/SDL_stretch_c.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | #include "SDL_config.h" 23 | 24 | /* Perform a stretch blit between two surfaces of the same format. 25 | NOTE: This function is not safe to call from multiple threads! 26 | */ 27 | extern int SDL_SoftStretch(SDL_Surface *src, SDL_Rect *srcrect, 28 | SDL_Surface *dst, SDL_Rect *dstrect); 29 | 30 | -------------------------------------------------------------------------------- /LIBSDL/src/video/n3ds/SDL_n3dsevents_c.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | #include "SDL_config.h" 24 | 25 | #include "SDL_n3dsvideo.h" 26 | 27 | /* Variables and functions exported by SDL_sysevents.c to other parts 28 | of the native video subsystem (SDL_sysvideo.c) 29 | */ 30 | extern void N3DS_InitOSKeymap(_THIS); 31 | extern void N3DS_PumpEvents(_THIS); 32 | 33 | /* end of SDL_nullevents_c.h ... */ 34 | 35 | -------------------------------------------------------------------------------- /src/rfb/sasl.h: -------------------------------------------------------------------------------- 1 | #ifndef RFBSASL_H 2 | #define RFBSASL_H 3 | 4 | /* 5 | * Copyright (C) 2017 S. Waterman. All Rights Reserved. 6 | * 7 | * This is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This software is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this software; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 20 | * USA. 21 | */ 22 | 23 | #ifdef LIBVNCSERVER_HAVE_SASL 24 | 25 | #include 26 | 27 | /* 28 | * Perform the SASL authentication process 29 | */ 30 | rfbBool HandleSASLAuth(rfbClient *client); 31 | 32 | /* 33 | * Read from SASL when the SASL SSF is in use. 34 | */ 35 | int ReadFromSASL(rfbClient* client, char *out, unsigned int n); 36 | 37 | #endif /* LIBVNCSERVER_HAVE_SASL */ 38 | 39 | #endif /* RFBSASL_H */ 40 | -------------------------------------------------------------------------------- /LIBSDL/src/cdrom/dummy/SDL_syscdrom.c: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | #include "SDL_config.h" 23 | 24 | #if defined(SDL_CDROM_DUMMY) || defined(SDL_CDROM_DISABLED) 25 | 26 | /* Stub functions for system-level CD-ROM audio control */ 27 | 28 | #include "SDL_cdrom.h" 29 | #include "../SDL_syscdrom.h" 30 | 31 | int SDL_SYS_CDInit(void) 32 | { 33 | return(0); 34 | } 35 | 36 | void SDL_SYS_CDQuit(void) 37 | { 38 | return; 39 | } 40 | 41 | #endif /* SDL_CDROM_DUMMY || SDL_CDROM_DISABLED */ 42 | -------------------------------------------------------------------------------- /LIBSDL/src/video/SDL_RLEaccel_c.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | #include "SDL_config.h" 23 | 24 | /* Useful functions and variables from SDL_RLEaccel.c */ 25 | 26 | extern int SDL_RLESurface(SDL_Surface *surface); 27 | extern int SDL_RLEBlit(SDL_Surface *src, SDL_Rect *srcrect, 28 | SDL_Surface *dst, SDL_Rect *dstrect); 29 | extern int SDL_RLEAlphaBlit(SDL_Surface *src, SDL_Rect *srcrect, 30 | SDL_Surface *dst, SDL_Rect *dstrect); 31 | extern void SDL_UnRLESurface(SDL_Surface *surface, int recode); 32 | -------------------------------------------------------------------------------- /LIBSDL/src/audio/SDL_audio_c.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | #include "SDL_config.h" 23 | 24 | /* Functions and variables exported from SDL_audio.c for SDL_sysaudio.c */ 25 | 26 | /* Functions to get a list of "close" audio formats */ 27 | extern Uint16 SDL_FirstAudioFormat(Uint16 format); 28 | extern Uint16 SDL_NextAudioFormat(void); 29 | 30 | /* Function to calculate the size and silence for a SDL_AudioSpec */ 31 | extern void SDL_CalculateAudioSpec(SDL_AudioSpec *spec); 32 | 33 | /* The actual mixing thread function */ 34 | extern int SDLCALL SDL_RunAudio(void *audiop); 35 | 36 | -------------------------------------------------------------------------------- /LIBSDL/src/audio/SDL_mixer_m68k.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with this library; if not, write to the Free 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | #include "SDL_config.h" 23 | 24 | /* 25 | m68k assembly mix routines 26 | 27 | Patrice Mandin 28 | */ 29 | 30 | #if (defined(__m68k__) && !defined(__mcoldfire__)) && defined(__GNUC__) 31 | void SDL_MixAudio_m68k_U8(char* dst,char* src, long len, long volume, char* mix8); 32 | void SDL_MixAudio_m68k_S8(char* dst,char* src, long len, long volume); 33 | 34 | void SDL_MixAudio_m68k_S16MSB(short* dst,short* src, long len, long volume); 35 | void SDL_MixAudio_m68k_S16LSB(short* dst,short* src, long len, long volume); 36 | #endif 37 | -------------------------------------------------------------------------------- /LIBSDL/src/video/SDL_yuvfuncs.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | #include "SDL_config.h" 23 | 24 | /* This is the definition of the YUV video surface function structure */ 25 | 26 | #include "SDL_video.h" 27 | #include "SDL_sysvideo.h" 28 | 29 | #ifndef _THIS 30 | #define _THIS SDL_VideoDevice *_this 31 | #endif 32 | struct private_yuvhwfuncs { 33 | int (*Lock)(_THIS, SDL_Overlay *overlay); 34 | void (*Unlock)(_THIS, SDL_Overlay *overlay); 35 | int (*Display)(_THIS, SDL_Overlay *overlay, SDL_Rect *src, SDL_Rect *dst); 36 | void (*FreeHW)(_THIS, SDL_Overlay *overlay); 37 | }; 38 | -------------------------------------------------------------------------------- /LIBSDL/src/timer/SDL_systimer.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | #include "SDL_config.h" 23 | 24 | /* The system dependent timer handling functions */ 25 | 26 | #include "SDL_timer.h" 27 | #include "SDL_timer_c.h" 28 | 29 | 30 | /* Initialize the system dependent timer subsystem */ 31 | extern int SDL_SYS_TimerInit(void); 32 | 33 | /* Quit the system dependent timer subsystem */ 34 | extern void SDL_SYS_TimerQuit(void); 35 | 36 | /* Start a timer set up by SDL_SetTimer() */ 37 | extern int SDL_SYS_StartTimer(void); 38 | 39 | /* Stop a previously started timer */ 40 | extern void SDL_SYS_StopTimer(void); 41 | -------------------------------------------------------------------------------- /src/utilities.h: -------------------------------------------------------------------------------- 1 | /* 2 | * TinyVNC - A VNC client for Nintendo 3DS 3 | * 4 | * utilities.h - utility functions 5 | * 6 | * Copyright 2020 Sebastian Weber 7 | */ 8 | #ifndef _UTILITIES_H 9 | #define _UTILITIES_H 10 | 11 | /* 8-times unrolled loop */ 12 | #define DUFFS_LOOP(pixel_copy_increment, width) \ 13 | { int n = (width+7)/8; \ 14 | switch (width & 7) { \ 15 | case 0: do { pixel_copy_increment; \ 16 | case 7: pixel_copy_increment; \ 17 | case 6: pixel_copy_increment; \ 18 | case 5: pixel_copy_increment; \ 19 | case 4: pixel_copy_increment; \ 20 | case 3: pixel_copy_increment; \ 21 | case 2: pixel_copy_increment; \ 22 | case 1: pixel_copy_increment; \ 23 | } while ( --n > 0 ); \ 24 | } \ 25 | } 26 | 27 | #define MIN(a,b) \ 28 | ({ __typeof__ (a) _a = (a); \ 29 | __typeof__ (b) _b = (b); \ 30 | _a < _b ? _a : _b; }) 31 | 32 | #define MAX(a,b) \ 33 | ({ __typeof__ (a) _a = (a); \ 34 | __typeof__ (b) _b = (b); \ 35 | _a > _b ? _a : _b; }) 36 | 37 | #define LIMIT(a,l1,l2) \ 38 | ({ __typeof__ (a) _a = (a); \ 39 | __typeof__ (l1) _l1 = (l1); \ 40 | __typeof__ (l2) _l2 = (l2); \ 41 | _a < _l1 ? _l1 : (_a > _l2 ? _l2 : _a); }) 42 | 43 | extern u64 getmicrotime(); 44 | extern void printBits(size_t const size, void const * const ptr); 45 | extern void hex_dump(char *data, int size, char *caption); 46 | extern int fastscale(unsigned char *d, int dst_pitch, unsigned char *s, int src_width, int src_height, int src_pitch, int factor); 47 | 48 | #endif // _UTILITIES_H 49 | -------------------------------------------------------------------------------- /LIBSDL/src/video/SDL_yuv_sw_c.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | #include "SDL_config.h" 23 | 24 | #include "SDL_video.h" 25 | #include "SDL_sysvideo.h" 26 | 27 | /* This is the software implementation of the YUV video overlay support */ 28 | 29 | extern SDL_Overlay *SDL_CreateYUV_SW(_THIS, int width, int height, Uint32 format, SDL_Surface *display); 30 | 31 | extern int SDL_LockYUV_SW(_THIS, SDL_Overlay *overlay); 32 | 33 | extern void SDL_UnlockYUV_SW(_THIS, SDL_Overlay *overlay); 34 | 35 | extern int SDL_DisplayYUV_SW(_THIS, SDL_Overlay *overlay, SDL_Rect *src, SDL_Rect *dst); 36 | 37 | extern void SDL_FreeYUV_SW(_THIS, SDL_Overlay *overlay); 38 | -------------------------------------------------------------------------------- /src/rfb/d3des.h: -------------------------------------------------------------------------------- 1 | #ifndef D3DES_H 2 | #define D3DES_H 3 | 4 | /* 5 | * This is D3DES (V5.09) by Richard Outerbridge with the double and 6 | * triple-length support removed for use in VNC. 7 | * 8 | * These changes are: 9 | * Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved. 10 | * 11 | * This software is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 | */ 15 | 16 | /* d3des.h - 17 | * 18 | * Headers and defines for d3des.c 19 | * Graven Imagery, 1992. 20 | * 21 | * Copyright (c) 1988,1989,1990,1991,1992 by Richard Outerbridge 22 | * (GEnie : OUTER; CIS : [71755,204]) 23 | */ 24 | 25 | #define EN0 0 /* MODE == encrypt */ 26 | #define DE1 1 /* MODE == decrypt */ 27 | 28 | extern void rfbDesKey(unsigned char *, int); 29 | /* hexkey[8] MODE 30 | * Sets the internal key register according to the hexadecimal 31 | * key contained in the 8 bytes of hexkey, according to the DES, 32 | * for encryption or decryption according to MODE. 33 | */ 34 | 35 | 36 | extern void rfbDes(unsigned char *, unsigned char *); 37 | /* from[8] to[8] 38 | * Encrypts/Decrypts (according to the key currently loaded in the 39 | * internal key register) one block of eight bytes at address 'from' 40 | * into the block at address 'to'. They can be the same. 41 | */ 42 | 43 | /* d3des.h V5.09 rwo 9208.04 15:06 Graven Imagery 44 | ********************************************************************/ 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /LIBSDL/src/audio/n3ds/SDL_n3dsaudio.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | #include <3ds.h> 23 | #include "SDL_config.h" 24 | 25 | #ifndef _SDL_n3dsaudio_h 26 | #define _SDL_n3dsaudio_h 27 | 28 | #include "../SDL_sysaudio.h" 29 | 30 | #define _THIS SDL_AudioDevice *this 31 | 32 | #define NUM_BUFFERS 2 /* -- Don't lower this! */ 33 | 34 | struct SDL_PrivateAudioData { 35 | /* The file descriptor for the audio device */ 36 | Uint8 *mixbuf; 37 | Uint32 mixlen; 38 | Uint32 format; 39 | Uint32 samplerate; 40 | Uint32 channels; 41 | Uint8 bytePerSample; 42 | Uint32 isSigned; 43 | Uint32 nextbuf; 44 | ndspWaveBuf waveBuf[NUM_BUFFERS]; 45 | LightLock lock; 46 | CondVar cv; 47 | bool isCancelled; 48 | }; 49 | 50 | #endif /* _SDL_n3dsaudio_h */ 51 | -------------------------------------------------------------------------------- /LIBSDL/include/SDL/close_code.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Library General Public License for more details. 14 | 15 | You should have received a copy of the GNU Library General Public 16 | License along with this library; if not, write to the Free 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** 24 | * @file close_code.h 25 | * This file reverses the effects of begin_code.h and should be included 26 | * after you finish any function and structure declarations in your headers 27 | */ 28 | 29 | #undef _begin_code_h 30 | 31 | /** 32 | * @file close_code.h 33 | * Reset structure packing at previous byte alignment 34 | */ 35 | #if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__) 36 | #ifdef __BORLANDC__ 37 | #pragma nopackwarning 38 | #endif 39 | #if (defined(__MWERKS__) && defined(__MACOS__)) 40 | #pragma options align=reset 41 | #pragma enumsalwaysint reset 42 | #else 43 | #pragma pack(pop) 44 | #endif 45 | #endif /* Compiler needs structure packing set */ 46 | 47 | -------------------------------------------------------------------------------- /LIBSDL/src/events/SDL_sysevents.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is SDL_free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | #include "SDL_config.h" 23 | 24 | #include "../video/SDL_sysvideo.h" 25 | 26 | /* Useful functions and variables from SDL_sysevents.c */ 27 | 28 | #ifdef __BEOS__ /* The Be event loop runs in a separate thread */ 29 | #define MUST_THREAD_EVENTS 30 | #endif 31 | 32 | #ifdef __WIN32__ /* Win32 doesn't allow a separate event thread */ 33 | #define CANT_THREAD_EVENTS 34 | #endif 35 | 36 | #ifdef IPOD /* iPod doesn't support threading at all */ 37 | #define CANT_THREAD_EVENTS 38 | #endif 39 | 40 | #ifdef __MACOS__ /* MacOS 7/8 don't support preemptive multi-tasking */ 41 | #define CANT_THREAD_EVENTS 42 | #endif 43 | 44 | #ifdef __OS2__ /* The OS/2 event loop runs in a separate thread */ 45 | #define MUST_THREAD_EVENTS 46 | #endif 47 | -------------------------------------------------------------------------------- /LIBSDL/src/video/n3ds/vshader_shbin.s: -------------------------------------------------------------------------------- 1 | /* Generated by BIN2S - please don't edit directly */ 2 | .section .rodata 3 | .balign 4 4 | .global vshader_shbin_size 5 | .global vshader_shbin 6 | vshader_shbin: 7 | .byte 68, 86, 76, 66, 1, 0, 0, 0,140, 0, 0, 0, 68, 86, 76, 80 8 | .byte 0, 0, 0, 0, 40, 0, 0, 0, 8, 0, 0, 0, 72, 0, 0, 0 9 | .byte 7, 0, 0, 0,128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 10 | .byte 0, 0, 0, 0, 0, 0, 0, 78, 1,240, 7, 78, 2, 8, 2, 8 11 | .byte 3, 24, 2, 8, 4, 40, 2, 8, 5, 56, 2, 8, 6, 16, 32, 76 12 | .byte 0, 0, 0,136,110, 3, 0, 0, 0, 0, 0, 0,161, 10, 0, 0 13 | .byte 0, 0, 0, 0,104,195, 6, 0, 0, 0, 0, 0,100,195, 6, 0 14 | .byte 0, 0, 0, 0, 98,195, 6, 0, 0, 0, 0, 0, 97,195, 6, 0 15 | .byte 0, 0, 0, 0,111, 3, 0, 0, 0, 0, 0, 0, 68, 86, 76, 69 16 | .byte 2, 16, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 3, 0 17 | .byte 0, 0, 0, 0, 64, 0, 0, 0, 2, 0, 0, 0,104, 0, 0, 0 18 | .byte 0, 0, 0, 0,104, 0, 0, 0, 2, 0, 0, 0,120, 0, 0, 0 19 | .byte 2, 0, 0, 0,136, 0, 0, 0, 16, 0, 0, 0, 2, 0, 95, 0 20 | .byte 0, 0, 0, 0, 0, 0, 63, 0, 0, 0,191, 0,153,153, 59, 0 21 | .byte 2, 0, 94, 0, 51, 51, 61, 0, 0, 0, 0, 0, 0, 0, 0, 0 22 | .byte 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 3, 0, 1, 0 23 | .byte 15, 0, 0, 0, 0, 0, 0, 0, 16, 0, 19, 0, 11, 0, 0, 0 24 | .byte 120, 0,120, 0,112,114,111,106,101, 99,116,105,111,110, 0,116 25 | .byte 101,115,116, 0 26 | 27 | .global vshader_shbin_end 28 | vshader_shbin_end: 29 | 30 | .balign 4 31 | vshader_shbin_size: .int 292 32 | -------------------------------------------------------------------------------- /LIBSDL/src/audio/SDL_mixer_MMX_VC.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | #include "SDL_config.h" 23 | 24 | 25 | #if defined(SDL_BUGGY_MMX_MIXERS) /* buggy, so we're disabling them. --ryan. */ 26 | #if ((defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)) && defined(SDL_ASSEMBLY_ROUTINES) 27 | /* headers for MMX assembler version of SDL_MixAudio 28 | Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr) 29 | Converted to Intel ASM notation by Cth 30 | This code is licensed under the LGPL (see COPYING for details) 31 | 32 | Assumes buffer size in bytes is a multiple of 16 33 | Assumes SDL_MIX_MAXVOLUME = 128 34 | */ 35 | void SDL_MixAudio_MMX_S16_VC(char* ,char* ,unsigned int ,int ); 36 | void SDL_MixAudio_MMX_S8_VC(char* ,char* ,unsigned int ,int ); 37 | #endif 38 | #endif 39 | -------------------------------------------------------------------------------- /LIBSDL/src/events/SDL_expose.c: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | #include "SDL_config.h" 23 | 24 | /* Refresh event handling code for SDL */ 25 | 26 | #include "SDL_events.h" 27 | #include "SDL_events_c.h" 28 | 29 | 30 | /* This is global for SDL_eventloop.c */ 31 | int SDL_PrivateExpose(void) 32 | { 33 | int posted; 34 | SDL_Event events[32]; 35 | 36 | /* Pull out all old refresh events */ 37 | SDL_PeepEvents(events, sizeof(events)/sizeof(events[0]), 38 | SDL_GETEVENT, SDL_VIDEOEXPOSEMASK); 39 | 40 | /* Post the event, if desired */ 41 | posted = 0; 42 | if ( SDL_ProcessEvents[SDL_VIDEOEXPOSE] == SDL_ENABLE ) { 43 | SDL_Event event; 44 | event.type = SDL_VIDEOEXPOSE; 45 | if ( (SDL_EventOK == NULL) || (*SDL_EventOK)(&event) ) { 46 | posted = 1; 47 | SDL_PushEvent(&event); 48 | } 49 | } 50 | return(posted); 51 | } 52 | -------------------------------------------------------------------------------- /LIBSDL/src/joystick/SDL_joystick_c.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | #include "SDL_config.h" 23 | 24 | /* Useful functions and variables from SDL_joystick.c */ 25 | #include "SDL_joystick.h" 26 | 27 | /* The number of available joysticks on the system */ 28 | extern Uint8 SDL_numjoysticks; 29 | 30 | /* Internal event queueing functions */ 31 | extern int SDL_PrivateJoystickAxis(SDL_Joystick *joystick, 32 | Uint8 axis, Sint16 value); 33 | extern int SDL_PrivateJoystickBall(SDL_Joystick *joystick, 34 | Uint8 ball, Sint16 xrel, Sint16 yrel); 35 | extern int SDL_PrivateJoystickHat(SDL_Joystick *joystick, 36 | Uint8 hat, Uint8 value); 37 | extern int SDL_PrivateJoystickButton(SDL_Joystick *joystick, 38 | Uint8 button, Uint8 state); 39 | -------------------------------------------------------------------------------- /LIBSDL/src/timer/SDL_timer_c.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | #include "SDL_config.h" 23 | 24 | /* Useful functions and variables from SDL_timer.c */ 25 | #include "SDL_timer.h" 26 | 27 | #define ROUND_RESOLUTION(X) \ 28 | (((X+TIMER_RESOLUTION-1)/TIMER_RESOLUTION)*TIMER_RESOLUTION) 29 | 30 | extern int SDL_timer_started; 31 | extern int SDL_timer_running; 32 | 33 | /* Data to handle a single periodic alarm */ 34 | extern Uint32 SDL_alarm_interval; 35 | extern SDL_TimerCallback SDL_alarm_callback; 36 | 37 | /* Set whether or not the timer should use a thread. 38 | This should be called while the timer subsystem is running. 39 | */ 40 | extern int SDL_SetTimerThreaded(int value); 41 | 42 | extern int SDL_TimerInit(void); 43 | extern void SDL_TimerQuit(void); 44 | 45 | /* This function is called from the SDL event thread if it is available */ 46 | extern void SDL_ThreadedTimerCheck(void); 47 | -------------------------------------------------------------------------------- /LIBSDL/src/loadso/dummy/SDL_sysloadso.c: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | #include "SDL_config.h" 23 | 24 | #if defined(SDL_LOADSO_DUMMY) || defined(SDL_LOADSO_DISABLED) 25 | 26 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 27 | /* System dependent library loading routines */ 28 | 29 | #include "SDL_loadso.h" 30 | 31 | void *SDL_LoadObject(const char *sofile) 32 | { 33 | const char *loaderror = "SDL_LoadObject() not implemented"; 34 | SDL_SetError("Failed loading %s: %s", sofile, loaderror); 35 | return(NULL); 36 | } 37 | 38 | void *SDL_LoadFunction(void *handle, const char *name) 39 | { 40 | const char *loaderror = "SDL_LoadFunction() not implemented"; 41 | SDL_SetError("Failed loading %s: %s", name, loaderror); 42 | return(NULL); 43 | } 44 | 45 | void SDL_UnloadObject(void *handle) 46 | { 47 | /* no-op. */ 48 | } 49 | 50 | #endif /* SDL_LOADSO_DUMMY || SDL_LOADSO_DISABLED */ 51 | -------------------------------------------------------------------------------- /src/rfb/tls_none.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Christian Beier. 3 | * 4 | * This is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This software is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 17 | * USA. 18 | */ 19 | 20 | #include 21 | #include 22 | #include "tls.h" 23 | 24 | rfbBool HandleAnonTLSAuth(rfbClient* client) 25 | { 26 | rfbClientLog("TLS is not supported.\n"); 27 | return FALSE; 28 | } 29 | 30 | 31 | rfbBool HandleVeNCryptAuth(rfbClient* client) 32 | { 33 | rfbClientLog("TLS is not supported.\n"); 34 | return FALSE; 35 | } 36 | 37 | 38 | int ReadFromTLS(rfbClient* client, char *out, unsigned int n) 39 | { 40 | rfbClientLog("TLS is not supported.\n"); 41 | errno = EINTR; 42 | return -1; 43 | } 44 | 45 | 46 | int WriteToTLS(rfbClient* client, const char *buf, unsigned int n) 47 | { 48 | rfbClientLog("TLS is not supported.\n"); 49 | errno = EINTR; 50 | return -1; 51 | } 52 | 53 | 54 | void FreeTLS(rfbClient* client) 55 | { 56 | 57 | } 58 | 59 | #ifdef LIBVNCSERVER_HAVE_SASL 60 | int 61 | GetTLSCipherBits(rfbClient* client) 62 | { 63 | rfbClientLog("TLS is not supported.\n"); 64 | return 0; 65 | } 66 | #endif /* LIBVNCSERVER_HAVE_SASL */ 67 | 68 | -------------------------------------------------------------------------------- /src/vjoy-udp-feeder-client.h: -------------------------------------------------------------------------------- 1 | /* 2 | Client to vJoy-UDP-Feeder for N3DS 3 | https://github.com/klach/vjoy-udp-feeder 4 | (c) 2022 Sebastian Weber 5 | */ 6 | #include <3ds.h> 7 | 8 | #ifndef SGN 9 | #define SGN(x) \ 10 | ({ __typeof__ (x) _a = (x); \ 11 | ((__typeof__ (x))0 < _a) - (_a < (__typeof__ (x))0);}) 12 | #endif 13 | 14 | #define VJOY_UDP_ERRMSG_LENGTH 128 15 | 16 | struct vjoy_udp_coeffs { 17 | int cp_deadzone; // C-Pad 18 | int cp_max; 19 | int cp_threshold; // threshold is used to reduce network traffic. Only values that changed more than threshhold since last sent are transferred to the server 20 | int cs_deadzone; // C-Stick 21 | int cs_max; 22 | int cs_threshold; 23 | int acc_deadzone; // Accelerometer 24 | int acc_max; 25 | int acc_threshold; 26 | int gy_deadzone; // Gyro 27 | int gy_max; 28 | int gy_threshold; 29 | }; 30 | 31 | struct vjoy_udp_client { 32 | int socket; 33 | struct sockaddr_in addr1; // for button / joy / touch data 34 | struct sockaddr_in addr2; // for motion data 35 | char lasterrmsg[VJOY_UDP_ERRMSG_LENGTH]; 36 | int lasterrno; 37 | struct vjoy_udp_coeffs coeffs; 38 | u32 metabutton; // KEY_SELECT per default 39 | int mouse_relative; // 0 for absolute, 1 for relative mouse movements (default 0) 40 | int mouse_sensitivity; // mouse sensitivity for relative movements (default 10) 41 | int interval; // in which intervals (ms) should we send new data to the server? (default 75) 42 | }; 43 | 44 | extern int vjoy_udp_client_init(struct vjoy_udp_client *client, char *hostname, int port, int motionport); 45 | extern int vjoy_udp_client_update( 46 | struct vjoy_udp_client *client, 47 | u32 buttons, 48 | circlePosition *posCp, 49 | circlePosition *posStk, 50 | touchPosition *touch, 51 | accelVector *accel, 52 | angularRate *gyro, 53 | float slider); 54 | extern int vjoy_udp_client_shutdown(struct vjoy_udp_client *client); 55 | -------------------------------------------------------------------------------- /src/rfb/sockets.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LibVNCServer/LibVNCClient common platform socket defines and includes. 3 | * 4 | * Copyright (C) 2020 Christian Beier 5 | * 6 | * This is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This software is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 19 | * USA. 20 | */ 21 | 22 | #ifndef _RFB_COMMON_SOCKETS_H 23 | #define _RFB_COMMON_SOCKETS_H 24 | 25 | #ifdef WIN32 26 | /* 27 | Windows sockets 28 | */ 29 | #include 30 | #include 31 | 32 | #undef EWOULDBLOCK 33 | #define EWOULDBLOCK WSAEWOULDBLOCK 34 | 35 | #undef ETIMEDOUT 36 | #define ETIMEDOUT WSAETIMEDOUT 37 | 38 | #undef EINTR 39 | #define EINTR WSAEINTR 40 | 41 | #undef EINVAL 42 | #define EINVAL WSAEINVAL 43 | 44 | /* MinGW has those, but MSVC not */ 45 | #ifdef _MSC_VER 46 | #define SHUT_RD SD_RECEIVE 47 | #define SHUT_WR SD_SEND 48 | #define SHUT_RDWR SD_BOTH 49 | #endif 50 | 51 | #define read(sock,buf,len) recv(sock,buf,len,0) 52 | #define write(sock,buf,len) send(sock,buf,len,0) 53 | 54 | #else 55 | /* 56 | Unix sockets 57 | */ 58 | #include 59 | //#include 60 | #include 61 | #include 62 | #include 63 | #include 64 | #endif 65 | 66 | #endif /* _RFB_COMMON_SOCKETS_H */ 67 | -------------------------------------------------------------------------------- /src/dsu-server.h: -------------------------------------------------------------------------------- 1 | /* 2 | Cemuhook Server implementation for N3DS 3 | (c) 2022 Sebastian Weber 4 | 5 | https://v1993.github.io/cemuhook-protocol/ 6 | */ 7 | 8 | #define DSU_ERRMSG_LENGTH 128 9 | 10 | struct dsu_coeffs { 11 | int cp_deadzone; // C-Pad 12 | int cp_max; 13 | int cp_threshold; // threshold is used to reduce network traffic. Only values that changed more than threshhold since last sent are transferred to the server 14 | int cs_deadzone; // C-Stick 15 | int cs_max; 16 | int cs_threshold; 17 | int acc_deadzone; // Accelerometer 18 | int acc_threshold; 19 | int gy_deadzone; // Gyro 20 | int gy_threshold; 21 | float gy_raw2dps; 22 | }; 23 | 24 | struct dsu_client { 25 | u64 timestamp; 26 | u32 id; 27 | struct sockaddr_in addr; 28 | struct dsu_client *next; 29 | struct dsu_client *prev; 30 | u32 packet_count; 31 | u8 oldpacket[80]; 32 | }; 33 | 34 | struct dsu_server { 35 | int socket; 36 | char ipstr[INET_ADDRSTRLEN]; 37 | int port; 38 | char lasterrmsg[DSU_ERRMSG_LENGTH]; 39 | int lasterrno; 40 | struct dsu_client *cli_first; 41 | struct dsu_client *cli_last; 42 | struct dsu_coeffs coeffs; 43 | u32 button_meta; // KEY_SELECT per default 44 | u32 button_plus; // KEY_DUP per default (+meta) 45 | u32 button_minus; // KEY_DDOWN per default (+meta) 46 | u32 button_LSTCK_PUSH; // KEY_DLEFT per default (+meta) 47 | u32 button_RSTCK_PUSH; // KEY_DRIGHT per default (+meta) 48 | int interval; // in which minimum intervals (ms) should we send new data to the clients? (default 75) 49 | }; 50 | 51 | extern int dsu_server_init(struct dsu_server *server, int port); 52 | extern int dsu_server_shutdown(struct dsu_server *server); 53 | extern int dsu_server_run(struct dsu_server *server); 54 | extern int dsu_server_update( // all parameters can be NULL except server 55 | struct dsu_server *server, 56 | u32 buttons, 57 | circlePosition *posCp, 58 | circlePosition *posStk, 59 | touchPosition *touch, 60 | accelVector *accel, 61 | angularRate *gyro); 62 | -------------------------------------------------------------------------------- /LIBSDL/src/SDL_error_c.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | #include "SDL_config.h" 23 | 24 | /* This file defines a structure that carries language-independent 25 | error messages 26 | */ 27 | 28 | #ifndef _SDL_error_c_h 29 | #define _SDL_error_c_h 30 | 31 | #define ERR_MAX_STRLEN 128 32 | #define ERR_MAX_ARGS 5 33 | 34 | typedef struct SDL_error { 35 | /* This is a numeric value corresponding to the current error */ 36 | int error; 37 | 38 | /* This is a key used to index into a language hashtable containing 39 | internationalized versions of the SDL error messages. If the key 40 | is not in the hashtable, or no hashtable is available, the key is 41 | used directly as an error message format string. 42 | */ 43 | char key[ERR_MAX_STRLEN]; 44 | 45 | /* These are the arguments for the error functions */ 46 | int argc; 47 | union { 48 | void *value_ptr; 49 | #if 0 /* What is a character anyway? (UNICODE issues) */ 50 | unsigned char value_c; 51 | #endif 52 | int value_i; 53 | double value_f; 54 | char buf[ERR_MAX_STRLEN]; 55 | } args[ERR_MAX_ARGS]; 56 | } SDL_error; 57 | 58 | #endif /* _SDL_error_c_h */ 59 | -------------------------------------------------------------------------------- /LIBSDL/src/thread/SDL_systhread.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | #include "SDL_config.h" 23 | 24 | /* These are functions that need to be implemented by a port of SDL */ 25 | 26 | #ifndef _SDL_systhread_h 27 | #define _SDL_systhread_h 28 | 29 | #include "SDL_thread.h" 30 | 31 | /* This function creates a thread, passing args to SDL_RunThread(), 32 | saves a system-dependent thread id in thread->id, and returns 0 33 | on success. 34 | */ 35 | #ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD 36 | extern int SDL_SYS_CreateThread(SDL_Thread *thread, void *args, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread); 37 | #else 38 | extern int SDL_SYS_CreateThread(SDL_Thread *thread, void *args); 39 | #endif 40 | 41 | /* This function does any necessary setup in the child thread */ 42 | extern void SDL_SYS_SetupThread(void); 43 | 44 | /* This function waits for the thread to finish and frees any data 45 | allocated by SDL_SYS_CreateThread() 46 | */ 47 | extern void SDL_SYS_WaitThread(SDL_Thread *thread); 48 | 49 | /* This function kills the thread and returns */ 50 | extern void SDL_SYS_KillThread(SDL_Thread *thread); 51 | 52 | #endif /* _SDL_systhread_h */ 53 | -------------------------------------------------------------------------------- /LIBSDL/src/video/SDL_pixels_c.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | #include "SDL_config.h" 23 | 24 | /* Useful functions and variables from SDL_pixel.c */ 25 | 26 | #include "SDL_blit.h" 27 | 28 | /* Pixel format functions */ 29 | extern SDL_PixelFormat *SDL_AllocFormat(int bpp, 30 | Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); 31 | extern SDL_PixelFormat *SDL_ReallocFormat(SDL_Surface *surface, int bpp, 32 | Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); 33 | extern void SDL_FormatChanged(SDL_Surface *surface); 34 | extern void SDL_FreeFormat(SDL_PixelFormat *format); 35 | 36 | /* Blit mapping functions */ 37 | extern SDL_BlitMap *SDL_AllocBlitMap(void); 38 | extern void SDL_InvalidateMap(SDL_BlitMap *map); 39 | extern int SDL_MapSurface (SDL_Surface *src, SDL_Surface *dst); 40 | extern void SDL_FreeBlitMap(SDL_BlitMap *map); 41 | 42 | /* Miscellaneous functions */ 43 | extern Uint16 SDL_CalculatePitch(SDL_Surface *surface); 44 | extern void SDL_DitherColors(SDL_Color *colors, int bpp); 45 | extern Uint8 SDL_FindColor(SDL_Palette *pal, Uint8 r, Uint8 g, Uint8 b); 46 | extern void SDL_ApplyGamma(Uint16 *gamma, SDL_Color *colors, SDL_Color *output, int ncolors); 47 | -------------------------------------------------------------------------------- /src/rfb/rfbregion.h: -------------------------------------------------------------------------------- 1 | #ifndef SRAREGION_H 2 | #define SRAREGION_H 3 | 4 | /* -=- SRA - Simple Region Algorithm 5 | * A simple rectangular region implementation. 6 | * Copyright (c) 2001 James "Wez" Weatherall, Johannes E. Schindelin 7 | */ 8 | 9 | /* -=- sraRect */ 10 | 11 | typedef struct _rect { 12 | int x1; 13 | int y1; 14 | int x2; 15 | int y2; 16 | } sraRect; 17 | 18 | typedef struct sraRegion sraRegion; 19 | 20 | /* -=- Region manipulation functions */ 21 | 22 | extern sraRegion *sraRgnCreate(); 23 | extern sraRegion *sraRgnCreateRect(int x1, int y1, int x2, int y2); 24 | extern sraRegion *sraRgnCreateRgn(const sraRegion *src); 25 | 26 | extern void sraRgnDestroy(sraRegion *rgn); 27 | extern void sraRgnMakeEmpty(sraRegion *rgn); 28 | extern rfbBool sraRgnAnd(sraRegion *dst, const sraRegion *src); 29 | extern void sraRgnOr(sraRegion *dst, const sraRegion *src); 30 | extern rfbBool sraRgnSubtract(sraRegion *dst, const sraRegion *src); 31 | 32 | extern void sraRgnOffset(sraRegion *dst, int dx, int dy); 33 | 34 | extern rfbBool sraRgnPopRect(sraRegion *region, sraRect *rect, 35 | unsigned long flags); 36 | 37 | extern unsigned long sraRgnCountRects(const sraRegion *rgn); 38 | extern rfbBool sraRgnEmpty(const sraRegion *rgn); 39 | 40 | extern sraRegion *sraRgnBBox(const sraRegion *src); 41 | 42 | /* -=- rectangle iterator */ 43 | 44 | typedef struct sraRectangleIterator { 45 | rfbBool reverseX,reverseY; 46 | int ptrSize,ptrPos; 47 | struct sraSpan** sPtrs; 48 | } sraRectangleIterator; 49 | 50 | extern sraRectangleIterator *sraRgnGetIterator(sraRegion *s); 51 | extern sraRectangleIterator *sraRgnGetReverseIterator(sraRegion *s,rfbBool reverseX,rfbBool reverseY); 52 | extern rfbBool sraRgnIteratorNext(sraRectangleIterator *i,sraRect *r); 53 | extern void sraRgnReleaseIterator(sraRectangleIterator *i); 54 | 55 | void sraRgnPrint(const sraRegion *s); 56 | 57 | /* -=- Rectangle clipper (for speed) */ 58 | 59 | extern rfbBool sraClipRect(int *x, int *y, int *w, int *h, 60 | int cx, int cy, int cw, int ch); 61 | 62 | extern rfbBool sraClipRect2(int *x, int *y, int *x2, int *y2, 63 | int cx, int cy, int cx2, int cy2); 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /LIBSDL/include/SDL/SDL_error.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** 24 | * @file SDL_error.h 25 | * Simple error message routines for SDL 26 | */ 27 | 28 | #ifndef _SDL_error_h 29 | #define _SDL_error_h 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /** 40 | * @name Public functions 41 | */ 42 | /*@{*/ 43 | extern DECLSPEC void SDLCALL SDL_SetError(const char *fmt, ...); 44 | extern DECLSPEC char * SDLCALL SDL_GetError(void); 45 | extern DECLSPEC void SDLCALL SDL_ClearError(void); 46 | /*@}*/ 47 | 48 | /** 49 | * @name Private functions 50 | * @internal Private error message function - used internally 51 | */ 52 | /*@{*/ 53 | #define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM) 54 | #define SDL_Unsupported() SDL_Error(SDL_UNSUPPORTED) 55 | typedef enum { 56 | SDL_ENOMEM, 57 | SDL_EFREAD, 58 | SDL_EFWRITE, 59 | SDL_EFSEEK, 60 | SDL_UNSUPPORTED, 61 | SDL_LASTERROR 62 | } SDL_errorcode; 63 | extern DECLSPEC void SDLCALL SDL_Error(SDL_errorcode code); 64 | /*@}*/ 65 | 66 | /* Ends C function definitions when using C++ */ 67 | #ifdef __cplusplus 68 | } 69 | #endif 70 | #include "close_code.h" 71 | 72 | #endif /* _SDL_error_h */ 73 | -------------------------------------------------------------------------------- /LIBSDL/include/SDL/SDL_active.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** 24 | * @file SDL_active.h 25 | * Include file for SDL application focus event handling 26 | */ 27 | 28 | #ifndef _SDL_active_h 29 | #define _SDL_active_h 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_error.h" 33 | 34 | #include "begin_code.h" 35 | /* Set up for C function definitions, even when using C++ */ 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | /** @name The available application states */ 41 | /*@{*/ 42 | #define SDL_APPMOUSEFOCUS 0x01 /**< The app has mouse coverage */ 43 | #define SDL_APPINPUTFOCUS 0x02 /**< The app has input focus */ 44 | #define SDL_APPACTIVE 0x04 /**< The application is active */ 45 | /*@}*/ 46 | 47 | /* Function prototypes */ 48 | /** 49 | * This function returns the current state of the application, which is a 50 | * bitwise combination of SDL_APPMOUSEFOCUS, SDL_APPINPUTFOCUS, and 51 | * SDL_APPACTIVE. If SDL_APPACTIVE is set, then the user is able to 52 | * see your application, otherwise it has been iconified or disabled. 53 | */ 54 | extern DECLSPEC Uint8 SDLCALL SDL_GetAppState(void); 55 | 56 | 57 | /* Ends C function definitions when using C++ */ 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | #include "close_code.h" 62 | 63 | #endif /* _SDL_active_h */ 64 | -------------------------------------------------------------------------------- /src/rfb/tls.h: -------------------------------------------------------------------------------- 1 | #ifndef TLS_H 2 | #define TLS_H 3 | 4 | /* 5 | * Copyright (C) 2009 Vic Lee. 6 | * 7 | * This is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 2 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This software is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this software; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 20 | * USA. 21 | */ 22 | 23 | /* Handle Anonymous TLS Authentication (18) with the server. 24 | * After authentication, client->tlsSession will be set. 25 | */ 26 | rfbBool HandleAnonTLSAuth(rfbClient* client); 27 | 28 | /* Handle VeNCrypt Authentication (19) with the server. 29 | * The callback function GetX509Credential will be called. 30 | * After authentication, client->tlsSession will be set. 31 | */ 32 | rfbBool HandleVeNCryptAuth(rfbClient* client); 33 | 34 | /* Read desired bytes from TLS session. 35 | * It's a wrapper function over gnutls_record_recv() and return values 36 | * are same as read(), that is, >0 for actual bytes read, 0 for EOF, 37 | * or EAGAIN, EINTR. 38 | * This should be a non-blocking call. Blocking is handled in sockets.c. 39 | */ 40 | int ReadFromTLS(rfbClient* client, char *out, unsigned int n); 41 | 42 | /* Write desired bytes to TLS session. 43 | * It's a wrapper function over gnutls_record_send() and it will be 44 | * blocking call, until all bytes are written or error returned. 45 | */ 46 | int WriteToTLS(rfbClient* client, const char *buf, unsigned int n); 47 | 48 | /* Free TLS resources */ 49 | void FreeTLS(rfbClient* client); 50 | 51 | #ifdef LIBVNCSERVER_HAVE_SASL 52 | /* Get the number of bits in the current cipher */ 53 | int GetTLSCipherBits(rfbClient* client); 54 | #endif /* LIBVNCSERVER_HAVE_SASL */ 55 | 56 | #endif /* TLS_H */ 57 | -------------------------------------------------------------------------------- /LIBSDL/include/SDL/SDL_quit.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** @file SDL_quit.h 24 | * Include file for SDL quit event handling 25 | */ 26 | 27 | #ifndef _SDL_quit_h 28 | #define _SDL_quit_h 29 | 30 | #include "SDL_stdinc.h" 31 | #include "SDL_error.h" 32 | 33 | /** @file SDL_quit.h 34 | * An SDL_QUITEVENT is generated when the user tries to close the application 35 | * window. If it is ignored or filtered out, the window will remain open. 36 | * If it is not ignored or filtered, it is queued normally and the window 37 | * is allowed to close. When the window is closed, screen updates will 38 | * complete, but have no effect. 39 | * 40 | * SDL_Init() installs signal handlers for SIGINT (keyboard interrupt) 41 | * and SIGTERM (system termination request), if handlers do not already 42 | * exist, that generate SDL_QUITEVENT events as well. There is no way 43 | * to determine the cause of an SDL_QUITEVENT, but setting a signal 44 | * handler in your application will override the default generation of 45 | * quit events for that signal. 46 | */ 47 | 48 | /** @file SDL_quit.h 49 | * There are no functions directly affecting the quit event 50 | */ 51 | 52 | #define SDL_QuitRequested() \ 53 | (SDL_PumpEvents(), SDL_PeepEvents(NULL,0,SDL_PEEKEVENT,SDL_QUITMASK)) 54 | 55 | #endif /* _SDL_quit_h */ 56 | -------------------------------------------------------------------------------- /LIBSDL/src/thread/SDL_thread_c.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | #include "SDL_config.h" 23 | 24 | #ifndef _SDL_thread_c_h 25 | #define _SDL_thread_c_h 26 | 27 | /* Need the definitions of SYS_ThreadHandle */ 28 | #if SDL_THREADS_DISABLED 29 | #include "generic/SDL_systhread_c.h" 30 | #elif SDL_THREAD_BEOS 31 | #include "beos/SDL_systhread_c.h" 32 | #elif SDL_THREAD_DC 33 | #include "dc/SDL_systhread_c.h" 34 | #elif SDL_THREAD_OS2 35 | #include "os2/SDL_systhread_c.h" 36 | #elif SDL_THREAD_PTH 37 | #include "pth/SDL_systhread_c.h" 38 | #elif SDL_THREAD_PTHREAD 39 | #include "pthread/SDL_systhread_c.h" 40 | #elif SDL_THREAD_SPROC 41 | #include "irix/SDL_systhread_c.h" 42 | #elif SDL_THREAD_WIN32 43 | #include "win32/SDL_systhread_c.h" 44 | #elif SDL_THREAD_SYMBIAN 45 | #include "symbian/SDL_systhread_c.h" 46 | #elif SDL_THREAD_N3DS 47 | #include "n3ds/SDL_systhread_c.h" 48 | #else 49 | #error Need thread implementation for this platform 50 | #include "generic/SDL_systhread_c.h" 51 | #endif 52 | #include "../SDL_error_c.h" 53 | 54 | /* This is the system-independent thread info structure */ 55 | struct SDL_Thread { 56 | Uint32 threadid; 57 | SYS_ThreadHandle handle; 58 | int status; 59 | SDL_error errbuf; 60 | void *data; 61 | }; 62 | 63 | /* This is the function called to run a thread */ 64 | extern void SDL_RunThread(void *data); 65 | 66 | #endif /* _SDL_thread_c_h */ 67 | -------------------------------------------------------------------------------- /src/rfb/crypto.h: -------------------------------------------------------------------------------- 1 | #ifndef _RFB_CRYPTO_H 2 | #define _RFB_CRYPTO_H 1 3 | 4 | #include 5 | #include "rfb/rfbconfig.h" 6 | 7 | #define SHA1_HASH_SIZE 20 8 | #define MD5_HASH_SIZE 16 9 | 10 | /* Generates an MD5 hash of 'in' and writes it to 'out', which must be 16 bytes in size. */ 11 | int hash_md5(void *out, const void *in, const size_t in_len); 12 | 13 | /* Generates an SHA1 hash of 'in' and writes it to 'out', which must be 20 bytes in size. */ 14 | int hash_sha1(void *out, const void *in, const size_t in_len); 15 | 16 | /* Fill 'out' with 'len' random bytes. */ 17 | void random_bytes(void *out, size_t len); 18 | 19 | /* 20 | Takes the 8-byte key in 'key', reverses the bits in each byte of key as required by the RFB protocol, 21 | encrypts 'in' with the resulting key using single-key 56-bit DES and writes the result to 'out'. 22 | */ 23 | int encrypt_rfbdes(void *out, int *out_len, const unsigned char key[8], const void *in, const size_t in_len); 24 | 25 | /* 26 | Takes the 8-byte key in 'key', reverses the bits in each byte of key as required by the RFB protocol, 27 | decrypts 'in' with the resulting key using single-key 56-bit DES and writes the result to 'out'. 28 | */ 29 | int decrypt_rfbdes(void *out, int *out_len, const unsigned char key[8], const void *in, const size_t in_len); 30 | 31 | /* Encrypts 'in' with the the 16-byte key in 'key' using AES-128-ECB and writes the result to 'out'. */ 32 | int encrypt_aes128ecb(void *out, int *out_len, const unsigned char key[16], const void *in, const size_t in_len); 33 | 34 | /* 35 | Generates a Diffie-Hellman public-private keypair using the generator value 'gen' and prime modulo 36 | 'prime', writing the result to 'pub_out' and 'priv_out', which must be 'keylen' in size. 37 | */ 38 | int dh_generate_keypair(uint8_t *priv_out, uint8_t *pub_out, const uint8_t *gen, const size_t gen_len, const uint8_t *prime, const size_t keylen); 39 | 40 | /* 41 | Computes the shared Diffie-Hellman secret using the private key 'priv', the other side's public 42 | key 'pub' and the modulo prime 'prime' and writes it to 'shared_out', which must be 'keylen' in size. 43 | */ 44 | int dh_compute_shared_key(uint8_t *shared_out, const uint8_t *priv, const uint8_t *pub, const uint8_t *prime, const size_t keylen); 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /LIBSDL/src/events/SDL_resize.c: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | #include "SDL_config.h" 23 | 24 | /* Resize event handling code for SDL */ 25 | 26 | #include "SDL_events.h" 27 | #include "SDL_events_c.h" 28 | #include "../video/SDL_sysvideo.h" 29 | 30 | 31 | /* Keep the last resize event so we don't post duplicates */ 32 | static struct { 33 | int w; 34 | int h; 35 | } last_resize; 36 | 37 | /* This is global for SDL_eventloop.c */ 38 | int SDL_PrivateResize(int w, int h) 39 | { 40 | int posted; 41 | SDL_Event events[32]; 42 | 43 | /* See if this event would change the video surface */ 44 | if ( !w || !h || 45 | (( last_resize.w == w ) && ( last_resize.h == h )) || 46 | !SDL_VideoSurface ) { 47 | return(0); 48 | } 49 | last_resize.w = w; 50 | last_resize.h = h; 51 | 52 | SDL_SetMouseRange(w, h); 53 | 54 | /* Pull out all old resize events */ 55 | SDL_PeepEvents(events, sizeof(events)/sizeof(events[0]), 56 | SDL_GETEVENT, SDL_VIDEORESIZEMASK); 57 | 58 | /* Post the event, if desired */ 59 | posted = 0; 60 | if ( SDL_ProcessEvents[SDL_VIDEORESIZE] == SDL_ENABLE ) { 61 | SDL_Event event; 62 | event.type = SDL_VIDEORESIZE; 63 | event.resize.w = w; 64 | event.resize.h = h; 65 | if ( (SDL_EventOK == NULL) || (*SDL_EventOK)(&event) ) { 66 | posted = 1; 67 | SDL_PushEvent(&event); 68 | } 69 | } 70 | return(posted); 71 | } 72 | -------------------------------------------------------------------------------- /LIBSDL/src/audio/SDL_wave.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is SDL_free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | #include "SDL_config.h" 23 | 24 | /* WAVE files are little-endian */ 25 | 26 | /*******************************************/ 27 | /* Define values for Microsoft WAVE format */ 28 | /*******************************************/ 29 | #define RIFF 0x46464952 /* "RIFF" */ 30 | #define WAVE 0x45564157 /* "WAVE" */ 31 | #define FACT 0x74636166 /* "fact" */ 32 | #define LIST 0x5453494c /* "LIST" */ 33 | #define FMT 0x20746D66 /* "fmt " */ 34 | #define DATA 0x61746164 /* "data" */ 35 | #define PCM_CODE 0x0001 36 | #define MS_ADPCM_CODE 0x0002 37 | #define IMA_ADPCM_CODE 0x0011 38 | #define MP3_CODE 0x0055 39 | #define WAVE_MONO 1 40 | #define WAVE_STEREO 2 41 | 42 | /* Normally, these three chunks come consecutively in a WAVE file */ 43 | typedef struct WaveFMT { 44 | /* Not saved in the chunk we read: 45 | Uint32 FMTchunk; 46 | Uint32 fmtlen; 47 | */ 48 | Uint16 encoding; 49 | Uint16 channels; /* 1 = mono, 2 = stereo */ 50 | Uint32 frequency; /* One of 11025, 22050, or 44100 Hz */ 51 | Uint32 byterate; /* Average bytes per second */ 52 | Uint16 blockalign; /* Bytes per sample block */ 53 | Uint16 bitspersample; /* One of 8, 12, 16, or 4 for ADPCM */ 54 | } WaveFMT; 55 | 56 | /* The general chunk found in the WAVE file */ 57 | typedef struct Chunk { 58 | Uint32 magic; 59 | Uint32 length; 60 | Uint8 *data; 61 | } Chunk; 62 | 63 | -------------------------------------------------------------------------------- /src/rfb/corre-c.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved. 3 | * 4 | * This is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This software is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 17 | * USA. 18 | */ 19 | 20 | /* 21 | * corre.c - handle CoRRE encoding. 22 | * 23 | * This file shouldn't be compiled directly. It is included multiple times by 24 | * rfbproto.c, each time with a different definition of the macro BPP. For 25 | * each value of BPP, this file defines a function which handles a CoRRE 26 | * encoded rectangle with BPP bits per pixel. 27 | */ 28 | 29 | #define HandleCoRREBPP CONCAT2E(HandleCoRRE,BPP) 30 | #define CARDBPP CONCAT3E(uint,BPP,_t) 31 | 32 | static rfbBool 33 | HandleCoRREBPP (rfbClient* client, int rx, int ry, int rw, int rh) 34 | { 35 | rfbRREHeader hdr; 36 | int i; 37 | CARDBPP pix; 38 | uint8_t *ptr; 39 | int x, y, w, h; 40 | 41 | if (!ReadFromRFBServer(client, (char *)&hdr, sz_rfbRREHeader)) 42 | return FALSE; 43 | 44 | hdr.nSubrects = rfbClientSwap32IfLE(hdr.nSubrects); 45 | 46 | if (!ReadFromRFBServer(client, (char *)&pix, sizeof(pix))) 47 | return FALSE; 48 | 49 | client->GotFillRect(client, rx, ry, rw, rh, pix); 50 | 51 | if (hdr.nSubrects > RFB_BUFFER_SIZE / (4 + (BPP / 8)) || !ReadFromRFBServer(client, client->buffer, hdr.nSubrects * (4 + (BPP / 8)))) 52 | return FALSE; 53 | 54 | ptr = (uint8_t *)client->buffer; 55 | 56 | for (i = 0; i < hdr.nSubrects; i++) { 57 | pix = *(CARDBPP *)ptr; 58 | ptr += BPP/8; 59 | x = *ptr++; 60 | y = *ptr++; 61 | w = *ptr++; 62 | h = *ptr++; 63 | 64 | client->GotFillRect(client, rx+x, ry+y, w, h, pix); 65 | } 66 | 67 | return TRUE; 68 | } 69 | 70 | #undef CARDBPP 71 | -------------------------------------------------------------------------------- /LIBSDL/src/thread/n3ds/SDL_sysmutex.c: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | //#include "../../SDL_internal.h" 22 | 23 | #include "SDL_config.h" 24 | 25 | #include "SDL_sysmutex_c.h" 26 | 27 | /* Create a mutex */ 28 | SDL_mutex * 29 | SDL_CreateMutex(void) 30 | { 31 | SDL_mutex *mutex; 32 | 33 | /* Allocate mutex memory */ 34 | mutex = (SDL_mutex *) SDL_malloc(sizeof(*mutex)); 35 | if (mutex) { 36 | /* Initialize the inner recursive lock */ 37 | RecursiveLock_Init(&mutex->rl); 38 | } else { 39 | SDL_OutOfMemory(); 40 | } 41 | return mutex; 42 | } 43 | 44 | /* Free the mutex */ 45 | void 46 | SDL_DestroyMutex(SDL_mutex * mutex) 47 | { 48 | if (mutex) { 49 | SDL_free(mutex); 50 | } 51 | } 52 | 53 | /* Lock the semaphore */ 54 | int 55 | SDL_mutexP(SDL_mutex * mutex) 56 | { 57 | #if SDL_THREADS_DISABLED 58 | return 0; 59 | #else 60 | if (mutex == NULL) { 61 | SDL_SetError("Passed a NULL mutex"); 62 | return -1; 63 | } 64 | 65 | RecursiveLock_Lock(&mutex->rl); 66 | return 0; 67 | #endif /* SDL_THREADS_DISABLED */ 68 | } 69 | 70 | /* Unlock the mutex */ 71 | int 72 | SDL_mutexV(SDL_mutex * mutex) 73 | { 74 | #if SDL_THREADS_DISABLED 75 | return 0; 76 | #else 77 | if (mutex == NULL) { 78 | SDL_SetError("Passed a NULL mutex"); 79 | return -1; 80 | } 81 | 82 | RecursiveLock_Unlock(&mutex->rl); 83 | return 0; 84 | #endif /* SDL_THREADS_DISABLED */ 85 | } 86 | -------------------------------------------------------------------------------- /src/rfb/rre-c.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved. 3 | * 4 | * This is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This software is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 17 | * USA. 18 | */ 19 | 20 | /* 21 | * rre.c - handle RRE encoding. 22 | * 23 | * This file shouldn't be compiled directly. It is included multiple times by 24 | * rfbproto.c, each time with a different definition of the macro BPP. For 25 | * each value of BPP, this file defines a function which handles an RRE 26 | * encoded rectangle with BPP bits per pixel. 27 | */ 28 | 29 | #define HandleRREBPP CONCAT2E(HandleRRE,BPP) 30 | #define CARDBPP CONCAT3E(uint,BPP,_t) 31 | 32 | static rfbBool 33 | HandleRREBPP (rfbClient* client, int rx, int ry, int rw, int rh) 34 | { 35 | rfbRREHeader hdr; 36 | int i; 37 | CARDBPP pix; 38 | rfbRectangle subrect; 39 | 40 | if (!ReadFromRFBServer(client, (char *)&hdr, sz_rfbRREHeader)) 41 | return FALSE; 42 | 43 | hdr.nSubrects = rfbClientSwap32IfLE(hdr.nSubrects); 44 | 45 | if (!ReadFromRFBServer(client, (char *)&pix, sizeof(pix))) 46 | return FALSE; 47 | 48 | client->GotFillRect(client, rx, ry, rw, rh, pix); 49 | 50 | for (i = 0; i < hdr.nSubrects; i++) { 51 | if (!ReadFromRFBServer(client, (char *)&pix, sizeof(pix))) 52 | return FALSE; 53 | 54 | if (!ReadFromRFBServer(client, (char *)&subrect, sz_rfbRectangle)) 55 | return FALSE; 56 | 57 | subrect.x = rfbClientSwap16IfLE(subrect.x); 58 | subrect.y = rfbClientSwap16IfLE(subrect.y); 59 | subrect.w = rfbClientSwap16IfLE(subrect.w); 60 | subrect.h = rfbClientSwap16IfLE(subrect.h); 61 | 62 | client->GotFillRect(client, rx+subrect.x, ry+subrect.y, subrect.w, subrect.h, pix); 63 | } 64 | 65 | return TRUE; 66 | } 67 | 68 | #undef CARDBPP 69 | -------------------------------------------------------------------------------- /LIBSDL/include/SDL/SDL_cpuinfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** 24 | * @file SDL_cpuinfo.h 25 | * CPU feature detection for SDL 26 | */ 27 | 28 | #ifndef _SDL_cpuinfo_h 29 | #define _SDL_cpuinfo_h 30 | 31 | #include "SDL_stdinc.h" 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /** This function returns true if the CPU has the RDTSC instruction */ 40 | extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void); 41 | 42 | /** This function returns true if the CPU has MMX features */ 43 | extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void); 44 | 45 | /** This function returns true if the CPU has MMX Ext. features */ 46 | extern DECLSPEC SDL_bool SDLCALL SDL_HasMMXExt(void); 47 | 48 | /** This function returns true if the CPU has 3DNow features */ 49 | extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void); 50 | 51 | /** This function returns true if the CPU has 3DNow! Ext. features */ 52 | extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNowExt(void); 53 | 54 | /** This function returns true if the CPU has SSE features */ 55 | extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void); 56 | 57 | /** This function returns true if the CPU has SSE2 features */ 58 | extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void); 59 | 60 | /** This function returns true if the CPU has AltiVec features */ 61 | extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void); 62 | 63 | /* Ends C function definitions when using C++ */ 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | #include "close_code.h" 68 | 69 | #endif /* _SDL_cpuinfo_h */ 70 | -------------------------------------------------------------------------------- /LIBSDL/src/video/n3ds/SDL_n3dsvideo.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | #include "SDL_config.h" 23 | 24 | #ifndef _SDL_n3dsvideo_h 25 | #define _SDL_n3dsvideo_h 26 | 27 | #include "../SDL_sysvideo.h" 28 | 29 | #include <3ds.h> 30 | 31 | /* Hidden "this" pointer for the video functions */ 32 | #define _THIS SDL_VideoDevice *this 33 | 34 | /* Private display data */ 35 | 36 | struct SDL_PrivateVideoData { 37 | //GPU drawing specific 38 | int x1,y1,w1,h1; // drawing window for top screen; width and height of top screen part of the video buffer 39 | int x2,y2,w2,h2; // drawing window for bottom screen; width and height of bottom part of the video buffer 40 | float l1,r1,t1,b1; // GPU source window for the top part of the video buffer 41 | float l2,r2,t2,b2; // GPU source window for the bottom part of the video buffer 42 | float scalex,scaley; // scaling factors 43 | float scalex2,scaley2; // scaling factors 44 | 45 | // framebuffer data 46 | int w, h; // width and height of the video buffer 47 | void *buffer; 48 | Uint8 *palettedbuffer; 49 | Uint32 palette[256]; 50 | GSPGPU_FramebufferFormat mode; 51 | unsigned int flags; // backup of create device flags 52 | unsigned int screens; // SDL_TOPSCR, SDL_BOTTOMSCR, SDL_DUALSCR 53 | unsigned int console; // SDL_CONSOLETOP, SDL_CONSOLEBOTTOM 54 | unsigned int fitscreen; // SDL_TRIMBOTTOMSCR, SDL_FITWIDTH, SDL_FITHEIGHT (SDL_FULLSCREEN sets both SDL_FITWIDTH and SDL_FITHEIGHT) 55 | int byteperpixel; 56 | int bpp; 57 | // video surface 58 | SDL_Surface* currentVideoSurface; 59 | // Video process flags 60 | bool blockVideo; // block video output and events handlings on SDL_QUIT 61 | }; 62 | 63 | #endif /* _SDL_n3dsvideo_h */ 64 | -------------------------------------------------------------------------------- /LIBSDL/src/video/SDL_cursor_c.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | #include "SDL_config.h" 23 | 24 | /* Useful variables and functions from SDL_cursor.c */ 25 | #include "SDL_mouse.h" 26 | 27 | extern int SDL_CursorInit(Uint32 flags); 28 | extern void SDL_CursorPaletteChanged(void); 29 | extern void SDL_DrawCursor(SDL_Surface *screen); 30 | extern void SDL_DrawCursorNoLock(SDL_Surface *screen); 31 | extern void SDL_EraseCursor(SDL_Surface *screen); 32 | extern void SDL_EraseCursorNoLock(SDL_Surface *screen); 33 | extern void SDL_UpdateCursor(SDL_Surface *screen); 34 | extern void SDL_ResetCursor(void); 35 | extern void SDL_MoveCursor(int x, int y); 36 | extern void SDL_CursorQuit(void); 37 | 38 | #define INLINE_MOUSELOCK 39 | #ifdef INLINE_MOUSELOCK 40 | /* Inline (macro) versions of the mouse lock functions */ 41 | #include "SDL_mutex.h" 42 | 43 | extern SDL_mutex *SDL_cursorlock; 44 | 45 | #define SDL_LockCursor() \ 46 | do { \ 47 | if ( SDL_cursorlock ) { \ 48 | SDL_mutexP(SDL_cursorlock); \ 49 | } \ 50 | } while ( 0 ) 51 | #define SDL_UnlockCursor() \ 52 | do { \ 53 | if ( SDL_cursorlock ) { \ 54 | SDL_mutexV(SDL_cursorlock); \ 55 | } \ 56 | } while ( 0 ) 57 | #else 58 | extern void SDL_LockCursor(void); 59 | extern void SDL_UnlockCursor(void); 60 | #endif /* INLINE_MOUSELOCK */ 61 | 62 | /* Only for low-level mouse cursor drawing */ 63 | extern SDL_Cursor *SDL_cursor; 64 | extern void SDL_MouseRect(SDL_Rect *area); 65 | 66 | /* State definitions for the SDL cursor */ 67 | #define CURSOR_VISIBLE 0x01 68 | #define CURSOR_USINGSW 0x10 69 | #define SHOULD_DRAWCURSOR(X) \ 70 | (((X)&(CURSOR_VISIBLE|CURSOR_USINGSW)) == \ 71 | (CURSOR_VISIBLE|CURSOR_USINGSW)) 72 | 73 | extern volatile int SDL_cursorstate; 74 | -------------------------------------------------------------------------------- /LIBSDL/src/cdrom/SDL_syscdrom.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is SDL_free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | #include "SDL_config.h" 23 | 24 | /* This is the system specific header for the SDL CD-ROM API */ 25 | 26 | /* Structure of CD audio control functions */ 27 | extern struct CDcaps { 28 | /* Get the name of the specified drive */ 29 | const char *(*Name)(int drive); 30 | 31 | /* Open the specified drive, returning a drive id, or -1 on error */ 32 | int (*Open)(int drive); 33 | 34 | /* Get table-of-contents (number of tracks + track info) for disk. 35 | The TOC information should be stored in the cdrom structure. 36 | This function should return 0 on success, or -1 on error. 37 | */ 38 | int (*GetTOC)(SDL_CD *cdrom); 39 | 40 | /* Return the current status and play position, in frames, of the 41 | drive. 'position' may be NULL, and if so, should be ignored. 42 | */ 43 | CDstatus (*Status)(SDL_CD *cdrom, int *position); 44 | 45 | /* Play from frame 'start' to 'start+len' */ 46 | int (*Play)(SDL_CD *cdrom, int start, int len); 47 | 48 | /* Pause play */ 49 | int (*Pause)(SDL_CD *cdrom); 50 | 51 | /* Resume play */ 52 | int (*Resume)(SDL_CD *cdrom); 53 | 54 | /* Stop play */ 55 | int (*Stop)(SDL_CD *cdrom); 56 | 57 | /* Eject the current disk */ 58 | int (*Eject)(SDL_CD *cdrom); 59 | 60 | /* Close the specified drive */ 61 | void (*Close)(SDL_CD *cdrom); 62 | } SDL_CDcaps; 63 | 64 | /* The number of available CD-ROM drives on the system */ 65 | extern int SDL_numcds; 66 | 67 | /* Function to scan the system for CD-ROM drives and fill SDL_CDcaps. 68 | * This function should set SDL_numcds to the number of available CD 69 | * drives. Drive 0 should be the system default CD-ROM. 70 | * It should return 0, or -1 on an unrecoverable fatal error. 71 | */ 72 | extern int SDL_SYS_CDInit(void); 73 | 74 | /* Function to perform any system-specific CD-ROM related cleanup */ 75 | extern void SDL_SYS_CDQuit(void); 76 | 77 | -------------------------------------------------------------------------------- /LIBSDL/src/video/n3ds/SDL_n3dsevents.c: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | #include "SDL_config.h" 23 | 24 | /* Being a null driver, there's no event stream. We just define stubs for 25 | most of the API. */ 26 | 27 | #include <3ds.h> 28 | 29 | #include "SDL.h" 30 | #include "../../events/SDL_sysevents.h" 31 | #include "../../events/SDL_events_c.h" 32 | 33 | #include "SDL_n3dsvideo.h" 34 | #include "SDL_n3dsevents_c.h" 35 | 36 | void N3DS_PumpEvents(_THIS) 37 | { 38 | svcSleepThread(100000); // 0.1 ms 39 | 40 | if (!aptMainLoop()) 41 | { 42 | static bool pushedQuit = false; 43 | if (!pushedQuit) { 44 | SDL_Event sdlevent; 45 | sdlevent.type = SDL_QUIT; 46 | SDL_PushEvent(&sdlevent); 47 | pushedQuit = true; 48 | } 49 | return; 50 | } 51 | 52 | hidScanInput(); 53 | 54 | if (hidKeysHeld() & KEY_TOUCH) { 55 | touchPosition touch; 56 | 57 | hidTouchRead (&touch); 58 | 59 | // TO DO: handle fit screen on x and y.Y and Y to be considered separately 60 | 61 | if(this->hidden->screens&SDL_TOPSCR && this->hidden->screens&SDL_BOTTOMSCR) { 62 | if (touch.px != 0 || touch.py != 0) { 63 | SDL_PrivateMouseMotion (0, 0, 64 | touch.px + (this->hidden->w1 - 320)/2, 65 | this->hidden->y2 + touch.py + (this->hidden->h2 - 240)/2); 66 | if (!SDL_GetMouseState (NULL, NULL)) 67 | SDL_PrivateMouseButton (SDL_PRESSED, 1, 0, 0); 68 | } 69 | } else { 70 | if (touch.px != 0 || touch.py != 0) { 71 | SDL_PrivateMouseMotion (0, 0, (touch.px * this->hidden->w1) / 320, (touch.py * this->hidden->h1) / 240); 72 | if (!SDL_GetMouseState (NULL, NULL)) 73 | SDL_PrivateMouseButton (SDL_PRESSED, 1, 0, 0); 74 | } 75 | } 76 | } else { 77 | if (SDL_GetMouseState (NULL, NULL)) 78 | SDL_PrivateMouseButton (SDL_RELEASED, 1, 0, 0); 79 | } 80 | } 81 | 82 | void N3DS_InitOSKeymap(_THIS) 83 | { 84 | // Do nothing 85 | } 86 | 87 | 88 | /* end of SDL_nullevents.c ... */ 89 | 90 | -------------------------------------------------------------------------------- /LIBSDL/src/events/SDL_active.c: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | #include "SDL_config.h" 23 | 24 | /* Application focus/iconification handling code for SDL */ 25 | 26 | #include "SDL_events.h" 27 | #include "SDL_events_c.h" 28 | 29 | 30 | /* These are static for our active event handling code */ 31 | static Uint8 SDL_appstate = 0; 32 | 33 | /* Public functions */ 34 | int SDL_AppActiveInit(void) 35 | { 36 | /* Start completely active */ 37 | SDL_appstate = (SDL_APPACTIVE|SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS); 38 | 39 | /* That's it! */ 40 | return(0); 41 | } 42 | void SDL_AppActiveQuit(void) 43 | { 44 | } 45 | 46 | Uint8 SDL_GetAppState(void) 47 | { 48 | return(SDL_appstate); 49 | } 50 | 51 | /* This is global for SDL_eventloop.c */ 52 | int SDL_PrivateAppActive(Uint8 gain, Uint8 state) 53 | { 54 | int posted; 55 | Uint8 new_state; 56 | 57 | /* Modify the current state with the given mask */ 58 | if ( gain ) { 59 | new_state = (SDL_appstate | state); 60 | } else { 61 | new_state = (SDL_appstate & ~state); 62 | } 63 | 64 | /* Drop events that don't change state */ 65 | if ( new_state == SDL_appstate ) { 66 | return(0); 67 | } 68 | 69 | /* Update internal active state */ 70 | SDL_appstate = new_state; 71 | 72 | /* Post the event, if desired */ 73 | posted = 0; 74 | if ( SDL_ProcessEvents[SDL_ACTIVEEVENT] == SDL_ENABLE ) { 75 | SDL_Event event; 76 | SDL_memset(&event, 0, sizeof(event)); 77 | event.type = SDL_ACTIVEEVENT; 78 | event.active.gain = gain; 79 | event.active.state = state; 80 | if ( (SDL_EventOK == NULL) || (*SDL_EventOK)(&event) ) { 81 | posted = 1; 82 | SDL_PushEvent(&event); 83 | } 84 | } 85 | 86 | /* If we lost keyboard focus, post key-up events */ 87 | if ( (state & SDL_APPINPUTFOCUS) && !gain ) { 88 | SDL_ResetKeyboard(); 89 | } 90 | /* If we were minimized, post button-up events */ 91 | if ( (state & SDL_APPACTIVE) && !gain ) { 92 | SDL_ResetMouse(); 93 | } 94 | return(posted); 95 | } 96 | -------------------------------------------------------------------------------- /LIBSDL/src/thread/n3ds/SDL_systhread.c: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include "SDL_config.h" 27 | 28 | #include "SDL_error.h" 29 | #include "SDL_thread.h" 30 | #include "../SDL_systhread.h" 31 | #include "../SDL_thread_c.h" 32 | #include <3ds.h> 33 | 34 | #define STACKSIZE (128 * 1024) 35 | 36 | void ThreadEntry(void *arg) 37 | { 38 | SDL_RunThread(arg); 39 | } 40 | 41 | int SDL_SYS_CreateThread(SDL_Thread *thread, void *args) 42 | { 43 | // s32 priority = 0x2F; 44 | s32 priority = 0x30; 45 | 46 | /* Set priority of new thread higher than the current thread */ 47 | svcGetThreadPriority(&priority, CUR_THREAD_HANDLE); 48 | if(priority>0x19) priority--; 49 | else priority = 0x19; //priority 0x18 is for video thread that is activated by a signal and than must run at maximum priority to avoid flickering 50 | if(priority>0x2F) priority = 0x2F; 51 | 52 | thread->handle = threadCreate(ThreadEntry, args, 53 | STACKSIZE, priority, -2, false); 54 | 55 | thread->threadid = (int) thread->handle; 56 | if (!thread->threadid) 57 | { 58 | SDL_SetError("Create Thread failed"); 59 | return(-1); 60 | } 61 | 62 | return 0; 63 | } 64 | 65 | void SDL_SYS_SetupThread(void) 66 | { 67 | //Nothing, probably 68 | } 69 | 70 | Uint32 SDL_ThreadID(void) 71 | { 72 | //Incompatible with SDL API, this function will NOT return 73 | //a valid thread ID when called from the main thread. 74 | u32 threadID=0; 75 | Thread current = threadGetCurrent(); 76 | if (current) { 77 | Handle handle = threadGetHandle(current); 78 | svcGetThreadId(&threadID, handle); 79 | } 80 | 81 | return threadID; 82 | } 83 | 84 | void SDL_SYS_WaitThread(SDL_Thread *thread) 85 | { 86 | threadJoin(thread->handle, U64_MAX); 87 | } 88 | 89 | void SDL_SYS_KillThread(SDL_Thread *thread) 90 | { 91 | threadFree(thread->handle); 92 | } 93 | 94 | -------------------------------------------------------------------------------- /src/rfb/crypto_included.c: -------------------------------------------------------------------------------- 1 | /* 2 | * crypto_included.c - Crypto wrapper (included version) 3 | */ 4 | 5 | /* 6 | * Copyright (C) 2011 Gernot Tenchio 7 | * Copyright (C) 2019 Christian Beier 8 | * 9 | * This is free software; you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation; either version 2 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * This software is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with this software; if not, write to the Free Software 21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 22 | * USA. 23 | */ 24 | 25 | #include 26 | #include "sha.h" 27 | #include "d3des.h" 28 | #include "crypto.h" 29 | 30 | 31 | int hash_md5(void *out, const void *in, const size_t in_len) 32 | { 33 | return 0; 34 | } 35 | 36 | int hash_sha1(void *out, const void *in, const size_t in_len) 37 | { 38 | SHA1Context sha1; 39 | if(SHA1Reset(&sha1) != shaSuccess) 40 | return 0; 41 | if(SHA1Input(&sha1, in, in_len) != shaSuccess) 42 | return 0; 43 | if(SHA1Result(&sha1, out) != shaSuccess) 44 | return 0; 45 | 46 | return 1; 47 | } 48 | 49 | void random_bytes(void *out, size_t len) 50 | { 51 | 52 | } 53 | 54 | int encrypt_rfbdes(void *out, int *out_len, const unsigned char key[8], const void *in, const size_t in_len) 55 | { 56 | int eightbyteblocks = in_len/8; 57 | int i; 58 | rfbDesKey((unsigned char*)key, EN0); 59 | for(i = 0; i < eightbyteblocks; ++i) 60 | rfbDes((unsigned char*)in + i*8, (unsigned char*)out + i*8); 61 | 62 | *out_len = in_len; 63 | 64 | return 1; 65 | } 66 | 67 | int decrypt_rfbdes(void *out, int *out_len, const unsigned char key[8], const void *in, const size_t in_len) 68 | { 69 | int eightbyteblocks = in_len/8; 70 | int i; 71 | rfbDesKey((unsigned char*)key, DE1); 72 | for(i = 0; i < eightbyteblocks; ++i) 73 | rfbDes((unsigned char*)in + i*8, (unsigned char*)out + i*8); 74 | 75 | *out_len = in_len; 76 | 77 | return 1; 78 | } 79 | 80 | int encrypt_aes128ecb(void *out, int *out_len, const unsigned char key[16], const void *in, const size_t in_len) 81 | { 82 | return 0; 83 | } 84 | 85 | int dh_generate_keypair(uint8_t *priv_out, uint8_t *pub_out, const uint8_t *gen, const size_t gen_len, const uint8_t *prime, const size_t keylen) 86 | { 87 | return 0; 88 | } 89 | 90 | int dh_compute_shared_key(uint8_t *shared_out, const uint8_t *priv, const uint8_t *pub, const uint8_t *prime, const size_t keylen) 91 | { 92 | return 0; 93 | } 94 | -------------------------------------------------------------------------------- /src/uibottom.h: -------------------------------------------------------------------------------- 1 | /* 2 | * TinyVNC - A VNC client for Nintendo 3DS 3 | * 4 | * uibottom.h - functions for handling 3DS bottom screen 5 | * 6 | * Copyright 2020 Sebastian Weber 7 | */ 8 | 9 | 10 | #ifndef UAE_UIBOTTOM_H 11 | #define UAE_UIBOTTOM_H 12 | 13 | // some colors for writing text 14 | #define COL_WHITE (SDL_Color){0xff, 0xff, 0xff, 0xff} 15 | #define COL_BLACK (SDL_Color){0, 0, 0, 0xff} 16 | #define COL_RED (SDL_Color){0xff, 0, 0, 0xff} 17 | #define COL_GREEN (SDL_Color){0, 0xff, 0, 0xff} 18 | #define COL_BLUE (SDL_Color){0, 0, 0xff, 0xff} 19 | #define COL_GRAY (SDL_Color){0x80, 0x80, 0x80, 0xff} 20 | #define COL_MAKE(x,y,z) (SDL_Color){x, y, z, 0xff} 21 | 22 | // exposed definitions 23 | typedef enum { 24 | UIB_NO = 0, 25 | UIB_REPAINT = 1, 26 | UIB_RECALC_KEYPRESS = 2, 27 | UIB_RECALC_MENU = 4, 28 | UIB_RECALC_VNC = 8 29 | } uib_action; 30 | 31 | typedef struct { 32 | int x,y,w,h,key,shftkey,sticky,repeat; 33 | const char *name; 34 | } uikbd_key; 35 | 36 | typedef enum { 37 | ALIGN_LEFT, 38 | ALIGN_RIGHT, 39 | ALIGN_CENTER 40 | } str_alignment; 41 | 42 | // exposed functions 43 | extern void make_key_event_norepeat(SDL_Event *e, int sym, int pressed); 44 | extern void make_key_event(SDL_Event *e, int sym, int pressed); 45 | extern void push_key_event(int sym, int pressed); 46 | extern void push_key_event_norepeat(int sym, int pressed); 47 | extern void checkKeyRepeat(); 48 | 49 | extern void uib_printtext(SDL_Surface *s, const char *str, int xo, int yo, int w, int h, SDL_Color tcol, SDL_Color bcol); 50 | extern void uib_printstring(SDL_Surface *s, const char *str, int x, int y, int maxchars, str_alignment align, SDL_Color tcol, SDL_Color bcol); 51 | extern void uib_show_message(u32 ms_time, char *format, ... ); 52 | extern int uib_printf(char *format, ...); 53 | extern int uib_vprintf(char *format, va_list arg); 54 | extern void uib_set_position(int x, int y); 55 | extern void uib_set_colors(SDL_Color text, SDL_Color background); 56 | extern void uib_reset_colors(); 57 | extern void uib_invert_colors(); 58 | extern void uib_clear(); 59 | extern SDL_Surface *myIMG_Load(char *fname); 60 | 61 | extern void uib_update(int what); 62 | extern int uib_handle_event(SDL_Event *, int taphandling); 63 | extern void uib_init(); 64 | extern int uib_handle_tap_processing(SDL_Event *e); 65 | extern void uib_enable_keyboard(int enable); 66 | extern void uib_enable_log(int enable); 67 | extern void uib_show_scrollbars(int x, int y, int w, int h); 68 | #define SCROLLBAR_WIDTH 2 69 | extern int uib_getBacklight(); 70 | extern void uib_setBacklight (int on); 71 | extern void toggle_keyboard(); 72 | 73 | extern rfbBool uibvnc_resize(rfbClient*); 74 | extern void uibvnc_cleanup(); 75 | extern void uibvnc_setScaling(int); 76 | extern void uib_qmenu_show(); 77 | 78 | // exposed variables 79 | extern int uib_qmenu_active; 80 | extern uikbd_key uikbd_keypos[]; 81 | extern uib_action uib_must_redraw; 82 | #endif -------------------------------------------------------------------------------- /LIBSDL/include/SDL/SDL_version.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** @file SDL_version.h 24 | * This header defines the current SDL version 25 | */ 26 | 27 | #ifndef _SDL_version_h 28 | #define _SDL_version_h 29 | 30 | #include "SDL_stdinc.h" 31 | 32 | #include "begin_code.h" 33 | /* Set up for C function definitions, even when using C++ */ 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | /** @name Version Number 39 | * Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL 40 | */ 41 | /*@{*/ 42 | #define SDL_MAJOR_VERSION 1 43 | #define SDL_MINOR_VERSION 2 44 | #define SDL_PATCHLEVEL 15 45 | /*@}*/ 46 | 47 | typedef struct SDL_version { 48 | Uint8 major; 49 | Uint8 minor; 50 | Uint8 patch; 51 | } SDL_version; 52 | 53 | /** 54 | * This macro can be used to fill a version structure with the compile-time 55 | * version of the SDL library. 56 | */ 57 | #define SDL_VERSION(X) \ 58 | { \ 59 | (X)->major = SDL_MAJOR_VERSION; \ 60 | (X)->minor = SDL_MINOR_VERSION; \ 61 | (X)->patch = SDL_PATCHLEVEL; \ 62 | } 63 | 64 | /** This macro turns the version numbers into a numeric value: 65 | * (1,2,3) -> (1203) 66 | * This assumes that there will never be more than 100 patchlevels 67 | */ 68 | #define SDL_VERSIONNUM(X, Y, Z) \ 69 | ((X)*1000 + (Y)*100 + (Z)) 70 | 71 | /** This is the version number macro for the current SDL version */ 72 | #define SDL_COMPILEDVERSION \ 73 | SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL) 74 | 75 | /** This macro will evaluate to true if compiled with SDL at least X.Y.Z */ 76 | #define SDL_VERSION_ATLEAST(X, Y, Z) \ 77 | (SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z)) 78 | 79 | /** This function gets the version of the dynamically linked SDL library. 80 | * it should NOT be used to fill a version structure, instead you should 81 | * use the SDL_Version() macro. 82 | */ 83 | extern DECLSPEC const SDL_version * SDLCALL SDL_Linked_Version(void); 84 | 85 | /* Ends C function definitions when using C++ */ 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | #include "close_code.h" 90 | 91 | #endif /* _SDL_version_h */ 92 | -------------------------------------------------------------------------------- /LIBSDL/src/thread/n3ds/SDL_syssem.c: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | //#include "../../SDL_internal.h" 22 | 23 | #include 24 | #include 25 | 26 | #include "SDL_config.h" 27 | 28 | #include "SDL_error.h" 29 | #include "SDL_thread.h" 30 | 31 | #include <3ds.h> 32 | 33 | struct SDL_semaphore { 34 | LightSemaphore sem; 35 | }; 36 | 37 | 38 | /* Create a semaphore */ 39 | SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) 40 | { 41 | SDL_sem *sem; 42 | 43 | sem = (SDL_sem *) malloc(sizeof(*sem)); 44 | if (sem != NULL) { 45 | LightSemaphore_Init(&sem->sem, initial_value, 255); 46 | } else { 47 | SDL_OutOfMemory(); 48 | } 49 | 50 | return sem; 51 | } 52 | 53 | /* Free the semaphore */ 54 | void SDL_DestroySemaphore(SDL_sem *sem) 55 | { 56 | if (sem != NULL) { 57 | free(sem); 58 | } 59 | } 60 | 61 | /* Waits on a semaphore */ 62 | int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) 63 | { 64 | if (sem == NULL) { 65 | SDL_SetError("Passed a NULL sem"); 66 | return -1; 67 | } 68 | 69 | if (timeout == SDL_MUTEX_MAXWAIT) { 70 | LightSemaphore_Acquire(&sem->sem, 1); 71 | return 0; 72 | } 73 | else if (timeout == 0) { 74 | int rc = LightSemaphore_TryAcquire(&sem->sem, 1); 75 | return rc != 0 ? SDL_MUTEX_TIMEDOUT : 0; 76 | } 77 | else { 78 | SDL_SetError("Non-trivial semaphore wait timeout values not supported"); 79 | return -1; 80 | } 81 | } 82 | 83 | int SDL_SemTryWait(SDL_sem *sem) 84 | { 85 | return SDL_SemWaitTimeout(sem, 0); 86 | } 87 | 88 | int SDL_SemWait(SDL_sem *sem) 89 | { 90 | return SDL_SemWaitTimeout(sem, SDL_MUTEX_MAXWAIT); 91 | } 92 | 93 | /* Returns the current count of the semaphore */ 94 | Uint32 SDL_SemValue(SDL_sem *sem) 95 | { 96 | return sem->sem.current_count; 97 | } 98 | 99 | int SDL_SemPost(SDL_sem *sem) 100 | { 101 | LightSemaphore_Release(&sem->sem, 1); 102 | return 0; 103 | } 104 | -------------------------------------------------------------------------------- /LIBSDL/include/SDL/SDL_loadso.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** @file SDL_loadso.h 24 | * System dependent library loading routines 25 | */ 26 | 27 | /** @file SDL_loadso.h 28 | * Some things to keep in mind: 29 | * - These functions only work on C function names. Other languages may 30 | * have name mangling and intrinsic language support that varies from 31 | * compiler to compiler. 32 | * - Make sure you declare your function pointers with the same calling 33 | * convention as the actual library function. Your code will crash 34 | * mysteriously if you do not do this. 35 | * - Avoid namespace collisions. If you load a symbol from the library, 36 | * it is not defined whether or not it goes into the global symbol 37 | * namespace for the application. If it does and it conflicts with 38 | * symbols in your code or other shared libraries, you will not get 39 | * the results you expect. :) 40 | */ 41 | 42 | 43 | #ifndef _SDL_loadso_h 44 | #define _SDL_loadso_h 45 | 46 | #include "SDL_stdinc.h" 47 | #include "SDL_error.h" 48 | 49 | #include "begin_code.h" 50 | /* Set up for C function definitions, even when using C++ */ 51 | #ifdef __cplusplus 52 | extern "C" { 53 | #endif 54 | 55 | /** 56 | * This function dynamically loads a shared object and returns a pointer 57 | * to the object handle (or NULL if there was an error). 58 | * The 'sofile' parameter is a system dependent name of the object file. 59 | */ 60 | extern DECLSPEC void * SDLCALL SDL_LoadObject(const char *sofile); 61 | 62 | /** 63 | * Given an object handle, this function looks up the address of the 64 | * named function in the shared object and returns it. This address 65 | * is no longer valid after calling SDL_UnloadObject(). 66 | */ 67 | extern DECLSPEC void * SDLCALL SDL_LoadFunction(void *handle, const char *name); 68 | 69 | /** Unload a shared object from memory */ 70 | extern DECLSPEC void SDLCALL SDL_UnloadObject(void *handle); 71 | 72 | /* Ends C function definitions when using C++ */ 73 | #ifdef __cplusplus 74 | } 75 | #endif 76 | #include "close_code.h" 77 | 78 | #endif /* _SDL_loadso_h */ 79 | -------------------------------------------------------------------------------- /LIBSDL/src/hermes/HeadMMX.h: -------------------------------------------------------------------------------- 1 | /* 2 | Header definitions for the MMX routines for the HERMES library 3 | Copyright (c) 1998 Christian Nentwich (c.nentwich@cs.ucl.ac.uk) 4 | This source code is licensed under the GNU LGPL 5 | 6 | Please refer to the file COPYING.LIB contained in the distribution for 7 | licensing conditions 8 | */ 9 | #include "SDL_config.h" 10 | 11 | #ifndef __HERMES_HEAD_MMX__ 12 | #define __HERMES_HEAD_MMX__ 13 | 14 | 15 | /* If you cannot stand ifdefs, then please do not look into this file, it's 16 | going to end your life :) */ 17 | 18 | #ifdef X86_ASSEMBLER 19 | 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | void STACKCALL ConvertMMX(HermesConverterInterface *); 26 | 27 | void STACKCALL ClearMMX_32(HermesClearInterface *); 28 | void STACKCALL ClearMMX_24(HermesClearInterface *); 29 | void STACKCALL ClearMMX_16(HermesClearInterface *); 30 | void STACKCALL ClearMMX_8(HermesClearInterface *); 31 | 32 | void ConvertMMXpII32_24RGB888(); 33 | void ConvertMMXpII32_16RGB565(); 34 | void ConvertMMXpII32_16BGR565(); 35 | void ConvertMMXpII32_16RGB555(); 36 | void ConvertMMXpII32_16BGR565(); 37 | void ConvertMMXpII32_16BGR555(); 38 | 39 | void ConvertMMXp32_16RGB555(); 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | 45 | 46 | 47 | /* Fix the underscore business with ELF compilers */ 48 | 49 | #if (defined(__ELF__) && defined(__GNUC__)) || defined(__SUNPRO_C) 50 | #ifdef __cplusplus 51 | extern "C" { 52 | #endif 53 | 54 | extern void _ConvertMMX(HermesConverterInterface *); 55 | extern void _ConvertMMXpII32_24RGB888(); 56 | extern void _ConvertMMXpII32_16RGB565(); 57 | extern void _ConvertMMXpII32_16BGR565(); 58 | extern void _ConvertMMXpII32_16RGB555(); 59 | extern void _ConvertMMXpII32_16BGR555(); 60 | 61 | #define ConvertMMX _ConvertMMX 62 | #define ConvertMMXpII32_24RGB888 _ConvertMMXpII32_24RGB888 63 | #define ConvertMMXpII32_16RGB565 _ConvertMMXpII32_16RGB565 64 | #define ConvertMMXpII32_16BGR565 _ConvertMMXpII32_16BGR565 65 | #define ConvertMMXpII32_16RGB555 _ConvertMMXpII32_16RGB555 66 | #define ConvertMMXpII32_16BGR555 _ConvertMMXpII32_16BGR555 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | 72 | #endif /* ELF and GNUC */ 73 | 74 | 75 | 76 | 77 | /* Make it work with Watcom */ 78 | #ifdef __WATCOMC__ 79 | #pragma warning 601 9 80 | 81 | #pragma aux ConvertMMX "_*" modify [EAX EBX ECX EDX ESI EDI] 82 | 83 | #pragma aux ClearMMX_32 "_*" modify [EAX EBX ECX EDX ESI EDI] 84 | #pragma aux ClearMMX_24 "_*" modify [EAX EBX ECX EDX ESI EDI] 85 | #pragma aux ClearMMX_16 "_*" modify [EAX EBX ECX EDX ESI EDI] 86 | #pragma aux ClearMMX_8 "_*" modify [EAX EBX ECX EDX ESI EDI] 87 | 88 | #pragma aux ConvertMMXpII32_24RGB888 "_*" 89 | #pragma aux ConvertMMXpII32_16RGB565 "_*" 90 | #pragma aux ConvertMMXpII32_16BGR565 "_*" 91 | #pragma aux ConvertMMXpII32_16RGB555 "_*" 92 | #pragma aux ConvertMMXpII32_16BGR555 "_*" 93 | #pragma aux ConvertMMXp32_16RGB555 "_*" 94 | 95 | #endif /* WATCOM */ 96 | 97 | #endif /* X86_ASSEMBLER */ 98 | 99 | 100 | #endif 101 | -------------------------------------------------------------------------------- /src/rfb/minilzo.h: -------------------------------------------------------------------------------- 1 | /* minilzo.h -- mini subset of the LZO real-time data compression library 2 | 3 | This file is part of the LZO real-time data compression library. 4 | 5 | Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer 6 | All Rights Reserved. 7 | 8 | The LZO library is free software; you can redistribute it and/or 9 | modify it under the terms of the GNU General Public License as 10 | published by the Free Software Foundation; either version 2 of 11 | the License, or (at your option) any later version. 12 | 13 | The LZO library is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with the LZO library; see the file COPYING. 20 | If not, write to the Free Software Foundation, Inc., 21 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 22 | 23 | Markus F.X.J. Oberhumer 24 | 25 | http://www.oberhumer.com/opensource/lzo/ 26 | */ 27 | 28 | /* 29 | * NOTE: 30 | * the full LZO package can be found at 31 | * http://www.oberhumer.com/opensource/lzo/ 32 | */ 33 | 34 | 35 | #ifndef __MINILZO_H 36 | #define __MINILZO_H 1 37 | 38 | #define MINILZO_VERSION 0x2070 39 | 40 | #ifdef __LZOCONF_H 41 | # error "you cannot use both LZO and miniLZO" 42 | #endif 43 | 44 | #undef LZO_HAVE_CONFIG_H 45 | #include "lzoconf.h" 46 | 47 | #if !defined(LZO_VERSION) || (LZO_VERSION != MINILZO_VERSION) 48 | # error "version mismatch in header files" 49 | #endif 50 | 51 | 52 | #ifdef __cplusplus 53 | extern "C" { 54 | #endif 55 | 56 | 57 | /*********************************************************************** 58 | // 59 | ************************************************************************/ 60 | 61 | /* Memory required for the wrkmem parameter. 62 | * When the required size is 0, you can also pass a NULL pointer. 63 | */ 64 | 65 | #define LZO1X_MEM_COMPRESS LZO1X_1_MEM_COMPRESS 66 | #define LZO1X_1_MEM_COMPRESS ((lzo_uint32_t) (16384L * lzo_sizeof_dict_t)) 67 | #define LZO1X_MEM_DECOMPRESS (0) 68 | 69 | 70 | /* compression */ 71 | LZO_EXTERN(int) 72 | lzo1x_1_compress ( const lzo_bytep src, lzo_uint src_len, 73 | lzo_bytep dst, lzo_uintp dst_len, 74 | lzo_voidp wrkmem ); 75 | 76 | /* decompression */ 77 | LZO_EXTERN(int) 78 | lzo1x_decompress ( const lzo_bytep src, lzo_uint src_len, 79 | lzo_bytep dst, lzo_uintp dst_len, 80 | lzo_voidp wrkmem /* NOT USED */ ); 81 | 82 | /* safe decompression with overrun testing */ 83 | LZO_EXTERN(int) 84 | lzo1x_decompress_safe ( const lzo_bytep src, lzo_uint src_len, 85 | lzo_bytep dst, lzo_uintp dst_len, 86 | lzo_voidp wrkmem /* NOT USED */ ); 87 | 88 | 89 | #ifdef __cplusplus 90 | } /* extern "C" */ 91 | #endif 92 | 93 | #endif /* already included */ 94 | 95 | -------------------------------------------------------------------------------- /src/mp3decoder.c: -------------------------------------------------------------------------------- 1 | /* 2 | * TinyVNC - A VNC client for Nintendo 3DS 3 | * 4 | * mp3decoder.c - functions for handling mp3 decoding 5 | * 6 | * Copyright 2020 Sebastian Weber 7 | */ 8 | 9 | #include 10 | #include 11 | #include "decoder.h" 12 | #include "mp3decoder.h" 13 | 14 | static mpg123_handle *mp3_handle = NULL; 15 | static int mp3_channels; 16 | static long mp3_rate; 17 | static int mp3_bitrate; 18 | static int infoavailable = 0; 19 | 20 | static int mp3_init() 21 | { 22 | mpg123_init(); 23 | mp3_handle = mpg123_new(NULL, NULL); 24 | mpg123_open_feed(mp3_handle); 25 | infoavailable = 0; 26 | return 0; 27 | } 28 | 29 | // returns 0 on success, non-zero on error 30 | static int mp3_feed(void *data, int size) 31 | { 32 | if (!mp3_handle) return -1; 33 | return mpg123_feed(mp3_handle, (const unsigned char *)data, size); 34 | } 35 | 36 | // returns the number of bytes decoded or a negative number on error 37 | static int mp3_decode(void **outdata, int *outsize) 38 | { 39 | if (!mp3_handle) return -1; 40 | size_t os; 41 | off_t frame_offset; 42 | int encoding; 43 | int err = mpg123_decode_frame(mp3_handle, &frame_offset, (unsigned char **)outdata, &os); 44 | *outsize = os; 45 | switch(err) { 46 | case MPG123_NEW_FORMAT: 47 | mpg123_getformat(mp3_handle, &mp3_rate, &mp3_channels, &encoding); 48 | // Ensure that this output format will not change (it might, when we allow it). 49 | mpg123_format_none(mp3_handle); 50 | mpg123_format(mp3_handle, mp3_rate, mp3_channels, MPG123_ENC_SIGNED_16); 51 | struct mpg123_frameinfo mi; 52 | mpg123_info(mp3_handle, &mi); 53 | mp3_bitrate=mi.bitrate; 54 | infoavailable = 1; 55 | return 0; 56 | case MPG123_OK: 57 | return *outsize; 58 | case MPG123_NEED_MORE: 59 | return 0; 60 | default: // we have an mpg error 61 | return -1; 62 | } 63 | return -1; 64 | } 65 | 66 | // return 0 on success, -1 on failure 67 | static int mp3_info(char **type, int *rate, int *channels, int *bitrate) 68 | { 69 | if (!infoavailable) return -1; 70 | if (type) *type = "mp3"; 71 | if (rate) *rate = mp3_rate; 72 | if (channels) *channels = mp3_channels; 73 | if (bitrate) *bitrate = mp3_bitrate; 74 | return 0; 75 | } 76 | 77 | 78 | static int mp3_close() 79 | { 80 | if (!mp3_handle) return -1; 81 | mpg123_close(mp3_handle); 82 | mpg123_delete(mp3_handle); 83 | mpg123_exit(); 84 | mp3_handle = NULL; 85 | infoavailable = 0; 86 | return 0; 87 | } 88 | 89 | // returns the last error string 90 | static const char *mp3_errstr() 91 | { 92 | if (!mp3_handle) return NULL; 93 | return mpg123_strerror(mp3_handle); 94 | } 95 | 96 | // return 0 on success, -1 on failure 97 | int mp3_checkmagic(char *m) { 98 | if (strlen(m) < 2 || m[0]!=0xff || (m[1]!=0xfb && m[1]!=0xf3 && m[1]!=0xf2)) 99 | return -1; 100 | return 0; 101 | } 102 | 103 | // initializes an audioDecoder struct with mp3-Decoder methods 104 | void mp3_create_decoder(audioDecoder *d) { 105 | d->init = mp3_init; 106 | d->feed = mp3_feed; 107 | d->decode = mp3_decode; 108 | d->info = mp3_info; 109 | d->close = mp3_close; 110 | d->errstr = mp3_errstr; 111 | } 112 | -------------------------------------------------------------------------------- /LIBSDL/src/joystick/SDL_sysjoystick.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is SDL_free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | #include "SDL_config.h" 23 | 24 | /* This is the system specific header for the SDL joystick API */ 25 | 26 | #include "SDL_joystick.h" 27 | 28 | /* The SDL joystick structure */ 29 | struct _SDL_Joystick { 30 | Uint8 index; /* Device index */ 31 | const char *name; /* Joystick name - system dependent */ 32 | 33 | int naxes; /* Number of axis controls on the joystick */ 34 | Sint16 *axes; /* Current axis states */ 35 | 36 | int nhats; /* Number of hats on the joystick */ 37 | Uint8 *hats; /* Current hat states */ 38 | 39 | int nballs; /* Number of trackballs on the joystick */ 40 | struct balldelta { 41 | int dx; 42 | int dy; 43 | } *balls; /* Current ball motion deltas */ 44 | 45 | int nbuttons; /* Number of buttons on the joystick */ 46 | Uint8 *buttons; /* Current button states */ 47 | 48 | struct joystick_hwdata *hwdata; /* Driver dependent information */ 49 | 50 | int ref_count; /* Reference count for multiple opens */ 51 | }; 52 | 53 | /* Function to scan the system for joysticks. 54 | * Joystick 0 should be the system default joystick. 55 | * This function should return the number of available joysticks, or -1 56 | * on an unrecoverable fatal error. 57 | */ 58 | extern int SDL_SYS_JoystickInit(void); 59 | 60 | /* Function to get the device-dependent name of a joystick */ 61 | extern const char *SDL_SYS_JoystickName(int index); 62 | 63 | /* Function to open a joystick for use. 64 | The joystick to open is specified by the index field of the joystick. 65 | This should fill the nbuttons and naxes fields of the joystick structure. 66 | It returns 0, or -1 if there is an error. 67 | */ 68 | extern int SDL_SYS_JoystickOpen(SDL_Joystick *joystick); 69 | 70 | /* Function to update the state of a joystick - called as a device poll. 71 | * This function shouldn't update the joystick structure directly, 72 | * but instead should call SDL_PrivateJoystick*() to deliver events 73 | * and update joystick device state. 74 | */ 75 | extern void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick); 76 | 77 | /* Function to close a joystick after use */ 78 | extern void SDL_SYS_JoystickClose(SDL_Joystick *joystick); 79 | 80 | /* Function to perform any system-specific joystick related cleanup */ 81 | extern void SDL_SYS_JoystickQuit(void); 82 | 83 | -------------------------------------------------------------------------------- /LIBSDL/src/events/SDL_events_c.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | #include "SDL_config.h" 23 | 24 | /* Useful functions and variables from SDL_events.c */ 25 | #include "SDL_events.h" 26 | 27 | /* Start and stop the event processing loop */ 28 | extern int SDL_StartEventLoop(Uint32 flags); 29 | extern void SDL_StopEventLoop(void); 30 | extern void SDL_QuitInterrupt(void); 31 | 32 | extern void SDL_Lock_EventThread(void); 33 | extern void SDL_Unlock_EventThread(void); 34 | extern Uint32 SDL_EventThreadID(void); 35 | 36 | /* Event handler init routines */ 37 | extern int SDL_AppActiveInit(void); 38 | extern int SDL_KeyboardInit(void); 39 | extern int SDL_MouseInit(void); 40 | extern int SDL_QuitInit(void); 41 | 42 | /* Event handler quit routines */ 43 | extern void SDL_AppActiveQuit(void); 44 | extern void SDL_KeyboardQuit(void); 45 | extern void SDL_MouseQuit(void); 46 | extern void SDL_QuitQuit(void); 47 | 48 | /* The event filter function */ 49 | extern SDL_EventFilter SDL_EventOK; 50 | 51 | /* The array of event processing states */ 52 | extern Uint8 SDL_ProcessEvents[SDL_NUMEVENTS]; 53 | 54 | /* Internal event queueing functions 55 | (from SDL_active.c, SDL_mouse.c, SDL_keyboard.c, SDL_quit.c, SDL_events.c) 56 | */ 57 | extern int SDL_PrivateAppActive(Uint8 gain, Uint8 state); 58 | extern int SDL_PrivateMouseMotion(Uint8 buttonstate, int relative, 59 | Sint16 x, Sint16 y); 60 | extern int SDL_PrivateMouseButton(Uint8 state, Uint8 button,Sint16 x,Sint16 y); 61 | extern int SDL_PrivateKeyboard(Uint8 state, SDL_keysym *key); 62 | extern int SDL_PrivateResize(int w, int h); 63 | extern int SDL_PrivateExpose(void); 64 | extern int SDL_PrivateQuit(void); 65 | extern int SDL_PrivateSysWMEvent(SDL_SysWMmsg *message); 66 | 67 | /* Used to clamp the mouse coordinates separately from the video surface */ 68 | extern void SDL_SetMouseRange(int maxX, int maxY); 69 | 70 | /* Used by the activity event handler to remove mouse focus */ 71 | extern void SDL_ResetMouse(void); 72 | 73 | /* Used by the activity event handler to remove keyboard focus */ 74 | extern void SDL_ResetKeyboard(void); 75 | 76 | /* Used by the event loop to queue pending keyboard repeat events */ 77 | extern void SDL_CheckKeyRepeat(void); 78 | 79 | /* Used by the OS keyboard code to detect whether or not to do UNICODE */ 80 | #ifndef DEFAULT_UNICODE_TRANSLATION 81 | #define DEFAULT_UNICODE_TRANSLATION 0 /* Default off because of overhead */ 82 | #endif 83 | extern int SDL_TranslateUNICODE; 84 | -------------------------------------------------------------------------------- /LIBSDL/include/SDL/SDL_platform.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** @file SDL_platform.h 24 | * Try to get a standard set of platform defines 25 | */ 26 | 27 | #ifndef _SDL_platform_h 28 | #define _SDL_platform_h 29 | 30 | #if defined(_AIX) 31 | #undef __AIX__ 32 | #define __AIX__ 1 33 | #endif 34 | #if defined(__BEOS__) 35 | #undef __BEOS__ 36 | #define __BEOS__ 1 37 | #endif 38 | #if defined(__HAIKU__) 39 | #undef __HAIKU__ 40 | #define __HAIKU__ 1 41 | #endif 42 | #if defined(bsdi) || defined(__bsdi) || defined(__bsdi__) 43 | #undef __BSDI__ 44 | #define __BSDI__ 1 45 | #endif 46 | #if defined(_arch_dreamcast) 47 | #undef __DREAMCAST__ 48 | #define __DREAMCAST__ 1 49 | #endif 50 | #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) 51 | #undef __FREEBSD__ 52 | #define __FREEBSD__ 1 53 | #endif 54 | #if defined(__HAIKU__) 55 | #undef __HAIKU__ 56 | #define __HAIKU__ 1 57 | #endif 58 | #if defined(hpux) || defined(__hpux) || defined(__hpux__) 59 | #undef __HPUX__ 60 | #define __HPUX__ 1 61 | #endif 62 | #if defined(sgi) || defined(__sgi) || defined(__sgi__) || defined(_SGI_SOURCE) 63 | #undef __IRIX__ 64 | #define __IRIX__ 1 65 | #endif 66 | #if defined(linux) || defined(__linux) || defined(__linux__) 67 | #undef __LINUX__ 68 | #define __LINUX__ 1 69 | #endif 70 | #if defined(__APPLE__) 71 | #undef __MACOSX__ 72 | #define __MACOSX__ 1 73 | #elif defined(macintosh) 74 | #undef __MACOS__ 75 | #define __MACOS__ 1 76 | #endif 77 | #if defined(__NetBSD__) 78 | #undef __NETBSD__ 79 | #define __NETBSD__ 1 80 | #endif 81 | #if defined(__OpenBSD__) 82 | #undef __OPENBSD__ 83 | #define __OPENBSD__ 1 84 | #endif 85 | #if defined(__OS2__) 86 | #undef __OS2__ 87 | #define __OS2__ 1 88 | #endif 89 | #if defined(osf) || defined(__osf) || defined(__osf__) || defined(_OSF_SOURCE) 90 | #undef __OSF__ 91 | #define __OSF__ 1 92 | #endif 93 | #if defined(__QNXNTO__) 94 | #undef __QNXNTO__ 95 | #define __QNXNTO__ 1 96 | #endif 97 | #if defined(riscos) || defined(__riscos) || defined(__riscos__) 98 | #undef __RISCOS__ 99 | #define __RISCOS__ 1 100 | #endif 101 | #if defined(__SVR4) 102 | #undef __SOLARIS__ 103 | #define __SOLARIS__ 1 104 | #endif 105 | #if defined(WIN32) || defined(_WIN32) 106 | #undef __WIN32__ 107 | #define __WIN32__ 1 108 | #endif 109 | #if defined(_3DS) 110 | #undef __N3DS__ 111 | #define __N3DS__ 1 112 | #endif 113 | 114 | #endif /* _SDL_platform_h */ 115 | -------------------------------------------------------------------------------- /LIBSDL/include/SDL/SDL_main.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | #ifndef _SDL_main_h 24 | #define _SDL_main_h 25 | 26 | #include "SDL_stdinc.h" 27 | 28 | /** @file SDL_main.h 29 | * Redefine main() on Win32 and MacOS so that it is called by winmain.c 30 | */ 31 | 32 | #if defined(__WIN32__) || \ 33 | (defined(__MWERKS__) && !defined(__BEOS__)) || \ 34 | defined(__MACOS__) || defined(__MACOSX__) || \ 35 | defined(__SYMBIAN32__) || defined(QWS) 36 | 37 | #ifdef __cplusplus 38 | #define C_LINKAGE "C" 39 | #else 40 | #define C_LINKAGE 41 | #endif /* __cplusplus */ 42 | 43 | /** The application's main() function must be called with C linkage, 44 | * and should be declared like this: 45 | * @code 46 | * #ifdef __cplusplus 47 | * extern "C" 48 | * #endif 49 | * int main(int argc, char *argv[]) 50 | * { 51 | * } 52 | * @endcode 53 | */ 54 | #define main SDL_main 55 | 56 | /** The prototype for the application's main() function */ 57 | extern C_LINKAGE int SDL_main(int argc, char *argv[]); 58 | 59 | 60 | /** @name From the SDL library code -- needed for registering the app on Win32 */ 61 | /*@{*/ 62 | #ifdef __WIN32__ 63 | 64 | #include "begin_code.h" 65 | #ifdef __cplusplus 66 | extern "C" { 67 | #endif 68 | 69 | /** This should be called from your WinMain() function, if any */ 70 | extern DECLSPEC void SDLCALL SDL_SetModuleHandle(void *hInst); 71 | /** This can also be called, but is no longer necessary */ 72 | extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style, void *hInst); 73 | /** This can also be called, but is no longer necessary (SDL_Quit calls it) */ 74 | extern DECLSPEC void SDLCALL SDL_UnregisterApp(void); 75 | #ifdef __cplusplus 76 | } 77 | #endif 78 | #include "close_code.h" 79 | #endif 80 | /*@}*/ 81 | 82 | /** @name From the SDL library code -- needed for registering QuickDraw on MacOS */ 83 | /*@{*/ 84 | #if defined(__MACOS__) 85 | 86 | #include "begin_code.h" 87 | #ifdef __cplusplus 88 | extern "C" { 89 | #endif 90 | 91 | /** Forward declaration so we don't need to include QuickDraw.h */ 92 | struct QDGlobals; 93 | 94 | /** This should be called from your main() function, if any */ 95 | extern DECLSPEC void SDLCALL SDL_InitQuickDraw(struct QDGlobals *the_qd); 96 | 97 | #ifdef __cplusplus 98 | } 99 | #endif 100 | #include "close_code.h" 101 | #endif 102 | /*@}*/ 103 | 104 | #endif /* Need to redefine main()? */ 105 | 106 | #endif /* _SDL_main_h */ 107 | -------------------------------------------------------------------------------- /src/utilities.c: -------------------------------------------------------------------------------- 1 | /* 2 | * TinyVNC - A VNC client for Nintendo 3DS 3 | * 4 | * utilities.c - utility functions 5 | * 6 | * Copyright 2020 Sebastian Weber 7 | */ 8 | 9 | #include <3ds.h> 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include "utilities.h" 15 | 16 | int fastscale(unsigned char *dst, int dst_pitch, unsigned char *src, int src_width, int src_height, int src_pitch, int factor) 17 | { 18 | if (factor < 2) return -1; 19 | 20 | int temp_r, temp_g, temp_b; 21 | int i1,i2; 22 | 23 | int dst_width = src_width / factor; 24 | int dst_height = src_height / factor; 25 | if (!dst_height || !dst_width) return -1; 26 | int factor_pow2 = factor * factor; 27 | int factor_mul4 = factor << 2; 28 | int src_skip1 = src_pitch - factor_mul4; 29 | int src_skip2 = factor_mul4 - factor * src_pitch; 30 | int src_skip3 = src_pitch * factor - dst_width * factor_mul4; 31 | int dst_skip = dst_pitch - (dst_width << 2); 32 | 33 | for (i1 = 0; i1 < dst_height; ++i1) 34 | { 35 | for (i2 = 0; i2 < dst_width; ++i2) 36 | { 37 | temp_r = temp_g = temp_b = 0; 38 | DUFFS_LOOP ({ 39 | DUFFS_LOOP ({ 40 | src++; // alpha 41 | temp_r += *(src++); 42 | temp_g += *(src++); 43 | temp_b += *(src++); 44 | }, factor); 45 | src += src_skip1; 46 | }, factor); 47 | *(dst++) = 255; // alpha 48 | *(dst++) = temp_r / factor_pow2; 49 | *(dst++) = temp_g / factor_pow2; 50 | *(dst++) = temp_b / factor_pow2; 51 | src += src_skip2; 52 | } 53 | dst += dst_skip; 54 | src += src_skip3; 55 | } 56 | return 0; 57 | } 58 | 59 | u64 getmicrotime() { 60 | struct timeval tv; 61 | gettimeofday(&tv,NULL); 62 | return tv.tv_sec*(u64)1000000+tv.tv_usec; 63 | } 64 | 65 | void printBits(size_t const size, void const * const ptr) 66 | { 67 | unsigned char *b = (unsigned char*) ptr; 68 | unsigned char byte; 69 | int i, j; 70 | 71 | for (i = size-1; i >= 0; i--) { 72 | for (j = 7; j >= 0; j--) { 73 | byte = (b[i] >> j) & 1; 74 | printf("%u", byte); 75 | } 76 | } 77 | } 78 | 79 | void hex_dump(char *data, int size, char *caption) 80 | { 81 | int i; // index in data... 82 | int j; // index in line... 83 | char temp[16]; 84 | char buffer[128]; 85 | char *ascii; 86 | 87 | memset(buffer, 0, 128); 88 | 89 | log_citra("---------> %s <--------- (%d bytes from %p)", caption, size, data); 90 | // Printing the ruler... 91 | //log_citra(" +0 +4 +8 +c 0 4 8 c "); 92 | 93 | // Hex portion of the line is 8 (the padding) + 3 * 16 = 52 chars long 94 | // We add another four bytes padding and place the ASCII version... 95 | ascii = buffer + 58; 96 | memset(buffer, ' ', 58 + 16); 97 | buffer[58 + 16] = '\0'; 98 | buffer[0] = '+'; 99 | buffer[1] = '0'; 100 | buffer[2] = '0'; 101 | buffer[3] = '0'; 102 | buffer[4] = '0'; 103 | for (i = 0, j = 0; i < size; i++, j++) 104 | { 105 | if (j == 16) 106 | { 107 | log_citra("%s", buffer); 108 | memset(buffer, ' ', 58 + 16); 109 | 110 | sprintf(temp, "+%04x", i); 111 | memcpy(buffer, temp, 5); 112 | 113 | j = 0; 114 | } 115 | 116 | sprintf(temp, "%02x", 0xff & data[i]); 117 | memcpy(buffer + 8 + (j * 3), temp, 2); 118 | if ((data[i] > 31) && (data[i] < 127)) 119 | ascii[j] = data[i]; 120 | else 121 | ascii[j] = '.'; 122 | } 123 | 124 | if (j != 0) 125 | log_citra("%s", buffer); 126 | } 127 | -------------------------------------------------------------------------------- /LIBSDL/include/SDL/SDL.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** @file SDL.h 24 | * Main include header for the SDL library 25 | */ 26 | 27 | #ifndef _SDL_H 28 | #define _SDL_H 29 | 30 | #include "SDL_main.h" 31 | #include "SDL_stdinc.h" 32 | #include "SDL_audio.h" 33 | #include "SDL_cdrom.h" 34 | #include "SDL_cpuinfo.h" 35 | #include "SDL_endian.h" 36 | #include "SDL_error.h" 37 | #include "SDL_events.h" 38 | #include "SDL_loadso.h" 39 | #include "SDL_mutex.h" 40 | #include "SDL_rwops.h" 41 | #include "SDL_thread.h" 42 | #include "SDL_timer.h" 43 | #include "SDL_video.h" 44 | #include "SDL_version.h" 45 | 46 | #include "begin_code.h" 47 | /* Set up for C function definitions, even when using C++ */ 48 | #ifdef __cplusplus 49 | extern "C" { 50 | #endif 51 | 52 | /** @file SDL.h 53 | * @note As of version 0.5, SDL is loaded dynamically into the application 54 | */ 55 | 56 | /** @name SDL_INIT Flags 57 | * These are the flags which may be passed to SDL_Init() -- you should 58 | * specify the subsystems which you will be using in your application. 59 | */ 60 | /*@{*/ 61 | #define SDL_INIT_TIMER 0x00000001 62 | #define SDL_INIT_AUDIO 0x00000010 63 | #define SDL_INIT_VIDEO 0x00000020 64 | #define SDL_INIT_CDROM 0x00000100 65 | #define SDL_INIT_JOYSTICK 0x00000200 66 | #define SDL_INIT_NOPARACHUTE 0x00100000 /**< Don't catch fatal signals */ 67 | #define SDL_INIT_EVENTTHREAD 0x01000000 /**< Not supported on all OS's */ 68 | #define SDL_INIT_EVERYTHING 0x0000FFFF 69 | /*@}*/ 70 | 71 | /** This function loads the SDL dynamically linked library and initializes 72 | * the subsystems specified by 'flags' (and those satisfying dependencies) 73 | * Unless the SDL_INIT_NOPARACHUTE flag is set, it will install cleanup 74 | * signal handlers for some commonly ignored fatal signals (like SIGSEGV) 75 | */ 76 | extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags); 77 | 78 | /** This function initializes specific SDL subsystems */ 79 | extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags); 80 | 81 | /** This function cleans up specific SDL subsystems */ 82 | extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags); 83 | 84 | /** This function returns mask of the specified subsystems which have 85 | * been initialized. 86 | * If 'flags' is 0, it returns a mask of all initialized subsystems. 87 | */ 88 | extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags); 89 | 90 | /** This function cleans up all initialized subsystems and unloads the 91 | * dynamically linked library. You should call it upon all exit conditions. 92 | */ 93 | extern DECLSPEC void SDLCALL SDL_Quit(void); 94 | 95 | /* Ends C function definitions when using C++ */ 96 | #ifdef __cplusplus 97 | } 98 | #endif 99 | #include "close_code.h" 100 | 101 | #endif /* _SDL_H */ 102 | -------------------------------------------------------------------------------- /LIBSDL/src/SDL_fatal.c: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | #include "SDL_config.h" 23 | 24 | /* General fatal signal handling code for SDL */ 25 | 26 | #ifdef HAVE_SIGNAL_H 27 | 28 | #include 29 | 30 | #include "SDL.h" 31 | #include "SDL_fatal.h" 32 | 33 | /* This installs some signal handlers for the more common fatal signals, 34 | so that if the programmer is lazy, the app doesn't die so horribly if 35 | the program crashes. 36 | */ 37 | 38 | static void SDL_Parachute(int sig) 39 | { 40 | signal(sig, SIG_DFL); 41 | SDL_Quit(); 42 | raise(sig); 43 | } 44 | 45 | static int SDL_fatal_signals[] = { 46 | SIGSEGV, 47 | #ifdef SIGBUS 48 | SIGBUS, 49 | #endif 50 | #ifdef SIGFPE 51 | SIGFPE, 52 | #endif 53 | #ifdef SIGQUIT 54 | SIGQUIT, 55 | #endif 56 | 0 57 | }; 58 | 59 | void SDL_InstallParachute(void) 60 | { 61 | /* Set a handler for any fatal signal not already handled */ 62 | int i; 63 | #ifdef HAVE_SIGACTION 64 | struct sigaction action; 65 | 66 | for ( i=0; SDL_fatal_signals[i]; ++i ) { 67 | sigaction(SDL_fatal_signals[i], NULL, &action); 68 | if ( action.sa_handler == SIG_DFL ) { 69 | action.sa_handler = SDL_Parachute; 70 | sigaction(SDL_fatal_signals[i], &action, NULL); 71 | } 72 | } 73 | #ifdef SIGALRM 74 | /* Set SIGALRM to be ignored -- necessary on Solaris */ 75 | sigaction(SIGALRM, NULL, &action); 76 | if ( action.sa_handler == SIG_DFL ) { 77 | action.sa_handler = SIG_IGN; 78 | sigaction(SIGALRM, &action, NULL); 79 | } 80 | #endif 81 | #else 82 | void (*ohandler)(int); 83 | 84 | for ( i=0; SDL_fatal_signals[i]; ++i ) { 85 | ohandler = signal(SDL_fatal_signals[i], SDL_Parachute); 86 | if ( ohandler != SIG_DFL ) { 87 | signal(SDL_fatal_signals[i], ohandler); 88 | } 89 | } 90 | #endif /* HAVE_SIGACTION */ 91 | return; 92 | } 93 | 94 | void SDL_UninstallParachute(void) 95 | { 96 | /* Remove a handler for any fatal signal handled */ 97 | int i; 98 | #ifdef HAVE_SIGACTION 99 | struct sigaction action; 100 | 101 | for ( i=0; SDL_fatal_signals[i]; ++i ) { 102 | sigaction(SDL_fatal_signals[i], NULL, &action); 103 | if ( action.sa_handler == SDL_Parachute ) { 104 | action.sa_handler = SIG_DFL; 105 | sigaction(SDL_fatal_signals[i], &action, NULL); 106 | } 107 | } 108 | #else 109 | void (*ohandler)(int); 110 | 111 | for ( i=0; SDL_fatal_signals[i]; ++i ) { 112 | ohandler = signal(SDL_fatal_signals[i], SIG_DFL); 113 | if ( ohandler != SDL_Parachute ) { 114 | signal(SDL_fatal_signals[i], ohandler); 115 | } 116 | } 117 | #endif /* HAVE_SIGACTION */ 118 | } 119 | 120 | #else 121 | 122 | /* No signals on this platform, nothing to do.. */ 123 | 124 | void SDL_InstallParachute(void) 125 | { 126 | return; 127 | } 128 | 129 | void SDL_UninstallParachute(void) 130 | { 131 | return; 132 | } 133 | 134 | #endif /* HAVE_SIGNAL_H */ 135 | -------------------------------------------------------------------------------- /LIBSDL/src/events/SDL_quit.c: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | #include "SDL_config.h" 23 | 24 | /* General quit handling code for SDL */ 25 | 26 | #ifdef HAVE_SIGNAL_H 27 | #include 28 | #endif 29 | 30 | #include "SDL_events.h" 31 | #include "SDL_events_c.h" 32 | 33 | 34 | #ifdef HAVE_SIGNAL_H 35 | static void SDL_HandleSIG(int sig) 36 | { 37 | /* Reset the signal handler */ 38 | signal(sig, SDL_HandleSIG); 39 | 40 | /* Signal a quit interrupt */ 41 | SDL_PrivateQuit(); 42 | } 43 | #endif /* HAVE_SIGNAL_H */ 44 | 45 | /* Public functions */ 46 | int SDL_QuitInit(void) 47 | { 48 | #ifdef HAVE_SIGACTION 49 | struct sigaction action; 50 | sigaction(SIGINT, NULL, &action); 51 | # ifdef HAVE_SA_SIGACTION 52 | if ( action.sa_handler == SIG_DFL && action.sa_sigaction == (void*)SIG_DFL ) { 53 | # else 54 | if ( action.sa_handler == SIG_DFL ) { 55 | # endif 56 | action.sa_handler = SDL_HandleSIG; 57 | sigaction(SIGINT, &action, NULL); 58 | } 59 | sigaction(SIGTERM, NULL, &action); 60 | # ifdef HAVE_SA_SIGACTION 61 | if ( action.sa_handler == SIG_DFL && action.sa_sigaction == (void*)SIG_DFL ) { 62 | # else 63 | if ( action.sa_handler == SIG_DFL ) { 64 | # endif 65 | action.sa_handler = SDL_HandleSIG; 66 | sigaction(SIGTERM, &action, NULL); 67 | } 68 | #elif HAVE_SIGNAL_H 69 | void (*ohandler)(int); 70 | 71 | /* Both SIGINT and SIGTERM are translated into quit interrupts */ 72 | ohandler = signal(SIGINT, SDL_HandleSIG); 73 | if ( ohandler != SIG_DFL ) 74 | signal(SIGINT, ohandler); 75 | ohandler = signal(SIGTERM, SDL_HandleSIG); 76 | if ( ohandler != SIG_DFL ) 77 | signal(SIGTERM, ohandler); 78 | #endif /* HAVE_SIGNAL_H */ 79 | 80 | /* That's it! */ 81 | return(0); 82 | } 83 | void SDL_QuitQuit(void) 84 | { 85 | #ifdef HAVE_SIGACTION 86 | struct sigaction action; 87 | sigaction(SIGINT, NULL, &action); 88 | if ( action.sa_handler == SDL_HandleSIG ) { 89 | action.sa_handler = SIG_DFL; 90 | sigaction(SIGINT, &action, NULL); 91 | } 92 | sigaction(SIGTERM, NULL, &action); 93 | if ( action.sa_handler == SDL_HandleSIG ) { 94 | action.sa_handler = SIG_DFL; 95 | sigaction(SIGTERM, &action, NULL); 96 | } 97 | #elif HAVE_SIGNAL_H 98 | void (*ohandler)(int); 99 | 100 | ohandler = signal(SIGINT, SIG_DFL); 101 | if ( ohandler != SDL_HandleSIG ) 102 | signal(SIGINT, ohandler); 103 | ohandler = signal(SIGTERM, SIG_DFL); 104 | if ( ohandler != SDL_HandleSIG ) 105 | signal(SIGTERM, ohandler); 106 | #endif /* HAVE_SIGNAL_H */ 107 | } 108 | 109 | /* This function returns 1 if it's okay to close the application window */ 110 | int SDL_PrivateQuit(void) 111 | { 112 | int posted; 113 | 114 | posted = 0; 115 | if ( SDL_ProcessEvents[SDL_QUIT] == SDL_ENABLE ) { 116 | SDL_Event event; 117 | event.type = SDL_QUIT; 118 | if ( (SDL_EventOK == NULL) || (*SDL_EventOK)(&event) ) { 119 | posted = 1; 120 | SDL_PushEvent(&event); 121 | } 122 | } 123 | return(posted); 124 | } 125 | -------------------------------------------------------------------------------- /src/rfb/hextile-c.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved. 3 | * 4 | * This is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This software is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this software; if not, write to the Free Software 16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 17 | * USA. 18 | */ 19 | 20 | /* 21 | * hextile.c - handle hextile encoding. 22 | * 23 | * This file shouldn't be compiled directly. It is included multiple times by 24 | * rfbproto.c, each time with a different definition of the macro BPP. For 25 | * each value of BPP, this file defines a function which handles a hextile 26 | * encoded rectangle with BPP bits per pixel. 27 | */ 28 | 29 | #define HandleHextileBPP CONCAT2E(HandleHextile,BPP) 30 | #define CARDBPP CONCAT3E(uint,BPP,_t) 31 | 32 | static rfbBool 33 | HandleHextileBPP (rfbClient* client, int rx, int ry, int rw, int rh) 34 | { 35 | CARDBPP bg = 0, fg; 36 | int i; 37 | uint8_t *ptr; 38 | int x, y, w, h; 39 | int sx, sy, sw, sh; 40 | uint8_t subencoding; 41 | uint8_t nSubrects; 42 | 43 | for (y = ry; y < ry+rh; y += 16) { 44 | for (x = rx; x < rx+rw; x += 16) { 45 | w = h = 16; 46 | if (rx+rw - x < 16) 47 | w = rx+rw - x; 48 | if (ry+rh - y < 16) 49 | h = ry+rh - y; 50 | 51 | if (!ReadFromRFBServer(client, (char *)&subencoding, 1)) 52 | return FALSE; 53 | 54 | if (subencoding & rfbHextileRaw) { 55 | if (!ReadFromRFBServer(client, client->buffer, w * h * (BPP / 8))) 56 | return FALSE; 57 | 58 | client->GotBitmap(client, (uint8_t *)client->buffer, x, y, w, h); 59 | 60 | continue; 61 | } 62 | 63 | if (subencoding & rfbHextileBackgroundSpecified) 64 | if (!ReadFromRFBServer(client, (char *)&bg, sizeof(bg))) 65 | return FALSE; 66 | 67 | client->GotFillRect(client, x, y, w, h, bg); 68 | 69 | if (subencoding & rfbHextileForegroundSpecified) 70 | if (!ReadFromRFBServer(client, (char *)&fg, sizeof(fg))) 71 | return FALSE; 72 | 73 | if (!(subencoding & rfbHextileAnySubrects)) { 74 | continue; 75 | } 76 | 77 | if (!ReadFromRFBServer(client, (char *)&nSubrects, 1)) 78 | return FALSE; 79 | 80 | ptr = (uint8_t*)client->buffer; 81 | 82 | if (subencoding & rfbHextileSubrectsColoured) { 83 | if (!ReadFromRFBServer(client, client->buffer, nSubrects * (2 + (BPP / 8)))) 84 | return FALSE; 85 | 86 | for (i = 0; i < nSubrects; i++) { 87 | #if BPP==8 88 | GET_PIXEL8(fg, ptr); 89 | #elif BPP==16 90 | GET_PIXEL16(fg, ptr); 91 | #elif BPP==32 92 | GET_PIXEL32(fg, ptr); 93 | #else 94 | #error "Invalid BPP" 95 | #endif 96 | sx = rfbHextileExtractX(*ptr); 97 | sy = rfbHextileExtractY(*ptr); 98 | ptr++; 99 | sw = rfbHextileExtractW(*ptr); 100 | sh = rfbHextileExtractH(*ptr); 101 | ptr++; 102 | 103 | client->GotFillRect(client, x+sx, y+sy, sw, sh, fg); 104 | } 105 | 106 | } else { 107 | if (!ReadFromRFBServer(client, client->buffer, nSubrects * 2)) 108 | return FALSE; 109 | 110 | for (i = 0; i < nSubrects; i++) { 111 | sx = rfbHextileExtractX(*ptr); 112 | sy = rfbHextileExtractY(*ptr); 113 | ptr++; 114 | sw = rfbHextileExtractW(*ptr); 115 | sh = rfbHextileExtractH(*ptr); 116 | ptr++; 117 | 118 | client->GotFillRect(client, x+sx, y+sy, sw, sh, fg); 119 | } 120 | } 121 | } 122 | } 123 | 124 | return TRUE; 125 | } 126 | 127 | #undef CARDBPP 128 | -------------------------------------------------------------------------------- /LIBSDL/src/thread/n3ds/SDL_syscond.c: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2014 Sam Lantinga 4 | 5 | This software is provided 'as-is', without any express or implied 6 | warranty. In no event will the authors be held liable for any damages 7 | arising from the use of this software. 8 | 9 | Permission is granted to anyone to use this software for any purpose, 10 | including commercial applications, and to alter it and redistribute it 11 | freely, subject to the following restrictions: 12 | 13 | 1. The origin of this software must not be misrepresented; you must not 14 | claim that you wrote the original software. If you use this software 15 | in a product, an acknowledgment in the product documentation would be 16 | appreciated but is not required. 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original software. 19 | 3. This notice may not be removed or altered from any source distribution. 20 | */ 21 | //#include "../../SDL_internal.h" 22 | 23 | #include "SDL_config.h" 24 | 25 | #include "SDL_sysmutex_c.h" 26 | 27 | struct SDL_cond 28 | { 29 | CondVar cv; 30 | }; 31 | 32 | /* Create a condition variable */ 33 | SDL_cond * 34 | SDL_CreateCond(void) 35 | { 36 | SDL_cond *cond; 37 | 38 | cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond)); 39 | if (cond) { 40 | CondVar_Init(&cond->cv); 41 | } else { 42 | SDL_OutOfMemory(); 43 | } 44 | return (cond); 45 | } 46 | 47 | /* Destroy a condition variable */ 48 | void 49 | SDL_DestroyCond(SDL_cond * cond) 50 | { 51 | if (cond) { 52 | SDL_free(cond); 53 | } 54 | } 55 | 56 | /* Restart one of the threads that are waiting on the condition variable */ 57 | int 58 | SDL_CondSignal(SDL_cond * cond) 59 | { 60 | if (!cond) { 61 | SDL_SetError("Passed a NULL condition variable"); 62 | return -1; 63 | } 64 | 65 | CondVar_Signal(&cond->cv); 66 | return 0; 67 | } 68 | 69 | /* Restart all threads that are waiting on the condition variable */ 70 | int 71 | SDL_CondBroadcast(SDL_cond * cond) 72 | { 73 | if (!cond) { 74 | SDL_SetError("Passed a NULL condition variable"); 75 | return -1; 76 | } 77 | 78 | CondVar_Broadcast(&cond->cv); 79 | return 0; 80 | } 81 | 82 | /* Wait on the condition variable for at most 'ms' milliseconds. 83 | The mutex must be locked before entering this function! 84 | The mutex is unlocked during the wait, and locked again after the wait. 85 | 86 | Typical use: 87 | 88 | Thread A: 89 | SDL_LockMutex(lock); 90 | while ( ! condition ) { 91 | SDL_CondWait(cond, lock); 92 | } 93 | SDL_UnlockMutex(lock); 94 | 95 | Thread B: 96 | SDL_LockMutex(lock); 97 | ... 98 | condition = true; 99 | ... 100 | SDL_CondSignal(cond); 101 | SDL_UnlockMutex(lock); 102 | */ 103 | int 104 | SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms) 105 | { 106 | if (!cond) { 107 | SDL_SetError("Passed a NULL condition variable"); 108 | return -1; 109 | } 110 | 111 | if (!mutex) { 112 | SDL_SetError("Passed a NULL mutex"); 113 | return -1; 114 | } 115 | 116 | RecursiveLock rl_backup = mutex->rl; 117 | mutex->rl.thread_tag = 0; 118 | mutex->rl.counter = 0; 119 | 120 | Result res = 0; 121 | if (ms == SDL_MUTEX_MAXWAIT) 122 | CondVar_Wait(&cond->cv, &mutex->rl.lock); 123 | else 124 | res = CondVar_WaitTimeout(&cond->cv, &mutex->rl.lock, (s64)ms * 1000000LL); 125 | 126 | mutex->rl.thread_tag = rl_backup.thread_tag; 127 | mutex->rl.counter = rl_backup.counter; 128 | 129 | return R_SUCCEEDED(res) ? 0 : SDL_MUTEX_TIMEDOUT; 130 | } 131 | 132 | /* Wait on the condition variable forever */ 133 | int 134 | SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex) 135 | { 136 | return SDL_CondWaitTimeout(cond, mutex, SDL_MUTEX_MAXWAIT); 137 | } 138 | -------------------------------------------------------------------------------- /LIBSDL/include/SDL/SDL_keyboard.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | /** @file SDL_keyboard.h 24 | * Include file for SDL keyboard event handling 25 | */ 26 | 27 | #ifndef _SDL_keyboard_h 28 | #define _SDL_keyboard_h 29 | 30 | #include "SDL_stdinc.h" 31 | #include "SDL_error.h" 32 | #include "SDL_keysym.h" 33 | 34 | #include "begin_code.h" 35 | /* Set up for C function definitions, even when using C++ */ 36 | #ifdef __cplusplus 37 | extern "C" { 38 | #endif 39 | 40 | /** Keysym structure 41 | * 42 | * - The scancode is hardware dependent, and should not be used by general 43 | * applications. If no hardware scancode is available, it will be 0. 44 | * 45 | * - The 'unicode' translated character is only available when character 46 | * translation is enabled by the SDL_EnableUNICODE() API. If non-zero, 47 | * this is a UNICODE character corresponding to the keypress. If the 48 | * high 9 bits of the character are 0, then this maps to the equivalent 49 | * ASCII character: 50 | * @code 51 | * char ch; 52 | * if ( (keysym.unicode & 0xFF80) == 0 ) { 53 | * ch = keysym.unicode & 0x7F; 54 | * } else { 55 | * An international character.. 56 | * } 57 | * @endcode 58 | */ 59 | typedef struct SDL_keysym { 60 | Uint8 scancode; /**< hardware specific scancode */ 61 | SDLKey sym; /**< SDL virtual keysym */ 62 | SDLMod mod; /**< current key modifiers */ 63 | Uint16 unicode; /**< translated character */ 64 | } SDL_keysym; 65 | 66 | /** This is the mask which refers to all hotkey bindings */ 67 | #define SDL_ALL_HOTKEYS 0xFFFFFFFF 68 | 69 | /* Function prototypes */ 70 | /** 71 | * Enable/Disable UNICODE translation of keyboard input. 72 | * 73 | * This translation has some overhead, so translation defaults off. 74 | * 75 | * @param[in] enable 76 | * If 'enable' is 1, translation is enabled. 77 | * If 'enable' is 0, translation is disabled. 78 | * If 'enable' is -1, the translation state is not changed. 79 | * 80 | * @return It returns the previous state of keyboard translation. 81 | */ 82 | extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable); 83 | 84 | #define SDL_DEFAULT_REPEAT_DELAY 500 85 | #define SDL_DEFAULT_REPEAT_INTERVAL 30 86 | /** 87 | * Enable/Disable keyboard repeat. Keyboard repeat defaults to off. 88 | * 89 | * @param[in] delay 90 | * 'delay' is the initial delay in ms between the time when a key is 91 | * pressed, and keyboard repeat begins. 92 | * 93 | * @param[in] interval 94 | * 'interval' is the time in ms between keyboard repeat events. 95 | * 96 | * If 'delay' is set to 0, keyboard repeat is disabled. 97 | */ 98 | extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval); 99 | extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval); 100 | 101 | /** 102 | * Get a snapshot of the current state of the keyboard. 103 | * Returns an array of keystates, indexed by the SDLK_* syms. 104 | * Usage: 105 | * @code 106 | * Uint8 *keystate = SDL_GetKeyState(NULL); 107 | * if ( keystate[SDLK_RETURN] ) //... \ is pressed. 108 | * @endcode 109 | */ 110 | extern DECLSPEC Uint8 * SDLCALL SDL_GetKeyState(int *numkeys); 111 | 112 | /** 113 | * Get the current key modifier state 114 | */ 115 | extern DECLSPEC SDLMod SDLCALL SDL_GetModState(void); 116 | 117 | /** 118 | * Set the current key modifier state. 119 | * This does not change the keyboard state, only the key modifier flags. 120 | */ 121 | extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate); 122 | 123 | /** 124 | * Get the name of an SDL virtual keysym 125 | */ 126 | extern DECLSPEC char * SDLCALL SDL_GetKeyName(SDLKey key); 127 | 128 | /* Ends C function definitions when using C++ */ 129 | #ifdef __cplusplus 130 | } 131 | #endif 132 | #include "close_code.h" 133 | 134 | #endif /* _SDL_keyboard_h */ 135 | -------------------------------------------------------------------------------- /LIBSDL/include/SDL/SDL_thread.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | #ifndef _SDL_thread_h 24 | #define _SDL_thread_h 25 | 26 | /** @file SDL_thread.h 27 | * Header for the SDL thread management routines 28 | * 29 | * @note These are independent of the other SDL routines. 30 | */ 31 | 32 | #include "SDL_stdinc.h" 33 | #include "SDL_error.h" 34 | 35 | /* Thread synchronization primitives */ 36 | #include "SDL_mutex.h" 37 | 38 | #include "begin_code.h" 39 | /* Set up for C function definitions, even when using C++ */ 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | /** The SDL thread structure, defined in SDL_thread.c */ 45 | struct SDL_Thread; 46 | typedef struct SDL_Thread SDL_Thread; 47 | 48 | /** Create a thread */ 49 | #if ((defined(__WIN32__) && !defined(HAVE_LIBC)) || defined(__OS2__)) && !defined(__SYMBIAN32__) 50 | /** 51 | * We compile SDL into a DLL on OS/2. This means, that it's the DLL which 52 | * creates a new thread for the calling process with the SDL_CreateThread() 53 | * API. There is a problem with this, that only the RTL of the SDL.DLL will 54 | * be initialized for those threads, and not the RTL of the calling application! 55 | * To solve this, we make a little hack here. 56 | * We'll always use the caller's _beginthread() and _endthread() APIs to 57 | * start a new thread. This way, if it's the SDL.DLL which uses this API, 58 | * then the RTL of SDL.DLL will be used to create the new thread, and if it's 59 | * the application, then the RTL of the application will be used. 60 | * So, in short: 61 | * Always use the _beginthread() and _endthread() of the calling runtime library! 62 | */ 63 | #define SDL_PASSED_BEGINTHREAD_ENDTHREAD 64 | #ifndef _WIN32_WCE 65 | #include /* This has _beginthread() and _endthread() defined! */ 66 | #endif 67 | 68 | #ifdef __OS2__ 69 | typedef int (*pfnSDL_CurrentBeginThread)(void (*func)(void *), void *, unsigned, void *arg); 70 | typedef void (*pfnSDL_CurrentEndThread)(void); 71 | #else 72 | typedef uintptr_t (__cdecl *pfnSDL_CurrentBeginThread) (void *, unsigned, 73 | unsigned (__stdcall *func)(void *), void *arg, 74 | unsigned, unsigned *threadID); 75 | typedef void (__cdecl *pfnSDL_CurrentEndThread)(unsigned code); 76 | #endif 77 | 78 | extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (SDLCALL *fn)(void *), void *data, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread); 79 | 80 | #ifdef __OS2__ 81 | #define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthread, _endthread) 82 | #elif defined(_WIN32_WCE) 83 | #define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, NULL, NULL) 84 | #else 85 | #define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthreadex, _endthreadex) 86 | #endif 87 | #else 88 | extern DECLSPEC SDL_Thread * SDLCALL SDL_CreateThread(int (SDLCALL *fn)(void *), void *data); 89 | #endif 90 | 91 | /** Get the 32-bit thread identifier for the current thread */ 92 | extern DECLSPEC Uint32 SDLCALL SDL_ThreadID(void); 93 | 94 | /** Get the 32-bit thread identifier for the specified thread, 95 | * equivalent to SDL_ThreadID() if the specified thread is NULL. 96 | */ 97 | extern DECLSPEC Uint32 SDLCALL SDL_GetThreadID(SDL_Thread *thread); 98 | 99 | /** Wait for a thread to finish. 100 | * The return code for the thread function is placed in the area 101 | * pointed to by 'status', if 'status' is not NULL. 102 | */ 103 | extern DECLSPEC void SDLCALL SDL_WaitThread(SDL_Thread *thread, int *status); 104 | 105 | /** Forcefully kill a thread without worrying about its state */ 106 | extern DECLSPEC void SDLCALL SDL_KillThread(SDL_Thread *thread); 107 | 108 | 109 | /* Ends C function definitions when using C++ */ 110 | #ifdef __cplusplus 111 | } 112 | #endif 113 | #include "close_code.h" 114 | 115 | #endif /* _SDL_thread_h */ 116 | -------------------------------------------------------------------------------- /LIBSDL/src/video/SDL_yuv.c: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | #include "SDL_config.h" 23 | 24 | /* This is the implementation of the YUV video surface support */ 25 | 26 | #include "SDL_video.h" 27 | #include "SDL_sysvideo.h" 28 | #include "SDL_yuvfuncs.h" 29 | #include "SDL_yuv_sw_c.h" 30 | 31 | 32 | SDL_Overlay *SDL_CreateYUVOverlay(int w, int h, Uint32 format, 33 | SDL_Surface *display) 34 | { 35 | SDL_VideoDevice *video = current_video; 36 | SDL_VideoDevice *this = current_video; 37 | const char *yuv_hwaccel; 38 | SDL_Overlay *overlay; 39 | 40 | if ( (display->flags & SDL_OPENGL) == SDL_OPENGL ) { 41 | SDL_SetError("YUV overlays are not supported in OpenGL mode"); 42 | return NULL; 43 | } 44 | 45 | /* Display directly on video surface, if possible */ 46 | if ( SDL_getenv("SDL_VIDEO_YUV_DIRECT") ) { 47 | if ( (display == SDL_PublicSurface) && 48 | ((SDL_VideoSurface->format->BytesPerPixel == 2) || 49 | (SDL_VideoSurface->format->BytesPerPixel == 4)) ) { 50 | display = SDL_VideoSurface; 51 | } 52 | } 53 | overlay = NULL; 54 | yuv_hwaccel = SDL_getenv("SDL_VIDEO_YUV_HWACCEL"); 55 | if ( ((display == SDL_VideoSurface) && video->CreateYUVOverlay) && 56 | (!yuv_hwaccel || (SDL_atoi(yuv_hwaccel) > 0)) ) { 57 | overlay = video->CreateYUVOverlay(this, w, h, format, display); 58 | } 59 | /* If hardware YUV overlay failed ... */ 60 | if ( overlay == NULL ) { 61 | overlay = SDL_CreateYUV_SW(this, w, h, format, display); 62 | } 63 | return overlay; 64 | } 65 | 66 | int SDL_LockYUVOverlay(SDL_Overlay *overlay) 67 | { 68 | if ( overlay == NULL ) { 69 | SDL_SetError("Passed NULL overlay"); 70 | return -1; 71 | } 72 | return overlay->hwfuncs->Lock(current_video, overlay); 73 | } 74 | 75 | void SDL_UnlockYUVOverlay(SDL_Overlay *overlay) 76 | { 77 | if ( overlay == NULL ) { 78 | return; 79 | } 80 | overlay->hwfuncs->Unlock(current_video, overlay); 81 | } 82 | 83 | int SDL_DisplayYUVOverlay(SDL_Overlay *overlay, SDL_Rect *dstrect) 84 | { 85 | SDL_Rect src, dst; 86 | int srcx, srcy, srcw, srch; 87 | int dstx, dsty, dstw, dsth; 88 | 89 | if ( overlay == NULL || dstrect == NULL ) { 90 | SDL_SetError("Passed NULL overlay or dstrect"); 91 | return -1; 92 | } 93 | 94 | /* Clip the rectangle to the screen area */ 95 | srcx = 0; 96 | srcy = 0; 97 | srcw = overlay->w; 98 | srch = overlay->h; 99 | dstx = dstrect->x; 100 | dsty = dstrect->y; 101 | dstw = dstrect->w; 102 | dsth = dstrect->h; 103 | if ( dstx < 0 ) { 104 | srcw += (dstx * overlay->w) / dstrect->w; 105 | dstw += dstx; 106 | srcx -= (dstx * overlay->w) / dstrect->w; 107 | dstx = 0; 108 | } 109 | if ( (dstx+dstw) > current_video->screen->w ) { 110 | int extra = (dstx+dstw - current_video->screen->w); 111 | srcw -= (extra * overlay->w) / dstrect->w; 112 | dstw -= extra; 113 | } 114 | if ( dsty < 0 ) { 115 | srch += (dsty * overlay->h) / dstrect->h; 116 | dsth += dsty; 117 | srcy -= (dsty * overlay->h) / dstrect->h; 118 | dsty = 0; 119 | } 120 | if ( (dsty+dsth) > current_video->screen->h ) { 121 | int extra = (dsty+dsth - current_video->screen->h); 122 | srch -= (extra * overlay->h) / dstrect->h; 123 | dsth -= extra; 124 | } 125 | if ( srcw <= 0 || srch <= 0 || 126 | srch <= 0 || dsth <= 0 ) { 127 | return 0; 128 | } 129 | /* Ugh, I can't wait for SDL_Rect to be int values */ 130 | src.x = srcx; 131 | src.y = srcy; 132 | src.w = srcw; 133 | src.h = srch; 134 | dst.x = dstx; 135 | dst.y = dsty; 136 | dst.w = dstw; 137 | dst.h = dsth; 138 | return overlay->hwfuncs->Display(current_video, overlay, &src, &dst); 139 | } 140 | 141 | void SDL_FreeYUVOverlay(SDL_Overlay *overlay) 142 | { 143 | if ( overlay == NULL ) { 144 | return; 145 | } 146 | if ( overlay->hwfuncs ) { 147 | overlay->hwfuncs->FreeHW(current_video, overlay); 148 | } 149 | SDL_free(overlay); 150 | } 151 | -------------------------------------------------------------------------------- /LIBSDL/src/video/math_private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ==================================================== 3 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 4 | * 5 | * Developed at SunPro, a Sun Microsystems, Inc. business. 6 | * Permission to use, copy, modify, and distribute this 7 | * software is freely granted, provided that this notice 8 | * is preserved. 9 | * ==================================================== 10 | */ 11 | 12 | /* 13 | * from: @(#)fdlibm.h 5.1 93/09/24 14 | * $Id$ 15 | */ 16 | 17 | #ifndef _MATH_PRIVATE_H_ 18 | #define _MATH_PRIVATE_H_ 19 | 20 | #include "SDL_name.h" 21 | #include "SDL_endian.h" 22 | 23 | #define huge really_big /* huge is a reserved keyword in VC++ 6.0 */ 24 | #define u_int32_t uint32_t 25 | 26 | /* The original fdlibm code used statements like: 27 | n0 = ((*(int*)&one)>>29)^1; * index of high word * 28 | ix0 = *(n0+(int*)&x); * high word of x * 29 | ix1 = *((1-n0)+(int*)&x); * low word of x * 30 | to dig two 32 bit words out of the 64 bit IEEE floating point 31 | value. That is non-ANSI, and, moreover, the gcc instruction 32 | scheduler gets it wrong. We instead use the following macros. 33 | Unlike the original code, we determine the endianness at compile 34 | time, not at run time; I don't see much benefit to selecting 35 | endianness at run time. */ 36 | 37 | /* A union which permits us to convert between a double and two 32 bit 38 | ints. */ 39 | 40 | /* 41 | * Math on arm is special: 42 | * For FPA, float words are always big-endian. 43 | * For VFP, floats words follow the memory system mode. 44 | */ 45 | 46 | #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) || \ 47 | (!defined(__VFP_FP__) && (defined(__arm__) || defined(__thumb__))) 48 | 49 | typedef union 50 | { 51 | double value; 52 | struct 53 | { 54 | u_int32_t msw; 55 | u_int32_t lsw; 56 | } parts; 57 | } ieee_double_shape_type; 58 | 59 | #else 60 | 61 | typedef union 62 | { 63 | double value; 64 | struct 65 | { 66 | u_int32_t lsw; 67 | u_int32_t msw; 68 | } parts; 69 | } ieee_double_shape_type; 70 | 71 | #endif 72 | 73 | /* Get two 32 bit ints from a double. */ 74 | 75 | #define EXTRACT_WORDS(ix0,ix1,d) \ 76 | do { \ 77 | ieee_double_shape_type ew_u; \ 78 | ew_u.value = (d); \ 79 | (ix0) = ew_u.parts.msw; \ 80 | (ix1) = ew_u.parts.lsw; \ 81 | } while (0) 82 | 83 | /* Get the more significant 32 bit int from a double. */ 84 | 85 | #define GET_HIGH_WORD(i,d) \ 86 | do { \ 87 | ieee_double_shape_type gh_u; \ 88 | gh_u.value = (d); \ 89 | (i) = gh_u.parts.msw; \ 90 | } while (0) 91 | 92 | /* Get the less significant 32 bit int from a double. */ 93 | 94 | #define GET_LOW_WORD(i,d) \ 95 | do { \ 96 | ieee_double_shape_type gl_u; \ 97 | gl_u.value = (d); \ 98 | (i) = gl_u.parts.lsw; \ 99 | } while (0) 100 | 101 | /* Set a double from two 32 bit ints. */ 102 | 103 | #define INSERT_WORDS(d,ix0,ix1) \ 104 | do { \ 105 | ieee_double_shape_type iw_u; \ 106 | iw_u.parts.msw = (ix0); \ 107 | iw_u.parts.lsw = (ix1); \ 108 | (d) = iw_u.value; \ 109 | } while (0) 110 | 111 | /* Set the more significant 32 bits of a double from an int. */ 112 | 113 | #define SET_HIGH_WORD(d,v) \ 114 | do { \ 115 | ieee_double_shape_type sh_u; \ 116 | sh_u.value = (d); \ 117 | sh_u.parts.msw = (v); \ 118 | (d) = sh_u.value; \ 119 | } while (0) 120 | 121 | /* Set the less significant 32 bits of a double from an int. */ 122 | 123 | #define SET_LOW_WORD(d,v) \ 124 | do { \ 125 | ieee_double_shape_type sl_u; \ 126 | sl_u.value = (d); \ 127 | sl_u.parts.lsw = (v); \ 128 | (d) = sl_u.value; \ 129 | } while (0) 130 | 131 | /* A union which permits us to convert between a float and a 32 bit 132 | int. */ 133 | 134 | typedef union 135 | { 136 | float value; 137 | u_int32_t word; 138 | } ieee_float_shape_type; 139 | 140 | /* Get a 32 bit int from a float. */ 141 | 142 | #define GET_FLOAT_WORD(i,d) \ 143 | do { \ 144 | ieee_float_shape_type gf_u; \ 145 | gf_u.value = (d); \ 146 | (i) = gf_u.word; \ 147 | } while (0) 148 | 149 | /* Set a float from a 32 bit int. */ 150 | 151 | #define SET_FLOAT_WORD(d,i) \ 152 | do { \ 153 | ieee_float_shape_type sf_u; \ 154 | sf_u.word = (i); \ 155 | (d) = sf_u.value; \ 156 | } while (0) 157 | 158 | 159 | #ifdef __STDC__ 160 | static const double 161 | #else 162 | static double 163 | #endif 164 | zero = 0.0, 165 | one = 1.0, 166 | two = 2.0, 167 | two53 = 9007199254740992.0, /* 0x43400000, 0x00000000 */ 168 | two54 = 1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */ 169 | twom54 = 5.55111512312578270212e-17, /* 0x3C900000, 0x00000000 */ 170 | huge = 1.0e+300, 171 | tiny = 1.0e-300; 172 | 173 | #endif /* _MATH_PRIVATE_H_ */ 174 | -------------------------------------------------------------------------------- /src/rfb/threading.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LibVNCServer/LibVNCClient common platform threading defines and includes. 3 | * 4 | * Copyright (C) 2020 Christian Beier 5 | * 6 | * This is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This software is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this software; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 19 | * USA. 20 | */ 21 | 22 | #ifndef _RFB_COMMON_THREADING_H 23 | #define _RFB_COMMON_THREADING_H 24 | 25 | #include 26 | 27 | #ifdef LIBVNCSERVER_HAVE_LIBPTHREAD 28 | #include 29 | #if 0 /* debugging */ 30 | #define LOCK(mutex) (rfbLog("%s:%d LOCK(%s,0x%x)\n",__FILE__,__LINE__,#mutex,&(mutex)), pthread_mutex_lock(&(mutex))) 31 | #define UNLOCK(mutex) (rfbLog("%s:%d UNLOCK(%s,0x%x)\n",__FILE__,__LINE__,#mutex,&(mutex)), pthread_mutex_unlock(&(mutex))) 32 | #define MUTEX(mutex) pthread_mutex_t (mutex) 33 | #define INIT_MUTEX(mutex) (rfbLog("%s:%d INIT_MUTEX(%s,0x%x)\n",__FILE__,__LINE__,#mutex,&(mutex)), pthread_mutex_init(&(mutex),NULL)) 34 | #define TINI_MUTEX(mutex) (rfbLog("%s:%d TINI_MUTEX(%s)\n",__FILE__,__LINE__,#mutex), pthread_mutex_destroy(&(mutex))) 35 | #define TSIGNAL(cond) (rfbLog("%s:%d TSIGNAL(%s)\n",__FILE__,__LINE__,#cond), pthread_cond_signal(&(cond))) 36 | #define WAIT(cond,mutex) (rfbLog("%s:%d WAIT(%s,%s)\n",__FILE__,__LINE__,#cond,#mutex), pthread_cond_wait(&(cond),&(mutex))) 37 | #define COND(cond) pthread_cond_t (cond) 38 | #define INIT_COND(cond) (rfbLog("%s:%d INIT_COND(%s)\n",__FILE__,__LINE__,#cond), pthread_cond_init(&(cond),NULL)) 39 | #define TINI_COND(cond) (rfbLog("%s:%d TINI_COND(%s)\n",__FILE__,__LINE__,#cond), pthread_cond_destroy(&(cond))) 40 | #define IF_PTHREADS(x) x 41 | #else 42 | #if !NONETWORK 43 | #define LOCK(mutex) pthread_mutex_lock(&(mutex)) 44 | #define UNLOCK(mutex) pthread_mutex_unlock(&(mutex)) 45 | #endif 46 | #define MUTEX(mutex) pthread_mutex_t (mutex) 47 | #define MUTEX_SIZE (sizeof(pthread_mutex_t)) 48 | #define INIT_MUTEX(mutex) pthread_mutex_init(&(mutex),NULL) 49 | #define TINI_MUTEX(mutex) pthread_mutex_destroy(&(mutex)) 50 | #define TSIGNAL(cond) pthread_cond_signal(&(cond)) 51 | #define WAIT(cond,mutex) pthread_cond_wait(&(cond),&(mutex)) 52 | #define COND(cond) pthread_cond_t (cond) 53 | #define INIT_COND(cond) pthread_cond_init(&(cond),NULL) 54 | #define TINI_COND(cond) pthread_cond_destroy(&(cond)) 55 | #define IF_PTHREADS(x) x 56 | #define THREAD_ROUTINE_RETURN_TYPE void* 57 | #define THREAD_ROUTINE_RETURN_VALUE NULL 58 | #define THREAD_SLEEP_MS(ms) usleep(ms*1000) 59 | #define THREAD_JOIN(thread) pthread_join(thread, NULL) 60 | #define CURRENT_THREAD_ID pthread_self() 61 | #endif 62 | #elif defined(LIBVNCSERVER_HAVE_WIN32THREADS) 63 | #include 64 | #define LOCK(mutex) EnterCriticalSection(&(mutex)) 65 | #define UNLOCK(mutex) LeaveCriticalSection(&(mutex)) 66 | #define MUTEX(mutex) CRITICAL_SECTION (mutex) 67 | #define MUTEX_SIZE (sizeof(CRITICAL_SECTION)) 68 | #define INIT_MUTEX(mutex) InitializeCriticalSection(&(mutex)) 69 | #define TINI_MUTEX(mutex) DeleteCriticalSection(&(mutex)) 70 | #define TSIGNAL(cond) WakeAllConditionVariable(&(cond)) 71 | #define WAIT(cond,mutex) SleepConditionVariableCS(&(cond),&(mutex),INFINITE); 72 | #define COND(cond) CONDITION_VARIABLE (cond) 73 | #define INIT_COND(cond) InitializeConditionVariable(&(cond)); 74 | #define TINI_COND(cond) 75 | #define IF_PTHREADS(x) 76 | #define THREAD_ROUTINE_RETURN_TYPE void 77 | #define THREAD_ROUTINE_RETURN_VALUE 78 | #define THREAD_SLEEP_MS(ms) Sleep(ms) 79 | #define THREAD_JOIN(thread) WaitForSingleObject((HANDLE)thread, INFINITE) 80 | #define CURRENT_THREAD_ID GetCurrentThreadId() 81 | #else 82 | #define LOCK(mutex) 83 | #define UNLOCK(mutex) 84 | #define MUTEX(mutex) 85 | #define INIT_MUTEX(mutex) 86 | #define TINI_MUTEX(mutex) 87 | #define TSIGNAL(cond) 88 | #define WAIT(cond,mutex) this_is_unsupported 89 | #define COND(cond) 90 | #define INIT_COND(cond) 91 | #define TINI_COND(cond) 92 | #define IF_PTHREADS(x) 93 | #endif 94 | 95 | #endif /* _RFB_COMMON_THREADING_H */ 96 | -------------------------------------------------------------------------------- /LIBSDL/src/video/e_log.h: -------------------------------------------------------------------------------- 1 | /* @(#)e_log.c 5.1 93/09/24 */ 2 | /* 3 | * ==================================================== 4 | * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 5 | * 6 | * Developed at SunPro, a Sun Microsystems, Inc. business. 7 | * Permission to use, copy, modify, and distribute this 8 | * software is freely granted, provided that this notice 9 | * is preserved. 10 | * ==================================================== 11 | */ 12 | 13 | #if defined(LIBM_SCCS) && !defined(lint) 14 | static char rcsid[] = "$NetBSD: e_log.c,v 1.8 1995/05/10 20:45:49 jtc Exp $"; 15 | #endif 16 | 17 | /* __ieee754_log(x) 18 | * Return the logrithm of x 19 | * 20 | * Method : 21 | * 1. Argument Reduction: find k and f such that 22 | * x = 2^k * (1+f), 23 | * where sqrt(2)/2 < 1+f < sqrt(2) . 24 | * 25 | * 2. Approximation of log(1+f). 26 | * Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s) 27 | * = 2s + 2/3 s**3 + 2/5 s**5 + ....., 28 | * = 2s + s*R 29 | * We use a special Reme algorithm on [0,0.1716] to generate 30 | * a polynomial of degree 14 to approximate R The maximum error 31 | * of this polynomial approximation is bounded by 2**-58.45. In 32 | * other words, 33 | * 2 4 6 8 10 12 14 34 | * R(z) ~ Lg1*s +Lg2*s +Lg3*s +Lg4*s +Lg5*s +Lg6*s +Lg7*s 35 | * (the values of Lg1 to Lg7 are listed in the program) 36 | * and 37 | * | 2 14 | -58.45 38 | * | Lg1*s +...+Lg7*s - R(z) | <= 2 39 | * | | 40 | * Note that 2s = f - s*f = f - hfsq + s*hfsq, where hfsq = f*f/2. 41 | * In order to guarantee error in log below 1ulp, we compute log 42 | * by 43 | * log(1+f) = f - s*(f - R) (if f is not too large) 44 | * log(1+f) = f - (hfsq - s*(hfsq+R)). (better accuracy) 45 | * 46 | * 3. Finally, log(x) = k*ln2 + log(1+f). 47 | * = k*ln2_hi+(f-(hfsq-(s*(hfsq+R)+k*ln2_lo))) 48 | * Here ln2 is split into two floating point number: 49 | * ln2_hi + ln2_lo, 50 | * where n*ln2_hi is always exact for |n| < 2000. 51 | * 52 | * Special cases: 53 | * log(x) is NaN with signal if x < 0 (including -INF) ; 54 | * log(+INF) is +INF; log(0) is -INF with signal; 55 | * log(NaN) is that NaN with no signal. 56 | * 57 | * Accuracy: 58 | * according to an error analysis, the error is always less than 59 | * 1 ulp (unit in the last place). 60 | * 61 | * Constants: 62 | * The hexadecimal values are the intended ones for the following 63 | * constants. The decimal values may be used, provided that the 64 | * compiler will convert from decimal to binary accurately enough 65 | * to produce the hexadecimal values shown. 66 | */ 67 | 68 | /*#include "math.h"*/ 69 | #include "math_private.h" 70 | 71 | #ifdef __STDC__ 72 | static const double 73 | #else 74 | static double 75 | #endif 76 | ln2_hi = 6.93147180369123816490e-01, /* 3fe62e42 fee00000 */ 77 | ln2_lo = 1.90821492927058770002e-10, /* 3dea39ef 35793c76 */ 78 | Lg1 = 6.666666666666735130e-01, /* 3FE55555 55555593 */ 79 | Lg2 = 3.999999999940941908e-01, /* 3FD99999 9997FA04 */ 80 | Lg3 = 2.857142874366239149e-01, /* 3FD24924 94229359 */ 81 | Lg4 = 2.222219843214978396e-01, /* 3FCC71C5 1D8E78AF */ 82 | Lg5 = 1.818357216161805012e-01, /* 3FC74664 96CB03DE */ 83 | Lg6 = 1.531383769920937332e-01, /* 3FC39A09 D078C69F */ 84 | Lg7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */ 85 | 86 | #ifdef __STDC__ 87 | double __ieee754_log(double x) 88 | #else 89 | double __ieee754_log(x) 90 | double x; 91 | #endif 92 | { 93 | double hfsq,f,s,z,R,w,t1,t2,dk; 94 | int32_t k,hx,i,j; 95 | u_int32_t lx; 96 | 97 | EXTRACT_WORDS(hx,lx,x); 98 | 99 | k=0; 100 | if (hx < 0x00100000) { /* x < 2**-1022 */ 101 | if (((hx&0x7fffffff)|lx)==0) 102 | return -two54/zero; /* log(+-0)=-inf */ 103 | if (hx<0) return (x-x)/zero; /* log(-#) = NaN */ 104 | k -= 54; x *= two54; /* subnormal number, scale up x */ 105 | GET_HIGH_WORD(hx,x); 106 | } 107 | if (hx >= 0x7ff00000) return x+x; 108 | k += (hx>>20)-1023; 109 | hx &= 0x000fffff; 110 | i = (hx+0x95f64)&0x100000; 111 | SET_HIGH_WORD(x,hx|(i^0x3ff00000)); /* normalize x or x/2 */ 112 | k += (i>>20); 113 | f = x-1.0; 114 | if((0x000fffff&(2+hx))<3) { /* |f| < 2**-20 */ 115 | if(f==zero) {if(k==0) return zero; else {dk=(double)k; 116 | return dk*ln2_hi+dk*ln2_lo;} 117 | } 118 | R = f*f*(0.5-0.33333333333333333*f); 119 | if(k==0) return f-R; else {dk=(double)k; 120 | return dk*ln2_hi-((R-dk*ln2_lo)-f);} 121 | } 122 | s = f/(2.0+f); 123 | dk = (double)k; 124 | z = s*s; 125 | i = hx-0x6147a; 126 | w = z*z; 127 | j = 0x6b851-hx; 128 | t1= w*(Lg2+w*(Lg4+w*Lg6)); 129 | t2= z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7))); 130 | i |= j; 131 | R = t2+t1; 132 | if(i>0) { 133 | hfsq=0.5*f*f; 134 | if(k==0) return f-(hfsq-s*(hfsq+R)); else 135 | return dk*ln2_hi-((hfsq-(s*(hfsq+R)+dk*ln2_lo))-f); 136 | } else { 137 | if(k==0) return f-s*(f-R); else 138 | return dk*ln2_hi-((s*(f-R)-dk*ln2_lo)-f); 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /LIBSDL/include/SDL/SDL_timer.h: -------------------------------------------------------------------------------- 1 | /* 2 | SDL - Simple DirectMedia Layer 3 | Copyright (C) 1997-2012 Sam Lantinga 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Lesser General Public 7 | License as published by the Free Software Foundation; either 8 | version 2.1 of the License, or (at your option) any later version. 9 | 10 | This library is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | Lesser General Public License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public 16 | License along with this library; if not, write to the Free Software 17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | 19 | Sam Lantinga 20 | slouken@libsdl.org 21 | */ 22 | 23 | #ifndef _SDL_timer_h 24 | #define _SDL_timer_h 25 | 26 | /** @file SDL_timer.h 27 | * Header for the SDL time management routines 28 | */ 29 | 30 | #include "SDL_stdinc.h" 31 | #include "SDL_error.h" 32 | 33 | #include "begin_code.h" 34 | /* Set up for C function definitions, even when using C++ */ 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | /** This is the OS scheduler timeslice, in milliseconds */ 40 | #define SDL_TIMESLICE 10 41 | 42 | /** This is the maximum resolution of the SDL timer on all platforms */ 43 | #define TIMER_RESOLUTION 10 /**< Experimentally determined */ 44 | 45 | /** 46 | * Get the number of milliseconds since the SDL library initialization. 47 | * Note that this value wraps if the program runs for more than ~49 days. 48 | */ 49 | extern DECLSPEC Uint32 SDLCALL SDL_GetTicks(void); 50 | 51 | /** Wait a specified number of milliseconds before returning */ 52 | extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms); 53 | 54 | /** Function prototype for the timer callback function */ 55 | typedef Uint32 (SDLCALL *SDL_TimerCallback)(Uint32 interval); 56 | 57 | /** 58 | * Set a callback to run after the specified number of milliseconds has 59 | * elapsed. The callback function is passed the current timer interval 60 | * and returns the next timer interval. If the returned value is the 61 | * same as the one passed in, the periodic alarm continues, otherwise a 62 | * new alarm is scheduled. If the callback returns 0, the periodic alarm 63 | * is cancelled. 64 | * 65 | * To cancel a currently running timer, call SDL_SetTimer(0, NULL); 66 | * 67 | * The timer callback function may run in a different thread than your 68 | * main code, and so shouldn't call any functions from within itself. 69 | * 70 | * The maximum resolution of this timer is 10 ms, which means that if 71 | * you request a 16 ms timer, your callback will run approximately 20 ms 72 | * later on an unloaded system. If you wanted to set a flag signaling 73 | * a frame update at 30 frames per second (every 33 ms), you might set a 74 | * timer for 30 ms: 75 | * @code SDL_SetTimer((33/10)*10, flag_update); @endcode 76 | * 77 | * If you use this function, you need to pass SDL_INIT_TIMER to SDL_Init(). 78 | * 79 | * Under UNIX, you should not use raise or use SIGALRM and this function 80 | * in the same program, as it is implemented using setitimer(). You also 81 | * should not use this function in multi-threaded applications as signals 82 | * to multi-threaded apps have undefined behavior in some implementations. 83 | * 84 | * This function returns 0 if successful, or -1 if there was an error. 85 | */ 86 | extern DECLSPEC int SDLCALL SDL_SetTimer(Uint32 interval, SDL_TimerCallback callback); 87 | 88 | /** @name New timer API 89 | * New timer API, supports multiple timers 90 | * Written by Stephane Peter 91 | */ 92 | /*@{*/ 93 | 94 | /** 95 | * Function prototype for the new timer callback function. 96 | * The callback function is passed the current timer interval and returns 97 | * the next timer interval. If the returned value is the same as the one 98 | * passed in, the periodic alarm continues, otherwise a new alarm is 99 | * scheduled. If the callback returns 0, the periodic alarm is cancelled. 100 | */ 101 | typedef Uint32 (SDLCALL *SDL_NewTimerCallback)(Uint32 interval, void *param); 102 | 103 | /** Definition of the timer ID type */ 104 | typedef struct _SDL_TimerID *SDL_TimerID; 105 | 106 | /** Add a new timer to the pool of timers already running. 107 | * Returns a timer ID, or NULL when an error occurs. 108 | */ 109 | extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval, SDL_NewTimerCallback callback, void *param); 110 | 111 | /** 112 | * Remove one of the multiple timers knowing its ID. 113 | * Returns a boolean value indicating success. 114 | */ 115 | extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID t); 116 | 117 | /*@}*/ 118 | 119 | /* Ends C function definitions when using C++ */ 120 | #ifdef __cplusplus 121 | } 122 | #endif 123 | #include "close_code.h" 124 | 125 | #endif /* _SDL_timer_h */ 126 | -------------------------------------------------------------------------------- /src/rfb/listen.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2012 Christian Beier 3 | * Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved. 4 | * 5 | * This is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This software is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this software; if not, write to the Free Software 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 18 | * USA. 19 | */ 20 | 21 | /* 22 | * listen.c - listen for incoming connections 23 | */ 24 | 25 | #ifdef __STRICT_ANSI__ 26 | #define _BSD_SOURCE 27 | #endif 28 | #if LIBVNCSERVER_HAVE_UNISTD_H 29 | #include 30 | #endif 31 | #include 32 | #ifdef WIN32 33 | #include 34 | #else // #ifdef WIN32 35 | #include 36 | //#include 37 | #endif 38 | #if LIBVNCSERVER_HAVE_SYS_TIME_H 39 | #include 40 | #endif 41 | #include 42 | 43 | /* 44 | * listenForIncomingConnections() - listen for incoming connections from 45 | * servers, and fork a new process to deal with each connection. 46 | */ 47 | 48 | void 49 | listenForIncomingConnections(rfbClient* client) 50 | { 51 | /* FIXME */ 52 | rfbClientErr("listenForIncomingConnections on MinGW32 NOT IMPLEMENTED\n"); 53 | return; 54 | } 55 | 56 | /* 57 | * listenForIncomingConnectionsNoFork() - listen for incoming connections 58 | * from servers, but DON'T fork, instead just wait timeout microseconds. 59 | * If timeout is negative, block indefinitely. 60 | * Returns 1 on success (there was an incoming connection on the listen socket 61 | * and we accepted it successfully), -1 on error, 0 on timeout. 62 | */ 63 | 64 | int 65 | listenForIncomingConnectionsNoFork(rfbClient* client, int timeout) 66 | { 67 | fd_set fds; 68 | struct timeval to; 69 | int r; 70 | 71 | to.tv_sec= timeout / 1000000; 72 | to.tv_usec= timeout % 1000000; 73 | 74 | client->listenSpecified = TRUE; 75 | 76 | if (client->listenSock == RFB_INVALID_SOCKET) 77 | { 78 | client->listenSock = ListenAtTcpPortAndAddress(client->listenPort, client->listenAddress); 79 | 80 | if (client->listenSock == RFB_INVALID_SOCKET) 81 | return -1; 82 | 83 | rfbClientLog("%s -listennofork: Listening on port %d\n", 84 | client->programName,client->listenPort); 85 | rfbClientLog("%s -listennofork: Command line errors are not reported until " 86 | "a connection comes in.\n", client->programName); 87 | } 88 | 89 | #ifdef LIBVNCSERVER_IPv6 /* only try that if we're IPv6-capable, otherwise we may try to bind to the same port which would make all that listening fail */ 90 | /* only do IPv6 listen of listen6Port is set */ 91 | if (client->listen6Port != RFB_INVALID_SOCKET && client->listen6Sock == RFB_INVALID_SOCKET) 92 | { 93 | client->listen6Sock = ListenAtTcpPortAndAddress(client->listen6Port, client->listen6Address); 94 | 95 | if (client->listen6Sock == RFB_INVALID_SOCKET) 96 | return -1; 97 | 98 | rfbClientLog("%s -listennofork: Listening on IPV6 port %d\n", 99 | client->programName,client->listenPort); 100 | rfbClientLog("%s -listennofork: Command line errors are not reported until " 101 | "a connection comes in.\n", client->programName); 102 | } 103 | #endif 104 | 105 | FD_ZERO(&fds); 106 | 107 | if(client->listenSock != RFB_INVALID_SOCKET) 108 | FD_SET(client->listenSock, &fds); 109 | if(client->listen6Sock != RFB_INVALID_SOCKET) 110 | FD_SET(client->listen6Sock, &fds); 111 | 112 | if (timeout < 0) 113 | r = select(rfbMax(client->listenSock, client->listen6Sock) +1, &fds, NULL, NULL, NULL); 114 | else 115 | r = select(rfbMax(client->listenSock, client->listen6Sock) +1, &fds, NULL, NULL, &to); 116 | 117 | if (r > 0) 118 | { 119 | if (FD_ISSET(client->listenSock, &fds)) 120 | client->sock = AcceptTcpConnection(client->listenSock); 121 | else if (FD_ISSET(client->listen6Sock, &fds)) 122 | client->sock = AcceptTcpConnection(client->listen6Sock); 123 | 124 | if (client->sock == RFB_INVALID_SOCKET) 125 | return -1; 126 | if (!SetNonBlocking(client->sock)) 127 | return -1; 128 | 129 | if(client->listenSock != RFB_INVALID_SOCKET) { 130 | rfbCloseSocket(client->listenSock); 131 | client->listenSock = RFB_INVALID_SOCKET; 132 | } 133 | if(client->listen6Sock != RFB_INVALID_SOCKET) { 134 | rfbCloseSocket(client->listen6Sock); 135 | client->listen6Sock = RFB_INVALID_SOCKET; 136 | } 137 | return r; 138 | } 139 | 140 | /* r is now either 0 (timeout) or -1 (error) */ 141 | return r; 142 | } 143 | 144 | 145 | -------------------------------------------------------------------------------- /LIBSDL/src/joystick/n3ds/SDL_sysjoystick.c: -------------------------------------------------------------------------------- 1 | #include "SDL_config.h" 2 | 3 | #include <3ds.h> 4 | 5 | #include "SDL_error.h" 6 | #include "SDL_events.h" 7 | #include "SDL_joystick.h" 8 | #include "../SDL_sysjoystick.h" 9 | #include "../SDL_joystick_c.h" 10 | 11 | #include "../../video/n3ds/SDL_n3dsvideo.h" 12 | 13 | int old_x = 0, old_y = 0; 14 | int old_cs_x = 0, old_cs_y = 0; 15 | u32 key_press, key_release = 0; 16 | int old_dpad_state = 0; 17 | 18 | int SDL_SYS_JoystickInit (void) { 19 | SDL_numjoysticks = 1; 20 | 21 | return 1; 22 | } 23 | 24 | const char *SDL_SYS_JoystickName (int index) { 25 | if(!index) 26 | return "3DS builtin joypad"; 27 | 28 | SDL_SetError ("No joystick available with that index"); 29 | 30 | return (NULL); 31 | } 32 | 33 | int SDL_SYS_JoystickOpen(SDL_Joystick *joystick) { 34 | joystick->nbuttons = 10; 35 | joystick->nhats = 1; 36 | joystick->nballs = 0; 37 | joystick->naxes = 4; 38 | 39 | return 0; 40 | } 41 | 42 | void SDL_SYS_JoystickUpdate (SDL_Joystick *joystick) { 43 | 44 | if (!aptIsActive()) { 45 | // Avoid pumping events if we are not in the foreground. 46 | return; 47 | } 48 | 49 | circlePosition circlePad; 50 | hidCircleRead(&circlePad); 51 | int x,y; 52 | x = circlePad.dx; 53 | y = circlePad.dy; 54 | if (x > 156) x= 156; 55 | if (x < -156) x= -156; 56 | if (y > 156) y= 156; 57 | if (y < -156) y= -156; 58 | if (old_x != x) { 59 | old_x = x; 60 | SDL_PrivateJoystickAxis (joystick, 0, x * 210); 61 | } 62 | if (old_y != y) { 63 | old_y = y; 64 | SDL_PrivateJoystickAxis (joystick, 1, - y * 210); 65 | } 66 | 67 | circlePosition circleStick = {0}; 68 | irrstCstickRead(&circleStick); 69 | x = circleStick.dx; 70 | y = circleStick.dy; 71 | if (x > 156) x= 156; 72 | if (x < -156) x= -156; 73 | if (y > 156) y= 156; 74 | if (y < -156) y= -156; 75 | if (old_cs_x != x) { 76 | old_cs_x = x; 77 | SDL_PrivateJoystickAxis (joystick, 2, x * 210); 78 | } 79 | if (old_cs_y != y) { 80 | old_cs_y = y; 81 | SDL_PrivateJoystickAxis (joystick, 3, - y * 210); 82 | } 83 | 84 | key_press = hidKeysDown (); 85 | int dpad_state = old_dpad_state; 86 | if ((key_press & KEY_A)) { 87 | SDL_PrivateJoystickButton (joystick, 1, SDL_PRESSED); 88 | } 89 | if ((key_press & KEY_B)) { 90 | SDL_PrivateJoystickButton (joystick, 2, SDL_PRESSED); 91 | } 92 | if ((key_press & KEY_X)) { 93 | SDL_PrivateJoystickButton (joystick, 3, SDL_PRESSED); 94 | } 95 | if ((key_press & KEY_Y)) { 96 | SDL_PrivateJoystickButton (joystick, 4, SDL_PRESSED); 97 | } 98 | if ((key_press & KEY_SELECT)) { 99 | SDL_PrivateJoystickButton (joystick, 7, SDL_PRESSED); 100 | } 101 | if ((key_press & KEY_START)) { 102 | SDL_PrivateJoystickButton (joystick, 0, SDL_PRESSED); 103 | } 104 | if ((key_press & KEY_L)) { 105 | SDL_PrivateJoystickButton (joystick, 5, SDL_PRESSED); 106 | } 107 | if ((key_press & KEY_R)) { 108 | SDL_PrivateJoystickButton (joystick, 6, SDL_PRESSED); 109 | } 110 | if ((key_press & KEY_DDOWN)) { 111 | dpad_state |= SDL_HAT_DOWN; 112 | } 113 | if ((key_press & KEY_DLEFT)) { 114 | dpad_state |= SDL_HAT_LEFT; 115 | } 116 | if ((key_press & KEY_DUP)) { 117 | dpad_state |= SDL_HAT_UP; 118 | } 119 | if ((key_press & KEY_DRIGHT)) { 120 | dpad_state |= SDL_HAT_RIGHT; 121 | } 122 | if ((key_press & KEY_ZL)) { 123 | SDL_PrivateJoystickButton (joystick, 8, SDL_PRESSED); 124 | } 125 | if ((key_press & KEY_ZR)) { 126 | SDL_PrivateJoystickButton (joystick, 9, SDL_PRESSED); 127 | } 128 | 129 | key_release = hidKeysUp (); 130 | if ((key_release & KEY_A)) { 131 | SDL_PrivateJoystickButton (joystick, 1, SDL_RELEASED); 132 | } 133 | if ((key_release & KEY_B)) { 134 | SDL_PrivateJoystickButton (joystick, 2, SDL_RELEASED); 135 | } 136 | if ((key_release & KEY_X)) { 137 | SDL_PrivateJoystickButton (joystick, 3, SDL_RELEASED); 138 | } 139 | if ((key_release & KEY_Y)) { 140 | SDL_PrivateJoystickButton (joystick, 4, SDL_RELEASED); 141 | } 142 | if ((key_release & KEY_SELECT)) { 143 | SDL_PrivateJoystickButton (joystick, 7, SDL_RELEASED); 144 | } 145 | if ((key_release & KEY_START)) { 146 | SDL_PrivateJoystickButton (joystick, 0, SDL_RELEASED); 147 | } 148 | if ((key_release & KEY_L)) { 149 | SDL_PrivateJoystickButton (joystick, 5, SDL_RELEASED); 150 | } 151 | if ((key_release & KEY_R)) { 152 | SDL_PrivateJoystickButton (joystick, 6, SDL_RELEASED); 153 | } 154 | if ((key_release & KEY_DDOWN)) { 155 | dpad_state &= ~SDL_HAT_DOWN; 156 | } 157 | if ((key_release & KEY_DLEFT)) { 158 | dpad_state &= ~SDL_HAT_LEFT; 159 | } 160 | if ((key_release & KEY_DUP)) { 161 | dpad_state &= ~SDL_HAT_UP; 162 | } 163 | if ((key_release & KEY_DRIGHT)) { 164 | dpad_state &= ~SDL_HAT_RIGHT; 165 | } 166 | if ((key_release & KEY_ZL)) { 167 | SDL_PrivateJoystickButton (joystick, 8, SDL_RELEASED); 168 | } 169 | if ((key_release & KEY_ZR)) { 170 | SDL_PrivateJoystickButton (joystick, 9, SDL_RELEASED); 171 | } 172 | 173 | if (dpad_state != old_dpad_state) { 174 | old_dpad_state = dpad_state; 175 | SDL_PrivateJoystickHat (joystick, 0, dpad_state); 176 | } 177 | } 178 | 179 | void SDL_SYS_JoystickClose (SDL_Joystick *joystick) { 180 | } 181 | 182 | void SDL_SYS_JoystickQuit (void) { 183 | } 184 | -------------------------------------------------------------------------------- /LIBSDL/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | .SUFFIXES: 3 | #--------------------------------------------------------------------------------- 4 | 5 | ifeq ($(strip $(DEVKITARM)),) 6 | $(error "Please set DEVKITARM in your environment. export DEVKITARM=devkitARM") 7 | endif 8 | 9 | include $(DEVKITARM)/3ds_rules 10 | 11 | #--------------------------------------------------------------------------------- 12 | # TARGET is the name of the output 13 | # BUILD is the directory where object files & intermediate files will be placed 14 | # SOURCES is a list of directories containing source code 15 | # DATA is a list of directories containing data files 16 | # INCLUDES is a list of directories containing header files 17 | #--------------------------------------------------------------------------------- 18 | TARGET := $(shell basename $(CURDIR)) 19 | BUILD := build 20 | SOURCES := $(shell find -L src -type d 2> /dev/null) 21 | DATA := data 22 | INCLUDES := include/SDL $(SOURCES) 23 | 24 | #--------------------------------------------------------------------------------- 25 | # options for code generation 26 | #--------------------------------------------------------------------------------- 27 | ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft 28 | 29 | CFLAGS := -g -Wall -O3 -mword-relocations \ 30 | -fdata-sections -fno-exceptions -ffast-math -std=gnu11 \ 31 | -fomit-frame-pointer -ffunction-sections \ 32 | $(ARCH) 33 | 34 | CFLAGS += $(INCLUDE) -DARM11 -D_3DS -D__3DS__ 35 | CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions 36 | 37 | ASFLAGS := -g $(ARCH) 38 | 39 | #--------------------------------------------------------------------------------- 40 | # list of directories containing libraries, this must be the top level containing 41 | # include and lib 42 | #--------------------------------------------------------------------------------- 43 | LIBDIRS := $(CTRULIB) 44 | 45 | #--------------------------------------------------------------------------------- 46 | # no real need to edit anything past this point unless you need to add additional 47 | # rules for different file extensions 48 | #--------------------------------------------------------------------------------- 49 | ifneq ($(BUILD),$(notdir $(CURDIR))) 50 | #--------------------------------------------------------------------------------- 51 | 52 | export OUTPUT := $(CURDIR)/lib/lib$(TARGET).a 53 | 54 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 55 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) 56 | 57 | export DEPSDIR := $(CURDIR)/$(BUILD) 58 | 59 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 60 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 61 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 62 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) 63 | 64 | #--------------------------------------------------------------------------------- 65 | # use CXX for linking C++ projects, CC for standard C 66 | #--------------------------------------------------------------------------------- 67 | ifeq ($(strip $(CPPFILES)),) 68 | #--------------------------------------------------------------------------------- 69 | export LD := $(CC) 70 | #--------------------------------------------------------------------------------- 71 | else 72 | #--------------------------------------------------------------------------------- 73 | export LD := $(CXX) 74 | #--------------------------------------------------------------------------------- 75 | endif 76 | #--------------------------------------------------------------------------------- 77 | 78 | export OFILES := $(addsuffix .o,$(BINFILES)) \ 79 | $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) 80 | 81 | export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ 82 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 83 | -I$(CURDIR)/$(BUILD) 84 | 85 | .PHONY: $(BUILD) clean all 86 | 87 | #--------------------------------------------------------------------------------- 88 | all: $(BUILD) 89 | 90 | lib: 91 | @[ -d $@ ] || mkdir -p $@ 92 | 93 | $(BUILD): lib 94 | @[ -d $@ ] || mkdir -p $@ 95 | @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 96 | 97 | #--------------------------------------------------------------------------------- 98 | clean: 99 | @echo clean ... 100 | @rm -fr $(BUILD) lib 101 | 102 | #--------------------------------------------------------------------------------- 103 | else 104 | 105 | DEPENDS := $(OFILES:.o=.d) 106 | 107 | #--------------------------------------------------------------------------------- 108 | # main targets 109 | #--------------------------------------------------------------------------------- 110 | $(OUTPUT) : $(OFILES) 111 | 112 | #--------------------------------------------------------------------------------- 113 | %.bin.o : %.bin 114 | #--------------------------------------------------------------------------------- 115 | @echo $(notdir $<) 116 | @$(bin2o) 117 | 118 | 119 | -include $(DEPENDS) 120 | 121 | #--------------------------------------------------------------------------------------- 122 | endif 123 | #--------------------------------------------------------------------------------------- 124 | --------------------------------------------------------------------------------