├── .gitignore ├── LICENSE.txt ├── README.md ├── TUIO2 ├── Doxyfile ├── FlashSender.cpp ├── FlashSender.h ├── LibExport.h ├── OscReceiver.cpp ├── OscReceiver.h ├── OscSender.h ├── TcpReceiver.cpp ├── TcpReceiver.h ├── TcpSender.cpp ├── TcpSender.h ├── TuioBounds.cpp ├── TuioBounds.h ├── TuioClient.cpp ├── TuioClient.h ├── TuioComponent.cpp ├── TuioComponent.h ├── TuioDispatcher.cpp ├── TuioDispatcher.h ├── TuioListener.h ├── TuioManager.cpp ├── TuioManager.h ├── TuioObject.cpp ├── TuioObject.h ├── TuioPoint.cpp ├── TuioPoint.h ├── TuioPointer.cpp ├── TuioPointer.h ├── TuioServer.cpp ├── TuioServer.h ├── TuioSource.h ├── TuioSymbol.cpp ├── TuioSymbol.h ├── TuioTime.cpp ├── TuioTime.h ├── TuioToken.cpp ├── TuioToken.h ├── UdpReceiver.cpp ├── UdpReceiver.h ├── UdpSender.cpp ├── UdpSender.h ├── WebSockSender.cpp └── WebSockSender.h ├── demos ├── English.lproj │ └── InfoPlist.strings ├── Makefile ├── SDLMain.m ├── TUIO.icns ├── TUIO.ico ├── TUIO2_CPP.sln ├── Tuio2Demo.cpp ├── Tuio2Demo.h ├── Tuio2Demo.plist ├── Tuio2Demo.rc ├── Tuio2Demo.vcxproj ├── Tuio2Demo.vcxproj.filters ├── Tuio2Demo.vcxproj.user ├── Tuio2Demo.xcodeproj │ └── project.pbxproj ├── Tuio2Dump.cpp ├── Tuio2Dump.h ├── Tuio2Dump.vcxproj ├── Tuio2Dump.vcxproj.filters ├── Tuio2Simulator.cpp ├── Tuio2Simulator.h ├── Tuio2Simulator.plist ├── Tuio2Simulator.rc ├── Tuio2Simulator.vcxproj ├── Tuio2Simulator.vcxproj.filters ├── Tuio2Simulator.vcxproj.user ├── Tuio2Simulator.xcodeproj │ └── project.pbxproj ├── Tuio2Test.cpp ├── Tuio2Test.h ├── libTUIO2.vcxproj ├── libTUIO2.vcxproj.filters ├── libTUIO2.vcxproj.user └── sdl │ ├── Win32 │ ├── SDL2.dll │ ├── SDL2.lib │ ├── SDL2main.lib │ ├── freeglut.dll │ └── freeglut.lib │ ├── include │ ├── GL │ │ ├── freeglut.h │ │ ├── freeglut_ext.h │ │ ├── freeglut_std.h │ │ └── glut.h │ ├── SDL.h │ ├── SDL_assert.h │ ├── SDL_atomic.h │ ├── SDL_audio.h │ ├── SDL_bits.h │ ├── SDL_blendmode.h │ ├── SDL_clipboard.h │ ├── SDL_config.h │ ├── SDL_cpuinfo.h │ ├── SDL_egl.h │ ├── SDL_endian.h │ ├── SDL_error.h │ ├── SDL_events.h │ ├── SDL_filesystem.h │ ├── SDL_gamecontroller.h │ ├── SDL_gesture.h │ ├── SDL_haptic.h │ ├── SDL_hints.h │ ├── SDL_joystick.h │ ├── SDL_keyboard.h │ ├── SDL_keycode.h │ ├── SDL_loadso.h │ ├── SDL_log.h │ ├── SDL_main.h │ ├── SDL_messagebox.h │ ├── SDL_mouse.h │ ├── SDL_mutex.h │ ├── SDL_name.h │ ├── SDL_opengl.h │ ├── SDL_opengl_glext.h │ ├── SDL_opengles.h │ ├── SDL_opengles2.h │ ├── SDL_opengles2_gl2.h │ ├── SDL_opengles2_gl2ext.h │ ├── SDL_opengles2_gl2platform.h │ ├── SDL_opengles2_khrplatform.h │ ├── SDL_pixels.h │ ├── SDL_platform.h │ ├── SDL_power.h │ ├── SDL_quit.h │ ├── SDL_rect.h │ ├── SDL_render.h │ ├── SDL_revision.h │ ├── SDL_rwops.h │ ├── SDL_scancode.h │ ├── SDL_shape.h │ ├── SDL_stdinc.h │ ├── SDL_surface.h │ ├── SDL_system.h │ ├── SDL_syswm.h │ ├── SDL_test.h │ ├── SDL_test_assert.h │ ├── SDL_test_common.h │ ├── SDL_test_compare.h │ ├── SDL_test_crc32.h │ ├── SDL_test_font.h │ ├── SDL_test_fuzzer.h │ ├── SDL_test_harness.h │ ├── SDL_test_images.h │ ├── SDL_test_log.h │ ├── SDL_test_md5.h │ ├── SDL_test_random.h │ ├── SDL_thread.h │ ├── SDL_timer.h │ ├── SDL_touch.h │ ├── SDL_types.h │ ├── SDL_version.h │ ├── SDL_video.h │ ├── begin_code.h │ └── close_code.h │ └── x64 │ ├── SDL2.dll │ ├── SDL2.lib │ ├── SDL2main.lib │ ├── freeglut.dll │ └── freeglut.lib └── oscpack ├── CHANGES ├── LICENSE ├── README ├── TODO ├── ip ├── IpEndpointName.cpp ├── IpEndpointName.h ├── NetworkingUtils.h ├── PacketListener.h ├── TimerListener.h ├── UdpSocket.h ├── posix │ ├── NetworkingUtils.cpp │ └── UdpSocket.cpp └── win32 │ ├── NetworkingUtils.cpp │ └── UdpSocket.cpp └── osc ├── MessageMappingOscPacketListener.h ├── OscException.h ├── OscHostEndianness.h ├── OscOutboundPacketStream.cpp ├── OscOutboundPacketStream.h ├── OscPacketListener.h ├── OscPrintReceivedElements.cpp ├── OscPrintReceivedElements.h ├── OscReceivedElements.cpp ├── OscReceivedElements.h ├── OscTypes.cpp └── OscTypes.h /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *.mode1v3 3 | 4 | *.pbxuser 5 | 6 | *.perspectivev3 7 | 8 | project.xcworkspace 9 | 10 | *.xcuserdatad 11 | 12 | build 13 | 14 | doc 15 | 16 | *.o 17 | 18 | *.so 19 | 20 | *.a 21 | 22 | *.db 23 | 24 | *.dylib 25 | 26 | Tuio2Dump 27 | 28 | Tuio2Test 29 | 30 | Tuio2Demo 31 | 32 | Tuio2Simulator 33 | 34 | *.sdf 35 | 36 | *.suo 37 | 38 | Debug 39 | 40 | Release 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | TUIO 2.0 C++ Library 2 | ==================== 3 | 4 | TUIO 2.0 is an open framework that defines a common protocol and API for tangible interactive 5 | surfaces. The TUIO protocol allows the encoding and transmission of an abstract description of 6 | interactive surfaces and tangible objects, including their geometries and relations as well as 7 | multi-pointer input. 8 | 9 | http://www.tuio.org/?tuio20 10 | 11 | 12 | Current Implementation 13 | ---------------------- 14 | 15 | - encapsulates the TUIO 2.0 Token, Pointer, Symbol and Bounds components 16 | - provides Server and Client implementations for TUIO 2.0 encoding/decoding 17 | - optional TCP and Flash transport layers in addition to the default UDP transport 18 | - supports the multiplexing of multiple TUIO2 sources 19 | 20 | Alpha Code and API 21 | ------------------ 22 | 23 | This library currently only implements a subset of the TUIO 2.0 specification, 24 | the remaining object geometries and relations will be added subsequently. 25 | The current code also defines a general API for the encapsulation of TUIO components. 26 | This API is already quite usable, but may still contain several partially or badly implemented sections, 27 | which are obviously subject to completion, change and improvements. 28 | 29 | Example Projects 30 | ---------------- 31 | 32 | Apart from the actual cross-platform TUIO 2.0 implementation, this repository also provides several example 33 | projects that serve for the illustration and testing of the overall API functionality. This includes TUIO 2.0 34 | client and server demonstrations with a simple SDL2 GUI as well as some simple console test applications. 35 | These examples should equally work on Linux, Mac OS X and Windows operating systems, the according Makefile 36 | as well as XCode and Visual Studio project files are included. The Windows project already include the 37 | necessary libraries, to build the GUI example on Linux make sure you have the SDL2, OpenGL and GLUT 38 | libraries and headers installed on your system, the latest version 2.0.4 is recommended. On Mac OS X you 39 | need to install the SDL2 Framework to /Library/Frameworks. 40 | 41 | Integration and Testing 42 | ---------------------- 43 | 44 | Developers are encouraged to integrate this TUIO 2.0 library into their projects, 45 | in order to support the development and testing of this common shared code base. 46 | The library is licensed under the LGPL in order to facilitate this collaboration. 47 | 48 | 49 | Feedback and Consultation 50 | -------------------------- 51 | Please use the provided Github infrastructure for the discussion related to the design 52 | and implementation of this library or the TUIO 2.0 specification in general. 53 | Any suggestions for improvements of the API design and code quality are most welcome, 54 | and should be submitted and discussed through pull requests. 55 | 56 | For any other inquiries please get in touch with Martin Kaltebrunner via martin[at]tuio.org, 57 | although you may need to insist to receive a reply on this noisy communication channel. 58 | 59 | -------------------------------------------------------------------------------- /TUIO2/Doxyfile: -------------------------------------------------------------------------------- 1 | # Doxyfile 1.5.6 2 | # Project related configuration options 3 | DOXYFILE_ENCODING = UTF-8 4 | PROJECT_NAME = "TUIO2 C++ Developer API" 5 | # Build related configuration options 6 | EXTRACT_ALL = NO 7 | EXTRACT_PRIVATE = NO 8 | EXTRACT_STATIC = NO 9 | EXTRACT_LOCAL_CLASSES = YES 10 | # configuration options related to the HTML output 11 | GENERATE_HTML = YES 12 | HTML_OUTPUT = ../doc 13 | HTML_FILE_EXTENSION = .html 14 | GENERATE_TREEVIEW = YES 15 | GENERATE_LATEX = NO 16 | -------------------------------------------------------------------------------- /TUIO2/LibExport.h: -------------------------------------------------------------------------------- 1 | /* 2 | TUIO2 C++ Library 3 | Copyright (c) 2005-2017 Martin Kaltenbrunner 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 3.0 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. 17 | */ 18 | 19 | #ifndef INCLUDED_LIBEXPORT_H 20 | #define INCLUDED_LIBEXPORT_H 21 | 22 | #ifdef WIN32 23 | #pragma warning(disable: 4251) // disable annoying template exporting warnings 24 | #pragma warning(disable: 4275) // disable warning caused by not exported OSC classes 25 | 26 | #ifdef LIB_EXPORT 27 | #define LIBDECL __declspec(dllexport) 28 | #else 29 | // #define LIBDECL __declspec(dllimport) 30 | #define LIBDECL 31 | #endif 32 | #else 33 | #define LIBDECL 34 | #endif 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /TUIO2/OscReceiver.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | TUIO2 C++ Library 3 | Copyright (c) 2009-2017 Martin Kaltenbrunner 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 3.0 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. 17 | */ 18 | 19 | #include "OscReceiver.h" 20 | 21 | using namespace TUIO2; 22 | using namespace osc; 23 | 24 | void OscReceiver::ProcessMessage( const ReceivedMessage& msg, const IpEndpointName& remoteEndpoint) { 25 | for (std::list::iterator client=clientList.begin(); client!= clientList.end(); client++) 26 | (*client)->processOSC(msg); 27 | } 28 | 29 | void OscReceiver::ProcessBundle( const ReceivedBundle& b, const IpEndpointName& remoteEndpoint) { 30 | try { 31 | for( ReceivedBundle::const_iterator i = b.ElementsBegin(); i != b.ElementsEnd(); ++i ){ 32 | if( i->IsBundle() ) 33 | ProcessBundle( ReceivedBundle(*i), remoteEndpoint); 34 | else 35 | ProcessMessage( ReceivedMessage(*i), remoteEndpoint); 36 | } 37 | } catch (MalformedBundleException& e) { 38 | std::cerr << "malformed OSC bundle: " << e.what() << std::endl; 39 | } 40 | 41 | } 42 | 43 | void OscReceiver::ProcessPacket( const char *data, int size, const IpEndpointName& remoteEndpoint ) { 44 | try { 45 | ReceivedPacket p( data, size ); 46 | if(p.IsBundle()) ProcessBundle( ReceivedBundle(p), remoteEndpoint); 47 | else ProcessMessage( ReceivedMessage(p), remoteEndpoint); 48 | } catch (MalformedBundleException& e) { 49 | std::cerr << "malformed OSC bundle: " << e.what() << std::endl; 50 | } 51 | } 52 | 53 | bool OscReceiver::isConnected() { 54 | return connected; 55 | } 56 | 57 | void OscReceiver::addTuioClient(TuioClient *client) { 58 | clientList.push_back(client); 59 | } 60 | 61 | -------------------------------------------------------------------------------- /TUIO2/OscReceiver.h: -------------------------------------------------------------------------------- 1 | /* 2 | TUIO2 C++ Library 3 | Copyright (c) 2009-2017 Martin Kaltenbrunner 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 3.0 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. 17 | */ 18 | 19 | #ifndef INCLUDED_OSCRECEIVER_H 20 | #define INCLUDED_OSCRECEIVER_H 21 | 22 | #include "LibExport.h" 23 | #include "TuioClient.h" 24 | 25 | #include "osc/OscReceivedElements.h" 26 | #include "osc/OscHostEndianness.h" 27 | #include "ip/PacketListener.h" 28 | #include "ip/IpEndpointName.h" 29 | 30 | namespace TUIO2 { 31 | 32 | class TuioClient; // Forward declaration 33 | 34 | /** 35 | * The OscReceiver is the base class for the various OSC transport methods such as UDP, TCP ... 36 | * 37 | * @author Martin Kaltenbrunner 38 | * @version 2.0.a0 39 | */ 40 | class LIBDECL OscReceiver: public PacketListener { 41 | 42 | public: 43 | 44 | /** 45 | * The constructor is doing nothing in particular. 46 | */ 47 | OscReceiver() : connected(false) {}; 48 | 49 | /** 50 | * The destructor is doing nothing in particular. 51 | */ 52 | virtual ~OscReceiver() {}; 53 | 54 | /** 55 | * The OscReceiver connects and starts receiving TUIO messages via OSC 56 | * 57 | * @param lock running in the background if set to false (default) 58 | */ 59 | virtual void connect(bool lock=false) = 0; 60 | 61 | /** 62 | * The OscReceiver disconnects and stops receiving TUIO messages via OSC 63 | */ 64 | virtual void disconnect() = 0; 65 | 66 | /** 67 | * Returns true if this OscReceiver is currently connected. 68 | * @return true if this OscReceiver is currently connected 69 | */ 70 | bool isConnected(); 71 | 72 | /** 73 | * Attaches the provided TuioClient to this OscReceiver 74 | * 75 | * @param client a pointer to the TuioClient to attach 76 | */ 77 | void addTuioClient(TuioClient *client); 78 | 79 | /** 80 | * The OSC callback method where the incoming OSC data is received 81 | * 82 | * @param data the received OSC data 83 | * @param size the size of the received OSC data 84 | * @param remoteEndpoint the origin of the received OSC data 85 | */ 86 | void ProcessPacket( const char *data, int size, const IpEndpointName &remoteEndpoint ); 87 | 88 | protected: 89 | void ProcessBundle( const osc::ReceivedBundle& b, const IpEndpointName& remoteEndpoint); 90 | 91 | void ProcessMessage( const osc::ReceivedMessage& message, const IpEndpointName& remoteEndpoint); 92 | 93 | std::list clientList; 94 | bool connected; 95 | }; 96 | }; 97 | #endif /* INCLUDED_OSCRECEIVER_H */ 98 | -------------------------------------------------------------------------------- /TUIO2/OscSender.h: -------------------------------------------------------------------------------- 1 | /* 2 | TUIO2 C++ Library 3 | Copyright (c) 2009-2017 Martin Kaltenbrunner 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 3.0 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. 17 | */ 18 | 19 | #ifndef INCLUDED_OSCSENDER_H 20 | #define INCLUDED_OSCSENDER_H 21 | 22 | #include "LibExport.h" 23 | #include "osc/OscOutboundPacketStream.h" 24 | #include "osc/OscHostEndianness.h" 25 | #include "ip/NetworkingUtils.h" 26 | #include 27 | #include 28 | 29 | namespace TUIO2 { 30 | 31 | /** 32 | * The OscSender class is the base class for the various OSC transport methods such as UDP, TCP ... 33 | * 34 | * @author Martin Kaltenbrunner 35 | * @version 2.0.a0 36 | */ 37 | class LIBDECL OscSender { 38 | 39 | public: 40 | 41 | /** 42 | * The constructor is doing nothing in particular. 43 | */ 44 | OscSender (): local(true) {}; 45 | 46 | /** 47 | * The destructor is doing nothing in particular. 48 | */ 49 | virtual ~OscSender() {} 50 | 51 | /** 52 | * This method delivers the provided OSC data 53 | * 54 | * @param *bundle the OSC stream to deliver 55 | * @return true if the data was delivered successfully 56 | */ 57 | virtual bool sendOscPacket (osc::OutboundPacketStream *bundle) = 0; 58 | 59 | /** 60 | * This method returns the connection state 61 | * 62 | * @return true if the connection is alive 63 | */ 64 | virtual bool isConnected () = 0; 65 | 66 | /** 67 | * This method returns if this OscSender delivers locally 68 | * 69 | * @return true if this OscSender delivers locally 70 | */ 71 | bool isLocal () { return local; }; 72 | 73 | /** 74 | * This method returns the maximum bundle size in bytes 75 | * 76 | * @return the maximum bundle size in bytes 77 | */ 78 | int getBufferSize () { return buffer_size; }; 79 | 80 | virtual const char* tuio_type() = 0; 81 | 82 | protected: 83 | unsigned int buffer_size; 84 | bool local; 85 | }; 86 | } 87 | 88 | 89 | #endif /* INCLUDED_OSCSENDER_H */ 90 | 91 | -------------------------------------------------------------------------------- /TUIO2/TcpReceiver.h: -------------------------------------------------------------------------------- 1 | /* 2 | TUIO2 C++ Library 3 | Copyright (c) 2009-2017 Martin Kaltenbrunner 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 3.0 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. 17 | */ 18 | 19 | #ifndef INCLUDED_TCPRECEIVER_H 20 | #define INCLUDED_TCPRECEIVER_H 21 | 22 | #include "OscReceiver.h" 23 | #define MAX_TCP_SIZE 65536 24 | 25 | #ifdef WIN32 26 | #include 27 | #include 28 | #include 29 | typedef int socklen_t; 30 | #else 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #endif 38 | 39 | namespace TUIO2 { 40 | 41 | /** 42 | * The TcpReceiver provides the OscReceiver functionality for the TCP transport method 43 | * 44 | * @author Martin Kaltenbrunner 45 | * @version 1.1.6 46 | */ 47 | class LIBDECL TcpReceiver: public OscReceiver { 48 | 49 | public: 50 | 51 | /** 52 | * This constructor creates a TcpReceiver instance listening to the provided TCP port 53 | * 54 | * @param port the number of the TCP port to listen to, defaults to 3333 55 | */ 56 | TcpReceiver (int port=3333); 57 | 58 | /** 59 | * This constructor creates a TcpReceiver connected to the provided host and TCP port 60 | * 61 | * @param host the host name to connect 62 | * @param port the number of the TCP port to listen to, defaults to 3333 63 | */ 64 | TcpReceiver (const char *host, int port); 65 | 66 | /** 67 | * The destructor is doing nothing in particular. 68 | */ 69 | virtual ~TcpReceiver(); 70 | 71 | /** 72 | * The TcpReceiver connects and starts receiving TUIO messages via TCP 73 | * 74 | * @param lock running in the background if set to false (default) 75 | */ 76 | void connect(bool lock=false); 77 | 78 | /** 79 | * The TcpReceiver disconnects and stops receiving TUIO messages via TCP 80 | */ 81 | void disconnect(); 82 | 83 | #ifndef WIN32 84 | int tcp_socket; 85 | std::list tcp_client_list; 86 | #else 87 | SOCKET tcp_socket; 88 | std::list tcp_client_list; 89 | #endif 90 | 91 | static const char* tuio_type() { return "TUIO2/TCP"; } 92 | 93 | private: 94 | 95 | #ifndef WIN32 96 | pthread_t server_thread; 97 | #else 98 | HANDLE server_thread; 99 | DWORD ServerThreadId; 100 | #endif 101 | 102 | bool locked; 103 | }; 104 | }; 105 | #endif /* INCLUDED_TcpReceiver_H */ 106 | -------------------------------------------------------------------------------- /TUIO2/TcpSender.h: -------------------------------------------------------------------------------- 1 | /* 2 | TUIO2 C++ Library 3 | Copyright (c) 2009-2017 Martin Kaltenbrunner 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 3.0 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. 17 | */ 18 | 19 | #ifndef INCLUDED_TCPSENDER_H 20 | #define INCLUDED_TCPSENDER_H 21 | 22 | #include "OscSender.h" 23 | 24 | #ifdef WIN32 25 | #include 26 | #include 27 | #include 28 | typedef int socklen_t; 29 | #else 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #endif 37 | 38 | #include 39 | #define MAX_TCP_SIZE 65536 40 | 41 | namespace TUIO2 { 42 | 43 | /** 44 | * The TcpSender implements the TCP transport method for OSC 45 | * 46 | * @author Martin Kaltenbrunner 47 | * @version 2.0.a0 48 | */ 49 | class LIBDECL TcpSender : public OscSender { 50 | 51 | public: 52 | 53 | /** 54 | * The default constructor creates a TcpSender that sends to the default TUIO port 3333 on localhost 55 | */ 56 | TcpSender(); 57 | 58 | /** 59 | * This constructor creates a TcpSender that sends to the provided port on the the given host 60 | * 61 | * @param host the receiving host name 62 | * @param port the outgoing TUIO TCP port number 63 | */ 64 | TcpSender(const char *host, int port); 65 | 66 | /** 67 | * This constructor creates a TcpSender that listens to the provided port 68 | * 69 | * @param port the incoming TUIO TCP port number 70 | */ 71 | TcpSender(int port); 72 | 73 | /** 74 | * The destructor closes the socket. 75 | */ 76 | virtual ~TcpSender(); 77 | 78 | /** 79 | * This method delivers the provided OSC data 80 | * 81 | * @param *bundle the OSC stream to deliver 82 | * @return true if the data was delivered successfully 83 | */ 84 | 85 | bool sendOscPacket (osc::OutboundPacketStream *bundle); 86 | 87 | /** 88 | * This method returns the connection state 89 | * 90 | * @return true if the connection is alive 91 | */ 92 | bool isConnected (); 93 | 94 | /** 95 | * This method is called whenever a new client connects 96 | * 97 | * @param tcp_client the socket handle of the new client 98 | */ 99 | virtual void newClient( int tcp_client ); 100 | 101 | int port_no; 102 | 103 | #ifdef WIN32 104 | SOCKET tcp_socket; 105 | std::list tcp_client_list; 106 | #else 107 | int tcp_socket; 108 | std::list tcp_client_list; 109 | #endif 110 | bool connected; 111 | const char* tuio_type() { return "TUIO2/TCP"; } 112 | 113 | protected: 114 | char data_size[4]; 115 | char data_buffer[MAX_TCP_SIZE+4]; 116 | 117 | 118 | #ifdef WIN32 119 | HANDLE server_thread; 120 | DWORD ServerThreadId; 121 | #else 122 | pthread_t server_thread; 123 | #endif 124 | 125 | }; 126 | } 127 | #endif /* INCLUDED_TCPSENDER_H */ 128 | -------------------------------------------------------------------------------- /TUIO2/TuioBounds.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | TUIO2 C++ Library 3 | Copyright (c) 2009-2017 Martin Kaltenbrunner 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 3.0 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. 17 | */ 18 | 19 | #include "TuioBounds.h" 20 | using namespace TUIO2; 21 | 22 | TuioBounds::TuioBounds (TuioTime ttime, TuioObject *tobj, float xp, float yp, float a, float w, float h, float f):TuioComponent(ttime, tobj, xp, yp,a) { 23 | width = w; 24 | height = h; 25 | area = f; 26 | } 27 | 28 | TuioBounds::TuioBounds (TuioObject *tobj, float xp, float yp, float a, float w, float h, float f):TuioComponent(tobj, xp, yp, a) { 29 | width = w; 30 | height = h; 31 | area = f; 32 | } 33 | 34 | TuioBounds::TuioBounds (TuioBounds *tbnd):TuioComponent(tbnd) { 35 | angle = tbnd->getAngle(); 36 | width = tbnd->getWidth(); 37 | height = tbnd->getHeight(); 38 | area = tbnd->getArea(); 39 | rotation_speed = 0.0f; 40 | rotation_accel = 0.0f; 41 | } 42 | 43 | void TuioBounds::update (TuioTime ttime, float xp, float yp, float a, float w, float h, float f, float xs, float ys, float rs, float ma, float ra) { 44 | TuioComponent::update(ttime,xp,yp,a,xs,ys,rs,ma,ra); 45 | width = w; 46 | height = h; 47 | area = f; 48 | } 49 | 50 | void TuioBounds::update (float xp, float yp, float a, float w, float h, float f, float xs, float ys, float rs, float ma, float ra) { 51 | TuioComponent::update(xp,yp,a,xs,ys,rs,ma,ra); 52 | width = w; 53 | height = h; 54 | area = f; 55 | } 56 | 57 | void TuioBounds::update (TuioTime ttime, float xp, float yp, float a, float w, float h, float f) { 58 | TuioComponent::update(ttime,xp,yp,a); 59 | 60 | width = w; 61 | height = h; 62 | area = f; 63 | } 64 | 65 | void TuioBounds::stop (TuioTime ttime) { 66 | update(ttime,xpos,ypos,angle,width,height,area); 67 | } 68 | 69 | void TuioBounds::update (TuioBounds *tbnd) { 70 | TuioComponent::update(tbnd); 71 | width = tbnd->getWidth(); 72 | height = tbnd->getHeight(); 73 | area = tbnd->getArea(); 74 | } 75 | 76 | float TuioBounds::getWidth() const{ 77 | return width; 78 | } 79 | 80 | float TuioBounds::getHeight() const{ 81 | return height; 82 | } 83 | 84 | int TuioBounds::getScreenWidth(int w) const{ 85 | return (int)(w*width); 86 | } 87 | 88 | int TuioBounds::getScreenHeight(int h) const{ 89 | return (int)(h*height); 90 | } 91 | 92 | float TuioBounds::getArea() const{ 93 | return area; 94 | } 95 | -------------------------------------------------------------------------------- /TUIO2/TuioListener.h: -------------------------------------------------------------------------------- 1 | /* 2 | TUIO2 C++ Library 3 | Copyright (c) 2009-2017 Martin Kaltenbrunner 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 3.0 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. 17 | */ 18 | 19 | #ifndef INCLUDED_TUIOLISTENER_H 20 | #define INCLUDED_TUIOLISTENER_H 21 | 22 | #include "TuioObject.h" 23 | 24 | namespace TUIO2 { 25 | 26 | /** 27 | *

The TuioListener interface provides a simple callback infrastructure which is used by the {@link TuioClient} class 28 | * to dispatch TUIO events to all registered instances of classes that implement the TuioListener interface defined here.

29 | *

Any class that implements the TuioListener interface is required to implement all of the callback methods defined here. 30 | * The {@link TuioClient} makes use of these interface methods in order to dispatch TUIO events to all registered TuioListener implementations.

31 | *

32 | * public class MyTuioListener implements TuioListener
33 | * ...

34 | * MyTuioListener listener = new MyTuioListener();
35 | * TuioClient client = new TuioClient();
36 | * client.addTuioListener(listener);
37 | * client.start();
38 | *

39 | * 40 | * @author Martin Kaltenbrunner 41 | * @version 2.0.a0 42 | */ 43 | class LIBDECL TuioListener { 44 | 45 | public: 46 | /** 47 | * The destructor is doing nothing in particular. 48 | */ 49 | virtual ~TuioListener(){}; 50 | 51 | /** 52 | * This callback method is invoked by the TuioClient when a new TUIO Component is added to the session. 53 | * 54 | * @param tobj the TuioObject reference that encapsulates all related TUIO Components 55 | */ 56 | virtual void tuioAdd(TuioObject *tobj)=0; 57 | 58 | /** 59 | * This callback method is invoked by the TuioClient when an existing TUIO Component is updated during the session. 60 | * 61 | * @param tobj the TuioObject reference that encapsulates all related TUIO Components 62 | */ 63 | virtual void tuioUpdate(TuioObject *tobj)=0; 64 | 65 | /** 66 | * This callback method is invoked by the TuioClient when a TUIO Component is removed from the session. 67 | * 68 | * @param tobj the TuioObject reference that encapsulates all related TUIO Components 69 | */ 70 | virtual void tuioRemove(TuioObject *tobj)=0; 71 | 72 | /** 73 | * This callback method is invoked by the TuioClient to mark the end of a received TUIO message bundle. 74 | * 75 | * @param ftime the TuioTime associated to the current TUIO message bundle 76 | */ 77 | virtual void tuioRefresh(TuioTime ftime)=0; 78 | }; 79 | } 80 | #endif /* INCLUDED_TUIOLISTENER_H */ 81 | -------------------------------------------------------------------------------- /TUIO2/TuioPoint.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | TUIO2 C++ Library 3 | Copyright (c) 2009-2017 Martin Kaltenbrunner 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 3.0 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. 17 | */ 18 | 19 | #include "TuioPoint.h" 20 | 21 | using namespace TUIO2; 22 | 23 | TuioPoint::TuioPoint (float xp, float yp) { 24 | xpos = xp; 25 | ypos = yp; 26 | currentTime = TuioTime::getSystemTime(); 27 | startTime = currentTime; 28 | } 29 | 30 | TuioPoint::TuioPoint (TuioTime ttime, float xp, float yp) { 31 | xpos = xp; 32 | ypos = yp; 33 | currentTime = ttime; 34 | startTime = currentTime; 35 | } 36 | 37 | TuioPoint::TuioPoint (TuioPoint *tpoint) { 38 | xpos = tpoint->getX(); 39 | ypos = tpoint->getY(); 40 | currentTime = TuioTime::getSystemTime(); 41 | startTime = currentTime; 42 | } 43 | 44 | void TuioPoint::update (TuioPoint *tpoint) { 45 | xpos = tpoint->getX(); 46 | ypos = tpoint->getY(); 47 | } 48 | 49 | void TuioPoint::update (float xp, float yp) { 50 | xpos = xp; 51 | ypos = yp; 52 | } 53 | 54 | void TuioPoint::update (TuioTime ttime, float xp, float yp) { 55 | xpos = xp; 56 | ypos = yp; 57 | currentTime = ttime; 58 | } 59 | 60 | 61 | float TuioPoint::getX() const{ 62 | return xpos; 63 | } 64 | 65 | float TuioPoint::getY() const{ 66 | return ypos; 67 | } 68 | 69 | float TuioPoint::getDistance(float xp, float yp) const{ 70 | float dx = xpos-xp; 71 | float dy = ypos-yp; 72 | return sqrtf(dx*dx+dy*dy); 73 | } 74 | 75 | float TuioPoint::getScreenDistance(float xp, float yp, int w, int h) const{ 76 | float dx = w*xpos-w*xp; 77 | float dy = h*ypos-h*yp; 78 | return sqrtf(dx*dx+dy*dy); 79 | } 80 | 81 | float TuioPoint::getDistance(TuioPoint *tpoint) const{ 82 | return getDistance(tpoint->getX(),tpoint->getY()); 83 | } 84 | 85 | 86 | float TuioPoint::getAngle(float xp, float yp) const{ 87 | float side = xpos-xp; 88 | float height = ypos-yp; 89 | float distance = getDistance(xp,yp); 90 | 91 | float angle = (float)(asin(side/distance)+M_PI/2); 92 | if (height<0) angle = 2.0f*(float)M_PI-angle; 93 | 94 | return angle; 95 | } 96 | 97 | float TuioPoint::getAngle(TuioPoint *tpoint) const{ 98 | return getAngle(tpoint->getX(),tpoint->getY()); 99 | } 100 | 101 | float TuioPoint::getAngleDegrees(float xp, float yp) const{ 102 | return ((getAngle(xp,yp)/(float)M_PI)*180.0f); 103 | } 104 | 105 | float TuioPoint::getAngleDegrees(TuioPoint *tpoint) const{ 106 | return ((getAngle(tpoint)/(float)M_PI)*180.0f); 107 | } 108 | 109 | int TuioPoint::getScreenX(int width) const{ 110 | return (int)floor(xpos*width+0.5f); 111 | } 112 | 113 | int TuioPoint::getScreenY(int height) const{ 114 | return (int)floor(ypos*height+0.5f); 115 | } 116 | 117 | TuioTime TuioPoint::getTuioTime() const{ 118 | return currentTime; 119 | } 120 | 121 | TuioTime TuioPoint::getStartTime() const{ 122 | return startTime; 123 | } 124 | 125 | -------------------------------------------------------------------------------- /TUIO2/TuioPointer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | TUIO2 C++ Library 3 | Copyright (c) 2009-2017 Martin Kaltenbrunner 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 3.0 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. 17 | */ 18 | 19 | #include "TuioPointer.h" 20 | 21 | using namespace TUIO2; 22 | 23 | TuioPointer::TuioPointer (TuioTime ttime, TuioObject *tobj, unsigned short ti, unsigned short ui, unsigned int pi, float xp, float yp, float a, float sa, float r, float p):TuioComponent(ttime,tobj,xp,yp,a) { 24 | type_id = ti; 25 | user_id = ui; 26 | pointer_id = pi; 27 | shear = sa; 28 | radius = r; 29 | pressure = p; 30 | } 31 | 32 | TuioPointer::TuioPointer (TuioObject *tobj, unsigned short ti, unsigned short ui, unsigned int pi, float xp, float yp, float a, float sa, float r, float p):TuioComponent(tobj,xp,yp,a) { 33 | type_id = ti; 34 | user_id = ui; 35 | shear = sa; 36 | pointer_id = pi; 37 | radius = r; 38 | pressure = p; 39 | } 40 | 41 | TuioPointer::TuioPointer (TuioObject *tobj, unsigned int pi, float xp, float yp, float a, float sa, float r, float p):TuioComponent(tobj,xp,yp,a) { 42 | type_id = 0; 43 | user_id = 0; 44 | pointer_id = pi; 45 | shear = sa; 46 | radius = r; 47 | pressure = p; 48 | } 49 | 50 | TuioPointer::TuioPointer (TuioPointer *tptr):TuioComponent(tptr) { 51 | pointer_id = tptr->getPointerID(); 52 | type_id = tptr->getTypeID(); 53 | user_id = tptr->getUserID(); 54 | shear = tptr->getShear(); 55 | radius = tptr->getRadius(); 56 | pressure = tptr->getPressure(); 57 | } 58 | 59 | void TuioPointer::update (TuioTime ttime, float xp, float yp, float a, float sa, float r, float p, float xs, float ys, float ps, float ma, float pa) { 60 | TuioComponent::update(ttime,xp,yp,a,xs,ys,0,ma,0); 61 | shear = sa; 62 | radius = r; 63 | pressure = p; 64 | pressure_speed = ps; 65 | pressure_accel = pa; 66 | } 67 | 68 | void TuioPointer::update (float xp, float yp, float a, float sa, float r, float p, float xs, float ys, float ps, float ma, float pa) { 69 | TuioComponent::update(xp,yp,a,xs,ys,0,ma,0); 70 | shear = sa; 71 | radius = r; 72 | pressure = p; 73 | pressure_speed = ps; 74 | pressure_accel = pa; 75 | } 76 | 77 | void TuioPointer::update (TuioTime ttime, float xp, float yp, float a, float sa, float r, float p) { 78 | TuioComponent::update(ttime,xp,yp,a); 79 | shear = sa; 80 | radius = r; 81 | pressure = p; 82 | } 83 | 84 | void TuioPointer::update (TuioPointer *tptr) { 85 | TuioComponent::update(tptr); 86 | shear = tptr->getShear(); 87 | radius = tptr->getRadius(); 88 | pressure = tptr->getPressure(); 89 | } 90 | 91 | unsigned int TuioPointer::getPointerID() const{ 92 | return pointer_id; 93 | }; 94 | 95 | unsigned short TuioPointer::getTypeID() const{ 96 | return type_id; 97 | }; 98 | 99 | unsigned short TuioPointer::getUserID() const{ 100 | return user_id; 101 | }; 102 | 103 | unsigned int TuioPointer::getTypeUserID() const { 104 | int tu_id = user_id << 16 | type_id; 105 | return tu_id; 106 | } 107 | 108 | void TuioPointer::setTypeUserID(unsigned int tu_id) { 109 | user_id = tu_id >> 16; 110 | type_id = tu_id & 0x0000FFFF; 111 | } 112 | 113 | float TuioPointer::getShear() const{ 114 | return shear; 115 | }; 116 | 117 | float TuioPointer::getRadius() const{ 118 | return radius; 119 | }; 120 | 121 | float TuioPointer::getPressure() const{ 122 | return pressure; 123 | }; 124 | 125 | float TuioPointer::getPressureSpeed() const{ 126 | return pressure_speed; 127 | } 128 | 129 | float TuioPointer::getPressureAccel() const{ 130 | return pressure_accel; 131 | } 132 | 133 | -------------------------------------------------------------------------------- /TUIO2/TuioSymbol.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | TUIO2 C++ Library 3 | Copyright (c) 2009-2017 Martin Kaltenbrunner 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 3.0 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. 17 | */ 18 | 19 | #include "TuioSymbol.h" 20 | 21 | using namespace TUIO2; 22 | 23 | TuioSymbol::TuioSymbol (TuioTime ttime, TuioObject *tobj, unsigned short ti, unsigned short ui, unsigned int sym, const char *type, const char *data):TuioComponent(ttime,tobj,0,0,0) { 24 | currentTime = ttime; 25 | startTime = currentTime; 26 | type_id = ti; 27 | user_id = ui; 28 | symbol_id = sym; 29 | symbol_type = std::string(type); 30 | symbol_data = std::string(data); 31 | state = TUIO_ADDED; 32 | } 33 | 34 | TuioSymbol::TuioSymbol (TuioObject *tobj, unsigned short ti, unsigned short ui, unsigned int sym, const char *type, const char *data):TuioComponent(tobj,0,0,0) { 35 | currentTime = TuioTime::getSystemTime(); 36 | startTime = currentTime; 37 | type_id = ti; 38 | user_id = ui; 39 | symbol_id = sym; 40 | symbol_type = std::string(type); 41 | symbol_data = std::string(data); 42 | state = TUIO_ADDED; 43 | } 44 | 45 | TuioSymbol::TuioSymbol (TuioSymbol *tsym):TuioComponent(tsym->getTuioTime(),tsym->getContainingTuioObject(),0,0,0) { 46 | currentTime = TuioTime::getSystemTime(); 47 | startTime = currentTime; 48 | session_id = tsym->getSessionID(); 49 | type_id = tsym->getTypeID(); 50 | user_id = tsym->getUserID(); 51 | symbol_id = tsym->getSymbolID(); 52 | symbol_type = tsym->getSymbolType(); 53 | symbol_data = tsym->getSymbolData(); 54 | state = TUIO_ADDED; 55 | } 56 | 57 | unsigned int TuioSymbol::getSymbolID() const { 58 | return symbol_id; 59 | } 60 | 61 | unsigned short TuioSymbol::getTypeID() const { 62 | return type_id; 63 | } 64 | 65 | unsigned short TuioSymbol::getUserID() const { 66 | return user_id; 67 | } 68 | 69 | unsigned int TuioSymbol::getTypeUserID() const { 70 | int tu_id = user_id << 16 | type_id; 71 | return tu_id; 72 | } 73 | 74 | void TuioSymbol::setTypeUserID(unsigned int tu_id) { 75 | user_id = tu_id >> 16; 76 | type_id = tu_id & 0x0000FFFF; 77 | } 78 | 79 | const char* TuioSymbol::getSymbolType() const { 80 | return symbol_type.c_str(); 81 | } 82 | 83 | const char* TuioSymbol::getSymbolData() const { 84 | return symbol_data.c_str(); 85 | } 86 | 87 | void TuioSymbol::update(TuioTime ttime) { 88 | TuioComponent::update(ttime,0,0); 89 | 90 | } 91 | 92 | -------------------------------------------------------------------------------- /TUIO2/TuioTime.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | TUIO2 C++ Library 3 | Copyright (c) 2009-2017 Martin Kaltenbrunner 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 3.0 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. 17 | */ 18 | 19 | #include "TuioTime.h" 20 | using namespace TUIO2; 21 | 22 | long TuioTime::start_seconds = 0; 23 | long TuioTime::start_micro_seconds = 0; 24 | 25 | TuioTime::TuioTime (long msec) { 26 | seconds = msec/MSEC_SECOND; 27 | micro_seconds = USEC_MILLISECOND*(msec%MSEC_SECOND); 28 | } 29 | 30 | TuioTime::TuioTime (osc::TimeTag timetag) { 31 | osc::uint32 secs = timetag >> 32; 32 | osc::uint32 frac = timetag & 0x00000000FFFFFFFF; 33 | 34 | seconds = secs - JAN_1970; 35 | micro_seconds = frac / NTP_UNITS; 36 | } 37 | 38 | TuioTime::TuioTime (long sec, long usec) { 39 | seconds = sec; 40 | micro_seconds = usec; 41 | } 42 | 43 | TuioTime TuioTime::operator+(long us) { 44 | long sec = seconds + us/USEC_SECOND; 45 | long usec = micro_seconds + us%USEC_SECOND; 46 | return TuioTime(sec,usec); 47 | } 48 | 49 | TuioTime TuioTime::operator+(TuioTime ttime) { 50 | long sec = seconds + ttime.getSeconds(); 51 | long usec = micro_seconds + ttime.getMicroseconds(); 52 | sec += usec/USEC_SECOND; 53 | usec = usec%USEC_SECOND; 54 | return TuioTime(sec,usec); 55 | } 56 | 57 | TuioTime TuioTime::operator-(long us) { 58 | long sec = seconds - us/USEC_SECOND; 59 | long usec = micro_seconds - us%USEC_SECOND; 60 | 61 | if (usec<0) { 62 | usec += USEC_SECOND; 63 | sec--; 64 | } 65 | 66 | return TuioTime(sec,usec); 67 | } 68 | 69 | TuioTime TuioTime::operator-(TuioTime ttime) { 70 | long sec = seconds - ttime.getSeconds(); 71 | long usec = micro_seconds - ttime.getMicroseconds(); 72 | 73 | if (usec<0) { 74 | usec += USEC_SECOND; 75 | sec--; 76 | } 77 | 78 | return TuioTime(sec,usec); 79 | } 80 | 81 | void TuioTime::operator=(TuioTime ttime) { 82 | seconds = ttime.getSeconds(); 83 | micro_seconds = ttime.getMicroseconds(); 84 | } 85 | 86 | bool TuioTime::operator==(TuioTime ttime) { 87 | if ((seconds==(long)ttime.getSeconds()) && (micro_seconds==(long)ttime.getMicroseconds())) return true; 88 | else return false; 89 | } 90 | 91 | bool TuioTime::operator!=(TuioTime ttime) { 92 | if ((seconds!=(long)ttime.getSeconds()) || (micro_seconds!=(long)ttime.getMicroseconds())) return true; 93 | else return false; 94 | } 95 | 96 | void TuioTime::reset() { 97 | seconds = 0; 98 | micro_seconds = 0; 99 | 100 | TuioTime system_time = getSystemTime(); 101 | seconds = system_time.getSeconds(); 102 | micro_seconds = system_time.getMicroseconds(); 103 | } 104 | 105 | long TuioTime::getSeconds() const{ 106 | return seconds; 107 | } 108 | 109 | long TuioTime::getMicroseconds() const{ 110 | return micro_seconds; 111 | } 112 | 113 | long TuioTime::getTotalMilliseconds() const{ 114 | return seconds*MSEC_SECOND+micro_seconds/MSEC_SECOND; 115 | } 116 | 117 | unsigned int TuioTime::getFrameID() const{ 118 | return frame_id; 119 | } 120 | 121 | void TuioTime::setFrameID(unsigned int f_id) { 122 | frame_id = f_id; 123 | } 124 | 125 | /*void TuioTime::initSession() { 126 | TuioTime startTime = TuioTime::getSystemTime(); 127 | start_seconds = startTime.getSeconds(); 128 | start_micro_seconds = startTime.getMicroseconds(); 129 | } 130 | 131 | TuioTime TuioTime::getSessionTime() { 132 | return (getSystemTime() - getStartTime()); 133 | }*/ 134 | 135 | TuioTime TuioTime::getStartTime() { 136 | return TuioTime(start_seconds,start_micro_seconds); 137 | } 138 | 139 | TuioTime TuioTime::getSystemTime() { 140 | #ifdef WIN32 141 | TuioTime systemTime(GetTickCount()); 142 | #else 143 | struct timeval tv; 144 | struct timezone tz; 145 | gettimeofday(&tv,&tz); 146 | TuioTime systemTime(tv.tv_sec,tv.tv_usec); 147 | #endif 148 | return systemTime; 149 | } 150 | 151 | osc::TimeTag TuioTime::getSystemTimeTag() { 152 | 153 | TuioTime systemTime = getSystemTime(); 154 | 155 | osc::uint32 secs = (osc::uint32)systemTime.getSeconds() + JAN_1970; 156 | osc::uint32 frac = systemTime.getMicroseconds() * NTP_UNITS; 157 | 158 | osc::uint64 timetag = (osc::uint64) secs << 32 | frac; 159 | return osc::TimeTag(timetag); 160 | } 161 | -------------------------------------------------------------------------------- /TUIO2/TuioToken.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | TUIO2 C++ Library 3 | Copyright (c) 2009-2017 Martin Kaltenbrunner 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 3.0 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. 17 | */ 18 | 19 | #include "TuioToken.h" 20 | 21 | using namespace TUIO2; 22 | 23 | TuioToken::TuioToken (TuioTime ttime, TuioObject *tobj, unsigned short ti, unsigned short ui, unsigned int sym, float xp, float yp, float a):TuioComponent(ttime, tobj, xp, yp,a) { 24 | type_id = ti; 25 | user_id = ui; 26 | symbol_id = sym; 27 | } 28 | 29 | TuioToken::TuioToken (TuioObject *tobj, unsigned short ti, unsigned short ui, unsigned int sym, float xp, float yp, float a):TuioComponent(tobj, xp, yp, a) { 30 | type_id = ti; 31 | user_id = ui; 32 | symbol_id = sym; 33 | } 34 | 35 | TuioToken::TuioToken (TuioObject *tobj, unsigned int sym, float xp, float yp, float a):TuioComponent(tobj, xp, yp, a) { 36 | type_id = 0; 37 | user_id = 0; 38 | symbol_id = sym; 39 | } 40 | 41 | TuioToken::TuioToken (TuioToken *ttok):TuioComponent(ttok) { 42 | symbol_id = ttok->getSymbolID(); 43 | } 44 | 45 | void TuioToken::stop (TuioTime ttime) { 46 | update(ttime,xpos,ypos,angle); 47 | } 48 | 49 | unsigned int TuioToken::getSymbolID() const{ 50 | return symbol_id; 51 | } 52 | 53 | unsigned short TuioToken::getTypeID() const{ 54 | return type_id; 55 | }; 56 | 57 | unsigned short TuioToken::getUserID() const{ 58 | return user_id; 59 | }; 60 | 61 | unsigned int TuioToken::getTypeUserID() const { 62 | int tu_id = user_id << 16 | type_id; 63 | return tu_id; 64 | } 65 | 66 | void TuioToken::setTypeUserID(unsigned int tu_id) { 67 | user_id = tu_id >> 16; 68 | type_id = tu_id & 0x0000FFFF; 69 | } 70 | -------------------------------------------------------------------------------- /TUIO2/UdpReceiver.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | TUIO2 C++ Library 3 | Copyright (c) 2009-2017 Martin Kaltenbrunner 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 3.0 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. 17 | */ 18 | 19 | #include "UdpReceiver.h" 20 | 21 | using namespace TUIO2; 22 | using namespace osc; 23 | 24 | #ifndef WIN32 25 | static void* ClientThreadFunc( void* obj ) 26 | #else 27 | static DWORD WINAPI ClientThreadFunc( LPVOID obj ) 28 | #endif 29 | { 30 | static_cast(obj)->socket->Run(); 31 | return 0; 32 | }; 33 | 34 | UdpReceiver::UdpReceiver(int port):locked (false) { 35 | try { 36 | socket = new UdpListeningReceiveSocket(IpEndpointName( IpEndpointName::ANY_ADDRESS, port ), this ); 37 | } catch (std::exception &e) { 38 | std::cerr << "could not bind to UDP port " << port << std::endl; 39 | socket = NULL; 40 | } 41 | 42 | if (socket!=NULL) { 43 | if (!socket->IsBound()) { 44 | delete socket; 45 | socket = NULL; 46 | } else std::cout << "listening to " << tuio_type() << " messages on port " << port << std::endl; 47 | } 48 | } 49 | 50 | UdpReceiver::~UdpReceiver() { 51 | delete socket; 52 | } 53 | 54 | void UdpReceiver::connect(bool lk) { 55 | 56 | if (connected) return; 57 | if (socket==NULL) return; 58 | locked = lk; 59 | 60 | if (!locked) { 61 | #ifndef WIN32 62 | pthread_create(&thread , NULL, ClientThreadFunc, this); 63 | #else 64 | DWORD threadId; 65 | thread = CreateThread( 0, 0, ClientThreadFunc, this, 0, &threadId ); 66 | #endif 67 | } else socket->Run(); 68 | 69 | connected = true; 70 | } 71 | 72 | void UdpReceiver::disconnect() { 73 | 74 | if (!connected) return; 75 | if (socket==NULL) { 76 | connected = false; 77 | locked = false; 78 | return; 79 | } 80 | socket->Break(); 81 | 82 | if (!locked) { 83 | #ifdef WIN32 84 | if( thread ) CloseHandle( thread ); 85 | #endif 86 | thread = 0; 87 | } else locked = false; 88 | 89 | connected = false; 90 | } 91 | 92 | 93 | -------------------------------------------------------------------------------- /TUIO2/UdpReceiver.h: -------------------------------------------------------------------------------- 1 | /* 2 | TUIO2 C++ Library 3 | Copyright (c) 2009-2017 Martin Kaltenbrunner 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 3.0 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. 17 | */ 18 | 19 | #ifndef INCLUDED_UDPRECEIVER_H 20 | #define INCLUDED_UDPRECEIVER_H 21 | 22 | #include "OscReceiver.h" 23 | #include "ip/UdpSocket.h" 24 | 25 | namespace TUIO2 { 26 | 27 | /** 28 | * The UdpReceiver provides the OscReceiver functionality for the UDP transport method 29 | * 30 | * @author Martin Kaltenbrunner 31 | * @version 1.1.6 32 | */ 33 | class LIBDECL UdpReceiver: public OscReceiver { 34 | 35 | public: 36 | 37 | /** 38 | * The UDP socket is only public to be accessible from the thread function 39 | */ 40 | UdpListeningReceiveSocket *socket; 41 | 42 | /** 43 | * This constructor creates a UdpReceiver instance listening to the provided UDP port 44 | * 45 | * @param port the number of the UDP port to listen to, defaults to 3333 46 | */ 47 | UdpReceiver (int port=3333); 48 | 49 | /** 50 | * The destructor is doing nothing in particular. 51 | */ 52 | virtual ~UdpReceiver(); 53 | 54 | /** 55 | * The UdpReceiver connects and starts receiving TUIO messages via UDP 56 | * 57 | * @param lock running in the background if set to false (default) 58 | */ 59 | void connect(bool lock=false); 60 | 61 | /** 62 | * The UdpReceiver disconnects and stops receiving TUIO messages via UDP 63 | */ 64 | void disconnect(); 65 | 66 | static const char* tuio_type() { return "TUIO2/UDP"; } 67 | 68 | private: 69 | 70 | #ifndef WIN32 71 | pthread_t thread; 72 | #else 73 | HANDLE thread; 74 | #endif 75 | 76 | bool locked; 77 | }; 78 | }; 79 | #endif /* INCLUDED_UDPRECEIVER_H */ 80 | -------------------------------------------------------------------------------- /TUIO2/UdpSender.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | TUIO2 C++ Library 3 | Copyright (c) 2009-2017 Martin Kaltenbrunner 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 3.0 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. 17 | */ 18 | 19 | #include "UdpSender.h" 20 | 21 | using namespace TUIO2; 22 | 23 | UdpSender::UdpSender() { 24 | try { 25 | local = true; 26 | long unsigned int ip = GetHostByName("localhost"); 27 | socket = new UdpTransmitSocket(IpEndpointName(ip, 3333)); 28 | buffer_size = MAX_UDP_SIZE; 29 | std::cout << tuio_type() << " messages to " << "127.0.0.1@3333" << std::endl; 30 | } catch (std::exception &e) { 31 | std::cout << "could not create UDP socket" << std::endl; 32 | socket = NULL; 33 | throw std::exception(); 34 | } 35 | } 36 | 37 | UdpSender::UdpSender(const char *host, int port) { 38 | try { 39 | if ((strcmp(host,"127.0.0.1")==0) || (strcmp(host,"localhost")==0)) { 40 | local = true; 41 | buffer_size = MAX_UDP_SIZE; 42 | } else { 43 | local = false; 44 | buffer_size = IP_MTU_SIZE; 45 | } 46 | long unsigned int ip = GetHostByName(host); 47 | socket = new UdpTransmitSocket(IpEndpointName(ip, port)); 48 | std::cout << tuio_type() << " messages to " << host << "@" << port << std::endl; 49 | } catch (std::exception &e) { 50 | std::cout << "could not create UDP socket" << std::endl; 51 | socket = NULL; 52 | throw std::exception(); 53 | } 54 | } 55 | 56 | UdpSender::UdpSender(const char *host, int port, int size) { 57 | try { 58 | if ((strcmp(host,"127.0.0.1")==0) || (strcmp(host,"localhost")==0)) { 59 | local = true; 60 | } else local = false; 61 | long unsigned int ip = GetHostByName(host); 62 | socket = new UdpTransmitSocket(IpEndpointName(ip, port)); 63 | if (buffer_size>MAX_UDP_SIZE) buffer_size = MAX_UDP_SIZE; 64 | else if (buffer_sizeSize() > buffer_size ) return false; 85 | if ( bundle->Size() == 0 ) return false; 86 | 87 | socket->Send( bundle->Data(), bundle->Size() ); 88 | return true; 89 | } 90 | -------------------------------------------------------------------------------- /TUIO2/UdpSender.h: -------------------------------------------------------------------------------- 1 | /* 2 | TUIO2 C++ Library 3 | Copyright (c) 2009-2017 Martin Kaltenbrunner 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 3.0 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. 17 | */ 18 | 19 | #ifndef INCLUDED_UDPSENDER_H 20 | #define INCLUDED_UDPSENDER_H 21 | 22 | #include "OscSender.h" 23 | #include "ip/UdpSocket.h" 24 | 25 | #define IP_MTU_SIZE 1500 26 | #define MAX_UDP_SIZE 4096 27 | #define MIN_UDP_SIZE 576 28 | 29 | namespace TUIO2 { 30 | 31 | /** 32 | * The UdpSender implements the UDP transport method for OSC 33 | * 34 | * @author Martin Kaltenbrunner 35 | * @version 1.1.6 36 | */ 37 | class LIBDECL UdpSender : public OscSender { 38 | 39 | public: 40 | 41 | /** 42 | * The default constructor creates a UdpSender that sends to the default UDP port 3333 on localhost 43 | * using the maximum packet size of 65536 bytes for single packets on the loopback device 44 | */ 45 | UdpSender(); 46 | 47 | /** 48 | * This constructor creates a UdpSender that sends to the provided port on the the given host 49 | * using the default MTU size of 1500 bytes to deliver unfragmented UDP packets on a LAN 50 | * 51 | * @param host the receiving host name 52 | * @param port the outgoing UDP port number 53 | */ 54 | 55 | UdpSender(const char *host, int port); 56 | /** 57 | * This constructor creates a UdpSender that sends to the provided port on the the given host 58 | * the UDP packet size can be set to a value between 576 and 65536 bytes 59 | * 60 | * @param host the receiving host name 61 | * @param port the outgoing UDP port number 62 | * @param size the maximum UDP packet size 63 | */ 64 | UdpSender(const char *host, int port, int size); 65 | 66 | /** 67 | * The destructor closes the socket. 68 | */ 69 | virtual ~UdpSender(); 70 | 71 | /** 72 | * This method delivers the provided OSC data 73 | * 74 | * @param *bundle the OSC stream to deliver 75 | * @return true if the data was delivered successfully 76 | */ 77 | 78 | bool sendOscPacket (osc::OutboundPacketStream *bundle); 79 | 80 | /** 81 | * This method returns the connection state 82 | * 83 | * @return true if the connection is alive 84 | */ 85 | bool isConnected (); 86 | 87 | const char* tuio_type() { return "TUIO2/UDP"; } 88 | 89 | private: 90 | UdpTransmitSocket *socket; 91 | }; 92 | } 93 | #endif /* INCLUDED_UDPSENDER_H */ 94 | -------------------------------------------------------------------------------- /TUIO2/WebSockSender.h: -------------------------------------------------------------------------------- 1 | /* 2 | TUIO2 C++ Library 3 | Copyright (c) 2009-2017 Martin Kaltenbrunner 4 | WebSockSender (c) 2015 Florian Echtler 5 | 6 | This library is free software; you can redistribute it and/or 7 | modify it under the terms of the GNU Lesser General Public 8 | License as published by the Free Software Foundation; either 9 | version 3.0 of the License, or (at your option) any later version. 10 | 11 | This library 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 GNU 14 | Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public 17 | License along with this library. 18 | */ 19 | 20 | #ifndef INCLUDED_WEBSOCKSENDER_H 21 | #define INCLUDED_WEBSOCKSENDER_H 22 | 23 | #if defined(_MSC_VER) && _MSC_VER < 1900 24 | #include 25 | #include 26 | #define snprintf c99_snprintf 27 | #define vsnprintf c99_vsnprintf 28 | 29 | __inline int c99_vsnprintf(char *outBuf, size_t size, const char *format, va_list ap) 30 | { 31 | int count = -1; 32 | 33 | if (size != 0) 34 | count = _vsnprintf_s(outBuf, size, _TRUNCATE, format, ap); 35 | if (count == -1) 36 | count = _vscprintf(format, ap); 37 | 38 | return count; 39 | } 40 | 41 | __inline int c99_snprintf(char *outBuf, size_t size, const char *format, ...) 42 | { 43 | int count; 44 | va_list ap; 45 | 46 | va_start(ap, format); 47 | count = c99_vsnprintf(outBuf, size, format, ap); 48 | va_end(ap); 49 | 50 | return count; 51 | } 52 | 53 | #endif 54 | 55 | 56 | /* All of these macros assume use on a 32-bit variable. 57 | Additionally, SWAP assumes we're little-endian. */ 58 | #define SWAP(a) ((((a) >> 24) & 0x000000ff) | (((a) >> 8) & 0x0000ff00) | \ 59 | (((a) << 8) & 0x00ff0000) | (((a) << 24) & 0xff000000)) 60 | #define ROL(a, b) (((a) << (b)) | ((a) >> (32 - (b)))) 61 | #define ROR(a, b) ROL((a), (32 - (b))) 62 | #define SHA1_HASH_SIZE (160/8) 63 | 64 | #include "TcpSender.h" 65 | #include 66 | #include 67 | #include 68 | #include 69 | 70 | namespace TUIO2 { 71 | 72 | /** 73 | * The WebSockSender implements the WebSocket transport method for OSC 74 | * 75 | * @author Florian Echtler 76 | * @version 2.0.a0 77 | */ 78 | class LIBDECL WebSockSender : public TcpSender { 79 | 80 | public: 81 | 82 | /** 83 | * The default constructor creates a WebSockSender that listens to the default HTTP-alt port 8080 on localhost 84 | */ 85 | WebSockSender(); 86 | 87 | /** 88 | * This constructor creates a WebSockSender that listens to the provided port 89 | * 90 | * @param port the listening WebSocket port number 91 | */ 92 | WebSockSender(int port); 93 | 94 | /** 95 | * The destructor closes the socket. 96 | */ 97 | virtual ~WebSockSender() {} 98 | 99 | /** 100 | * This method delivers the provided OSC data 101 | * 102 | * @param *bundle the OSC stream to deliver 103 | * @return true if the data was delivered successfully 104 | */ 105 | bool sendOscPacket (osc::OutboundPacketStream *bundle); 106 | 107 | /** 108 | * This method is called whenever a new client connects 109 | * 110 | * @param tcp_client the socket handle of the new client 111 | */ 112 | void newClient( int tcp_client ); 113 | 114 | const char* tuio_type() { return "TUIO2/WEB"; } 115 | private: 116 | 117 | void sha1( uint8_t digest[SHA1_HASH_SIZE], const uint8_t* inbuf, size_t length ); 118 | std::string base64( uint8_t* buffer, size_t size ); 119 | }; 120 | } 121 | #endif /* INCLUDED_WEBSOCKSENDER_H */ 122 | -------------------------------------------------------------------------------- /demos/English.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | CFBundleName = "SimpleSimulator"; 4 | CFBundleShortVersionString = "SimpleSimulator version 2.0a0"; 5 | CFBundleGetInfoString = "SimpleSimulator version 2.0a0, Copyright 2009-2016 Martin Kaltenbrunner"; 6 | NSHumanReadableCopyright = "Copyright 2009-2016\nMartin Kaltenbrunner\nmartin@tuio.org"; 7 | -------------------------------------------------------------------------------- /demos/Makefile: -------------------------------------------------------------------------------- 1 | PLATFORM=$(shell uname) 2 | ENDIANESS=OSC_HOST_LITTLE_ENDIAN 3 | 4 | LD_FLAGS = -lGL -lGLU -lglut 5 | 6 | SDL_LDFLAGS := $(shell sdl2-config --libs) 7 | SDL_CFLAGS := $(shell sdl2-config --cflags) 8 | 9 | TUIO_DEMO = Tuio2Demo 10 | TUIO_DUMP = Tuio2Dump 11 | TUIO_SIMULATOR = Tuio2Simulator 12 | TUIO_TEST = Tuio2Test 13 | TUIO_STATIC = libTUIO2.a 14 | TUIO_SHARED = libTUIO2.so 15 | 16 | INCLUDES = -I../TUIO2 -I../oscpack 17 | #CFLAGS = -g -Wall -O3 -fPIC $(SDL_CFLAGS) 18 | CFLAGS = -w -O3 -fPIC $(SDL_CFLAGS) 19 | CXXFLAGS = $(CFLAGS) $(INCLUDES) -D$(ENDIANESS) 20 | SHARED_OPTIONS = -shared -Wl,-soname,$(TUIO_SHARED) 21 | 22 | ifeq ($(PLATFORM), Darwin) 23 | CC = gcc 24 | # CXX = g++ -stdlib=libstdc++ 25 | # CFLAGS += -mmacosx-version-min=10.6 -arch i386 -arch x86_64 26 | # CXXFLAGS += -mmacosx-version-min=10.6 -arch i386 -arch x86_64 27 | CXX = g++ -stdlib=libc++ 28 | CFLAGS += -mmacosx-version-min=10.9 -arch x86_64 29 | CXXFLAGS += -mmacosx-version-min=10.9 -arch x86_64 30 | TUIO_SHARED = libTUIO2.dylib 31 | LD_FLAGS = -framework OpenGL -framework GLUT -framework SDL2 -framework Cocoa 32 | SDL_CFLAGS = 33 | SHARED_OPTIONS = -dynamiclib -Wl,-dylib_install_name,$(TUIO_SHARED) 34 | SDL_LDFLAGS = 35 | endif 36 | 37 | DEMO_SOURCES = Tuio2Demo.cpp 38 | DEMO_OBJECTS = Tuio2Demo.o 39 | DUMP_SOURCES = Tuio2Dump.cpp 40 | DUMP_OBJECTS = Tuio2Dump.o 41 | TEST_SOURCES = Tuio2Test.cpp 42 | TEST_OBJECTS = Tuio2Test.o 43 | SIMULATOR_SOURCES = Tuio2Simulator.cpp 44 | SIMULATOR_OBJECTS = Tuio2Simulator.o 45 | 46 | COMMON_TUIO_SOURCES = ../TUIO2/TuioTime.cpp ../TUIO2/TuioPoint.cpp ../TUIO2/TuioObject.cpp ../TUIO2/TuioComponent.cpp ../TUIO2/TuioToken.cpp ../TUIO2/TuioPointer.cpp ../TUIO2/TuioBounds.cpp ../TUIO2/TuioSymbol.cpp ../TUIO2/TuioDispatcher.cpp ../TUIO2/TuioManager.cpp 47 | SERVER_TUIO_SOURCES = ../TUIO2/TuioServer.cpp ../TUIO2/UdpSender.cpp ../TUIO2/TcpSender.cpp ../TUIO2/FlashSender.cpp ../TUIO2/WebSockSender.cpp 48 | CLIENT_TUIO_SOURCES = ../TUIO2/TuioClient.cpp ../TUIO2/OscReceiver.cpp ../TUIO2/UdpReceiver.cpp ../TUIO2/TcpReceiver.cpp 49 | OSC_SOURCES = ../oscpack/osc/OscTypes.cpp ../oscpack/osc/OscOutboundPacketStream.cpp ../oscpack/osc/OscReceivedElements.cpp ../oscpack/osc/OscPrintReceivedElements.cpp ../oscpack/ip/posix/NetworkingUtils.cpp ../oscpack/ip/posix/UdpSocket.cpp 50 | 51 | COMMON_TUIO_OBJECTS = $(COMMON_TUIO_SOURCES:.cpp=.o) 52 | SERVER_TUIO_OBJECTS = $(SERVER_TUIO_SOURCES:.cpp=.o) 53 | CLIENT_TUIO_OBJECTS = $(CLIENT_TUIO_SOURCES:.cpp=.o) 54 | TEST_OBJECTS = $(TEST_SOURCES:.cpp=.o) 55 | OSC_OBJECTS = $(OSC_SOURCES:.cpp=.o) 56 | 57 | all: $(TUIO_DUMP) $(TUIO_DEMO) $(TUIO_SIMULATOR) $(TUIO_TEST) $(TUIO_STATIC) $(TUIO_SHARED) 58 | 59 | %.o: %.cpp 60 | @echo [CXX] $@ 61 | @ $(CXX) $(CXXFLAGS) -o $@ -c $< 62 | %.o: %.m 63 | @echo [CC] $@ 64 | @ $(CC) $(CFLAGS) -o $@ -c $< 65 | 66 | $(TUIO_STATIC): $(COMMON_TUIO_OBJECTS) $(CLIENT_TUIO_OBJECTS) $(SERVER_TUIO_OBJECTS) $(OSC_OBJECTS) 67 | @echo [LD] $(TUIO_STATIC) 68 | @ ar rcs $(TUIO_STATIC) $(COMMON_TUIO_OBJECTS) $(CLIENT_TUIO_OBJECTS) $(SERVER_TUIO_OBJECTS) $(OSC_OBJECTS) 69 | 70 | $(TUIO_SHARED): $(COMMON_TUIO_OBJECTS) $(CLIENT_TUIO_OBJECTS) $(SERVER_TUIO_OBJECTS) $(OSC_OBJECTS) 71 | @echo [LD] $(TUIO_SHARED) 72 | @ $(CXX) $+ -lpthread $(SHARED_OPTIONS) -o $(TUIO_SHARED) 73 | 74 | $(TUIO_DUMP): $(COMMON_TUIO_OBJECTS) $(CLIENT_TUIO_OBJECTS) $(OSC_OBJECTS) $(DUMP_OBJECTS) 75 | @echo [LD] $(TUIO_DUMP) 76 | @ $(CXX) $+ -lpthread -o $(TUIO_DUMP) 77 | 78 | $(TUIO_DEMO): $(COMMON_TUIO_OBJECTS) $(CLIENT_TUIO_OBJECTS) $(OSC_OBJECTS) $(DEMO_OBJECTS) 79 | @echo [LD] $(TUIO_DEMO) 80 | @ $(CXX) $+ -lpthread -o $(TUIO_DEMO) $(LD_FLAGS) $(SDL_LDFLAGS) 81 | 82 | $(TUIO_SIMULATOR): $(COMMON_TUIO_OBJECTS) $(SERVER_TUIO_OBJECTS) $(OSC_OBJECTS) $(SIMULATOR_OBJECTS) 83 | @echo [LD] $(TUIO_SIMULATOR) 84 | @ $(CXX) $+ -lpthread -o $(TUIO_SIMULATOR) $(LD_FLAGS) $(SDL_LDFLAGS) 85 | 86 | $(TUIO_TEST): $(COMMON_TUIO_OBJECTS) $(SERVER_TUIO_OBJECTS) $(OSC_OBJECTS) $(TEST_OBJECTS) 87 | @echo [LD] $(TUIO_TEST) 88 | @$(CXX) $+ -lpthread -o $(TUIO_TEST) $(LD_FLAGS) 89 | 90 | clean: 91 | @echo [CLEAN] $(TUIO_DUMP) $(TUIO_DEMO) $(TUIO_SIMULATOR) $(TUIO_TEST) $(TUIO_STATIC) $(TUIO_SHARED) 92 | @ rm -f $(TUIO_DUMP) $(TUIO_DEMO) $(TUIO_SIMULATOR) $(TUIO_TEST) $(TUIO_STATIC) $(TUIO_SHARED) 93 | @ rm -f $(COMMON_TUIO_OBJECTS) $(CLIENT_TUIO_OBJECTS) $(SERVER_TUIO_OBJECTS) $(TEST_OBJECTS) $(OSC_OBJECTS) $(DUMP_OBJECTS) $(DEMO_OBJECTS) $(SIMULATOR_OBJECTS) 94 | -------------------------------------------------------------------------------- /demos/TUIO.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkalten/TUIO20_CPP/b3fc7998670200091e5768747c3e04ac758084e3/demos/TUIO.icns -------------------------------------------------------------------------------- /demos/TUIO.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkalten/TUIO20_CPP/b3fc7998670200091e5768747c3e04ac758084e3/demos/TUIO.ico -------------------------------------------------------------------------------- /demos/TUIO2_CPP.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 12.00 2 | # Visual Studio Express 2012 for Windows Desktop 3 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libTUIO2", "libTUIO2.vcxproj", "{E1C28E7D-466C-4D0A-AEB1-CFFD0F6F5645}" 4 | EndProject 5 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tuio2Dump", "Tuio2Dump.vcxproj", "{5E2EAE4F-8668-4647-98CA-562358EACC10}" 6 | ProjectSection(ProjectDependencies) = postProject 7 | {E1C28E7D-466C-4D0A-AEB1-CFFD0F6F5645} = {E1C28E7D-466C-4D0A-AEB1-CFFD0F6F5645} 8 | EndProjectSection 9 | EndProject 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tuio2Demo", "Tuio2Demo.vcxproj", "{8737A4B6-C44F-4397-9BB5-432646375E9F}" 11 | ProjectSection(ProjectDependencies) = postProject 12 | {E1C28E7D-466C-4D0A-AEB1-CFFD0F6F5645} = {E1C28E7D-466C-4D0A-AEB1-CFFD0F6F5645} 13 | EndProjectSection 14 | EndProject 15 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tuio2Simulator", "Tuio2Simulator.vcxproj", "{810E065A-EC96-4C3F-8C8B-7EAE285DC797}" 16 | ProjectSection(ProjectDependencies) = postProject 17 | {E1C28E7D-466C-4D0A-AEB1-CFFD0F6F5645} = {E1C28E7D-466C-4D0A-AEB1-CFFD0F6F5645} 18 | EndProjectSection 19 | EndProject 20 | Global 21 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 22 | Debug|Win32 = Debug|Win32 23 | Debug|x64 = Debug|x64 24 | Release|Win32 = Release|Win32 25 | Release|x64 = Release|x64 26 | EndGlobalSection 27 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 28 | {E1C28E7D-466C-4D0A-AEB1-CFFD0F6F5645}.Debug|Win32.ActiveCfg = Debug|Win32 29 | {E1C28E7D-466C-4D0A-AEB1-CFFD0F6F5645}.Debug|Win32.Build.0 = Debug|Win32 30 | {E1C28E7D-466C-4D0A-AEB1-CFFD0F6F5645}.Debug|x64.ActiveCfg = Debug|x64 31 | {E1C28E7D-466C-4D0A-AEB1-CFFD0F6F5645}.Debug|x64.Build.0 = Debug|x64 32 | {E1C28E7D-466C-4D0A-AEB1-CFFD0F6F5645}.Release|Win32.ActiveCfg = Release|Win32 33 | {E1C28E7D-466C-4D0A-AEB1-CFFD0F6F5645}.Release|Win32.Build.0 = Release|Win32 34 | {E1C28E7D-466C-4D0A-AEB1-CFFD0F6F5645}.Release|x64.ActiveCfg = Release|x64 35 | {E1C28E7D-466C-4D0A-AEB1-CFFD0F6F5645}.Release|x64.Build.0 = Release|x64 36 | {5E2EAE4F-8668-4647-98CA-562358EACC10}.Debug|Win32.ActiveCfg = Debug|Win32 37 | {5E2EAE4F-8668-4647-98CA-562358EACC10}.Debug|Win32.Build.0 = Debug|Win32 38 | {5E2EAE4F-8668-4647-98CA-562358EACC10}.Debug|x64.ActiveCfg = Debug|x64 39 | {5E2EAE4F-8668-4647-98CA-562358EACC10}.Debug|x64.Build.0 = Debug|x64 40 | {5E2EAE4F-8668-4647-98CA-562358EACC10}.Release|Win32.ActiveCfg = Release|Win32 41 | {5E2EAE4F-8668-4647-98CA-562358EACC10}.Release|Win32.Build.0 = Release|Win32 42 | {5E2EAE4F-8668-4647-98CA-562358EACC10}.Release|x64.ActiveCfg = Release|x64 43 | {5E2EAE4F-8668-4647-98CA-562358EACC10}.Release|x64.Build.0 = Release|x64 44 | {8737A4B6-C44F-4397-9BB5-432646375E9F}.Debug|Win32.ActiveCfg = Debug|Win32 45 | {8737A4B6-C44F-4397-9BB5-432646375E9F}.Debug|Win32.Build.0 = Debug|Win32 46 | {8737A4B6-C44F-4397-9BB5-432646375E9F}.Debug|x64.ActiveCfg = Debug|x64 47 | {8737A4B6-C44F-4397-9BB5-432646375E9F}.Debug|x64.Build.0 = Debug|x64 48 | {8737A4B6-C44F-4397-9BB5-432646375E9F}.Release|Win32.ActiveCfg = Release|Win32 49 | {8737A4B6-C44F-4397-9BB5-432646375E9F}.Release|Win32.Build.0 = Release|Win32 50 | {8737A4B6-C44F-4397-9BB5-432646375E9F}.Release|x64.ActiveCfg = Release|x64 51 | {8737A4B6-C44F-4397-9BB5-432646375E9F}.Release|x64.Build.0 = Release|x64 52 | {810E065A-EC96-4C3F-8C8B-7EAE285DC797}.Debug|Win32.ActiveCfg = Debug|Win32 53 | {810E065A-EC96-4C3F-8C8B-7EAE285DC797}.Debug|Win32.Build.0 = Debug|Win32 54 | {810E065A-EC96-4C3F-8C8B-7EAE285DC797}.Debug|x64.ActiveCfg = Debug|x64 55 | {810E065A-EC96-4C3F-8C8B-7EAE285DC797}.Debug|x64.Build.0 = Debug|x64 56 | {810E065A-EC96-4C3F-8C8B-7EAE285DC797}.Release|Win32.ActiveCfg = Release|Win32 57 | {810E065A-EC96-4C3F-8C8B-7EAE285DC797}.Release|Win32.Build.0 = Release|Win32 58 | {810E065A-EC96-4C3F-8C8B-7EAE285DC797}.Release|x64.ActiveCfg = Release|x64 59 | {810E065A-EC96-4C3F-8C8B-7EAE285DC797}.Release|x64.Build.0 = Release|x64 60 | EndGlobalSection 61 | GlobalSection(SolutionProperties) = preSolution 62 | HideSolutionNode = FALSE 63 | EndGlobalSection 64 | EndGlobal 65 | -------------------------------------------------------------------------------- /demos/Tuio2Demo.h: -------------------------------------------------------------------------------- 1 | /* 2 | TUIO2 C++ GUI Demo 3 | Copyright (c) 2009-2017 Martin Kaltenbrunner 4 | 5 | This program 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 program 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 program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef INCLUDED_TUIO2DEMO_H 21 | #define INCLUDED_TUIO2DEMO_H 22 | 23 | #include "TuioListener.h" 24 | #include "TuioClient.h" 25 | #include "UdpReceiver.h" 26 | #include "TcpReceiver.h" 27 | #include 28 | #include 29 | 30 | #ifdef __APPLE__ 31 | #include 32 | #include 33 | #include 34 | #include 35 | #else 36 | #include "SDL.h" 37 | #include 38 | #include 39 | #include 40 | #endif 41 | 42 | using namespace TUIO2; 43 | 44 | class Tuio2Demo : public TuioListener { 45 | 46 | public: 47 | Tuio2Demo(int port); 48 | ~Tuio2Demo() { 49 | tuioClient->disconnect(); 50 | delete tuioClient; 51 | delete osc_receiver; 52 | } 53 | 54 | void tuioAdd(TuioObject *tobj); 55 | void tuioUpdate(TuioObject *tobj); 56 | void tuioRemove(TuioObject *tobj); 57 | void tuioRefresh(TuioTime frameTime); 58 | 59 | void run(); 60 | 61 | private: 62 | void drawObjects(); 63 | void drawString(char *str); 64 | void processEvents(); 65 | void initWindow(); 66 | 67 | SDL_Window *window; 68 | SDL_Renderer *renderer; 69 | bool verbose, fullscreen, running; 70 | 71 | int width, height; 72 | int screen_width, screen_height; 73 | int window_width, window_height; 74 | 75 | TuioClient *tuioClient; 76 | OscReceiver *osc_receiver; 77 | }; 78 | 79 | #endif /* INCLUDED_Tuio2Demo_H */ 80 | -------------------------------------------------------------------------------- /demos/Tuio2Demo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | Tuio2Demo 9 | CFBundleIconFile 10 | TUIO 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | TuioDemo 15 | CFBundlePackageType 16 | APPL 17 | CFBundleSignature 18 | TUIO 19 | CFBundleVersion 20 | 2.0.a0 21 | Minimum system version 22 | 10.6 23 | NSMainNibFile 24 | SDLMain 25 | NSPrincipalClass 26 | NSApplication 27 | 28 | 29 | -------------------------------------------------------------------------------- /demos/Tuio2Demo.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | //#include "resource.h" 4 | 5 | #define APSTUDIO_READONLY_SYMBOLS 6 | ///////////////////////////////////////////////////////////////////////////// 7 | // 8 | // Generated from the TEXTINCLUDE 2 resource. 9 | // 10 | #include "windows.h" 11 | 12 | ///////////////////////////////////////////////////////////////////////////// 13 | #undef APSTUDIO_READONLY_SYMBOLS 14 | 15 | ///////////////////////////////////////////////////////////////////////////// 16 | // English (U.S.) resources 17 | 18 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 19 | #ifdef _WIN32 20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 21 | #pragma code_page(1252) 22 | 23 | 24 | ///////////////////////////////////////////////////////////////////////////// 25 | // 26 | // Version 27 | // 28 | 29 | VS_VERSION_INFO VERSIONINFO 30 | PRODUCTVERSION 1,9,9 31 | FILEVERSION 1,9,9,0 32 | FILETYPE 0x1L 33 | FILESUBTYPE 0x0L 34 | BEGIN 35 | BLOCK "StringFileInfo" 36 | BEGIN 37 | BLOCK "040904b0" 38 | BEGIN 39 | VALUE "Comments", "\0" 40 | VALUE "CompanyName", "TUIO.org\0" 41 | VALUE "FileDescription", "Tangible Interaction Framework\0" 42 | VALUE "FileVersion", "1, 9, 9, 0\0" 43 | VALUE "InternalName", "Tuio2Demo.exe\0" 44 | VALUE "LegalCopyright", "2016 Martin Kaltenbrunner.\0" 45 | VALUE "LegalTrademarks", "\0" 46 | VALUE "OriginalFilename", "Tuio2Demo.exe\0" 47 | VALUE "ProductName", "TuioDemo\0" 48 | VALUE "ProductVersion", "1, 9, 9\0" 49 | VALUE "SpecialBuild", "Release\0" 50 | END 51 | END 52 | BLOCK "VarFileInfo" 53 | BEGIN 54 | VALUE "Translation", 0x409, 1200 55 | END 56 | END 57 | 58 | #endif //_WIN32 59 | 60 | ///////////////////////////////////////////////////////////////////////////// 61 | // 62 | // Icon 63 | // 64 | 65 | // Icon with lowest ID value placed first to ensure application icon 66 | // remains consistent on all systems. 67 | IDI_ICON1 ICON "TUIO.ico" 68 | #endif // English (U.S.) resources 69 | ///////////////////////////////////////////////////////////////////////////// 70 | 71 | 72 | -------------------------------------------------------------------------------- /demos/Tuio2Demo.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | Header Files 19 | 20 | 21 | 22 | 23 | Source Files 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /demos/Tuio2Demo.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | PATH=%PATH%;$(SolutionDir)sdl\$(Platform)\; $(LocalDebuggerEnvironment) 5 | WindowsLocalDebugger 6 | 7 | 8 | PATH=%PATH%;$(SolutionDir)sdl\$(Platform)\; $(LocalDebuggerEnvironment) 9 | WindowsLocalDebugger 10 | 11 | 12 | PATH=%PATH%;$(SolutionDir)sdl\$(Platform)\; $(LocalDebuggerEnvironment) 13 | WindowsLocalDebugger 14 | 15 | 16 | PATH=%PATH%;$(SolutionDir)sdl\$(Platform)\; $(LocalDebuggerEnvironment) 17 | WindowsLocalDebugger 18 | 19 | -------------------------------------------------------------------------------- /demos/Tuio2Dump.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | TUIO2 C++ Example - part of the reacTIVision project 3 | Copyright (c) 2009-2017 Martin Kaltenbrunner 4 | 5 | This program 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 program 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 program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include "Tuio2Dump.h" 21 | 22 | void Tuio2Dump::tuioAdd(TuioObject *tobj) { 23 | 24 | if(tobj->containsNewTuioToken()) std::cout << "add tok " << tobj->getTuioToken()->getSessionID() << std::endl; 25 | if(tobj->containsNewTuioPointer()) std::cout << "add ptr " << tobj->getTuioPointer()->getSessionID() << std::endl; 26 | if(tobj->containsNewTuioBounds()) std::cout << "add bnd " << tobj->getTuioBounds()->getSessionID() << std::endl; 27 | if(tobj->containsNewTuioSymbol()) std::cout << "add sym " << tobj->getTuioSymbol()->getSessionID() << std::endl; 28 | //std::cout << "add obj " << tobj->getSymbolID() << " (" << tobj->getSessionID() << "/"<< tobj->getTuioSourceID() << ") "<< tobj->getX() << " " << tobj->getY() << " " << tobj->getAngle() << std::endl; 29 | std::cout << std::flush; 30 | } 31 | 32 | void Tuio2Dump::tuioUpdate(TuioObject *tobj) { 33 | if(tobj->containsTuioToken()) std::cout << "set tok " << tobj->getTuioToken()->getSessionID() << std::endl; 34 | if(tobj->containsTuioPointer()) std::cout << "set ptr " << tobj->getTuioPointer()->getSessionID() << std::endl; 35 | if(tobj->containsTuioBounds()) std::cout << "set bnd " << tobj->getTuioBounds()->getSessionID() << std::endl; 36 | if(tobj->containsTuioSymbol()) std::cout << "set sym " << tobj->getTuioSymbol()->getSessionID() << std::endl; 37 | //std::cout << "set obj " << tobj->getSymbolID() << " (" << tobj->getSessionID() << "/"<< tobj->getTuioSourceID() << ") "<< tobj->getX() << " " << tobj->getY() << " " << tobj->getAngle() << " " << tobj->getMotionSpeed() << " " << tobj->getRotationSpeed() << " " << tobj->getMotionAccel() << " " << tobj->getRotationAccel() << std::endl; 38 | std::cout << std::flush; 39 | } 40 | 41 | void Tuio2Dump::tuioRemove(TuioObject *tobj) { 42 | if(tobj->containsTuioToken()) std::cout << "del tok " << tobj->getSessionID() << std::endl; 43 | if(tobj->containsTuioPointer()) std::cout << "del ptr " << tobj->getSessionID() << std::endl; 44 | if(tobj->containsTuioBounds()) std::cout << "del bnd " << tobj->getSessionID() << std::endl; 45 | if(tobj->containsTuioSymbol()) std::cout << "del sym " << tobj->getSessionID() << std::endl; 46 | //std::cout << "del obj " << tobj->getSymbolID() << " (" << tobj->getSessionID() << "/"<< tobj->getTuioSourceID() << ")" << std::endl; 47 | std::cout << std::flush; 48 | } 49 | 50 | void Tuio2Dump::tuioRefresh(TuioTime frameTime) { 51 | std::cout << "refresh " << frameTime.getFrameID() << " "<< frameTime.getTotalMilliseconds() << std::endl; 52 | std::cout << std::flush; 53 | } 54 | 55 | int main(int argc, char* argv[]) 56 | { 57 | if( argc >= 2 && strcmp( argv[1], "-h" ) == 0 ){ 58 | std::cout << "usage: TuioDump [port]\n"; 59 | return 0; 60 | } 61 | 62 | int port = 3333; 63 | if( argc == 2 ) port = atoi( argv[1] ); 64 | else if( argc == 3 ) port = atoi( argv[2] ); 65 | 66 | Tuio2Dump dump; 67 | OscReceiver *receiver; 68 | receiver = new UdpReceiver(port); 69 | //if (argc<3) receiver = new TcpReceiver(port); 70 | //else if (argc==3) receiver = new TcpReceiver(argv[1], port); 71 | // receiver = new DevReceiver(0); 72 | TuioClient client(receiver); 73 | client.addTuioListener(&dump); 74 | client.connect(true); 75 | 76 | delete receiver; 77 | return 0; 78 | } 79 | 80 | 81 | -------------------------------------------------------------------------------- /demos/Tuio2Dump.h: -------------------------------------------------------------------------------- 1 | /* 2 | TUIO2 C++ Example - part of the reacTIVision project 3 | Copyright (c) 2009-2017 Martin Kaltenbrunner 4 | 5 | This program 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 program 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 program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef INCLUDED_TUIO2DUMP_H 21 | #define INCLUDED_TUIO2DUMP_H 22 | 23 | #include "TuioListener.h" 24 | #include "TuioClient.h" 25 | #include "UdpReceiver.h" 26 | #include "TcpReceiver.h" 27 | #include 28 | 29 | using namespace TUIO2; 30 | 31 | class Tuio2Dump : public TuioListener { 32 | 33 | public: 34 | void tuioAdd(TuioObject *tobj); 35 | void tuioUpdate(TuioObject *tobj); 36 | void tuioRemove(TuioObject *tobj); 37 | void tuioRefresh(TuioTime frameTime); 38 | }; 39 | 40 | #endif /* INCLUDED_TUIO2DUMP_H */ 41 | -------------------------------------------------------------------------------- /demos/Tuio2Dump.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | 14 | 15 | Header Files 16 | 17 | 18 | 19 | 20 | Source Files 21 | 22 | 23 | -------------------------------------------------------------------------------- /demos/Tuio2Simulator.h: -------------------------------------------------------------------------------- 1 | /* 2 | TUIO2 C++ Server Demo 3 | Copyright (c) 2009-2017 Martin Kaltenbrunner 4 | 5 | This program 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 program 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 program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef INCLUDED_TUIO2SIMULATOR_H 21 | #define INCLUDED_TUIO2SIMULATOR_H 22 | 23 | #include "TuioServer.h" 24 | #include "TuioPointer.h" 25 | #include "osc/OscTypes.h" 26 | #include 27 | #include 28 | 29 | #include "WebSockSender.h" 30 | #include "FlashSender.h" 31 | #include "TcpSender.h" 32 | 33 | #ifdef __APPLE__ 34 | #include 35 | #include 36 | #include 37 | #include 38 | #else 39 | #include "SDL.h" 40 | #include 41 | #include 42 | #include 43 | #endif 44 | 45 | using namespace TUIO2; 46 | 47 | class Tuio2Simulator { 48 | 49 | public: 50 | Tuio2Simulator(TuioServer *server); 51 | ~Tuio2Simulator() {}; 52 | 53 | void run(); 54 | TuioServer *tuioServer; 55 | std::list stickyPointerList; 56 | std::list jointPointerList; 57 | std::list activePointerList; 58 | 59 | private: 60 | void drawFrame(); 61 | void drawString(const char *str); 62 | void processEvents(); 63 | void initWindow(); 64 | 65 | SDL_Window *window; 66 | SDL_Renderer *renderer; 67 | bool verbose, fullupdate, periodic, fullscreen, running, help; 68 | 69 | int width, height; 70 | int screen_width, screen_height; 71 | int window_width, window_height; 72 | TuioTime frameTime; 73 | 74 | void mousePressed(float x, float y); 75 | void mouseReleased(float x, float y); 76 | void mouseDragged(float x, float y); 77 | //int s_id; 78 | }; 79 | 80 | #endif /* INCLUDED_TUIO2SIMULATOR_H */ 81 | -------------------------------------------------------------------------------- /demos/Tuio2Simulator.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | Tuio2Simulator 9 | CFBundleIconFile 10 | TUIO 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | SimpleSimulator 15 | CFBundlePackageType 16 | APPL 17 | CFBundleSignature 18 | TUIO 19 | CFBundleVersion 20 | 2.0.a0 21 | Minimum system version 22 | 10.6 23 | NSMainNibFile 24 | SDLMain 25 | NSPrincipalClass 26 | NSApplication 27 | 28 | 29 | -------------------------------------------------------------------------------- /demos/Tuio2Simulator.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | //#include "resource.h" 4 | 5 | #define APSTUDIO_READONLY_SYMBOLS 6 | ///////////////////////////////////////////////////////////////////////////// 7 | // 8 | // Generated from the TEXTINCLUDE 2 resource. 9 | // 10 | #include "windows.h" 11 | 12 | ///////////////////////////////////////////////////////////////////////////// 13 | #undef APSTUDIO_READONLY_SYMBOLS 14 | 15 | ///////////////////////////////////////////////////////////////////////////// 16 | // English (U.S.) resources 17 | 18 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 19 | #ifdef _WIN32 20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 21 | #pragma code_page(1252) 22 | 23 | 24 | ///////////////////////////////////////////////////////////////////////////// 25 | // 26 | // Version 27 | // 28 | 29 | VS_VERSION_INFO VERSIONINFO 30 | PRODUCTVERSION 1,9,9 31 | FILEVERSION 1,9,9,0 32 | FILETYPE 0x1L 33 | FILESUBTYPE 0x0L 34 | BEGIN 35 | BLOCK "StringFileInfo" 36 | BEGIN 37 | BLOCK "040904b0" 38 | BEGIN 39 | VALUE "Comments", "\0" 40 | VALUE "CompanyName", "TUIO.org\0" 41 | VALUE "FileDescription", "Tangible Interaction Framework\0" 42 | VALUE "FileVersion", "1, 9, 9, 0\0" 43 | VALUE "InternalName", "Tuio2Simulator.exe\0" 44 | VALUE "LegalCopyright", "2017 Martin Kaltenbrunner.\0" 45 | VALUE "LegalTrademarks", "\0" 46 | VALUE "OriginalFilename", "Tuio2Simulator.exe\0" 47 | VALUE "ProductName", "Tuio2Simulator\0" 48 | VALUE "ProductVersion", "1, 9, 9\0" 49 | VALUE "SpecialBuild", "Release\0" 50 | END 51 | END 52 | BLOCK "VarFileInfo" 53 | BEGIN 54 | VALUE "Translation", 0x409, 1200 55 | END 56 | END 57 | 58 | #endif //_WIN32 59 | 60 | ///////////////////////////////////////////////////////////////////////////// 61 | // 62 | // Icon 63 | // 64 | 65 | // Icon with lowest ID value placed first to ensure application icon 66 | // remains consistent on all systems. 67 | IDI_ICON1 ICON "TUIO.ico" 68 | #endif // English (U.S.) resources 69 | ///////////////////////////////////////////////////////////////////////////// 70 | 71 | 72 | -------------------------------------------------------------------------------- /demos/Tuio2Simulator.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | Header Files 19 | 20 | 21 | 22 | 23 | Source Files 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /demos/Tuio2Simulator.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | PATH=%PATH%;$(SolutionDir)sdl\$(Platform)\; $(LocalDebuggerEnvironment) 5 | WindowsLocalDebugger 6 | 7 | 8 | PATH=%PATH%;$(SolutionDir)sdl\$(Platform)\; $(LocalDebuggerEnvironment) 9 | WindowsLocalDebugger 10 | 11 | 12 | PATH=%PATH%;$(SolutionDir)sdl\$(Platform)\; $(LocalDebuggerEnvironment) 13 | WindowsLocalDebugger 14 | 15 | 16 | PATH=%PATH%;$(SolutionDir)sdl\$(Platform)\; $(LocalDebuggerEnvironment) 17 | WindowsLocalDebugger 18 | 19 | -------------------------------------------------------------------------------- /demos/Tuio2Test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | TUIO2 C++ Test 3 | Copyright (c) 2009-2017 Martin Kaltenbrunner 4 | 5 | This program 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 program 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 program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #include "Tuio2Test.h" 21 | 22 | Tuio2Test::Tuio2Test(TuioServer *server) 23 | : width (1024) 24 | , height(768) 25 | { 26 | tuioServer = server; 27 | tuioServer->setSourceName("t2test"); 28 | tuioServer->setDimension(width,height); 29 | tuioServer->setVerbose(true); 30 | } 31 | 32 | 33 | 34 | void Tuio2Test::run() { 35 | 36 | frameTime = TuioTime::getSystemTime(); 37 | tuioServer->initTuioFrame(frameTime); 38 | TuioObject *tobj = tuioServer->createTuioObject(); 39 | tuioServer->addTuioPointer(tobj,0.0,0.0,0.0,0.0,0.0,0.0); 40 | tuioServer->addTuioToken(tobj,0,0.0,0.0,0.0); 41 | tuioServer->addTuioBounds(tobj,0,0,0,0,0,0); 42 | tuioServer->addTuioSymbol(tobj,0,0,0,"type0","data0"); 43 | tuioServer->commitTuioFrame(); 44 | usleep(10000); 45 | 46 | frameTime = TuioTime::getSystemTime(); 47 | tuioServer->initTuioFrame(frameTime); 48 | TuioObject *to = tuioServer->createTuioPointer(0.1,0.1,0.1,0.1,0.1,0.1); 49 | TuioPointer *pointer = to->getTuioPointer(); 50 | to = tuioServer->createTuioToken(1,0.1,0.1,0.1); 51 | TuioToken *token = to->getTuioToken(); 52 | to = tuioServer->createTuioBounds(0,0,0,0,0,0); 53 | TuioBounds *bounds = to->getTuioBounds(); 54 | to = tuioServer->createTuioSymbol(0,0,0,"type1","data1"); 55 | TuioSymbol *symbol = to->getTuioSymbol(); 56 | tuioServer->commitTuioFrame(); 57 | usleep(100000); 58 | 59 | frameTime = TuioTime::getSystemTime(); 60 | tuioServer->initTuioFrame(frameTime); 61 | TuioPointer *tp = tobj->getTuioPointer(); 62 | tuioServer->updateTuioPointer(tp,0.01,0.01,0.01,0.01,0.01,0.01); 63 | TuioToken *tt = tobj->getTuioToken(); 64 | tuioServer->updateTuioToken(tt,0.01,0.01,0.01); 65 | TuioBounds *tb = tobj->getTuioBounds(); 66 | tuioServer->updateTuioBounds(tb,0.01,0.01,0.01,0.01,0.01,0.01); 67 | tuioServer->commitTuioFrame(); 68 | usleep(100000); 69 | 70 | frameTime = TuioTime::getSystemTime(); 71 | tuioServer->initTuioFrame(frameTime); 72 | tuioServer->updateTuioPointer(pointer,0.11,0.11,0.11,0.11,0.11,0.11); 73 | tuioServer->updateTuioToken(token,0.11,0.11,0.11); 74 | tuioServer->updateTuioBounds(bounds,0.11,0.11,0.11,0.11,0.11,0.11); 75 | tuioServer->commitTuioFrame(); 76 | usleep(100000); 77 | 78 | frameTime = TuioTime::getSystemTime(); 79 | tuioServer->initTuioFrame(frameTime); 80 | tuioServer->removeTuioObject(tobj); 81 | tuioServer->commitTuioFrame(); 82 | usleep(100000); 83 | 84 | frameTime = TuioTime::getSystemTime(); 85 | tuioServer->initTuioFrame(frameTime); 86 | tuioServer->removeTuioPointer(pointer); 87 | tuioServer->removeTuioToken(token); 88 | tuioServer->removeTuioBounds(bounds); 89 | tuioServer->removeTuioSymbol(symbol); 90 | tuioServer->commitTuioFrame(); 91 | } 92 | 93 | int main(int argc, char* argv[]) 94 | { 95 | TuioServer *server; 96 | if( argc == 3 ) { 97 | server = new TuioServer(argv[1],atoi(argv[2])); 98 | } else server = new TuioServer(); // default is UDP port 3333 on localhost 99 | 100 | // add an additional TUIO/TCP sender 101 | OscSender *tcp_sender; 102 | if( argc == 2 ) { 103 | tcp_sender = new TcpSender(atoi(argv[1])); 104 | } else if ( argc == 3 ) { 105 | tcp_sender = new TcpSender(argv[1],atoi(argv[2])); 106 | } else tcp_sender = new TcpSender(3333); 107 | server->addOscSender(tcp_sender); 108 | 109 | // add an additional TUIO/FLC sender 110 | OscSender *flash_sender = new FlashSender(); 111 | server->addOscSender(flash_sender); 112 | 113 | // add an additional WebSocket sender 114 | WebSockSender *websock_sender = new WebSockSender(); 115 | server->addOscSender(websock_sender); 116 | sleep(5); // give web client time to connect 117 | 118 | Tuio2Test *test = new Tuio2Test(server); 119 | test->run(); 120 | 121 | delete test; 122 | delete server; 123 | delete flash_sender; 124 | delete tcp_sender; 125 | delete websock_sender; 126 | return 0; 127 | } 128 | -------------------------------------------------------------------------------- /demos/Tuio2Test.h: -------------------------------------------------------------------------------- 1 | /* 2 | TUIO2 C++ Test 3 | Copyright (c) 2009-2017 Martin Kaltenbrunner 4 | 5 | This program 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 program 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 program; if not, write to the Free Software 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 | */ 19 | 20 | #ifndef INCLUDED_TUIO2TEST_H 21 | #define INCLUDED_TUIO2TEST_H 22 | 23 | #include "TuioServer.h" 24 | #include "TuioPointer.h" 25 | #include "osc/OscTypes.h" 26 | #include 27 | #include 28 | 29 | #include "FlashSender.h" 30 | #include "TcpSender.h" 31 | #include "WebSockSender.h" 32 | 33 | using namespace TUIO2; 34 | 35 | class Tuio2Test { 36 | 37 | public: 38 | Tuio2Test(TuioServer *server); 39 | Tuio2Test() {}; 40 | 41 | void run(); 42 | TuioServer *tuioServer; 43 | 44 | private: 45 | 46 | int width, height; 47 | TuioTime frameTime; 48 | 49 | }; 50 | 51 | #endif /* INCLUDED_TUIO2TEST_H */ 52 | -------------------------------------------------------------------------------- /demos/libTUIO2.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /demos/sdl/Win32/SDL2.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkalten/TUIO20_CPP/b3fc7998670200091e5768747c3e04ac758084e3/demos/sdl/Win32/SDL2.dll -------------------------------------------------------------------------------- /demos/sdl/Win32/SDL2.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkalten/TUIO20_CPP/b3fc7998670200091e5768747c3e04ac758084e3/demos/sdl/Win32/SDL2.lib -------------------------------------------------------------------------------- /demos/sdl/Win32/SDL2main.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkalten/TUIO20_CPP/b3fc7998670200091e5768747c3e04ac758084e3/demos/sdl/Win32/SDL2main.lib -------------------------------------------------------------------------------- /demos/sdl/Win32/freeglut.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkalten/TUIO20_CPP/b3fc7998670200091e5768747c3e04ac758084e3/demos/sdl/Win32/freeglut.dll -------------------------------------------------------------------------------- /demos/sdl/Win32/freeglut.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkalten/TUIO20_CPP/b3fc7998670200091e5768747c3e04ac758084e3/demos/sdl/Win32/freeglut.lib -------------------------------------------------------------------------------- /demos/sdl/include/GL/freeglut.h: -------------------------------------------------------------------------------- 1 | #ifndef __FREEGLUT_H__ 2 | #define __FREEGLUT_H__ 3 | 4 | /* 5 | * freeglut.h 6 | * 7 | * The freeglut library include file 8 | * 9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 10 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 11 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 12 | * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 13 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 14 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 15 | */ 16 | 17 | #include "freeglut_std.h" 18 | #include "freeglut_ext.h" 19 | 20 | /*** END OF FILE ***/ 21 | 22 | #endif /* __FREEGLUT_H__ */ 23 | -------------------------------------------------------------------------------- /demos/sdl/include/GL/glut.h: -------------------------------------------------------------------------------- 1 | #ifndef __GLUT_H__ 2 | #define __GLUT_H__ 3 | 4 | /* 5 | * glut.h 6 | * 7 | * The freeglut library include file 8 | * 9 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 10 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 11 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 12 | * PAWEL W. OLSZTA BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 13 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 14 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 15 | */ 16 | 17 | #include "freeglut_std.h" 18 | 19 | /*** END OF FILE ***/ 20 | 21 | #endif /* __GLUT_H__ */ 22 | -------------------------------------------------------------------------------- /demos/sdl/include/SDL.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | /** 23 | * \file SDL.h 24 | * 25 | * Main include header for the SDL library 26 | */ 27 | 28 | 29 | #ifndef _SDL_H 30 | #define _SDL_H 31 | 32 | #include "SDL_main.h" 33 | #include "SDL_stdinc.h" 34 | #include "SDL_assert.h" 35 | #include "SDL_atomic.h" 36 | #include "SDL_audio.h" 37 | #include "SDL_clipboard.h" 38 | #include "SDL_cpuinfo.h" 39 | #include "SDL_endian.h" 40 | #include "SDL_error.h" 41 | #include "SDL_events.h" 42 | #include "SDL_filesystem.h" 43 | #include "SDL_joystick.h" 44 | #include "SDL_gamecontroller.h" 45 | #include "SDL_haptic.h" 46 | #include "SDL_hints.h" 47 | #include "SDL_loadso.h" 48 | #include "SDL_log.h" 49 | #include "SDL_messagebox.h" 50 | #include "SDL_mutex.h" 51 | #include "SDL_power.h" 52 | #include "SDL_render.h" 53 | #include "SDL_rwops.h" 54 | #include "SDL_system.h" 55 | #include "SDL_thread.h" 56 | #include "SDL_timer.h" 57 | #include "SDL_version.h" 58 | #include "SDL_video.h" 59 | 60 | #include "begin_code.h" 61 | /* Set up for C function definitions, even when using C++ */ 62 | #ifdef __cplusplus 63 | extern "C" { 64 | #endif 65 | 66 | /* As of version 0.5, SDL is loaded dynamically into the application */ 67 | 68 | /** 69 | * \name SDL_INIT_* 70 | * 71 | * These are the flags which may be passed to SDL_Init(). You should 72 | * specify the subsystems which you will be using in your application. 73 | */ 74 | /* @{ */ 75 | #define SDL_INIT_TIMER 0x00000001 76 | #define SDL_INIT_AUDIO 0x00000010 77 | #define SDL_INIT_VIDEO 0x00000020 /**< SDL_INIT_VIDEO implies SDL_INIT_EVENTS */ 78 | #define SDL_INIT_JOYSTICK 0x00000200 /**< SDL_INIT_JOYSTICK implies SDL_INIT_EVENTS */ 79 | #define SDL_INIT_HAPTIC 0x00001000 80 | #define SDL_INIT_GAMECONTROLLER 0x00002000 /**< SDL_INIT_GAMECONTROLLER implies SDL_INIT_JOYSTICK */ 81 | #define SDL_INIT_EVENTS 0x00004000 82 | #define SDL_INIT_NOPARACHUTE 0x00100000 /**< compatibility; this flag is ignored. */ 83 | #define SDL_INIT_EVERYTHING ( \ 84 | SDL_INIT_TIMER | SDL_INIT_AUDIO | SDL_INIT_VIDEO | SDL_INIT_EVENTS | \ 85 | SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC | SDL_INIT_GAMECONTROLLER \ 86 | ) 87 | /* @} */ 88 | 89 | /** 90 | * This function initializes the subsystems specified by \c flags 91 | */ 92 | extern DECLSPEC int SDLCALL SDL_Init(Uint32 flags); 93 | 94 | /** 95 | * This function initializes specific SDL subsystems 96 | * 97 | * Subsystem initialization is ref-counted, you must call 98 | * SDL_QuitSubSystem for each SDL_InitSubSystem to correctly 99 | * shutdown a subsystem manually (or call SDL_Quit to force shutdown). 100 | * If a subsystem is already loaded then this call will 101 | * increase the ref-count and return. 102 | */ 103 | extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags); 104 | 105 | /** 106 | * This function cleans up specific SDL subsystems 107 | */ 108 | extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags); 109 | 110 | /** 111 | * This function returns a mask of the specified subsystems which have 112 | * previously been initialized. 113 | * 114 | * If \c flags is 0, it returns a mask of all initialized subsystems. 115 | */ 116 | extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags); 117 | 118 | /** 119 | * This function cleans up all initialized subsystems. You should 120 | * call it upon all exit conditions. 121 | */ 122 | extern DECLSPEC void SDLCALL SDL_Quit(void); 123 | 124 | /* Ends C function definitions when using C++ */ 125 | #ifdef __cplusplus 126 | } 127 | #endif 128 | #include "close_code.h" 129 | 130 | #endif /* _SDL_H */ 131 | 132 | /* vi: set ts=4 sw=4 expandtab: */ 133 | -------------------------------------------------------------------------------- /demos/sdl/include/SDL_bits.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | /** 23 | * \file SDL_bits.h 24 | * 25 | * Functions for fiddling with bits and bitmasks. 26 | */ 27 | 28 | #ifndef _SDL_bits_h 29 | #define _SDL_bits_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 | * \file SDL_bits.h 41 | */ 42 | 43 | /** 44 | * Get the index of the most significant bit. Result is undefined when called 45 | * with 0. This operation can also be stated as "count leading zeroes" and 46 | * "log base 2". 47 | * 48 | * \return Index of the most significant bit, or -1 if the value is 0. 49 | */ 50 | SDL_FORCE_INLINE int 51 | SDL_MostSignificantBitIndex32(Uint32 x) 52 | { 53 | #if defined(__GNUC__) && __GNUC__ >= 4 54 | /* Count Leading Zeroes builtin in GCC. 55 | * http://gcc.gnu.org/onlinedocs/gcc-4.3.4/gcc/Other-Builtins.html 56 | */ 57 | if (x == 0) { 58 | return -1; 59 | } 60 | return 31 - __builtin_clz(x); 61 | #else 62 | /* Based off of Bit Twiddling Hacks by Sean Eron Anderson 63 | * , released in the public domain. 64 | * http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog 65 | */ 66 | const Uint32 b[] = {0x2, 0xC, 0xF0, 0xFF00, 0xFFFF0000}; 67 | const int S[] = {1, 2, 4, 8, 16}; 68 | 69 | int msbIndex = 0; 70 | int i; 71 | 72 | if (x == 0) { 73 | return -1; 74 | } 75 | 76 | for (i = 4; i >= 0; i--) 77 | { 78 | if (x & b[i]) 79 | { 80 | x >>= S[i]; 81 | msbIndex |= S[i]; 82 | } 83 | } 84 | 85 | return msbIndex; 86 | #endif 87 | } 88 | 89 | /* Ends C function definitions when using C++ */ 90 | #ifdef __cplusplus 91 | } 92 | #endif 93 | #include "close_code.h" 94 | 95 | #endif /* _SDL_bits_h */ 96 | 97 | /* vi: set ts=4 sw=4 expandtab: */ 98 | -------------------------------------------------------------------------------- /demos/sdl/include/SDL_blendmode.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | /** 23 | * \file SDL_blendmode.h 24 | * 25 | * Header file declaring the SDL_BlendMode enumeration 26 | */ 27 | 28 | #ifndef _SDL_blendmode_h 29 | #define _SDL_blendmode_h 30 | 31 | #include "begin_code.h" 32 | /* Set up for C function definitions, even when using C++ */ 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /** 38 | * \brief The blend mode used in SDL_RenderCopy() and drawing operations. 39 | */ 40 | typedef enum 41 | { 42 | SDL_BLENDMODE_NONE = 0x00000000, /**< no blending 43 | dstRGBA = srcRGBA */ 44 | SDL_BLENDMODE_BLEND = 0x00000001, /**< alpha blending 45 | dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA)) 46 | dstA = srcA + (dstA * (1-srcA)) */ 47 | SDL_BLENDMODE_ADD = 0x00000002, /**< additive blending 48 | dstRGB = (srcRGB * srcA) + dstRGB 49 | dstA = dstA */ 50 | SDL_BLENDMODE_MOD = 0x00000004 /**< color modulate 51 | dstRGB = srcRGB * dstRGB 52 | dstA = dstA */ 53 | } SDL_BlendMode; 54 | 55 | /* Ends C function definitions when using C++ */ 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | #include "close_code.h" 60 | 61 | #endif /* _SDL_blendmode_h */ 62 | 63 | /* vi: set ts=4 sw=4 expandtab: */ 64 | -------------------------------------------------------------------------------- /demos/sdl/include/SDL_clipboard.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | /** 23 | * \file SDL_clipboard.h 24 | * 25 | * Include file for SDL clipboard handling 26 | */ 27 | 28 | #ifndef _SDL_clipboard_h 29 | #define _SDL_clipboard_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 | /* Function prototypes */ 40 | 41 | /** 42 | * \brief Put UTF-8 text into the clipboard 43 | * 44 | * \sa SDL_GetClipboardText() 45 | */ 46 | extern DECLSPEC int SDLCALL SDL_SetClipboardText(const char *text); 47 | 48 | /** 49 | * \brief Get UTF-8 text from the clipboard, which must be freed with SDL_free() 50 | * 51 | * \sa SDL_SetClipboardText() 52 | */ 53 | extern DECLSPEC char * SDLCALL SDL_GetClipboardText(void); 54 | 55 | /** 56 | * \brief Returns a flag indicating whether the clipboard exists and contains a text string that is non-empty 57 | * 58 | * \sa SDL_GetClipboardText() 59 | */ 60 | extern DECLSPEC SDL_bool SDLCALL SDL_HasClipboardText(void); 61 | 62 | 63 | /* Ends C function definitions when using C++ */ 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | #include "close_code.h" 68 | 69 | #endif /* _SDL_clipboard_h */ 70 | 71 | /* vi: set ts=4 sw=4 expandtab: */ 72 | -------------------------------------------------------------------------------- /demos/sdl/include/SDL_cpuinfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | /** 23 | * \file SDL_cpuinfo.h 24 | * 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 | /* Need to do this here because intrin.h has C++ code in it */ 34 | /* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */ 35 | #if defined(_MSC_VER) && (_MSC_VER >= 1500) && (defined(_M_IX86) || defined(_M_X64)) 36 | #include 37 | #ifndef _WIN64 38 | #define __MMX__ 39 | #define __3dNOW__ 40 | #endif 41 | #define __SSE__ 42 | #define __SSE2__ 43 | #elif defined(__MINGW64_VERSION_MAJOR) 44 | #include 45 | #else 46 | #ifdef __ALTIVEC__ 47 | #if HAVE_ALTIVEC_H && !defined(__APPLE_ALTIVEC__) 48 | #include 49 | #undef pixel 50 | #endif 51 | #endif 52 | #ifdef __MMX__ 53 | #include 54 | #endif 55 | #ifdef __3dNOW__ 56 | #include 57 | #endif 58 | #ifdef __SSE__ 59 | #include 60 | #endif 61 | #ifdef __SSE2__ 62 | #include 63 | #endif 64 | #endif 65 | 66 | #include "begin_code.h" 67 | /* Set up for C function definitions, even when using C++ */ 68 | #ifdef __cplusplus 69 | extern "C" { 70 | #endif 71 | 72 | /* This is a guess for the cacheline size used for padding. 73 | * Most x86 processors have a 64 byte cache line. 74 | * The 64-bit PowerPC processors have a 128 byte cache line. 75 | * We'll use the larger value to be generally safe. 76 | */ 77 | #define SDL_CACHELINE_SIZE 128 78 | 79 | /** 80 | * This function returns the number of CPU cores available. 81 | */ 82 | extern DECLSPEC int SDLCALL SDL_GetCPUCount(void); 83 | 84 | /** 85 | * This function returns the L1 cache line size of the CPU 86 | * 87 | * This is useful for determining multi-threaded structure padding 88 | * or SIMD prefetch sizes. 89 | */ 90 | extern DECLSPEC int SDLCALL SDL_GetCPUCacheLineSize(void); 91 | 92 | /** 93 | * This function returns true if the CPU has the RDTSC instruction. 94 | */ 95 | extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void); 96 | 97 | /** 98 | * This function returns true if the CPU has AltiVec features. 99 | */ 100 | extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void); 101 | 102 | /** 103 | * This function returns true if the CPU has MMX features. 104 | */ 105 | extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void); 106 | 107 | /** 108 | * This function returns true if the CPU has 3DNow! features. 109 | */ 110 | extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void); 111 | 112 | /** 113 | * This function returns true if the CPU has SSE features. 114 | */ 115 | extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void); 116 | 117 | /** 118 | * This function returns true if the CPU has SSE2 features. 119 | */ 120 | extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void); 121 | 122 | /** 123 | * This function returns true if the CPU has SSE3 features. 124 | */ 125 | extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE3(void); 126 | 127 | /** 128 | * This function returns true if the CPU has SSE4.1 features. 129 | */ 130 | extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE41(void); 131 | 132 | /** 133 | * This function returns true if the CPU has SSE4.2 features. 134 | */ 135 | extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE42(void); 136 | 137 | /** 138 | * This function returns true if the CPU has AVX features. 139 | */ 140 | extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX(void); 141 | 142 | /** 143 | * This function returns true if the CPU has AVX2 features. 144 | */ 145 | extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX2(void); 146 | 147 | /** 148 | * This function returns the amount of RAM configured in the system, in MB. 149 | */ 150 | extern DECLSPEC int SDLCALL SDL_GetSystemRAM(void); 151 | 152 | 153 | /* Ends C function definitions when using C++ */ 154 | #ifdef __cplusplus 155 | } 156 | #endif 157 | #include "close_code.h" 158 | 159 | #endif /* _SDL_cpuinfo_h */ 160 | 161 | /* vi: set ts=4 sw=4 expandtab: */ 162 | -------------------------------------------------------------------------------- /demos/sdl/include/SDL_error.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | /** 23 | * \file SDL_error.h 24 | * 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 | /* Public functions */ 40 | /* SDL_SetError() unconditionally returns -1. */ 41 | extern DECLSPEC int SDLCALL SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); 42 | extern DECLSPEC const char *SDLCALL SDL_GetError(void); 43 | extern DECLSPEC void SDLCALL SDL_ClearError(void); 44 | 45 | /** 46 | * \name Internal error functions 47 | * 48 | * \internal 49 | * Private error reporting function - used internally. 50 | */ 51 | /* @{ */ 52 | #define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM) 53 | #define SDL_Unsupported() SDL_Error(SDL_UNSUPPORTED) 54 | #define SDL_InvalidParamError(param) SDL_SetError("Parameter '%s' is invalid", (param)) 55 | typedef enum 56 | { 57 | SDL_ENOMEM, 58 | SDL_EFREAD, 59 | SDL_EFWRITE, 60 | SDL_EFSEEK, 61 | SDL_UNSUPPORTED, 62 | SDL_LASTERROR 63 | } SDL_errorcode; 64 | /* SDL_Error() unconditionally returns -1. */ 65 | extern DECLSPEC int SDLCALL SDL_Error(SDL_errorcode code); 66 | /* @} *//* Internal error functions */ 67 | 68 | /* Ends C function definitions when using C++ */ 69 | #ifdef __cplusplus 70 | } 71 | #endif 72 | #include "close_code.h" 73 | 74 | #endif /* _SDL_error_h */ 75 | 76 | /* vi: set ts=4 sw=4 expandtab: */ 77 | -------------------------------------------------------------------------------- /demos/sdl/include/SDL_gesture.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | /** 23 | * \file SDL_gesture.h 24 | * 25 | * Include file for SDL gesture event handling. 26 | */ 27 | 28 | #ifndef _SDL_gesture_h 29 | #define _SDL_gesture_h 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_error.h" 33 | #include "SDL_video.h" 34 | 35 | #include "SDL_touch.h" 36 | 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 | typedef Sint64 SDL_GestureID; 45 | 46 | /* Function prototypes */ 47 | 48 | /** 49 | * \brief Begin Recording a gesture on the specified touch, or all touches (-1) 50 | * 51 | * 52 | */ 53 | extern DECLSPEC int SDLCALL SDL_RecordGesture(SDL_TouchID touchId); 54 | 55 | 56 | /** 57 | * \brief Save all currently loaded Dollar Gesture templates 58 | * 59 | * 60 | */ 61 | extern DECLSPEC int SDLCALL SDL_SaveAllDollarTemplates(SDL_RWops *dst); 62 | 63 | /** 64 | * \brief Save a currently loaded Dollar Gesture template 65 | * 66 | * 67 | */ 68 | extern DECLSPEC int SDLCALL SDL_SaveDollarTemplate(SDL_GestureID gestureId,SDL_RWops *dst); 69 | 70 | 71 | /** 72 | * \brief Load Dollar Gesture templates from a file 73 | * 74 | * 75 | */ 76 | extern DECLSPEC int SDLCALL SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src); 77 | 78 | 79 | /* Ends C function definitions when using C++ */ 80 | #ifdef __cplusplus 81 | } 82 | #endif 83 | #include "close_code.h" 84 | 85 | #endif /* _SDL_gesture_h */ 86 | 87 | /* vi: set ts=4 sw=4 expandtab: */ 88 | -------------------------------------------------------------------------------- /demos/sdl/include/SDL_loadso.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | /** 23 | * \file SDL_loadso.h 24 | * 25 | * System dependent library loading routines 26 | * 27 | * Some things to keep in mind: 28 | * \li These functions only work on C function names. Other languages may 29 | * have name mangling and intrinsic language support that varies from 30 | * compiler to compiler. 31 | * \li Make sure you declare your function pointers with the same calling 32 | * convention as the actual library function. Your code will crash 33 | * mysteriously if you do not do this. 34 | * \li Avoid namespace collisions. If you load a symbol from the library, 35 | * it is not defined whether or not it goes into the global symbol 36 | * namespace for the application. If it does and it conflicts with 37 | * symbols in your code or other shared libraries, you will not get 38 | * the results you expect. :) 39 | */ 40 | 41 | #ifndef _SDL_loadso_h 42 | #define _SDL_loadso_h 43 | 44 | #include "SDL_stdinc.h" 45 | #include "SDL_error.h" 46 | 47 | #include "begin_code.h" 48 | /* Set up for C function definitions, even when using C++ */ 49 | #ifdef __cplusplus 50 | extern "C" { 51 | #endif 52 | 53 | /** 54 | * This function dynamically loads a shared object and returns a pointer 55 | * to the object handle (or NULL if there was an error). 56 | * The 'sofile' parameter is a system dependent name of the object file. 57 | */ 58 | extern DECLSPEC void *SDLCALL SDL_LoadObject(const char *sofile); 59 | 60 | /** 61 | * Given an object handle, this function looks up the address of the 62 | * named function in the shared object and returns it. This address 63 | * is no longer valid after calling SDL_UnloadObject(). 64 | */ 65 | extern DECLSPEC void *SDLCALL SDL_LoadFunction(void *handle, 66 | const char *name); 67 | 68 | /** 69 | * Unload a shared object from memory. 70 | */ 71 | extern DECLSPEC void SDLCALL SDL_UnloadObject(void *handle); 72 | 73 | /* Ends C function definitions when using C++ */ 74 | #ifdef __cplusplus 75 | } 76 | #endif 77 | #include "close_code.h" 78 | 79 | #endif /* _SDL_loadso_h */ 80 | 81 | /* vi: set ts=4 sw=4 expandtab: */ 82 | -------------------------------------------------------------------------------- /demos/sdl/include/SDL_name.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | #ifndef _SDLname_h_ 23 | #define _SDLname_h_ 24 | 25 | #if defined(__STDC__) || defined(__cplusplus) 26 | #define NeedFunctionPrototypes 1 27 | #endif 28 | 29 | #define SDL_NAME(X) SDL_##X 30 | 31 | #endif /* _SDLname_h_ */ 32 | 33 | /* vi: set ts=4 sw=4 expandtab: */ 34 | -------------------------------------------------------------------------------- /demos/sdl/include/SDL_opengles.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | /** 23 | * \file SDL_opengles.h 24 | * 25 | * This is a simple file to encapsulate the OpenGL ES 1.X API headers. 26 | */ 27 | 28 | #ifdef __IPHONEOS__ 29 | #include 30 | #include 31 | #else 32 | #include 33 | #include 34 | #endif 35 | 36 | #ifndef APIENTRY 37 | #define APIENTRY 38 | #endif 39 | -------------------------------------------------------------------------------- /demos/sdl/include/SDL_opengles2.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | /** 23 | * \file SDL_opengles2.h 24 | * 25 | * This is a simple file to encapsulate the OpenGL ES 2.0 API headers. 26 | */ 27 | #ifndef _MSC_VER 28 | 29 | #ifdef __IPHONEOS__ 30 | #include 31 | #include 32 | #else 33 | #include 34 | #include 35 | #include 36 | #endif 37 | 38 | #else /* _MSC_VER */ 39 | 40 | /* OpenGL ES2 headers for Visual Studio */ 41 | #include "SDL_opengles2_khrplatform.h" 42 | #include "SDL_opengles2_gl2platform.h" 43 | #include "SDL_opengles2_gl2.h" 44 | #include "SDL_opengles2_gl2ext.h" 45 | 46 | #endif /* _MSC_VER */ 47 | 48 | #ifndef APIENTRY 49 | #define APIENTRY GL_APIENTRY 50 | #endif 51 | -------------------------------------------------------------------------------- /demos/sdl/include/SDL_opengles2_gl2platform.h: -------------------------------------------------------------------------------- 1 | #ifndef __gl2platform_h_ 2 | #define __gl2platform_h_ 3 | 4 | /* $Revision: 10602 $ on $Date:: 2010-03-04 22:35:34 -0800 #$ */ 5 | 6 | /* 7 | * This document is licensed under the SGI Free Software B License Version 8 | * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . 9 | */ 10 | 11 | /* Platform-specific types and definitions for OpenGL ES 2.X gl2.h 12 | * 13 | * Adopters may modify khrplatform.h and this file to suit their platform. 14 | * You are encouraged to submit all modifications to the Khronos group so that 15 | * they can be included in future versions of this file. Please submit changes 16 | * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla) 17 | * by filing a bug against product "OpenGL-ES" component "Registry". 18 | */ 19 | 20 | /*#include */ 21 | 22 | #ifndef GL_APICALL 23 | #define GL_APICALL KHRONOS_APICALL 24 | #endif 25 | 26 | #ifndef GL_APIENTRY 27 | #define GL_APIENTRY KHRONOS_APIENTRY 28 | #endif 29 | 30 | #endif /* __gl2platform_h_ */ 31 | -------------------------------------------------------------------------------- /demos/sdl/include/SDL_power.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | #ifndef _SDL_power_h 23 | #define _SDL_power_h 24 | 25 | /** 26 | * \file SDL_power.h 27 | * 28 | * Header for the SDL power management routines. 29 | */ 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 | * \brief The basic state for the system's power supply. 41 | */ 42 | typedef enum 43 | { 44 | SDL_POWERSTATE_UNKNOWN, /**< cannot determine power status */ 45 | SDL_POWERSTATE_ON_BATTERY, /**< Not plugged in, running on the battery */ 46 | SDL_POWERSTATE_NO_BATTERY, /**< Plugged in, no battery available */ 47 | SDL_POWERSTATE_CHARGING, /**< Plugged in, charging battery */ 48 | SDL_POWERSTATE_CHARGED /**< Plugged in, battery charged */ 49 | } SDL_PowerState; 50 | 51 | 52 | /** 53 | * \brief Get the current power supply details. 54 | * 55 | * \param secs Seconds of battery life left. You can pass a NULL here if 56 | * you don't care. Will return -1 if we can't determine a 57 | * value, or we're not running on a battery. 58 | * 59 | * \param pct Percentage of battery life left, between 0 and 100. You can 60 | * pass a NULL here if you don't care. Will return -1 if we 61 | * can't determine a value, or we're not running on a battery. 62 | * 63 | * \return The state of the battery (if any). 64 | */ 65 | extern DECLSPEC SDL_PowerState SDLCALL SDL_GetPowerInfo(int *secs, int *pct); 66 | 67 | /* Ends C function definitions when using C++ */ 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | #include "close_code.h" 72 | 73 | #endif /* _SDL_power_h */ 74 | 75 | /* vi: set ts=4 sw=4 expandtab: */ 76 | -------------------------------------------------------------------------------- /demos/sdl/include/SDL_quit.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | /** 23 | * \file SDL_quit.h 24 | * 25 | * Include file for SDL quit event handling. 26 | */ 27 | 28 | #ifndef _SDL_quit_h 29 | #define _SDL_quit_h 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_error.h" 33 | 34 | /** 35 | * \file SDL_quit.h 36 | * 37 | * An ::SDL_QUIT event is generated when the user tries to close the application 38 | * window. If it is ignored or filtered out, the window will remain open. 39 | * If it is not ignored or filtered, it is queued normally and the window 40 | * is allowed to close. When the window is closed, screen updates will 41 | * complete, but have no effect. 42 | * 43 | * SDL_Init() installs signal handlers for SIGINT (keyboard interrupt) 44 | * and SIGTERM (system termination request), if handlers do not already 45 | * exist, that generate ::SDL_QUIT events as well. There is no way 46 | * to determine the cause of an ::SDL_QUIT event, but setting a signal 47 | * handler in your application will override the default generation of 48 | * quit events for that signal. 49 | * 50 | * \sa SDL_Quit() 51 | */ 52 | 53 | /* There are no functions directly affecting the quit event */ 54 | 55 | #define SDL_QuitRequested() \ 56 | (SDL_PumpEvents(), (SDL_PeepEvents(NULL,0,SDL_PEEKEVENT,SDL_QUIT,SDL_QUIT) > 0)) 57 | 58 | #endif /* _SDL_quit_h */ 59 | -------------------------------------------------------------------------------- /demos/sdl/include/SDL_revision.h: -------------------------------------------------------------------------------- 1 | #define SDL_REVISION "hg-10001:e12c38730512" 2 | #define SDL_REVISION_NUMBER 10001 3 | -------------------------------------------------------------------------------- /demos/sdl/include/SDL_test.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | /** 23 | * \file SDL_test.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | #ifndef _SDL_test_h 31 | #define _SDL_test_h 32 | 33 | #include "SDL.h" 34 | #include "SDL_test_common.h" 35 | #include "SDL_test_font.h" 36 | #include "SDL_test_random.h" 37 | #include "SDL_test_fuzzer.h" 38 | #include "SDL_test_crc32.h" 39 | #include "SDL_test_md5.h" 40 | #include "SDL_test_log.h" 41 | #include "SDL_test_assert.h" 42 | #include "SDL_test_harness.h" 43 | #include "SDL_test_images.h" 44 | #include "SDL_test_compare.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 | /* Global definitions */ 53 | 54 | /* 55 | * Note: Maximum size of SDLTest log message is less than SDL's limit 56 | * to ensure we can fit additional information such as the timestamp. 57 | */ 58 | #define SDLTEST_MAX_LOGMESSAGE_LENGTH 3584 59 | 60 | /* Ends C function definitions when using C++ */ 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | #include "close_code.h" 65 | 66 | #endif /* _SDL_test_h */ 67 | 68 | /* vi: set ts=4 sw=4 expandtab: */ 69 | -------------------------------------------------------------------------------- /demos/sdl/include/SDL_test_assert.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | /** 23 | * \file SDL_test_assert.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* 31 | * 32 | * Assert API for test code and test cases 33 | * 34 | */ 35 | 36 | #ifndef _SDL_test_assert_h 37 | #define _SDL_test_assert_h 38 | 39 | #include "begin_code.h" 40 | /* Set up for C function definitions, even when using C++ */ 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | /** 46 | * \brief Fails the assert. 47 | */ 48 | #define ASSERT_FAIL 0 49 | 50 | /** 51 | * \brief Passes the assert. 52 | */ 53 | #define ASSERT_PASS 1 54 | 55 | /** 56 | * \brief Assert that logs and break execution flow on failures. 57 | * 58 | * \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0). 59 | * \param assertDescription Message to log with the assert describing it. 60 | */ 61 | void SDLTest_Assert(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(2); 62 | 63 | /** 64 | * \brief Assert for test cases that logs but does not break execution flow on failures. Updates assertion counters. 65 | * 66 | * \param assertCondition Evaluated condition or variable to assert; fail (==0) or pass (!=0). 67 | * \param assertDescription Message to log with the assert describing it. 68 | * 69 | * \returns Returns the assertCondition so it can be used to externally to break execution flow if desired. 70 | */ 71 | int SDLTest_AssertCheck(int assertCondition, SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(2); 72 | 73 | /** 74 | * \brief Explicitly pass without checking an assertion condition. Updates assertion counter. 75 | * 76 | * \param assertDescription Message to log with the assert describing it. 77 | */ 78 | void SDLTest_AssertPass(SDL_PRINTF_FORMAT_STRING const char *assertDescription, ...) SDL_PRINTF_VARARG_FUNC(1); 79 | 80 | /** 81 | * \brief Resets the assert summary counters to zero. 82 | */ 83 | void SDLTest_ResetAssertSummary(); 84 | 85 | /** 86 | * \brief Logs summary of all assertions (total, pass, fail) since last reset as INFO or ERROR. 87 | */ 88 | void SDLTest_LogAssertSummary(); 89 | 90 | 91 | /** 92 | * \brief Converts the current assert summary state to a test result. 93 | * 94 | * \returns TEST_RESULT_PASSED, TEST_RESULT_FAILED, or TEST_RESULT_NO_ASSERT 95 | */ 96 | int SDLTest_AssertSummaryToTestResult(); 97 | 98 | #ifdef __cplusplus 99 | } 100 | #endif 101 | #include "close_code.h" 102 | 103 | #endif /* _SDL_test_assert_h */ 104 | 105 | /* vi: set ts=4 sw=4 expandtab: */ 106 | -------------------------------------------------------------------------------- /demos/sdl/include/SDL_test_compare.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | /** 23 | * \file SDL_test_compare.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* 31 | 32 | Defines comparison functions (i.e. for surfaces). 33 | 34 | */ 35 | 36 | #ifndef _SDL_test_compare_h 37 | #define _SDL_test_compare_h 38 | 39 | #include "SDL.h" 40 | 41 | #include "SDL_test_images.h" 42 | 43 | #include "begin_code.h" 44 | /* Set up for C function definitions, even when using C++ */ 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | /** 50 | * \brief Compares a surface and with reference image data for equality 51 | * 52 | * \param surface Surface used in comparison 53 | * \param referenceSurface Test Surface used in comparison 54 | * \param allowable_error Allowable difference (=sum of squared difference for each RGB component) in blending accuracy. 55 | * 56 | * \returns 0 if comparison succeeded, >0 (=number of pixels for which the comparison failed) if comparison failed, -1 if any of the surfaces were NULL, -2 if the surface sizes differ. 57 | */ 58 | int SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface, int allowable_error); 59 | 60 | 61 | /* Ends C function definitions when using C++ */ 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | #include "close_code.h" 66 | 67 | #endif /* _SDL_test_compare_h */ 68 | 69 | /* vi: set ts=4 sw=4 expandtab: */ 70 | -------------------------------------------------------------------------------- /demos/sdl/include/SDL_test_crc32.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | /** 23 | * \file SDL_test_crc32.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* 31 | 32 | Implements CRC32 calculations (default output is Perl String::CRC32 compatible). 33 | 34 | */ 35 | 36 | #ifndef _SDL_test_crc32_h 37 | #define _SDL_test_crc32_h 38 | 39 | #include "begin_code.h" 40 | /* Set up for C function definitions, even when using C++ */ 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | 46 | /* ------------ Definitions --------- */ 47 | 48 | /* Definition shared by all CRC routines */ 49 | 50 | #ifndef CrcUint32 51 | #define CrcUint32 unsigned int 52 | #endif 53 | #ifndef CrcUint8 54 | #define CrcUint8 unsigned char 55 | #endif 56 | 57 | #ifdef ORIGINAL_METHOD 58 | #define CRC32_POLY 0x04c11db7 /* AUTODIN II, Ethernet, & FDDI */ 59 | #else 60 | #define CRC32_POLY 0xEDB88320 /* Perl String::CRC32 compatible */ 61 | #endif 62 | 63 | /** 64 | * Data structure for CRC32 (checksum) computation 65 | */ 66 | typedef struct { 67 | CrcUint32 crc32_table[256]; /* CRC table */ 68 | } SDLTest_Crc32Context; 69 | 70 | /* ---------- Function Prototypes ------------- */ 71 | 72 | /** 73 | * \brief Initialize the CRC context 74 | * 75 | * Note: The function initializes the crc table required for all crc calculations. 76 | * 77 | * \param crcContext pointer to context variable 78 | * 79 | * \returns 0 for OK, -1 on error 80 | * 81 | */ 82 | int SDLTest_Crc32Init(SDLTest_Crc32Context * crcContext); 83 | 84 | 85 | /** 86 | * \brief calculate a crc32 from a data block 87 | * 88 | * \param crcContext pointer to context variable 89 | * \param inBuf input buffer to checksum 90 | * \param inLen length of input buffer 91 | * \param crc32 pointer to Uint32 to store the final CRC into 92 | * 93 | * \returns 0 for OK, -1 on error 94 | * 95 | */ 96 | int SDLTest_crc32Calc(SDLTest_Crc32Context * crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32); 97 | 98 | /* Same routine broken down into three steps */ 99 | int SDLTest_Crc32CalcStart(SDLTest_Crc32Context * crcContext, CrcUint32 *crc32); 100 | int SDLTest_Crc32CalcEnd(SDLTest_Crc32Context * crcContext, CrcUint32 *crc32); 101 | int SDLTest_Crc32CalcBuffer(SDLTest_Crc32Context * crcContext, CrcUint8 *inBuf, CrcUint32 inLen, CrcUint32 *crc32); 102 | 103 | 104 | /** 105 | * \brief clean up CRC context 106 | * 107 | * \param crcContext pointer to context variable 108 | * 109 | * \returns 0 for OK, -1 on error 110 | * 111 | */ 112 | 113 | int SDLTest_Crc32Done(SDLTest_Crc32Context * crcContext); 114 | 115 | 116 | /* Ends C function definitions when using C++ */ 117 | #ifdef __cplusplus 118 | } 119 | #endif 120 | #include "close_code.h" 121 | 122 | #endif /* _SDL_test_crc32_h */ 123 | 124 | /* vi: set ts=4 sw=4 expandtab: */ 125 | -------------------------------------------------------------------------------- /demos/sdl/include/SDL_test_font.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | /** 23 | * \file SDL_test_font.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | #ifndef _SDL_test_font_h 31 | #define _SDL_test_font_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 | /* Function prototypes */ 40 | 41 | #define FONT_CHARACTER_SIZE 8 42 | 43 | /** 44 | * \brief Draw a string in the currently set font. 45 | * 46 | * \param renderer The renderer to draw on. 47 | * \param x The X coordinate of the upper left corner of the character. 48 | * \param y The Y coordinate of the upper left corner of the character. 49 | * \param c The character to draw. 50 | * 51 | * \returns Returns 0 on success, -1 on failure. 52 | */ 53 | int SDLTest_DrawCharacter( SDL_Renderer *renderer, int x, int y, char c ); 54 | 55 | /** 56 | * \brief Draw a string in the currently set font. 57 | * 58 | * \param renderer The renderer to draw on. 59 | * \param x The X coordinate of the upper left corner of the string. 60 | * \param y The Y coordinate of the upper left corner of the string. 61 | * \param s The string to draw. 62 | * 63 | * \returns Returns 0 on success, -1 on failure. 64 | */ 65 | int SDLTest_DrawString( SDL_Renderer * renderer, int x, int y, const char *s ); 66 | 67 | 68 | /* Ends C function definitions when using C++ */ 69 | #ifdef __cplusplus 70 | } 71 | #endif 72 | #include "close_code.h" 73 | 74 | #endif /* _SDL_test_font_h */ 75 | 76 | /* vi: set ts=4 sw=4 expandtab: */ 77 | -------------------------------------------------------------------------------- /demos/sdl/include/SDL_test_harness.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | /** 23 | * \file SDL_test_harness.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* 31 | Defines types for test case definitions and the test execution harness API. 32 | 33 | Based on original GSOC code by Markus Kauppila 34 | */ 35 | 36 | #ifndef _SDL_test_harness_h 37 | #define _SDL_test_harness_h 38 | 39 | #include "begin_code.h" 40 | /* Set up for C function definitions, even when using C++ */ 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | 46 | /* ! Definitions for test case structures */ 47 | #define TEST_ENABLED 1 48 | #define TEST_DISABLED 0 49 | 50 | /* ! Definition of all the possible test return values of the test case method */ 51 | #define TEST_ABORTED -1 52 | #define TEST_STARTED 0 53 | #define TEST_COMPLETED 1 54 | #define TEST_SKIPPED 2 55 | 56 | /* ! Definition of all the possible test results for the harness */ 57 | #define TEST_RESULT_PASSED 0 58 | #define TEST_RESULT_FAILED 1 59 | #define TEST_RESULT_NO_ASSERT 2 60 | #define TEST_RESULT_SKIPPED 3 61 | #define TEST_RESULT_SETUP_FAILURE 4 62 | 63 | /* !< Function pointer to a test case setup function (run before every test) */ 64 | typedef void (*SDLTest_TestCaseSetUpFp)(void *arg); 65 | 66 | /* !< Function pointer to a test case function */ 67 | typedef int (*SDLTest_TestCaseFp)(void *arg); 68 | 69 | /* !< Function pointer to a test case teardown function (run after every test) */ 70 | typedef void (*SDLTest_TestCaseTearDownFp)(void *arg); 71 | 72 | /** 73 | * Holds information about a single test case. 74 | */ 75 | typedef struct SDLTest_TestCaseReference { 76 | /* !< Func2Stress */ 77 | SDLTest_TestCaseFp testCase; 78 | /* !< Short name (or function name) "Func2Stress" */ 79 | char *name; 80 | /* !< Long name or full description "This test pushes func2() to the limit." */ 81 | char *description; 82 | /* !< Set to TEST_ENABLED or TEST_DISABLED (test won't be run) */ 83 | int enabled; 84 | } SDLTest_TestCaseReference; 85 | 86 | /** 87 | * Holds information about a test suite (multiple test cases). 88 | */ 89 | typedef struct SDLTest_TestSuiteReference { 90 | /* !< "PlatformSuite" */ 91 | char *name; 92 | /* !< The function that is run before each test. NULL skips. */ 93 | SDLTest_TestCaseSetUpFp testSetUp; 94 | /* !< The test cases that are run as part of the suite. Last item should be NULL. */ 95 | const SDLTest_TestCaseReference **testCases; 96 | /* !< The function that is run after each test. NULL skips. */ 97 | SDLTest_TestCaseTearDownFp testTearDown; 98 | } SDLTest_TestSuiteReference; 99 | 100 | 101 | /** 102 | * \brief Execute a test suite using the given run seed and execution key. 103 | * 104 | * \param testSuites Suites containing the test case. 105 | * \param userRunSeed Custom run seed provided by user, or NULL to autogenerate one. 106 | * \param userExecKey Custom execution key provided by user, or 0 to autogenerate one. 107 | * \param filter Filter specification. NULL disables. Case sensitive. 108 | * \param testIterations Number of iterations to run each test case. 109 | * 110 | * \returns Test run result; 0 when all tests passed, 1 if any tests failed. 111 | */ 112 | int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *userRunSeed, Uint64 userExecKey, const char *filter, int testIterations); 113 | 114 | 115 | /* Ends C function definitions when using C++ */ 116 | #ifdef __cplusplus 117 | } 118 | #endif 119 | #include "close_code.h" 120 | 121 | #endif /* _SDL_test_harness_h */ 122 | 123 | /* vi: set ts=4 sw=4 expandtab: */ 124 | -------------------------------------------------------------------------------- /demos/sdl/include/SDL_test_images.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | /** 23 | * \file SDL_test_images.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* 31 | 32 | Defines some images for tests. 33 | 34 | */ 35 | 36 | #ifndef _SDL_test_images_h 37 | #define _SDL_test_images_h 38 | 39 | #include "SDL.h" 40 | 41 | #include "begin_code.h" 42 | /* Set up for C function definitions, even when using C++ */ 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | /** 48 | *Type for test images. 49 | */ 50 | typedef struct SDLTest_SurfaceImage_s { 51 | int width; 52 | int height; 53 | unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */ 54 | const char *pixel_data; 55 | } SDLTest_SurfaceImage_t; 56 | 57 | /* Test images */ 58 | SDL_Surface *SDLTest_ImageBlit(); 59 | SDL_Surface *SDLTest_ImageBlitColor(); 60 | SDL_Surface *SDLTest_ImageBlitAlpha(); 61 | SDL_Surface *SDLTest_ImageBlitBlendAdd(); 62 | SDL_Surface *SDLTest_ImageBlitBlend(); 63 | SDL_Surface *SDLTest_ImageBlitBlendMod(); 64 | SDL_Surface *SDLTest_ImageBlitBlendNone(); 65 | SDL_Surface *SDLTest_ImageBlitBlendAll(); 66 | SDL_Surface *SDLTest_ImageFace(); 67 | SDL_Surface *SDLTest_ImagePrimitives(); 68 | SDL_Surface *SDLTest_ImagePrimitivesBlend(); 69 | 70 | /* Ends C function definitions when using C++ */ 71 | #ifdef __cplusplus 72 | } 73 | #endif 74 | #include "close_code.h" 75 | 76 | #endif /* _SDL_test_images_h */ 77 | 78 | /* vi: set ts=4 sw=4 expandtab: */ 79 | -------------------------------------------------------------------------------- /demos/sdl/include/SDL_test_log.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | /** 23 | * \file SDL_test_log.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* 31 | * 32 | * Wrapper to log in the TEST category 33 | * 34 | */ 35 | 36 | #ifndef _SDL_test_log_h 37 | #define _SDL_test_log_h 38 | 39 | #include "begin_code.h" 40 | /* Set up for C function definitions, even when using C++ */ 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | /** 46 | * \brief Prints given message with a timestamp in the TEST category and INFO priority. 47 | * 48 | * \param fmt Message to be logged 49 | */ 50 | void SDLTest_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); 51 | 52 | /** 53 | * \brief Prints given message with a timestamp in the TEST category and the ERROR priority. 54 | * 55 | * \param fmt Message to be logged 56 | */ 57 | void SDLTest_LogError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(1); 58 | 59 | /* Ends C function definitions when using C++ */ 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | #include "close_code.h" 64 | 65 | #endif /* _SDL_test_log_h */ 66 | 67 | /* vi: set ts=4 sw=4 expandtab: */ 68 | -------------------------------------------------------------------------------- /demos/sdl/include/SDL_test_random.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | /** 23 | * \file SDL_test_random.h 24 | * 25 | * Include file for SDL test framework. 26 | * 27 | * This code is a part of the SDL2_test library, not the main SDL library. 28 | */ 29 | 30 | /* 31 | 32 | A "32-bit Multiply with carry random number generator. Very fast. 33 | Includes a list of recommended multipliers. 34 | 35 | multiply-with-carry generator: x(n) = a*x(n-1) + carry mod 2^32. 36 | period: (a*2^31)-1 37 | 38 | */ 39 | 40 | #ifndef _SDL_test_random_h 41 | #define _SDL_test_random_h 42 | 43 | #include "begin_code.h" 44 | /* Set up for C function definitions, even when using C++ */ 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | /* --- Definitions */ 50 | 51 | /* 52 | * Macros that return a random number in a specific format. 53 | */ 54 | #define SDLTest_RandomInt(c) ((int)SDLTest_Random(c)) 55 | 56 | /* 57 | * Context structure for the random number generator state. 58 | */ 59 | typedef struct { 60 | unsigned int a; 61 | unsigned int x; 62 | unsigned int c; 63 | unsigned int ah; 64 | unsigned int al; 65 | } SDLTest_RandomContext; 66 | 67 | 68 | /* --- Function prototypes */ 69 | 70 | /** 71 | * \brief Initialize random number generator with two integers. 72 | * 73 | * Note: The random sequence of numbers returned by ...Random() is the 74 | * same for the same two integers and has a period of 2^31. 75 | * 76 | * \param rndContext pointer to context structure 77 | * \param xi integer that defines the random sequence 78 | * \param ci integer that defines the random sequence 79 | * 80 | */ 81 | void SDLTest_RandomInit(SDLTest_RandomContext * rndContext, unsigned int xi, 82 | unsigned int ci); 83 | 84 | /** 85 | * \brief Initialize random number generator based on current system time. 86 | * 87 | * \param rndContext pointer to context structure 88 | * 89 | */ 90 | void SDLTest_RandomInitTime(SDLTest_RandomContext *rndContext); 91 | 92 | 93 | /** 94 | * \brief Initialize random number generator based on current system time. 95 | * 96 | * Note: ...RandomInit() or ...RandomInitTime() must have been called 97 | * before using this function. 98 | * 99 | * \param rndContext pointer to context structure 100 | * 101 | * \returns A random number (32bit unsigned integer) 102 | * 103 | */ 104 | unsigned int SDLTest_Random(SDLTest_RandomContext *rndContext); 105 | 106 | 107 | /* Ends C function definitions when using C++ */ 108 | #ifdef __cplusplus 109 | } 110 | #endif 111 | #include "close_code.h" 112 | 113 | #endif /* _SDL_test_random_h */ 114 | 115 | /* vi: set ts=4 sw=4 expandtab: */ 116 | -------------------------------------------------------------------------------- /demos/sdl/include/SDL_timer.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | #ifndef _SDL_timer_h 23 | #define _SDL_timer_h 24 | 25 | /** 26 | * \file SDL_timer.h 27 | * 28 | * Header for the SDL time management routines. 29 | */ 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 | /** 41 | * \brief Get the number of milliseconds since the SDL library initialization. 42 | * 43 | * \note This value wraps if the program runs for more than ~49 days. 44 | */ 45 | extern DECLSPEC Uint32 SDLCALL SDL_GetTicks(void); 46 | 47 | /** 48 | * \brief Compare SDL ticks values, and return true if A has passed B 49 | * 50 | * e.g. if you want to wait 100 ms, you could do this: 51 | * Uint32 timeout = SDL_GetTicks() + 100; 52 | * while (!SDL_TICKS_PASSED(SDL_GetTicks(), timeout)) { 53 | * ... do work until timeout has elapsed 54 | * } 55 | */ 56 | #define SDL_TICKS_PASSED(A, B) ((Sint32)((B) - (A)) <= 0) 57 | 58 | /** 59 | * \brief Get the current value of the high resolution counter 60 | */ 61 | extern DECLSPEC Uint64 SDLCALL SDL_GetPerformanceCounter(void); 62 | 63 | /** 64 | * \brief Get the count per second of the high resolution counter 65 | */ 66 | extern DECLSPEC Uint64 SDLCALL SDL_GetPerformanceFrequency(void); 67 | 68 | /** 69 | * \brief Wait a specified number of milliseconds before returning. 70 | */ 71 | extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms); 72 | 73 | /** 74 | * Function prototype for the timer callback function. 75 | * 76 | * The callback function is passed the current timer interval and returns 77 | * the next timer interval. If the returned value is the same as the one 78 | * passed in, the periodic alarm continues, otherwise a new alarm is 79 | * scheduled. If the callback returns 0, the periodic alarm is cancelled. 80 | */ 81 | typedef Uint32 (SDLCALL * SDL_TimerCallback) (Uint32 interval, void *param); 82 | 83 | /** 84 | * Definition of the timer ID type. 85 | */ 86 | typedef int SDL_TimerID; 87 | 88 | /** 89 | * \brief Add a new timer to the pool of timers already running. 90 | * 91 | * \return A timer ID, or 0 when an error occurs. 92 | */ 93 | extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval, 94 | SDL_TimerCallback callback, 95 | void *param); 96 | 97 | /** 98 | * \brief Remove a timer knowing its ID. 99 | * 100 | * \return A boolean value indicating success or failure. 101 | * 102 | * \warning It is not safe to remove a timer multiple times. 103 | */ 104 | extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID id); 105 | 106 | 107 | /* Ends C function definitions when using C++ */ 108 | #ifdef __cplusplus 109 | } 110 | #endif 111 | #include "close_code.h" 112 | 113 | #endif /* _SDL_timer_h */ 114 | 115 | /* vi: set ts=4 sw=4 expandtab: */ 116 | -------------------------------------------------------------------------------- /demos/sdl/include/SDL_touch.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | /** 23 | * \file SDL_touch.h 24 | * 25 | * Include file for SDL touch event handling. 26 | */ 27 | 28 | #ifndef _SDL_touch_h 29 | #define _SDL_touch_h 30 | 31 | #include "SDL_stdinc.h" 32 | #include "SDL_error.h" 33 | #include "SDL_video.h" 34 | 35 | #include "begin_code.h" 36 | /* Set up for C function definitions, even when using C++ */ 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | typedef Sint64 SDL_TouchID; 42 | typedef Sint64 SDL_FingerID; 43 | 44 | typedef struct SDL_Finger 45 | { 46 | SDL_FingerID id; 47 | float x; 48 | float y; 49 | float pressure; 50 | } SDL_Finger; 51 | 52 | /* Used as the device ID for mouse events simulated with touch input */ 53 | #define SDL_TOUCH_MOUSEID ((Uint32)-1) 54 | 55 | 56 | /* Function prototypes */ 57 | 58 | /** 59 | * \brief Get the number of registered touch devices. 60 | */ 61 | extern DECLSPEC int SDLCALL SDL_GetNumTouchDevices(void); 62 | 63 | /** 64 | * \brief Get the touch ID with the given index, or 0 if the index is invalid. 65 | */ 66 | extern DECLSPEC SDL_TouchID SDLCALL SDL_GetTouchDevice(int index); 67 | 68 | /** 69 | * \brief Get the number of active fingers for a given touch device. 70 | */ 71 | extern DECLSPEC int SDLCALL SDL_GetNumTouchFingers(SDL_TouchID touchID); 72 | 73 | /** 74 | * \brief Get the finger object of the given touch, with the given index. 75 | */ 76 | extern DECLSPEC SDL_Finger * SDLCALL SDL_GetTouchFinger(SDL_TouchID touchID, int index); 77 | 78 | /* Ends C function definitions when using C++ */ 79 | #ifdef __cplusplus 80 | } 81 | #endif 82 | #include "close_code.h" 83 | 84 | #endif /* _SDL_touch_h */ 85 | 86 | /* vi: set ts=4 sw=4 expandtab: */ 87 | -------------------------------------------------------------------------------- /demos/sdl/include/SDL_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | /** 23 | * \file SDL_types.h 24 | * 25 | * \deprecated 26 | */ 27 | 28 | /* DEPRECATED */ 29 | #include "SDL_stdinc.h" 30 | -------------------------------------------------------------------------------- /demos/sdl/include/begin_code.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | /** 23 | * \file begin_code.h 24 | * 25 | * This file sets things up for C dynamic library function definitions, 26 | * static inlined functions, and structures aligned at 4-byte alignment. 27 | * If you don't like ugly C preprocessor code, don't look at this file. :) 28 | */ 29 | 30 | /* This shouldn't be nested -- included it around code only. */ 31 | #ifdef _begin_code_h 32 | #error Nested inclusion of begin_code.h 33 | #endif 34 | #define _begin_code_h 35 | 36 | #ifndef SDL_DEPRECATED 37 | # if (__GNUC__ >= 4) /* technically, this arrived in gcc 3.1, but oh well. */ 38 | # define SDL_DEPRECATED __attribute__((deprecated)) 39 | # else 40 | # define SDL_DEPRECATED 41 | # endif 42 | #endif 43 | 44 | #ifndef SDL_UNUSED 45 | # ifdef __GNUC__ 46 | # define SDL_UNUSED __attribute__((unused)) 47 | # else 48 | # define SDL_UNUSED 49 | # endif 50 | #endif 51 | 52 | /* Some compilers use a special export keyword */ 53 | #ifndef DECLSPEC 54 | # if defined(__WIN32__) || defined(__WINRT__) 55 | # ifdef __BORLANDC__ 56 | # ifdef BUILD_SDL 57 | # define DECLSPEC 58 | # else 59 | # define DECLSPEC __declspec(dllimport) 60 | # endif 61 | # else 62 | # define DECLSPEC __declspec(dllexport) 63 | # endif 64 | # else 65 | # if defined(__GNUC__) && __GNUC__ >= 4 66 | # define DECLSPEC __attribute__ ((visibility("default"))) 67 | # else 68 | # define DECLSPEC 69 | # endif 70 | # endif 71 | #endif 72 | 73 | /* By default SDL uses the C calling convention */ 74 | #ifndef SDLCALL 75 | #if (defined(__WIN32__) || defined(__WINRT__)) && !defined(__GNUC__) 76 | #define SDLCALL __cdecl 77 | #else 78 | #define SDLCALL 79 | #endif 80 | #endif /* SDLCALL */ 81 | 82 | /* Removed DECLSPEC on Symbian OS because SDL cannot be a DLL in EPOC */ 83 | #ifdef __SYMBIAN32__ 84 | #undef DECLSPEC 85 | #define DECLSPEC 86 | #endif /* __SYMBIAN32__ */ 87 | 88 | /* Force structure packing at 4 byte alignment. 89 | This is necessary if the header is included in code which has structure 90 | packing set to an alternate value, say for loading structures from disk. 91 | The packing is reset to the previous value in close_code.h 92 | */ 93 | #if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__) 94 | #ifdef _MSC_VER 95 | #pragma warning(disable: 4103) 96 | #endif 97 | #ifdef __BORLANDC__ 98 | #pragma nopackwarning 99 | #endif 100 | #ifdef _M_X64 101 | /* Use 8-byte alignment on 64-bit architectures, so pointers are aligned */ 102 | #pragma pack(push,8) 103 | #else 104 | #pragma pack(push,4) 105 | #endif 106 | #endif /* Compiler needs structure packing set */ 107 | 108 | #ifndef SDL_INLINE 109 | #if defined(__GNUC__) 110 | #define SDL_INLINE __inline__ 111 | #elif defined(_MSC_VER) || defined(__BORLANDC__) || \ 112 | defined(__DMC__) || defined(__SC__) || \ 113 | defined(__WATCOMC__) || defined(__LCC__) || \ 114 | defined(__DECC) 115 | #define SDL_INLINE __inline 116 | #ifndef __inline__ 117 | #define __inline__ __inline 118 | #endif 119 | #else 120 | #define SDL_INLINE inline 121 | #ifndef __inline__ 122 | #define __inline__ inline 123 | #endif 124 | #endif 125 | #endif /* SDL_INLINE not defined */ 126 | 127 | #ifndef SDL_FORCE_INLINE 128 | #if defined(_MSC_VER) 129 | #define SDL_FORCE_INLINE __forceinline 130 | #elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) ) 131 | #define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__ 132 | #else 133 | #define SDL_FORCE_INLINE static SDL_INLINE 134 | #endif 135 | #endif /* SDL_FORCE_INLINE not defined */ 136 | 137 | /* Apparently this is needed by several Windows compilers */ 138 | #if !defined(__MACH__) 139 | #ifndef NULL 140 | #ifdef __cplusplus 141 | #define NULL 0 142 | #else 143 | #define NULL ((void *)0) 144 | #endif 145 | #endif /* NULL */ 146 | #endif /* ! Mac OS X - breaks precompiled headers */ 147 | -------------------------------------------------------------------------------- /demos/sdl/include/close_code.h: -------------------------------------------------------------------------------- 1 | /* 2 | Simple DirectMedia Layer 3 | Copyright (C) 1997-2016 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 | /** 23 | * \file close_code.h 24 | * 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 | /* Reset structure packing at previous byte alignment */ 32 | #if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__) 33 | #ifdef __BORLANDC__ 34 | #pragma nopackwarning 35 | #endif 36 | #pragma pack(pop) 37 | #endif /* Compiler needs structure packing set */ 38 | -------------------------------------------------------------------------------- /demos/sdl/x64/SDL2.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkalten/TUIO20_CPP/b3fc7998670200091e5768747c3e04ac758084e3/demos/sdl/x64/SDL2.dll -------------------------------------------------------------------------------- /demos/sdl/x64/SDL2.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkalten/TUIO20_CPP/b3fc7998670200091e5768747c3e04ac758084e3/demos/sdl/x64/SDL2.lib -------------------------------------------------------------------------------- /demos/sdl/x64/SDL2main.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkalten/TUIO20_CPP/b3fc7998670200091e5768747c3e04ac758084e3/demos/sdl/x64/SDL2main.lib -------------------------------------------------------------------------------- /demos/sdl/x64/freeglut.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkalten/TUIO20_CPP/b3fc7998670200091e5768747c3e04ac758084e3/demos/sdl/x64/freeglut.dll -------------------------------------------------------------------------------- /demos/sdl/x64/freeglut.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkalten/TUIO20_CPP/b3fc7998670200091e5768747c3e04ac758084e3/demos/sdl/x64/freeglut.lib -------------------------------------------------------------------------------- /oscpack/CHANGES: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mkalten/TUIO20_CPP/b3fc7998670200091e5768747c3e04ac758084e3/oscpack/CHANGES -------------------------------------------------------------------------------- /oscpack/LICENSE: -------------------------------------------------------------------------------- 1 | oscpack -- Open Sound Control (OSC) packet manipulation library 2 | http://www.rossbencina.com/code/oscpack 3 | 4 | Copyright (c) 2004-2013 Ross Bencina 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files 8 | (the "Software"), to deal in the Software without restriction, 9 | including without limitation the rights to use, copy, modify, merge, 10 | publish, distribute, sublicense, and/or sell copies of the Software, 11 | and to permit persons to whom the Software is furnished to do so, 12 | subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be 15 | included in all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 19 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 20 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 21 | ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 22 | CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 23 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 | 25 | ### 26 | 27 | The text above constitutes the entire oscpack license; however, 28 | the oscpack developer(s) also make the following non-binding requests: 29 | 30 | Any person wishing to distribute modifications to the Software is 31 | requested to send the modifications to the original developer so that 32 | they can be incorporated into the canonical version. It is also 33 | requested that these non-binding requests be included whenever the 34 | above license is reproduced. -------------------------------------------------------------------------------- /oscpack/TODO: -------------------------------------------------------------------------------- 1 | TODO: 2 | 3 | - consider adding the local endpoint name to PacketListener::PacketReceived() params 4 | 5 | - consider adding ListenerThread class to support old seperate thread listener functionality, something like: 6 | 7 | class UdpSocketListenerThread{ 8 | public: 9 | UdpSocketListenerThread( UdpSocket& socket, Listener *listener ); 10 | UdpSocketListenerThread( UdpSocketReceiveMultiplexer *mux ); 11 | ~UdpSocketListenerThread(); 12 | 13 | void Run(); 14 | void Stop(); 15 | }; 16 | 17 | - work out a way to make the parsing classes totally safe. at a minimum this 18 | means adding functions to test for invalid float/doublevalues, 19 | making sure the iterators never pass the end of the message, ... 20 | (passing end of message can happen if: 21 | - too many args in type tags 22 | a. typetags overflow message size 23 | b. args fulfilling typetags overflow message size 24 | - strings too long or not terminated correctly 25 | - blobs too long or not terminated correctly 26 | 27 | if the message was fully checked during construction, the end() iterator 28 | could be moved back until only arguments which fit withing size() may 29 | be interated (this could be none). A flag could be set to indicate that 30 | something was wrong. 31 | 32 | - other packet badness could include: 33 | - time tags too far into the future (the scheduler should deal with 34 | that i guess). 35 | - message address patterns which aren't correctly terminated 36 | 37 | - improve the ability to parse messages without tags (SC uses methods which 38 | get the data and advance the iterator in one step.) 39 | - Check* could be modified to do this - ie if typetags are not present 40 | it could check that reading the field won't escape the message size 41 | and return the data, or return false if some consistency 42 | constraint is violated. 43 | (or alternately drop support for messages without type tags) 44 | 45 | 46 | - add a method to discard an inprogress message if it gets half 47 | constructed and the buffer is full in OutboundPacket 48 | 49 | - write a stress testing app which can send garbage packets to try to flush out other bugs in the parsing code. 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /oscpack/ip/IpEndpointName.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | oscpack -- Open Sound Control (OSC) packet manipulation library 3 | http://www.rossbencina.com/code/oscpack 4 | 5 | Copyright (c) 2004-2013 Ross Bencina 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining 8 | a copy of this software and associated documentation files 9 | (the "Software"), to deal in the Software without restriction, 10 | including without limitation the rights to use, copy, modify, merge, 11 | publish, distribute, sublicense, and/or sell copies of the Software, 12 | and to permit persons to whom the Software is furnished to do so, 13 | subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be 16 | included in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 21 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 22 | ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 23 | CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | /* 28 | The text above constitutes the entire oscpack license; however, 29 | the oscpack developer(s) also make the following non-binding requests: 30 | 31 | Any person wishing to distribute modifications to the Software is 32 | requested to send the modifications to the original developer so that 33 | they can be incorporated into the canonical version. It is also 34 | requested that these non-binding requests be included whenever the 35 | above license is reproduced. 36 | */ 37 | #include "IpEndpointName.h" 38 | 39 | #include 40 | 41 | #include "NetworkingUtils.h" 42 | 43 | 44 | unsigned long IpEndpointName::GetHostByName( const char *s ) 45 | { 46 | return ::GetHostByName(s); 47 | } 48 | 49 | 50 | void IpEndpointName::AddressAsString( char *s ) const 51 | { 52 | if( address == ANY_ADDRESS ){ 53 | std::sprintf( s, "" ); 54 | }else{ 55 | std::sprintf( s, "%d.%d.%d.%d", 56 | (int)((address >> 24) & 0xFF), 57 | (int)((address >> 16) & 0xFF), 58 | (int)((address >> 8) & 0xFF), 59 | (int)(address & 0xFF) ); 60 | } 61 | } 62 | 63 | 64 | void IpEndpointName::AddressAndPortAsString( char *s ) const 65 | { 66 | if( port == ANY_PORT ){ 67 | if( address == ANY_ADDRESS ){ 68 | std::sprintf( s, ":" ); 69 | }else{ 70 | std::sprintf( s, "%d.%d.%d.%d:", 71 | (int)((address >> 24) & 0xFF), 72 | (int)((address >> 16) & 0xFF), 73 | (int)((address >> 8) & 0xFF), 74 | (int)(address & 0xFF) ); 75 | } 76 | }else{ 77 | if( address == ANY_ADDRESS ){ 78 | std::sprintf( s, ":%d", port ); 79 | }else{ 80 | std::sprintf( s, "%d.%d.%d.%d:%d", 81 | (int)((address >> 24) & 0xFF), 82 | (int)((address >> 16) & 0xFF), 83 | (int)((address >> 8) & 0xFF), 84 | (int)(address & 0xFF), 85 | (int)port ); 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /oscpack/ip/IpEndpointName.h: -------------------------------------------------------------------------------- 1 | /* 2 | oscpack -- Open Sound Control (OSC) packet manipulation library 3 | http://www.rossbencina.com/code/oscpack 4 | 5 | Copyright (c) 2004-2013 Ross Bencina 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining 8 | a copy of this software and associated documentation files 9 | (the "Software"), to deal in the Software without restriction, 10 | including without limitation the rights to use, copy, modify, merge, 11 | publish, distribute, sublicense, and/or sell copies of the Software, 12 | and to permit persons to whom the Software is furnished to do so, 13 | subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be 16 | included in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 21 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 22 | ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 23 | CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | /* 28 | The text above constitutes the entire oscpack license; however, 29 | the oscpack developer(s) also make the following non-binding requests: 30 | 31 | Any person wishing to distribute modifications to the Software is 32 | requested to send the modifications to the original developer so that 33 | they can be incorporated into the canonical version. It is also 34 | requested that these non-binding requests be included whenever the 35 | above license is reproduced. 36 | */ 37 | #ifndef INCLUDED_OSCPACK_IPENDPOINTNAME_H 38 | #define INCLUDED_OSCPACK_IPENDPOINTNAME_H 39 | 40 | 41 | class IpEndpointName{ 42 | static unsigned long GetHostByName( const char *s ); 43 | public: 44 | static const unsigned long ANY_ADDRESS = 0xFFFFFFFF; 45 | static const int ANY_PORT = -1; 46 | 47 | IpEndpointName() 48 | : address( ANY_ADDRESS ), port( ANY_PORT ) {} 49 | IpEndpointName( int port_ ) 50 | : address( ANY_ADDRESS ), port( port_ ) {} 51 | IpEndpointName( unsigned long ipAddress_, int port_ ) 52 | : address( ipAddress_ ), port( port_ ) {} 53 | IpEndpointName( const char *addressName, int port_=ANY_PORT ) 54 | : address( GetHostByName( addressName ) ) 55 | , port( port_ ) {} 56 | IpEndpointName( int addressA, int addressB, int addressC, int addressD, int port_=ANY_PORT ) 57 | : address( ( (addressA << 24) | (addressB << 16) | (addressC << 8) | addressD ) ) 58 | , port( port_ ) {} 59 | 60 | // address and port are maintained in host byte order here 61 | unsigned long address; 62 | int port; 63 | 64 | bool IsMulticastAddress() const { return ((address >> 24) & 0xFF) >= 224 && ((address >> 24) & 0xFF) <= 239; } 65 | 66 | enum { ADDRESS_STRING_LENGTH=17 }; 67 | void AddressAsString( char *s ) const; 68 | 69 | enum { ADDRESS_AND_PORT_STRING_LENGTH=23}; 70 | void AddressAndPortAsString( char *s ) const; 71 | }; 72 | 73 | inline bool operator==( const IpEndpointName& lhs, const IpEndpointName& rhs ) 74 | { 75 | return (lhs.address == rhs.address && lhs.port == rhs.port ); 76 | } 77 | 78 | inline bool operator!=( const IpEndpointName& lhs, const IpEndpointName& rhs ) 79 | { 80 | return !(lhs == rhs); 81 | } 82 | 83 | #endif /* INCLUDED_OSCPACK_IPENDPOINTNAME_H */ 84 | -------------------------------------------------------------------------------- /oscpack/ip/NetworkingUtils.h: -------------------------------------------------------------------------------- 1 | /* 2 | oscpack -- Open Sound Control (OSC) packet manipulation library 3 | http://www.rossbencina.com/code/oscpack 4 | 5 | Copyright (c) 2004-2013 Ross Bencina 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining 8 | a copy of this software and associated documentation files 9 | (the "Software"), to deal in the Software without restriction, 10 | including without limitation the rights to use, copy, modify, merge, 11 | publish, distribute, sublicense, and/or sell copies of the Software, 12 | and to permit persons to whom the Software is furnished to do so, 13 | subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be 16 | included in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 21 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 22 | ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 23 | CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | /* 28 | The text above constitutes the entire oscpack license; however, 29 | the oscpack developer(s) also make the following non-binding requests: 30 | 31 | Any person wishing to distribute modifications to the Software is 32 | requested to send the modifications to the original developer so that 33 | they can be incorporated into the canonical version. It is also 34 | requested that these non-binding requests be included whenever the 35 | above license is reproduced. 36 | */ 37 | #ifndef INCLUDED_OSCPACK_NETWORKINGUTILS_H 38 | #define INCLUDED_OSCPACK_NETWORKINGUTILS_H 39 | 40 | 41 | // in general NetworkInitializer is only used internally, but if you're 42 | // application creates multiple sockets from different threads at runtime you 43 | // should instantiate one of these in main just to make sure the networking 44 | // layer is initialized. 45 | class NetworkInitializer{ 46 | public: 47 | NetworkInitializer(); 48 | ~NetworkInitializer(); 49 | }; 50 | 51 | 52 | // return ip address of host name in host byte order 53 | unsigned long GetHostByName( const char *name ); 54 | 55 | 56 | #endif /* INCLUDED_OSCPACK_NETWORKINGUTILS_H */ 57 | -------------------------------------------------------------------------------- /oscpack/ip/PacketListener.h: -------------------------------------------------------------------------------- 1 | /* 2 | oscpack -- Open Sound Control (OSC) packet manipulation library 3 | http://www.rossbencina.com/code/oscpack 4 | 5 | Copyright (c) 2004-2013 Ross Bencina 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining 8 | a copy of this software and associated documentation files 9 | (the "Software"), to deal in the Software without restriction, 10 | including without limitation the rights to use, copy, modify, merge, 11 | publish, distribute, sublicense, and/or sell copies of the Software, 12 | and to permit persons to whom the Software is furnished to do so, 13 | subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be 16 | included in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 21 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 22 | ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 23 | CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | /* 28 | The text above constitutes the entire oscpack license; however, 29 | the oscpack developer(s) also make the following non-binding requests: 30 | 31 | Any person wishing to distribute modifications to the Software is 32 | requested to send the modifications to the original developer so that 33 | they can be incorporated into the canonical version. It is also 34 | requested that these non-binding requests be included whenever the 35 | above license is reproduced. 36 | */ 37 | #ifndef INCLUDED_OSCPACK_PACKETLISTENER_H 38 | #define INCLUDED_OSCPACK_PACKETLISTENER_H 39 | 40 | 41 | class IpEndpointName; 42 | 43 | class PacketListener{ 44 | public: 45 | virtual ~PacketListener() {} 46 | virtual void ProcessPacket( const char *data, int size, 47 | const IpEndpointName& remoteEndpoint ) = 0; 48 | }; 49 | 50 | #endif /* INCLUDED_OSCPACK_PACKETLISTENER_H */ 51 | -------------------------------------------------------------------------------- /oscpack/ip/TimerListener.h: -------------------------------------------------------------------------------- 1 | /* 2 | oscpack -- Open Sound Control (OSC) packet manipulation library 3 | http://www.rossbencina.com/code/oscpack 4 | 5 | Copyright (c) 2004-2013 Ross Bencina 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining 8 | a copy of this software and associated documentation files 9 | (the "Software"), to deal in the Software without restriction, 10 | including without limitation the rights to use, copy, modify, merge, 11 | publish, distribute, sublicense, and/or sell copies of the Software, 12 | and to permit persons to whom the Software is furnished to do so, 13 | subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be 16 | included in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 21 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 22 | ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 23 | CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | /* 28 | The text above constitutes the entire oscpack license; however, 29 | the oscpack developer(s) also make the following non-binding requests: 30 | 31 | Any person wishing to distribute modifications to the Software is 32 | requested to send the modifications to the original developer so that 33 | they can be incorporated into the canonical version. It is also 34 | requested that these non-binding requests be included whenever the 35 | above license is reproduced. 36 | */ 37 | #ifndef INCLUDED_OSCPACK_TIMERLISTENER_H 38 | #define INCLUDED_OSCPACK_TIMERLISTENER_H 39 | 40 | 41 | class TimerListener{ 42 | public: 43 | virtual ~TimerListener() {} 44 | virtual void TimerExpired() = 0; 45 | }; 46 | 47 | #endif /* INCLUDED_OSCPACK_TIMERLISTENER_H */ 48 | -------------------------------------------------------------------------------- /oscpack/ip/posix/NetworkingUtils.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | oscpack -- Open Sound Control (OSC) packet manipulation library 3 | http://www.rossbencina.com/code/oscpack 4 | 5 | Copyright (c) 2004-2013 Ross Bencina 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining 8 | a copy of this software and associated documentation files 9 | (the "Software"), to deal in the Software without restriction, 10 | including without limitation the rights to use, copy, modify, merge, 11 | publish, distribute, sublicense, and/or sell copies of the Software, 12 | and to permit persons to whom the Software is furnished to do so, 13 | subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be 16 | included in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 21 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 22 | ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 23 | CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | /* 28 | The text above constitutes the entire oscpack license; however, 29 | the oscpack developer(s) also make the following non-binding requests: 30 | 31 | Any person wishing to distribute modifications to the Software is 32 | requested to send the modifications to the original developer so that 33 | they can be incorporated into the canonical version. It is also 34 | requested that these non-binding requests be included whenever the 35 | above license is reproduced. 36 | */ 37 | #include "ip/NetworkingUtils.h" 38 | 39 | #include 40 | #include 41 | #include 42 | 43 | #include 44 | 45 | 46 | 47 | NetworkInitializer::NetworkInitializer() {} 48 | 49 | NetworkInitializer::~NetworkInitializer() {} 50 | 51 | 52 | unsigned long GetHostByName( const char *name ) 53 | { 54 | unsigned long result = 0; 55 | 56 | struct hostent *h = gethostbyname( name ); 57 | if( h ){ 58 | struct in_addr a; 59 | std::memcpy( &a, h->h_addr_list[0], h->h_length ); 60 | result = ntohl(a.s_addr); 61 | } 62 | 63 | return result; 64 | } 65 | -------------------------------------------------------------------------------- /oscpack/ip/win32/NetworkingUtils.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | oscpack -- Open Sound Control (OSC) packet manipulation library 3 | http://www.rossbencina.com/code/oscpack 4 | 5 | Copyright (c) 2004-2013 Ross Bencina 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining 8 | a copy of this software and associated documentation files 9 | (the "Software"), to deal in the Software without restriction, 10 | including without limitation the rights to use, copy, modify, merge, 11 | publish, distribute, sublicense, and/or sell copies of the Software, 12 | and to permit persons to whom the Software is furnished to do so, 13 | subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be 16 | included in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 21 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 22 | ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 23 | CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | /* 28 | The text above constitutes the entire oscpack license; however, 29 | the oscpack developer(s) also make the following non-binding requests: 30 | 31 | Any person wishing to distribute modifications to the Software is 32 | requested to send the modifications to the original developer so that 33 | they can be incorporated into the canonical version. It is also 34 | requested that these non-binding requests be included whenever the 35 | above license is reproduced. 36 | */ 37 | #include "ip/NetworkingUtils.h" 38 | 39 | #include // this must come first to prevent errors with MSVC7 40 | #include 41 | 42 | #include 43 | 44 | 45 | static LONG initCount_ = 0; 46 | static bool winsockInitialized_ = false; 47 | 48 | NetworkInitializer::NetworkInitializer() 49 | { 50 | if( InterlockedIncrement( &initCount_ ) == 1 ){ 51 | // there is a race condition here if one thread tries to access 52 | // the library while another is still initializing it. 53 | // i can't think of an easy way to fix it so i'm telling you here 54 | // incase you need to init the library from two threads at once. 55 | // this is why the header file advises to instantiate one of these 56 | // in main() so that the initialization happens globally 57 | 58 | // initialize winsock 59 | WSAData wsaData; 60 | int nCode = WSAStartup(MAKEWORD(1, 1), &wsaData); 61 | if( nCode != 0 ){ 62 | //std::cout << "WSAStartup() failed with error code " << nCode << "\n"; 63 | }else{ 64 | winsockInitialized_ = true; 65 | } 66 | } 67 | } 68 | 69 | 70 | NetworkInitializer::~NetworkInitializer() 71 | { 72 | if( InterlockedDecrement( &initCount_ ) == 0 ){ 73 | if( winsockInitialized_ ){ 74 | WSACleanup(); 75 | winsockInitialized_ = false; 76 | } 77 | } 78 | } 79 | 80 | 81 | unsigned long GetHostByName( const char *name ) 82 | { 83 | NetworkInitializer networkInitializer; 84 | 85 | unsigned long result = 0; 86 | 87 | struct hostent *h = gethostbyname( name ); 88 | if( h ){ 89 | struct in_addr a; 90 | std::memcpy( &a, h->h_addr_list[0], h->h_length ); 91 | result = ntohl(a.s_addr); 92 | } 93 | 94 | return result; 95 | } 96 | -------------------------------------------------------------------------------- /oscpack/osc/MessageMappingOscPacketListener.h: -------------------------------------------------------------------------------- 1 | /* 2 | oscpack -- Open Sound Control (OSC) packet manipulation library 3 | http://www.rossbencina.com/code/oscpack 4 | 5 | Copyright (c) 2004-2013 Ross Bencina 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining 8 | a copy of this software and associated documentation files 9 | (the "Software"), to deal in the Software without restriction, 10 | including without limitation the rights to use, copy, modify, merge, 11 | publish, distribute, sublicense, and/or sell copies of the Software, 12 | and to permit persons to whom the Software is furnished to do so, 13 | subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be 16 | included in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 21 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 22 | ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 23 | CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | /* 28 | The text above constitutes the entire oscpack license; however, 29 | the oscpack developer(s) also make the following non-binding requests: 30 | 31 | Any person wishing to distribute modifications to the Software is 32 | requested to send the modifications to the original developer so that 33 | they can be incorporated into the canonical version. It is also 34 | requested that these non-binding requests be included whenever the 35 | above license is reproduced. 36 | */ 37 | #ifndef INCLUDED_OSCPACK_MESSAGEMAPPINGOSCPACKETLISTENER_H 38 | #define INCLUDED_OSCPACK_MESSAGEMAPPINGOSCPACKETLISTENER_H 39 | 40 | #include 41 | #include 42 | 43 | #include "OscPacketListener.h" 44 | 45 | 46 | 47 | namespace osc{ 48 | 49 | template< class T > 50 | class MessageMappingOscPacketListener : public OscPacketListener{ 51 | public: 52 | typedef void (T::*function_type)(const osc::ReceivedMessage&, const IpEndpointName&); 53 | 54 | protected: 55 | void RegisterMessageFunction( const char *addressPattern, function_type f ) 56 | { 57 | functions_.insert( std::make_pair( addressPattern, f ) ); 58 | } 59 | 60 | virtual void ProcessMessage( const osc::ReceivedMessage& m, 61 | const IpEndpointName& remoteEndpoint ) 62 | { 63 | typename function_map_type::iterator i = functions_.find( m.AddressPattern() ); 64 | if( i != functions_.end() ) 65 | (dynamic_cast(this)->*(i->second))( m, remoteEndpoint ); 66 | } 67 | 68 | private: 69 | struct cstr_compare{ 70 | bool operator()( const char *lhs, const char *rhs ) const 71 | { return std::strcmp( lhs, rhs ) < 0; } 72 | }; 73 | 74 | typedef std::map function_map_type; 75 | function_map_type functions_; 76 | }; 77 | 78 | } // namespace osc 79 | 80 | #endif /* INCLUDED_OSCPACK_MESSAGEMAPPINGOSCPACKETLISTENER_H */ -------------------------------------------------------------------------------- /oscpack/osc/OscException.h: -------------------------------------------------------------------------------- 1 | /* 2 | oscpack -- Open Sound Control (OSC) packet manipulation library 3 | http://www.rossbencina.com/code/oscpack 4 | 5 | Copyright (c) 2004-2013 Ross Bencina 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining 8 | a copy of this software and associated documentation files 9 | (the "Software"), to deal in the Software without restriction, 10 | including without limitation the rights to use, copy, modify, merge, 11 | publish, distribute, sublicense, and/or sell copies of the Software, 12 | and to permit persons to whom the Software is furnished to do so, 13 | subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be 16 | included in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 21 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 22 | ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 23 | CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | /* 28 | The text above constitutes the entire oscpack license; however, 29 | the oscpack developer(s) also make the following non-binding requests: 30 | 31 | Any person wishing to distribute modifications to the Software is 32 | requested to send the modifications to the original developer so that 33 | they can be incorporated into the canonical version. It is also 34 | requested that these non-binding requests be included whenever the 35 | above license is reproduced. 36 | */ 37 | #ifndef INCLUDED_OSCPACK_OSCEXCEPTION_H 38 | #define INCLUDED_OSCPACK_OSCEXCEPTION_H 39 | 40 | #include 41 | 42 | namespace osc{ 43 | 44 | class Exception : public std::exception { 45 | const char *what_; 46 | 47 | public: 48 | Exception() throw() {} 49 | Exception( const Exception& src ) throw() 50 | : std::exception( src ) 51 | , what_( src.what_ ) {} 52 | Exception( const char *w ) throw() 53 | : what_( w ) {} 54 | Exception& operator=( const Exception& src ) throw() 55 | { what_ = src.what_; return *this; } 56 | virtual ~Exception() throw() {} 57 | virtual const char* what() const throw() { return what_; } 58 | }; 59 | 60 | } // namespace osc 61 | 62 | #endif /* INCLUDED_OSCPACK_OSCEXCEPTION_H */ 63 | -------------------------------------------------------------------------------- /oscpack/osc/OscHostEndianness.h: -------------------------------------------------------------------------------- 1 | /* 2 | oscpack -- Open Sound Control (OSC) packet manipulation library 3 | http://www.rossbencina.com/code/oscpack 4 | 5 | Copyright (c) 2004-2013 Ross Bencina 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining 8 | a copy of this software and associated documentation files 9 | (the "Software"), to deal in the Software without restriction, 10 | including without limitation the rights to use, copy, modify, merge, 11 | publish, distribute, sublicense, and/or sell copies of the Software, 12 | and to permit persons to whom the Software is furnished to do so, 13 | subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be 16 | included in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 21 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 22 | ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 23 | CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | /* 28 | The text above constitutes the entire oscpack license; however, 29 | the oscpack developer(s) also make the following non-binding requests: 30 | 31 | Any person wishing to distribute modifications to the Software is 32 | requested to send the modifications to the original developer so that 33 | they can be incorporated into the canonical version. It is also 34 | requested that these non-binding requests be included whenever the 35 | above license is reproduced. 36 | */ 37 | #ifndef INCLUDED_OSCPACK_OSCHOSTENDIANNESS_H 38 | #define INCLUDED_OSCPACK_OSCHOSTENDIANNESS_H 39 | 40 | /* 41 | Make sure either OSC_HOST_LITTLE_ENDIAN or OSC_HOST_BIG_ENDIAN is defined 42 | 43 | We try to use preprocessor symbols to deduce the host endianness. 44 | 45 | Alternatively you can define one of the above symbols from the command line. 46 | Usually you do this with the -D flag to the compiler. e.g.: 47 | 48 | $ g++ -DOSC_HOST_LITTLE_ENDIAN ... 49 | */ 50 | 51 | #if defined(OSC_HOST_LITTLE_ENDIAN) || defined(OSC_HOST_BIG_ENDIAN) 52 | 53 | // endianness defined on the command line. nothing to do here. 54 | 55 | #elif defined(__WIN32__) || defined(WIN32) || defined(WINCE) 56 | 57 | // assume that __WIN32__ is only defined on little endian systems 58 | 59 | #define OSC_HOST_LITTLE_ENDIAN 1 60 | #undef OSC_HOST_BIG_ENDIAN 61 | 62 | #elif defined(__APPLE__) 63 | 64 | #if defined(__LITTLE_ENDIAN__) 65 | 66 | #define OSC_HOST_LITTLE_ENDIAN 1 67 | #undef OSC_HOST_BIG_ENDIAN 68 | 69 | #elif defined(__BIG_ENDIAN__) 70 | 71 | #define OSC_HOST_BIG_ENDIAN 1 72 | #undef OSC_HOST_LITTLE_ENDIAN 73 | 74 | #endif 75 | 76 | #elif defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && defined(__ORDER_BIG_ENDIAN__) 77 | 78 | // should cover gcc and clang 79 | 80 | #if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) 81 | 82 | #define OSC_HOST_LITTLE_ENDIAN 1 83 | #undef OSC_HOST_BIG_ENDIAN 84 | 85 | #elif (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) 86 | 87 | #define OSC_HOST_BIG_ENDIAN 1 88 | #undef OSC_HOST_LITTLE_ENDIAN 89 | 90 | #endif 91 | 92 | #else 93 | 94 | // gcc defines __LITTLE_ENDIAN__ and __BIG_ENDIAN__ 95 | // for others used here see http://sourceforge.net/p/predef/wiki/Endianness/ 96 | #if (defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)) \ 97 | || (defined(__ARMEL__) && !defined(__ARMEB__)) \ 98 | || (defined(__AARCH64EL__) && !defined(__AARCH64EB__)) \ 99 | || (defined(_MIPSEL) && !defined(_MIPSEB)) \ 100 | || (defined(__MIPSEL) && !defined(__MIPSEB)) \ 101 | || (defined(__MIPSEL__) && !defined(__MIPSEB__)) 102 | 103 | #define OSC_HOST_LITTLE_ENDIAN 1 104 | #undef OSC_HOST_BIG_ENDIAN 105 | 106 | #elif (defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__)) \ 107 | || (defined(__ARMEB__) && !defined(__ARMEL__)) \ 108 | || (defined(__AARCH64EB__) && !defined(__AARCH64EL__)) \ 109 | || (defined(_MIPSEB) && !defined(_MIPSEL)) \ 110 | || (defined(__MIPSEB) && !defined(__MIPSEL)) \ 111 | || (defined(__MIPSEB__) && !defined(__MIPSEL__)) 112 | 113 | #define OSC_HOST_BIG_ENDIAN 1 114 | #undef OSC_HOST_LITTLE_ENDIAN 115 | 116 | #endif 117 | 118 | #endif 119 | 120 | #if !defined(OSC_HOST_LITTLE_ENDIAN) && !defined(OSC_HOST_BIG_ENDIAN) 121 | 122 | #error please edit OSCHostEndianness.h or define one of {OSC_HOST_LITTLE_ENDIAN, OSC_HOST_BIG_ENDIAN} to configure endianness 123 | 124 | #endif 125 | 126 | #endif /* INCLUDED_OSCPACK_OSCHOSTENDIANNESS_H */ 127 | 128 | -------------------------------------------------------------------------------- /oscpack/osc/OscPacketListener.h: -------------------------------------------------------------------------------- 1 | /* 2 | oscpack -- Open Sound Control (OSC) packet manipulation library 3 | http://www.rossbencina.com/code/oscpack 4 | 5 | Copyright (c) 2004-2013 Ross Bencina 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining 8 | a copy of this software and associated documentation files 9 | (the "Software"), to deal in the Software without restriction, 10 | including without limitation the rights to use, copy, modify, merge, 11 | publish, distribute, sublicense, and/or sell copies of the Software, 12 | and to permit persons to whom the Software is furnished to do so, 13 | subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be 16 | included in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 21 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 22 | ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 23 | CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | /* 28 | The text above constitutes the entire oscpack license; however, 29 | the oscpack developer(s) also make the following non-binding requests: 30 | 31 | Any person wishing to distribute modifications to the Software is 32 | requested to send the modifications to the original developer so that 33 | they can be incorporated into the canonical version. It is also 34 | requested that these non-binding requests be included whenever the 35 | above license is reproduced. 36 | */ 37 | #ifndef INCLUDED_OSCPACK_OSCPACKETLISTENER_H 38 | #define INCLUDED_OSCPACK_OSCPACKETLISTENER_H 39 | 40 | #include "OscReceivedElements.h" 41 | #include "../ip/PacketListener.h" 42 | 43 | 44 | namespace osc{ 45 | 46 | class OscPacketListener : public PacketListener{ 47 | protected: 48 | virtual void ProcessBundle( const osc::ReceivedBundle& b, 49 | const IpEndpointName& remoteEndpoint ) 50 | { 51 | // ignore bundle time tag for now 52 | 53 | for( ReceivedBundle::const_iterator i = b.ElementsBegin(); 54 | i != b.ElementsEnd(); ++i ){ 55 | if( i->IsBundle() ) 56 | ProcessBundle( ReceivedBundle(*i), remoteEndpoint ); 57 | else 58 | ProcessMessage( ReceivedMessage(*i), remoteEndpoint ); 59 | } 60 | } 61 | 62 | virtual void ProcessMessage( const osc::ReceivedMessage& m, 63 | const IpEndpointName& remoteEndpoint ) = 0; 64 | 65 | public: 66 | virtual void ProcessPacket( const char *data, int size, 67 | const IpEndpointName& remoteEndpoint ) 68 | { 69 | osc::ReceivedPacket p( data, size ); 70 | if( p.IsBundle() ) 71 | ProcessBundle( ReceivedBundle(p), remoteEndpoint ); 72 | else 73 | ProcessMessage( ReceivedMessage(p), remoteEndpoint ); 74 | } 75 | }; 76 | 77 | } // namespace osc 78 | 79 | #endif /* INCLUDED_OSCPACK_OSCPACKETLISTENER_H */ 80 | -------------------------------------------------------------------------------- /oscpack/osc/OscPrintReceivedElements.h: -------------------------------------------------------------------------------- 1 | /* 2 | oscpack -- Open Sound Control (OSC) packet manipulation library 3 | http://www.rossbencina.com/code/oscpack 4 | 5 | Copyright (c) 2004-2013 Ross Bencina 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining 8 | a copy of this software and associated documentation files 9 | (the "Software"), to deal in the Software without restriction, 10 | including without limitation the rights to use, copy, modify, merge, 11 | publish, distribute, sublicense, and/or sell copies of the Software, 12 | and to permit persons to whom the Software is furnished to do so, 13 | subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be 16 | included in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 21 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 22 | ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 23 | CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | /* 28 | The text above constitutes the entire oscpack license; however, 29 | the oscpack developer(s) also make the following non-binding requests: 30 | 31 | Any person wishing to distribute modifications to the Software is 32 | requested to send the modifications to the original developer so that 33 | they can be incorporated into the canonical version. It is also 34 | requested that these non-binding requests be included whenever the 35 | above license is reproduced. 36 | */ 37 | #ifndef INCLUDED_OSCPACK_OSCPRINTRECEIVEDELEMENTS_H 38 | #define INCLUDED_OSCPACK_OSCPRINTRECEIVEDELEMENTS_H 39 | 40 | #include 41 | 42 | #include "OscReceivedElements.h" 43 | 44 | 45 | namespace osc{ 46 | 47 | std::ostream& operator<<( std::ostream & os, const ReceivedPacket& p ); 48 | std::ostream& operator<<( std::ostream & os, const ReceivedMessageArgument& arg ); 49 | std::ostream& operator<<( std::ostream & os, const ReceivedMessage& m ); 50 | std::ostream& operator<<( std::ostream & os, const ReceivedBundle& b ); 51 | 52 | } // namespace osc 53 | 54 | #endif /* INCLUDED_OSCPACK_OSCPRINTRECEIVEDELEMENTS_H */ 55 | -------------------------------------------------------------------------------- /oscpack/osc/OscTypes.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | oscpack -- Open Sound Control (OSC) packet manipulation library 3 | http://www.rossbencina.com/code/oscpack 4 | 5 | Copyright (c) 2004-2013 Ross Bencina 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining 8 | a copy of this software and associated documentation files 9 | (the "Software"), to deal in the Software without restriction, 10 | including without limitation the rights to use, copy, modify, merge, 11 | publish, distribute, sublicense, and/or sell copies of the Software, 12 | and to permit persons to whom the Software is furnished to do so, 13 | subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be 16 | included in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 21 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 22 | ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 23 | CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | */ 26 | 27 | /* 28 | The text above constitutes the entire oscpack license; however, 29 | the oscpack developer(s) also make the following non-binding requests: 30 | 31 | Any person wishing to distribute modifications to the Software is 32 | requested to send the modifications to the original developer so that 33 | they can be incorporated into the canonical version. It is also 34 | requested that these non-binding requests be included whenever the 35 | above license is reproduced. 36 | */ 37 | #include "OscTypes.h" 38 | 39 | namespace osc{ 40 | 41 | BundleInitiator BeginBundleImmediate(1); 42 | BundleTerminator EndBundle; 43 | MessageTerminator EndMessage; 44 | NilType OscNil; 45 | #ifndef _OBJC_OBJC_H_ 46 | NilType Nil; // Objective-C defines Nil. so our Nil is deprecated. use OscNil instead 47 | #endif 48 | InfinitumType Infinitum; 49 | ArrayInitiator BeginArray; 50 | ArrayTerminator EndArray; 51 | 52 | } // namespace osc 53 | --------------------------------------------------------------------------------