From: DeaDDooMER Date: Sat, 29 Dec 2018 08:50:51 +0000 (+0300) Subject: Added stubs for gl, enet and sdl2 X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=3d2ad22a4edfeab661196c15d6b57fa3b3eca216;p=d2df-sdl.git Added stubs for gl, enet and sdl2 --- diff --git a/src/game/Doom2DF.lpr b/src/game/Doom2DF.lpr index 3239be1..f50c895 100644 --- a/src/game/Doom2DF.lpr +++ b/src/game/Doom2DF.lpr @@ -48,11 +48,22 @@ uses {$IFDEF USE_MINIUPNPC} miniupnpc in '../lib/miniupnpc/miniupnpc.pas', {$ENDIF} +{$IFDEF USE_SDL2WRAP} + SDL2 in '../wrappers/sdl2/sdl2.pas', + {$IFDEF USE_SDLMIXER} + SDL2_mixer in '../wrappers/sdl2/SDL2_mixer.pas', + {$ENDIF} +{$ELSE} SDL2 in '../lib/sdl2/sdl2.pas', -{$IFDEF USE_SDLMIXER} - SDL2_mixer in '../lib/sdl2/SDL2_mixer.pas', + {$IFDEF USE_SDLMIXER} + SDL2_mixer in '../lib/sdl2/SDL2_mixer.pas', + {$ENDIF} {$ENDIF} +{$IFDEF USE_ENETWRAP} + ENet in '../wrappers/enet/enet.pas', +{$ELSE} ENet in '../lib/enet/enet.pp', +{$ENDIF} e_graphics in '../engine/e_graphics.pas', e_input in '../engine/e_input.pas', e_log in '../engine/e_log.pas', diff --git a/src/nogl/noGL.pas b/src/nogl/noGL.pas index 20d18bc..0e1566c 100644 --- a/src/nogl/noGL.pas +++ b/src/nogl/noGL.pas @@ -170,6 +170,12 @@ interface procedure nogl_Init; procedure nogl_Quit; -{$I noGLES1.inc} +{$IFDEF USE_GLES1}} + {$I noGLES1.inc} +{$ELSE} + {$IFDEF USE_GLSTUB} + {$I noGLSTUB.inc} + {$ENDIF} +{$ENDIF} end. diff --git a/src/nogl/noGLSTUB.inc b/src/nogl/noGLSTUB.inc new file mode 100644 index 0000000..dc01c71 --- /dev/null +++ b/src/nogl/noGLSTUB.inc @@ -0,0 +1,193 @@ +implementation + + procedure glEnable(cap: GLenum); + begin + end; + + procedure glDisable(cap: GLenum); + begin + end; + + function glIsEnabled(cap: GLenum): GLboolean; + begin + result := 0 + end; + + function glGetString(name: GLenum): PChar; + begin + result := '' + end; + + procedure glClearColor(red, green, blue, alpha: GLclampf); + begin + end; + + procedure glClear(mask: GLbitfield); + begin + end; + + procedure glAlphaFunc(func: GLenum; ref: GLclampf); + begin + end; + + procedure glBlendFunc(sfactor, dfactor: GLenum); + begin + end; + + procedure glPointSize(size: GLfloat); + begin + end; + + procedure glLineWidth(width: GLfloat); + begin + end; + + procedure glGetIntegerv(pname: GLenum; params: PGLint); + begin + end; + + procedure glFlush; + begin + end; + + procedure glFinish; + begin + end; + + procedure glBegin(mode: GLenum); + begin + end; + + procedure glEnd; + begin + end; + + procedure glVertex2f(x, y: GLfloat); + begin + end; + + procedure glVertex2i(x, y: GLint); + begin + end; + + procedure glColor4f(red, green, blue, alpha: GLfloat); + begin + end; + + procedure glColor4ub(red, green, blue, alpha: GLubyte); + begin + end; + + procedure glColor3ub(red, green, blue: GLubyte); + begin + end; + + procedure glTexCoord2f(s, t: GLfloat); + begin + end; + + procedure glTexCoord2i(s, t: GLint); + begin + end; + + procedure glReadPixels(x, y: GLint; width, height: GLsizei; format, atype: GLenum; pixels: Pointer); + begin + end; + + procedure glLoadIdentity; + begin + end; + + procedure glMatrixMode(mode: GLenum); + begin + end; + + procedure glLoadMatrixd(const m: PGLdouble); + begin + end; + + procedure glPushMatrix; + begin + end; + + procedure glPopMatrix; + begin + end; + + procedure glTranslatef(x, y, z: GLfloat); + begin + end; + + procedure glRotatef(angle, x, y, z: GLfloat); + begin + end; + + procedure glScalef(x, y, z: GLfloat); + begin + end; + + procedure glViewport(x, y: GLint; width, height: GLsizei); + begin + end; + + procedure glScissor(x, y: GLint; width, height: GLsizei); + begin + end; + + procedure glStencilMask(mask: GLuint); + begin + end; + + procedure glStencilFunc(func: GLenum; ref: GLint; mask: GLuint); + begin + end; + + procedure glStencilOp(fail, zfail, zpass: GLenum); + begin + end; + + procedure glColorMask(red, green, blue, alpha: GLboolean); + begin + end; + + procedure glBindTexture(target: GLenum; texture: GLuint); + begin + end; + + procedure glGenTextures(n: GLsizei; textures: PGLuint); + begin + end; + + procedure glTexEnvi(target: GLenum; pname: GLenum; param: GLint); + begin + end; + + procedure glTexParameterf(target: GLenum; pname: GLenum; param: GLfloat); + begin + end; + + procedure glTexParameteri(target: GLenum; pname: GLenum; param: GLint); + begin + end; + + procedure glTexImage2D(target: GLenum; level, internalformat: GLint; width, height: GLsizei; border: GLint; format, atype: GLenum; const pixels: Pointer); + begin + end; + + procedure glTexSubImage2D(target: GLenum; level, xoffset, yoffset: GLint; width, height: GLsizei; format, atype: GLenum; const pixels: Pointer); + begin + end; + + procedure glDeleteTextures(n: GLsizei; const textures: PGLuint); + begin + end; + + procedure nogl_Init; + begin + end; + + procedure nogl_Quit; + begin + end; + +initialization diff --git a/src/nogl/noGLuses.inc b/src/nogl/noGLuses.inc index 458f546..02c07fb 100644 --- a/src/nogl/noGLuses.inc +++ b/src/nogl/noGLuses.inc @@ -6,7 +6,7 @@ {$ENDIF} {$ENDIF} -{$IFDEF USE_GLES1} +{$IF DEFINED(USE_GLES1) or DEFINED(USE_GLSTUB)} {$IFNDEF USE_NANOGL} {$DEFINE USE_NOGL} {$ENDIF} diff --git a/src/wrappers/enet/enet.pas b/src/wrappers/enet/enet.pas new file mode 100644 index 0000000..faf071e --- /dev/null +++ b/src/wrappers/enet/enet.pas @@ -0,0 +1,870 @@ +{$INCLUDE ../shared/a_modes.inc} +{$SCOPEDENUMS OFF} +unit ENet; + +{$DEFINE libraryLibENetDecl := cdecl} +{$DEFINE libraryLibENetImp := cdecl} +{$DEFINE libraryLibENetVar := cvar} + +interface + +uses ctypes; + +//////////////////////////////////////////////////////////////////////////////// +// types.h +//////////////////////////////////////////////////////////////////////////////// + +type + enet_uint8 = cuchar; + penet_uint8 = ^enet_uint8; + + enet_uint16 = cushort; + penet_uint16 = ^enet_uint16; + + enet_uint32 = cuint; // TODO: why 'int' instead of 'long'? + penet_uint32 = ^enet_uint32; + + enet_size_t = NativeUInt; + penet_size_t = ^enet_size_t; + +//////////////////////////////////////////////////////////////////////////////// +// callbacks.h +//////////////////////////////////////////////////////////////////////////////// + +type + pENetCallbacks = ^TENetCallbacks; + TENetCallbacks = record + malloc : function( size: csize_t ): Pointer; cdecl; + free : procedure( memory: Pointer ); cdecl; + no_memory : procedure(); cdecl; + end; + +//////////////////////////////////////////////////////////////////////////////// +// protocol.h +//////////////////////////////////////////////////////////////////////////////// + +const + { unnamed enums } + ENET_PROTOCOL_MINIMUM_MTU = 576; + ENET_PROTOCOL_MAXIMUM_MTU = 4096; + ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS = 32; + ENET_PROTOCOL_MINIMUM_WINDOW_SIZE = 4096; + ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE = 65536; + ENET_PROTOCOL_MINIMUM_CHANNEL_COUNT = 1; + ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT = 255; + ENET_PROTOCOL_MAXIMUM_PEER_ID = $FFF; + ENET_PROTOCOL_MAXIMUM_FRAGMENT_COUNT = 1024 * 1024; + + { enum ENetProtocolFlag } + ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE = 1 shl 7; + ENET_PROTOCOL_COMMAND_FLAG_UNSEQUENCED = 1 shl 6; + ENET_PROTOCOL_HEADER_FLAG_COMPRESSED = 1 shl 14; + ENET_PROTOCOL_HEADER_FLAG_SENT_TIME = 1 shl 15; + ENET_PROTOCOL_HEADER_FLAG_MASK = ENET_PROTOCOL_HEADER_FLAG_COMPRESSED or + ENET_PROTOCOL_HEADER_FLAG_SENT_TIME; + ENET_PROTOCOL_HEADER_SESSION_MASK = 3 shl 12; + ENET_PROTOCOL_HEADER_SESSION_SHIFT = 12; + +type + { enums } + ENetProtocolCommand = ( ENET_PROTOCOL_COMMAND_NONE, + ENET_PROTOCOL_COMMAND_ACKNOWLEDGE, + ENET_PROTOCOL_COMMAND_CONNECT, + ENET_PROTOCOL_COMMAND_VERIFY_CONNECT, + ENET_PROTOCOL_COMMAND_DISCONNECT, + ENET_PROTOCOL_COMMAND_PING, + ENET_PROTOCOL_COMMAND_SEND_RELIABLE, + ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE, + ENET_PROTOCOL_COMMAND_SEND_FRAGMENT, + ENET_PROTOCOL_COMMAND_SEND_UNSEQUENCED, + ENET_PROTOCOL_COMMAND_BANDWIDTH_LIMIT, + ENET_PROTOCOL_COMMAND_THROTTLE_CONFIGURE, + ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE_FRAGMENT, + ENET_PROTOCOL_COMMAND_COUNT, + ENET_PROTOCOL_COMMAND_MASK = $0F ); + + { structs / unions } + pENetProtocolHeader = ^ENetProtocolHeader; + ENetProtocolHeader = packed record + peerID : enet_uint16; + sentTime : enet_uint16; + end; + + pENetProtocolCommandHeader = ^ENetProtocolCommandHeader; + ENetProtocolCommandHeader = packed record + command : enet_uint8; + channelID : enet_uint8; + reliableSequenceNumber : enet_uint16; + end; + + pENetProtocolAcknowledge = ^ENetProtocolAcknowledge; + ENetProtocolAcknowledge = packed record + header : ENetProtocolCommandHeader; + receivedReliableSequenceNumber : enet_uint16; + receivedSentTime : enet_uint16; + end; + + pENetProtocolConnect = ^ENetProtocolConnect; + ENetProtocolConnect = packed record + header : ENetProtocolCommandHeader; + outgoingPeerID : enet_uint16; + incomingSessionID : enet_uint8; + outgoingSessionID : enet_uint8; + mtu : enet_uint32; + windowSize : enet_uint32; + channelCount : enet_uint32; + incomingBandwidth : enet_uint32; + outgoingBandwidth : enet_uint32; + packetThrottleInterval : enet_uint32; + packetThrottleAcceleration : enet_uint32; + packetThrottleDeceleration : enet_uint32; + connectID : enet_uint32; + data : enet_uint32; + end; + + pENetProtocolVerifyConnect = ^ENetProtocolVerifyConnect; + ENetProtocolVerifyConnect = packed record + header : ENetProtocolCommandHeader; + outgoingPeerID : enet_uint16; + incomingSessionID : enet_uint8; + outgoingSessionID : enet_uint8; + mtu : enet_uint32; + windowSize : enet_uint32; + channelCount : enet_uint32; + incomingBandwidth : enet_uint32; + outgoingBandwidth : enet_uint32; + packetThrottleInterval : enet_uint32; + packetThrottleAcceleration : enet_uint32; + packetThrottleDeceleration : enet_uint32; + connectID : enet_uint32; + end; + + pENetProtocolBandwidthLimit = ^ENetProtocolBandwidthLimit; + ENetProtocolBandwidthLimit = packed record + header : ENetProtocolCommandHeader; + incomingBandwidth : enet_uint32; + outgoingBandwidth : enet_uint32; + end; + + pENetProtocolThrottleConfigure = ^ENetProtocolThrottleConfigure; + ENetProtocolThrottleConfigure = packed record + header : ENetProtocolCommandHeader; + packetThrottleInterval : enet_uint32; + packetThrottleAcceleration : enet_uint32; + packetThrottleDeceleration : enet_uint32; + end; + + pENetProtocolDisconnect = ^ENetProtocolDisconnect; + ENetProtocolDisconnect = packed record + header : ENetProtocolCommandHeader; + data : enet_uint32; + end; + + pENetProtocolPing = ^ENetProtocolPing; + ENetProtocolPing = packed record + header : ENetProtocolCommandHeader; + end; + + pENetProtocolSendReliable = ^ENetProtocolSendReliable; + ENetProtocolSendReliable = packed record + header : ENetProtocolCommandHeader; + dataLength : enet_uint16; + end; + + pENetProtocolSendUnreliable = ^ENetProtocolSendUnreliable; + ENetProtocolSendUnreliable = packed record + header : ENetProtocolCommandHeader; + unreliableSequenceNumber : enet_uint16; + dataLength : enet_uint16; + end; + + pENetProtocolSendUnsequenced = ^ENetProtocolSendUnsequenced; + ENetProtocolSendUnsequenced = packed record + header : ENetProtocolCommandHeader; + unsequencedGroup : enet_uint16; + dataLength : enet_uint16; + end; + + pENetProtocolSendFragment = ^ENetProtocolSendFragment; + ENetProtocolSendFragment = packed record + header : ENetProtocolCommandHeader; + startSequenceNumber : enet_uint16; + dataLength : enet_uint16; + fragmentCount : enet_uint32; + fragmentNumber : enet_uint32; + totalLength : enet_uint32; + fragmentOffset : enet_uint32; + end; + + pENetProtocol = ^TENetProtocol; + TENetProtocol = packed record //union + case Byte of + 0 : (header : ENetProtocolCommandHeader); + 1 : (acknowledge : ENetProtocolAcknowledge); + 2 : (connect : ENetProtocolConnect); + 3 : (verifyConnect : ENetProtocolVerifyConnect); + 4 : (disconnect : ENetProtocolDisconnect); + 5 : (ping : ENetProtocolPing); + 6 : (sendReliable : ENetProtocolSendReliable); + 7 : (sendUnreliable : ENetProtocolSendUnreliable); + 8 : (sendUnsequenced : ENetProtocolSendUnsequenced); + 9 : (sendFragment : ENetProtocolSendFragment); + 10: (bandwidthLimit : ENetProtocolBandwidthLimit); + 11: (throttleConfigure : ENetProtocolThrottleConfigure); + end; + +//////////////////////////////////////////////////////////////////////////////// +// win32.h / unix.h +//////////////////////////////////////////////////////////////////////////////// + +const + ENET_SOCKET_NULL = -1; + +type + ENetSocket = cint; + + //ENetSocketSet = TFDSet; + ENetSocketSet = record end; + pENetSocketSet = ^ENetSocketSet; + + pENetBuffer = ^ENetBuffer; + ENetBuffer = record + data : Pointer; + dataLength : csize_t; + end; + +{ inline macros } + +function ENET_HOST_TO_NET_16( value: cuint16 ): cuint16; inline; +function ENET_HOST_TO_NET_32( value: cuint32 ): cuint32; inline; + +function ENET_NET_TO_HOST_16( value: cuint16 ): cuint16; inline; +function ENET_NET_TO_HOST_32( value: cuint32 ): cuint32; inline; + +procedure ENET_SOCKETSET_EMPTY( var sockset: ENetSocketSet ); inline; +procedure ENET_SOCKETSET_ADD( var sockset: ENetSocketSet; socket: ENetSocket ); inline; +procedure ENET_SOCKETSET_REMOVE( var sockset: ENetSocketSet; socket: ENetSocket ); inline; +function ENET_SOCKETSET_CHECK( var sockset: ENetSocketSet; socket: ENetSocket ): cbool; inline; + +//////////////////////////////////////////////////////////////////////////////// +// list.h +//////////////////////////////////////////////////////////////////////////////// + +type + pENetListNode = ^ENetListNode; + ENetListNode = record + next : pENetListNode; + previous : pENetListNode; + end; + + pENetList = ^TENetList; + TENetList = record + sentinel : ENetListNode; + end; + + ENetListIterator = pENetListNode; + +{ inline macros } +function enet_list_begin( list: pENetList ): ENetListIterator; inline; +function enet_list_end( list: pENetList ): ENetListIterator; inline; + +function enet_list_empty( list: pENetList ): Boolean; inline; + +function enet_list_next( iterator: ENetListIterator ): ENetListIterator; inline; +function enet_list_previous( iterator: ENetListIterator ): ENetListIterator; inline; + +function enet_list_front( list: pENetList ): Pointer; inline; +function enet_list_back( list: pENetList ): Pointer; inline; + +//////////////////////////////////////////////////////////////////////////////// +// time.h +//////////////////////////////////////////////////////////////////////////////// + +const + ENET_TIME_OVERFLOW = 86400000; + +{ inline macros } +function ENET_TIME_LESS( const a, b: cint ): cbool; inline; +function ENET_TIME_GREATER( const a, b: cint ): cbool; inline; + +function ENET_TIME_LESS_EQUAL( const a, b: cint ): cbool; inline; +function ENET_TIME_GREATER_EQUAL( const a, b: cint ): cbool; inline; + +function ENET_TIME_DIFFERENCE( const a, b: cint ): cint; inline; + +//////////////////////////////////////////////////////////////////////////////// +// enet.h +//////////////////////////////////////////////////////////////////////////////// + +const + { defines } + ENET_VERSION_MAJOR = 1; + ENET_VERSION_MINOR = 3; + ENET_VERSION_PATCH = 13; + + ENET_HOST_ANY = 0; + ENET_HOST_BROADCAST_ = $FFFFFFFF; // "_" due to name conflict + ENET_PORT_ANY = 0; + + ENET_BUFFER_MAXIMUM = 1 + 2 * ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS; + + { unnamed enums } + ENET_HOST_RECEIVE_BUFFER_SIZE = 256 * 1024; + ENET_HOST_SEND_BUFFER_SIZE = 256 * 1024; + ENET_HOST_BANDWIDTH_THROTTLE_INTERVAL = 1000; + ENET_HOST_DEFAULT_MTU = 1400; + ENET_HOST_DEFAULT_MAXIMUM_PACKET_SIZE = 32 * 1024 * 1024; + ENET_HOST_DEFAULT_MAXIMUM_WAITING_DATA = 32 * 1024 * 1024; + + ENET_PEER_DEFAULT_ROUND_TRIP_TIME = 500; + ENET_PEER_DEFAULT_PACKET_THROTTLE = 32; + ENET_PEER_PACKET_THROTTLE_SCALE = 32; + ENET_PEER_PACKET_THROTTLE_COUNTER = 7; + ENET_PEER_PACKET_THROTTLE_ACCELERATION = 2; + ENET_PEER_PACKET_THROTTLE_DECELERATION = 2; + ENET_PEER_PACKET_THROTTLE_INTERVAL = 5000; + ENET_PEER_PACKET_LOSS_SCALE = 1 shl 16; + ENET_PEER_PACKET_LOSS_INTERVAL = 10000; + ENET_PEER_WINDOW_SIZE_SCALE = 64 * 1024; + ENET_PEER_TIMEOUT_LIMIT = 32; + ENET_PEER_TIMEOUT_MINIMUM = 5000; + ENET_PEER_TIMEOUT_MAXIMUM = 30000; + ENET_PEER_PING_INTERVAL_ = 500; // "_" due to name conflict + ENET_PEER_UNSEQUENCED_WINDOWS = 64; + ENET_PEER_UNSEQUENCED_WINDOW_SIZE = 1024; + ENET_PEER_FREE_UNSEQUENCED_WINDOWS = 32; + ENET_PEER_RELIABLE_WINDOWS = 16; + ENET_PEER_RELIABLE_WINDOW_SIZE = $1000; + ENET_PEER_FREE_RELIABLE_WINDOWS = 8; + + { enum ENetSocketWait } + ENET_SOCKET_WAIT_NONE = 0; + ENET_SOCKET_WAIT_SEND = 1 shl 0; + ENET_SOCKET_WAIT_RECEIVE = 1 shl 1; + ENET_SOCKET_WAIT_INTERRUPT = 1 shl 2; + + { enum ENetPacketFlag } + ENET_PACKET_FLAG_RELIABLE = 1 shl 0; + ENET_PACKET_FLAG_UNSEQUENCED = 1 shl 1; + ENET_PACKET_FLAG_NO_ALLOCATE = 1 shl 2; + ENET_PACKET_FLAG_UNRELIABLE_FRAGMENT = 1 shl 3; + ENET_PACKET_FLAG_SENT = 1 shl 8; + +type + { enums } + ENetSocketType = ( ENET_SOCKET_TYPE_STREAM = 1, + ENET_SOCKET_TYPE_DATAGRAM = 2 ); + + ENetSocketOption = ( ENET_SOCKOPT_NONBLOCK = 1, + ENET_SOCKOPT_BROADCAST = 2, + ENET_SOCKOPT_RCVBUF = 3, + ENET_SOCKOPT_SNDBUF = 4, + ENET_SOCKOPT_REUSEADDR = 5, + ENET_SOCKOPT_RCVTIMEO = 6, + ENET_SOCKOPT_SNDTIMEO = 7, + ENET_SOCKOPT_ERROR = 8, + ENET_SOCKOPT_NODELAY = 9 ); + + ENetSocketShutdown = ( ENET_SOCKET_SHUTDOWN_READ, + ENET_SOCKET_SHUTDOWN_WRITE, + ENET_SOCKET_SHUTDOWN_READ_WRITE ); + + ENetPeerState = ( ENET_PEER_STATE_DISCONNECTED, + ENET_PEER_STATE_CONNECTING, + ENET_PEER_STATE_ACKNOWLEDGING_CONNECT, + ENET_PEER_STATE_CONNECTION_PENDING, + ENET_PEER_STATE_CONNECTION_SUCCEEDED, + ENET_PEER_STATE_CONNECTED, + ENET_PEER_STATE_DISCONNECT_LATER, + ENET_PEER_STATE_DISCONNECTING, + ENET_PEER_STATE_ACKNOWLEDGING_DISCONNECT, + ENET_PEER_STATE_ZOMBIE ); + + ENetEventType = ( ENET_EVENT_TYPE_NONE, + ENET_EVENT_TYPE_CONNECT, + ENET_EVENT_TYPE_DISCONNECT, + ENET_EVENT_TYPE_RECEIVE ); + + { typedefs } + ENetVersion = enet_uint32; + + { pointers to structs } + pENetAddress = ^ENetAddress; + pENetPacket = ^ENetPacket; + pENetChannel = ^ENetChannel; + pENetPeer = ^ENetPeer; + pENetCompressor = ^ENetCompressor; + pENetHost = ^ENetHost; + pENetEvent = ^ENetEvent; + + { callbacks } + ENetPacketFreeCallback = procedure( packet: pENetPacket ); cdecl; + ENetChecksumCallback = function( const buffers: pENetBuffer; + bufferCount: csize_t ): enet_uint32; cdecl; + ENetInterceptCallback = function( host: pENetHost; + event: pENetEvent ): cint; cdecl; + + { structs } + ENetAddress = record + host : enet_uint32; + port : enet_uint16; + end; + ENetPacket = record + referenceCount : csize_t; + flags : enet_uint32; + data : penet_uint8; + dataLength : csize_t; + freeCallback : ENetPacketFreeCallback; + userData : Pointer; + end; + ENetChannel = record + outgoingReliableSequenceNumber : enet_uint16; + outgoingUnreliableSequenceNumber : enet_uint16; + usedReliableWindows : enet_uint16; + reliableWindows : array[ 0..ENET_PEER_RELIABLE_WINDOWS-1 ] of enet_uint16; + incomingReliableSequenceNumber : enet_uint16; + incomingUnreliableSequenceNumber : enet_uint16; + incomingReliableCommands : TENetList; + incomingUnreliableCommands : TENetList; + end; + ENetPeer = record + dispatchList : ENetListNode; + host : pENetHost; + outgoingPeerID : enet_uint16; + incomingPeerID : enet_uint16; + connectID : enet_uint32; + outgoingSessionID : enet_uint8; + incomingSessionID : enet_uint8; + address : ENetAddress; + data : Pointer; + state : ENetPeerState; + channels : pENetChannel; + channelCount : csize_t; + incomingBandwidth : enet_uint32; + outgoingBandwidth : enet_uint32; + incomingBandwidthThrottleEpoch : enet_uint32; + outgoingBandwidthThrottleEpoch : enet_uint32; + incomingDataTotal : enet_uint32; + outgoingDataTotal : enet_uint32; + lastSendTime : enet_uint32; + lastReceiveTime : enet_uint32; + nextTimeout : enet_uint32; + earliestTimeout : enet_uint32; + packetLossEpoch : enet_uint32; + packetsSent : enet_uint32; + packetsLost : enet_uint32; + packetLoss : enet_uint32; + packetLossVariance : enet_uint32; + packetThrottle : enet_uint32; + packetThrottleLimit : enet_uint32; + packetThrottleCounter : enet_uint32; + packetThrottleEpoch : enet_uint32; + packetThrottleAcceleration : enet_uint32; + packetThrottleDeceleration : enet_uint32; + packetThrottleInterval : enet_uint32; + pingInterval : enet_uint32; + timeoutLimit : enet_uint32; + timeoutMinimum : enet_uint32; + timeoutMaximum : enet_uint32; + lastRoundTripTime : enet_uint32; + lowestRoundTripTime : enet_uint32; + lastRoundTripTimeVariance : enet_uint32; + highestRoundTripTimeVariance : enet_uint32; + roundTripTime : enet_uint32; + roundTripTimeVariance : enet_uint32; + mtu : enet_uint32; + windowSize : enet_uint32; + reliableDataInTransit : enet_uint32; + outgoingReliableSequenceNumber : enet_uint16; + acknowledgements : TENetList; + sentReliableCommands : TENetList; + sentUnreliableCommands : TENetList; + outgoingReliableCommands : TENetList; + outgoingUnreliableCommands : TENetList; + dispatchedCommands : TENetList; + needsDispatch : cint; + incomingUnsequencedGroup : enet_uint16; + outgoingUnsequencedGroup : enet_uint16; + unsequencedWindow : array[ 0..(ENET_PEER_UNSEQUENCED_WINDOW_SIZE div 32)-1 ] of enet_uint32; + eventData : enet_uint32; + totalWaitingData : csize_t; + end; + ENetCompressor = record + context : Pointer; + compress : function( context: Pointer; const inBuffers: pENetBuffer; inBufferCount, inLimit: csize_t; outData: penet_uint8; outLimit: csize_t ): csize_t; cdecl; + decompress : function( context: Pointer; const inData: penet_uint8; inLimit: csize_t; outData: penet_uint8; outLimit: csize_t ): csize_t; cdecl; + destroy : procedure( context: Pointer ); cdecl; + end; + ENetHost = record + socket : ENetSocket; + address : ENetAddress; + incomingBandwidth : enet_uint32; + outgoingBandwidth : enet_uint32; + bandwidthThrottleEpoch : enet_uint32; + mtu : enet_uint32; + randomSeed : enet_uint32; + recalculateBandwidthLimits : cint; + peers : pENetPeer; + peerCount : csize_t; + channelLimit : csize_t; + serviceTime : enet_uint32; + dispatchQueue : TENetList; + continueSending : cint; + packetSize : csize_t; + headerFlags : enet_uint16; + commands : array[ 0..ENET_PROTOCOL_MAXIMUM_PACKET_COMMANDS-1 ] of TENetProtocol; + commandCount : csize_t; + buffers : array[ 0..ENET_BUFFER_MAXIMUM-1 ] of ENetBuffer; + bufferCount : csize_t; + checksum : ENetChecksumCallback; + compressor : ENetCompressor; + packetData : array[ 0..1, 0..ENET_PROTOCOL_MAXIMUM_MTU-1 ] of enet_uint8; + receivedAddress : ENetAddress; + receivedData : penet_uint8; + receivedDataLength : csize_t; + totalSentData : enet_uint32; + totalSentPackets : enet_uint32; + totalReceivedData : enet_uint32; + totalReceivedPackets : enet_uint32; + intercept : ENetInterceptCallback; + connectedPeers : csize_t; + bandwidthLimitedPeers : csize_t; + duplicatePeers : csize_t; + maximumPacketSize : csize_t; + maximumWaitingData : csize_t; + end; + ENetEvent = record + kind : ENetEventType; //originally "type", which conflicts + peer : pENetPeer; + channelID : enet_uint8; + data : enet_uint32; + packet : pENetPacket; + end; + +{ inline macros } +function ENET_VERSION_CREATE( const major, minor, patch: cint ): ENetVersion; inline; +function ENET_VERSION_GET_MAJOR( const version: ENetVersion ): cint; inline; +function ENET_VERSION_GET_MINOR( const version: ENetVersion ): cint; inline; +function ENET_VERSION_GET_PATCH( const version: ENetVersion ): cint; inline; +function ENET_VERSION(): ENetVersion; inline; + +{ library functions } +function enet_initialize(): cint; +//function enet_initialize_with_callbacks( version: ENetVersion; const inits: pENetCallbacks ): cint; libraryLibENetImp; +procedure enet_deinitialize(); +//function enet_linked_version(): ENetVersion; libraryLibENetImp; + +//function enet_time_get(): enet_uint32; libraryLibENetImp; +//procedure enet_time_set( newTimeBase: enet_uint32 ); libraryLibENetImp; + +function enet_socket_create( kind: ENetSocketType ): ENetSocket; +function enet_socket_bind( socket: ENetSocket; const address: pENetAddress ): cint; +//function enet_socket_get_address( socket: ENetSocket; address: pENetAddress ): cint; libraryLibENetImp; +//function enet_socket_listen( socket: ENetSocket; backlog: cint ): cint; libraryLibENetImp; +//function enet_socket_accept( socket: ENetSocket; address: pENetAddress ): ENetSocket; libraryLibENetImp; +//function enet_socket_connect( socket: ENetSocket; const address: pENetAddress ): cint; libraryLibENetImp; +function enet_socket_send( socket: ENetSocket; const address: pENetAddress; const buffers: pENetBuffer; bufferCount: csize_t ): cint; +function enet_socket_receive( socket: ENetSocket; address: pENetAddress; buffers: pENetBuffer; bufferCount: csize_t ): cint; +//function enet_socket_wait( socket: ENetSocket; condition: penet_uint32; timeout: enet_uint32 ): cint; +function enet_socket_set_option( socket: ENetSocket; option: ENetSocketOption; value: cint ): cint; +//function enet_socket_get_option( socket: ENetSocket; option: ENetSocketOption; value: pcint ): cint; libraryLibENetImp; +//function enet_socket_shutdown( socket: ENetSocket; how: ENetSocketShutdown ): cint; libraryLibENetImp; +procedure enet_socket_destroy( socket: ENetSocket ); +//function enet_socketset_select( maxSocket: ENetSocket; readSet: pENetSocketSet; writeSet: pENetSocketSet; timeout: enet_uint32 ): cint; libraryLibENetImp; + +function enet_address_set_host( address: pENetAddress; const hostName: PChar ): cint; +//function enet_address_get_host_ip( const address: pENetAddress; hostName: PChar; nameLength: csize_t ): cint; libraryLibENetImp; +//function enet_address_get_host( const address: pENetAddress; hostName: PChar; nameLength: csize_t ): cint; libraryLibENetImp; + +function enet_packet_create( const data: Pointer; dataLength: csize_t; flags: enet_uint32 ): pENetPacket; +procedure enet_packet_destroy( packet: pENetPacket ); +//function enet_packet_resize( packet: pENetPacket; dataLength: csize_t ): cint; libraryLibENetImp; +//function enet_crc32( const buffers: pENetBuffer; bufferCount: csize_t ): enet_uint32; libraryLibENetImp; + +function enet_host_create( const address: pENetAddress; peerCount, channelLimit: csize_t; incomingBandwidth, outgoingBandwidth: enet_uint32 ): pENetHost; +procedure enet_host_destroy( host: pENetHost ); +function enet_host_connect( host: pENetHost; const address: pENetAddress; channelCount: csize_t; data: enet_uint32 ): pENetPeer; +//function enet_host_check_events( host: pENetHost; event: pENetEvent ): cint; libraryLibENetImp; +function enet_host_service( host: pENetHost; event: pENetEvent; timeout: enet_uint32 ): cint; +procedure enet_host_flush( host: pENetHost ); +procedure enet_host_broadcast( host: pENetHost; channelID: enet_uint8; packet: pENetPacket ); +//procedure enet_host_compress( host: pENetHost; const compressor: pENetCompressor ); libraryLibENetImp; +//function enet_host_compress_with_range_coder( host: pENetHost ): cint; libraryLibENetImp; +//procedure enet_host_channel_limit( host: pENetHost; channelLimit: csize_t ); libraryLibENetImp; +//procedure enet_host_bandwidth_limit( host: pENetHost; incomingBandwidth, outgoingBandwidth: enet_uint32 ); libraryLibENetImp; + +function enet_peer_send( peer: pENetPeer; channelID: enet_uint8; packet: pENetPacket ): cint; +//function enet_peer_receive( peer: pENetPeer; channelID: penet_uint8 ): pENetPacket; libraryLibENetImp; +//procedure enet_peer_ping( peer: pENetPeer ); libraryLibENetImp; +//procedure enet_peer_ping_interval( peer: pENetPeer; pingInterval: enet_uint32 ); libraryLibENetImp; +procedure enet_peer_timeout( peer: pENetPeer; timeoutLimit, timeoutMinimum, timeoutMaximum: enet_uint32 ); +procedure enet_peer_reset( peer: pENetPeer ); +procedure enet_peer_disconnect( peer: pENetPeer; data: enet_uint32 ); +//procedure enet_peer_disconnect_now( peer: pENetPeer; data: enet_uint32 ); libraryLibENetImp; +//procedure enet_peer_disconnect_later( peer: pENetPeer; data: enet_uint32 ); libraryLibENetImp; +//procedure enet_peer_throttle_configure( peer: pENetPeer; interval, acceleration, deceleration: enet_uint32 ); libraryLibENetImp; + +//function enet_range_coder_create(): Pointer; libraryLibENetImp; +//procedure enet_range_coder_destroy( context: Pointer ); libraryLibENetImp; +//function enet_range_coder_compress( context: Pointer; const inBuffers: pENetBuffer; inBufferCount, inLiit: csize_t; outData: penet_uint8; outLimit: csize_t ): csize_t; libraryLibENetImp; +//function enet_range_coder_decompress( context: Pointer; const inData: penet_uint8; inLimit: csize_t; outData: penet_uint8; outLimit: csize_t ): csize_t; libraryLibENetImp; + +implementation + +//////////////////////////////////////////////////////////////////////////////// +// win32.h / unix.h +//////////////////////////////////////////////////////////////////////////////// + +function ENET_HOST_TO_NET_16( value: cuint16 ): cuint16; +begin +// Result := htons(value); + Result := value; +end; + +function ENET_HOST_TO_NET_32( value: cuint32 ): cuint32; +begin +// Result := htonl(value); + Result := value; +end; + +function ENET_NET_TO_HOST_16( value: cuint16 ): cuint16; +begin +// Result := ntohs(value); + Result := value; +end; + +function ENET_NET_TO_HOST_32( value: cuint32 ): cuint32; +begin +// Result := ntohl(value); + Result := value; +end; + +procedure ENET_SOCKETSET_EMPTY( var sockset: ENetSocketSet ); +begin +// fpFD_ZERO( sockset ); +end; + +procedure ENET_SOCKETSET_ADD( var sockset: ENetSocketSet; socket: ENetSocket ); +begin +// fpFD_SET( socket, sockset ); +end; + +procedure ENET_SOCKETSET_REMOVE( var sockset: ENetSocketSet; socket: ENetSocket ); +begin +// fpFD_CLR( socket, sockset ); +end; + +function ENET_SOCKETSET_CHECK( var sockset: ENetSocketSet; socket: ENetSocket ): cbool; +begin +// Result := fpFD_ISSET( socket, sockset ) = 1; + Result := false; +end; + +//////////////////////////////////////////////////////////////////////////////// +// list.h +//////////////////////////////////////////////////////////////////////////////// + +function enet_list_begin( list: pENetList ): ENetListIterator; +begin + Result := list^.sentinel.next; +end; + +function enet_list_end( list: pENetList ): ENetListIterator; +begin + Result := @( list^.sentinel ); +end; + +function enet_list_empty( list: pENetList ): Boolean; +begin + Result := enet_list_begin(list) = enet_list_end(list); +end; + +function enet_list_next( iterator: ENetListIterator ): ENetListIterator; +begin + Result := iterator^.next; +end; + +function enet_list_previous( iterator: ENetListIterator ): ENetListIterator; +begin + Result := iterator^.previous; +end; + +function enet_list_front( list: pENetList ): Pointer; +begin + Result := Pointer( list^.sentinel.next ); +end; + +function enet_list_back( list: pENetList ): Pointer; +begin + Result := Pointer( list^.sentinel.previous ); +end; + +//////////////////////////////////////////////////////////////////////////////// +// time.h +//////////////////////////////////////////////////////////////////////////////// + +function ENET_TIME_LESS( const a, b: cint ): cbool; +begin + Result := (a - b) >= ENET_TIME_OVERFLOW; +end; + +function ENET_TIME_GREATER( const a, b: cint ): cbool; +begin + Result := (b - a) >= ENET_TIME_OVERFLOW; +end; + +function ENET_TIME_LESS_EQUAL( const a, b: cint ): cbool; +begin + Result := not ENET_TIME_GREATER(a, b); +end; + +function ENET_TIME_GREATER_EQUAL( const a, b: cint ): cbool; +begin + Result := not ENET_TIME_LESS(a, b); +end; + +function ENET_TIME_DIFFERENCE( const a, b: cint ): cint; +begin + if (a - b) >= ENET_TIME_OVERFLOW then + Result := b - a + else + Result := a - b; +end; + +//////////////////////////////////////////////////////////////////////////////// +// enet.h +//////////////////////////////////////////////////////////////////////////////// + +function ENET_VERSION_CREATE( const major, minor, patch: cint ): ENetVersion; +begin + Result := (major shl 16) or (minor shl 8) or patch; +end; + +function ENET_VERSION_GET_MAJOR( const version: ENetVersion ): cint; +begin + Result := (version shr 16) and $FF; +end; + +function ENET_VERSION_GET_MINOR( const version: ENetVersion ): cint; +begin + Result := (version shr 8) and $FF; +end; + +function ENET_VERSION_GET_PATCH( const version: ENetVersion ): cint; +begin + Result := version and $FF; +end; + +function ENET_VERSION(): ENetVersion; +begin + Result := ENET_VERSION_CREATE( ENET_VERSION_MAJOR, ENET_VERSION_MINOR, ENET_VERSION_PATCH ); +end; + + + + + + + + +function enet_initialize(): cint; +begin + result := 0; +end; + +procedure enet_deinitialize; +begin +end; + +function enet_socket_create( kind: ENetSocketType ): ENetSocket; +begin + result := 0 +end; + +function enet_socket_bind( socket: ENetSocket; const address: pENetAddress ): cint; +begin + result := 0 +end; + +function enet_socket_send( socket: ENetSocket; const address: pENetAddress; const buffers: pENetBuffer; bufferCount: csize_t ): cint; +begin + result := 0 +end; + +function enet_socket_receive( socket: ENetSocket; address: pENetAddress; buffers: pENetBuffer; bufferCount: csize_t ): cint; +begin + result := 0 +end; + +function enet_socket_set_option( socket: ENetSocket; option: ENetSocketOption; value: cint ): cint; +begin + result := 0 +end; + +procedure enet_socket_destroy( socket: ENetSocket ); +begin +end; + +function enet_address_set_host( address: pENetAddress; const hostName: PChar ): cint; +begin + result := 0 +end; + +function enet_packet_create( const data: Pointer; dataLength: csize_t; flags: enet_uint32 ): pENetPacket; +begin + result := nil +end; + +procedure enet_packet_destroy( packet: pENetPacket ); +begin +end; + +function enet_host_create( const address: pENetAddress; peerCount, channelLimit: csize_t; incomingBandwidth, outgoingBandwidth: enet_uint32 ): pENetHost; +begin + result := nil +end; + +procedure enet_host_destroy( host: pENetHost ); +begin +end; + +function enet_host_connect( host: pENetHost; const address: pENetAddress; channelCount: csize_t; data: enet_uint32 ): pENetPeer; +begin + result := nil +end; + +function enet_host_service( host: pENetHost; event: pENetEvent; timeout: enet_uint32 ): cint; +begin + result := 0 +end; + +procedure enet_host_flush( host: pENetHost ); +begin +end; + +procedure enet_host_broadcast( host: pENetHost; channelID: enet_uint8; packet: pENetPacket ); +begin +end; + +function enet_peer_send( peer: pENetPeer; channelID: enet_uint8; packet: pENetPacket ): cint; +begin + result := 0 +end; + +procedure enet_peer_timeout( peer: pENetPeer; timeoutLimit, timeoutMinimum, timeoutMaximum: enet_uint32 ); +begin +end; + +procedure enet_peer_reset( peer: pENetPeer ); +begin +end; + +procedure enet_peer_disconnect( peer: pENetPeer; data: enet_uint32 ); +begin +end; + + + + + +end. diff --git a/src/wrappers/sdl2/SDL2_mixer.pas b/src/wrappers/sdl2/SDL2_mixer.pas new file mode 100644 index 0000000..0d944b6 --- /dev/null +++ b/src/wrappers/sdl2/SDL2_mixer.pas @@ -0,0 +1,250 @@ +{$INCLUDE ../shared/a_modes.inc} +{$SCOPEDENUMS OFF} +unit SDL2_mixer; + +interface + + uses SDL2; + + const + MIX_INIT_FLAC = $00000001; + MIX_INIT_MOD = $00000002; + MIX_INIT_MODPLUG = $00000004; + MIX_INIT_MP3 = $00000008; + MIX_INIT_OGG = $00000010; + MIX_INIT_FLUIDSYNTH = $00000020; + + MIX_DEFAULT_FREQUENCY = 22050; + MIX_DEFAULT_CHANNELS = 2; + MIX_MAX_VOLUME = 128; + +{$IFDEF FPC} + {$IF DEFINED(ENDIAN_LITTLE)} + MIX_DEFAULT_FORMAT = AUDIO_S16LSB; + {$ELSEIF DEFINED(ENDIAN_BIG)} + MIX_DEFAULT_FORMAT = AUDIO_S16MSB; + {$ELSE} + {$FATAL Unable to determine endianness.} + {$IFEND} +{$ENDIF} + + type + PMix_Chunk = ^TMix_Chunk; + TMix_Chunk = record + allocated: Integer; + abuf: PUInt8; + alen: UInt32; + volume: UInt8; + end; + + PMix_Music = ^TMix_Music; + TMix_Music = record end; + + TMix_Fading = (MIX_NO_FADING, MIX_FADING_OUT, MIX_FADING_IN); + + TMix_MusicType = (MUS_NONE, + MUS_CMD, + MUS_WAV, + MUS_MOD, + MUS_MID, + MUS_OGG, + MUS_MP3, + MUS_MP3_MAD, + MUS_FLAC, + MUS_MODPLUG); + + TMix_Channel_Finished = procedure(channel: Integer); cdecl; + + (** procedures **) + + function Mix_GetMusicType(music: TMix_Music): TMix_MusicType; + function Mix_Init(flags: Integer): Integer; + function Mix_OpenAudio(frequency: Integer; format: UInt16; channels: Integer; chunksize: Integer): Integer; + function Mix_GetError: PAnsiChar; + function Mix_QuerySpec(frequency: PInt; format: PUInt16; channels: PInt): Integer; + function Mix_GetNumChunkDecoders: Integer; + function Mix_GetChunkDecoder(index: Integer): PAnsiChar; + function Mix_GetNumMusicDecoders: Integer; + function Mix_GetMusicDecoder(index: Integer): PAnsiChar; + function Mix_AllocateChannels(numchans: Integer): Integer; + procedure Mix_ChannelFinished(channel_finished: TMix_Channel_Finished); + function Mix_LoadMUS(_file: PAnsiChar): PMix_Music; + function Mix_LoadMUS_RW(src: PSDL_RWops; freesrc: Integer): PMix_Music; + function Mix_LoadWAV(_file: PAnsiChar): PMix_Chunk; + function Mix_LoadWAV_RW(src: PSDL_RWops; freesrc: Integer): PMix_Chunk; + + function Mix_PlayChannel(channel: Integer; chunk: PMix_Chunk; loops: Integer): Integer; + function Mix_Volume(channel: Integer; volume: Integer): Integer; + function Mix_HaltMusic: Integer; + function Mix_PlayMusic(music: PMix_Music; loops: Integer): Integer; + function Mix_SetPanning(channel: Integer; left: UInt8; right: UInt8): Integer; + procedure Mix_FreeChunk(chunk: PMix_Chunk); + procedure Mix_FreeMusic(music: PMix_Music); + + function Mix_VolumeMusic(volume: Integer): Integer; + function Mix_HaltChannel(channel: Integer): Integer; + procedure Mix_CloseAudio; + function Mix_PlayingMusic: Integer; + function Mix_Paused(channel: Integer): Integer; + procedure Mix_Pause(channel: Integer); + procedure Mix_Resume(channel: Integer); + + procedure Mix_PauseMusic; + function Mix_PausedMusic: Integer; + procedure Mix_ResumeMusic; + +implementation + + function Mix_GetMusicType(music: TMix_Music): TMix_MusicType; + begin + result := TMix_MusicType.MUS_NONE + end; + + function Mix_Init(flags: Integer): Integer; + begin + result := 0 + end; + + function Mix_OpenAudio(frequency: Integer; format: UInt16; channels: Integer; chunksize: Integer): Integer; + begin + result := 0 + end; + + function Mix_GetError: PAnsiChar; + begin + result := '' + end; + + function Mix_QuerySpec(frequency: PInt; format: PUInt16; channels: PInt): Integer; + begin + result := 0 + end; + + function Mix_GetNumChunkDecoders: Integer; + begin + result := 0 + end; + + function Mix_GetChunkDecoder(index: Integer): PAnsiChar; + begin + result := '' + end; + + function Mix_GetNumMusicDecoders: Integer; + begin + result := 0 + end; + + function Mix_GetMusicDecoder(index: Integer): PAnsiChar; + begin + result := '' + end; + + function Mix_AllocateChannels(numchans: Integer): Integer; + begin + result := 0 + end; + + procedure Mix_ChannelFinished(channel_finished: TMix_Channel_Finished); + begin + end; + + function Mix_LoadMUS(_file: PAnsiChar): PMix_Music; + begin + result := nil + end; + + function Mix_LoadMUS_RW(src: PSDL_RWops; freesrc: Integer): PMix_Music; + begin + result := nil + end; + + function Mix_LoadWAV(_file: PAnsiChar): PMix_Chunk; + begin + Result := Mix_LoadWAV_RW(SDL_RWFromFile(_file, 'rb'), 1); + end; + + function Mix_LoadWAV_RW(src: PSDL_RWops; freesrc: Integer): PMix_Chunk; + begin + result := nil + end; + + function Mix_PlayChannel(channel: Integer; chunk: PMix_Chunk; loops: Integer): Integer; + begin + result := 0 + end; + + function Mix_Volume(channel: Integer; volume: Integer): Integer; + begin + result := 0 + end; + + function Mix_HaltMusic: Integer; + begin + result := 0 + end; + + function Mix_PlayMusic(music: PMix_Music; loops: Integer): Integer; + begin + result := 0 + end; + + function Mix_SetPanning(channel: Integer; left: UInt8; right: UInt8): Integer; + begin + result := 0 + end; + + procedure Mix_FreeChunk(chunk: PMix_Chunk); + begin + end; + + procedure Mix_FreeMusic(music: PMix_Music); + begin + end; + + function Mix_VolumeMusic(volume: Integer): Integer; + begin + result := 0 + end; + + function Mix_HaltChannel(channel: Integer): Integer; + begin + result := 0 + end; + + procedure Mix_CloseAudio; + begin + end; + + function Mix_PlayingMusic: Integer; + begin + result := 0 + end; + + function Mix_Paused(channel: Integer): Integer; + begin + result := 0 + end; + + procedure Mix_Pause(channel: Integer); + begin + end; + + procedure Mix_Resume(channel: Integer); + begin + end; + + procedure Mix_PauseMusic; + begin + end; + + function Mix_PausedMusic: Integer; + begin + result := 0 + end; + + procedure Mix_ResumeMusic; + begin + end; + +end. diff --git a/src/wrappers/sdl2/sdl2.pas b/src/wrappers/sdl2/sdl2.pas new file mode 100644 index 0000000..873ada5 --- /dev/null +++ b/src/wrappers/sdl2/sdl2.pas @@ -0,0 +1,616 @@ +{$INCLUDE ../shared/a_modes.inc} +{$SCOPEDENUMS OFF} +unit sdl2; + +interface + + {$I sdltype.inc} + {$I sdlscancode.inc} + + const + SDL_HAT_CENTERED = $00; + SDL_HAT_UP = $01; + SDL_HAT_RIGHT = $02; + SDL_HAT_DOWN = $04; + SDL_HAT_LEFT = $08; + SDL_HAT_RIGHTUP = SDL_HAT_RIGHT or SDL_HAT_UP; + SDL_HAT_RIGHTDOWN = SDL_HAT_RIGHT or SDL_HAT_DOWN; + SDL_HAT_LEFTUP = SDL_HAT_LEFT or SDL_HAT_UP; + SDL_HAT_LEFTDOWN = SDL_HAT_LEFT or SDL_HAT_DOWN; + + const + AUDIO_U8 = $0008; + AUDIO_S8 = $8008; + AUDIO_U16LSB = $0010; + AUDIO_S16LSB = $8010; + AUDIO_U16MSB = $1010; + AUDIO_S16MSB = $9010; + AUDIO_U16 = AUDIO_U16LSB; + AUDIO_S16 = AUDIO_S16LSB; + + const + SDL_TOUCH_MOUSEID = UInt32(-1); + + type + PSDL_Window = ^TSDL_Window; + TSDL_Window = record end; + + PSDL_Joystick = Pointer; + TSDL_JoystickGUID = record + data: array[0..15] of UInt8; + end; + TSDL_JoystickID = SInt32; + + PSDL_RWops = ^TSDL_RWops; + + TSize = function(context: PSDL_RWops): SInt64; cdecl; + TSeek = function(context: PSDL_RWops; offset: SInt64; whence: SInt32): SInt64; cdecl; + TRead = function(context: PSDL_RWops; ptr: Pointer; size: size_t; maxnum: size_t): size_t; cdecl; + TWrite = function(context: PSDL_RWops; const ptr: Pointer; size: size_t; num: size_t): size_t; cdecl; + TClose = function(context: PSDL_RWops): SInt32; cdecl; + + TStdio = record + autoclose: TSDL_Bool; + fp: file; + end; + + TMem = record + base: PUInt8; + here: PUInt8; + stop: PUInt8; + end; + + TUnknown = record + data1: Pointer; + end; + + TSDL_RWops = packed record + size: TSize; + seek: TSeek; + read: TRead; + write: TWrite; + close: TClose; + _type: UInt32; + case Integer of + 0: (stdio: TStdio); + 1: (mem: TMem); + 2: (unknown: TUnknown); + {$IFDEF ANDROID} + 3: (androidio: TAndroidIO); + {$ENDIF} + {$IFDEF WINDOWS} + 3: (windowsio: TWindowsIO); + {$ENDIF} + end; + + PSDL_TouchID = ^TSDL_TouchID; + TSDL_TouchID = SInt64; + + PSDL_FingerID = ^TSDL_FingerID; + TSDL_FingerID = SInt64; + + + const + { Touch events } + SDL_FINGERDOWN = $700; + SDL_FINGERUP = $701; + SDL_FINGERMOTION = $702; + + type + TSDL_TouchFingerEvent = record + type_: UInt32; + timestamp: UInt32; + touchId: TSDL_TouchID; + fingerId: TSDL_FingerID; + x, y, dx, dy: Float; + pressure: Float; + end; + + + const + SDL_WINDOWPOS_CENTERED_MASK = $2FFF0000; + SDL_WINDOWPOS_CENTERED = SDL_WINDOWPOS_CENTERED_MASK or 0; + + type + PSDL_DisplayMode = ^TSDL_DisplayMode; + TSDL_DisplayMode = record + format: UInt32; + w: SInt32; + h: SInt32; + refresh_rate: SInt32; + driverdata: Pointer; + end; + + TSDL_GLContext = Pointer; + + const + SDL_WINDOW_FULLSCREEN = $00000001; + SDL_WINDOW_OPENGL = $00000002; + SDL_WINDOW_SHOWN = $00000004; + SDL_WINDOW_HIDDEN = $00000008; + SDL_WINDOW_BORDERLESS = $00000010; + SDL_WINDOW_RESIZABLE = $00000020; + SDL_WINDOW_MINIMIZED = $00000040; + SDL_WINDOW_MAXIMIZED = $00000080; + SDL_WINDOW_INPUT_GRABBED = $00000100; + SDL_WINDOW_INPUT_FOCUS = $00000200; + SDL_WINDOW_MOUSE_FOCUS = $00000400; + SDL_WINDOW_FULLSCREEN_DESKTOP = SDL_WINDOW_FULLSCREEN or $00001000; + SDL_WINDOW_FOREIGN = $00000800; + SDL_WINDOW_ALLOW_HIGHDPI = $00002000; + + SDL_WINDOWEVENT_EXPOSED = 3; + SDL_WINDOWEVENT_MOVED = 4; + SDL_WINDOWEVENT_RESIZED = 5; + SDL_WINDOWEVENT_MINIMIZED = 7; + SDL_WINDOWEVENT_MAXIMIZED = 8; + SDL_WINDOWEVENT_RESTORED = 9; + SDL_WINDOWEVENT_FOCUS_GAINED = 12; + SDL_WINDOWEVENT_FOCUS_LOST = 13; + + SDL_DISABLE = 0; + SDL_ENABLE = 1; + + SDL_TEXTINPUTEVENT_TEXT_SIZE = 32; + + SDL_FIRSTEVENT = 0; + SDL_COMMONEVENT = 1; + SDL_QUITEV = $100; + SDL_WINDOWEVENT = $200; + SDL_KEYDOWN = $300; + SDL_KEYUP = $301; + //SDL_TEXTEDITING = $302; + SDL_TEXTINPUT = $303; + + type + TSDL_WindowEvent = record + type_: UInt32; // SDL_WINDOWEVENT + timestamp: UInt32; + windowID: UInt32; // The associated window + event: UInt8; // SDL_WindowEventID + padding1: UInt8; + padding2: UInt8; + padding3: UInt8; + data1: SInt32; // event dependent data + data2: SInt32; // event dependent data + end; + + PSDL_Keysym = ^TSDL_Keysym; + TSDL_Keysym = record + scancode: TSDL_ScanCode; // SDL physical key code - see SDL_Scancode for details + sym: TSDL_KeyCode; // SDL virtual key code - see SDL_Keycode for details + _mod: UInt16; // current key modifiers + unicode: UInt32; // (deprecated) use SDL_TextInputEvent instead + end; + + TSDL_KeyboardEvent = record + type_: UInt32; // SDL_KEYDOWN or SDL_KEYUP + timestamp: UInt32; + windowID: UInt32; // The window with keyboard focus, if any + state: UInt8; // SDL_PRESSED or SDL_RELEASED + _repeat: UInt8; // Non-zero if this is a key repeat + padding2: UInt8; + padding3: UInt8; + keysym: TSDL_KeySym; // The key that was pressed or released + end; + + TSDL_TextInputEvent = record + type_: UInt32; // SDL_TEXTINPUT + timestamp: UInt32; + windowID: UInt32; // The window with keyboard focus, if any + text: array[0..SDL_TEXTINPUTEVENT_TEXT_SIZE] of Char; // The input text + end; + + TSDL_QuitEvent = record + type_: UInt32; // SDL_QUIT + timestamp: UInt32; + end; + + PSDL_Event = ^TSDL_Event; + TSDL_Event = record + case Integer of + 0: (type_: UInt32); + //SDL_COMMONEVENT: (common: TSDL_CommonEvent); + SDL_WINDOWEVENT: (window: TSDL_WindowEvent); + SDL_KEYUP, + SDL_KEYDOWN: (key: TSDL_KeyboardEvent); + //SDL_TEXTEDITING: (edit: TSDL_TextEditingEvent); + SDL_TEXTINPUT: (text: TSDL_TextInputEvent); + //SDL_MOUSEMOTION: (motion: TSDL_MouseMotionEvent); + //SDL_MOUSEBUTTONUP, + //SDL_MOUSEBUTTONDOWN: (button: TSDL_MouseButtonEvent); + //SDL_MOUSEWHEEL: (wheel: TSDL_MouseWheelEvent); + //SDL_JOYAXISMOTION: (jaxis: TSDL_JoyAxisEvent); + //SDL_JOYBALLMOTION: (jball: TSDL_JoyBallEvent); + //SDL_JOYHATMOTION: (jhat: TSDL_JoyHatEvent); + //SDL_JOYBUTTONDOWN, + //SDL_JOYBUTTONUP: (jbutton: TSDL_JoyButtonEvent); + //SDL_JOYDEVICEADDED, + //SDL_JOYDEVICEREMOVED: (jdevice: TSDL_JoyDeviceEvent); + //SDL_CONTROLLERAXISMOTION: (caxis: TSDL_ControllerAxisEvent); + //SDL_CONTROLLERBUTTONUP, + //SDL_CONTROLLERBUTTONDOWN: (cbutton: TSDL_ControllerButtonEvent); + //SDL_CONTROLLERDEVICEADDED, + //SDL_CONTROLLERDEVICEREMOVED, + //SDL_CONTROLLERDEVICEREMAPPED: (cdevice: TSDL_ControllerDeviceEvent); + //SDL_AUDIODEVICEADDED, + //SDL_AUDIODEVICEREMOVED: (adevice: TSDL_AudioDeviceEvent); + SDL_QUITEV: (quit: TSDL_QuitEvent); + //SDL_USEREVENT: (user: TSDL_UserEvent); + //SDL_SYSWMEVENT: (syswm: TSDL_SysWMEvent); + SDL_FINGERDOWN, + SDL_FINGERUP, + SDL_FINGERMOTION: (tfinger: TSDL_TouchFingerEvent); + //SDL_MULTIGESTURE: (mgesture: TSDL_MultiGestureEvent); + //SDL_DOLLARGESTURE,SDL_DOLLARRECORD: (dgesture: TSDL_DollarGestureEvent); + //SDL_DROPFILE: (drop: TSDL_DropEvent); + end; + + const + SDL_GL_RED_SIZE = 0; + SDL_GL_GREEN_SIZE = 1; + SDL_GL_BLUE_SIZE = 2; + SDL_GL_ALPHA_SIZE = 3; + SDL_GL_BUFFER_SIZE = 4; + SDL_GL_DOUBLEBUFFER = 5; + SDL_GL_DEPTH_SIZE = 6; + SDL_GL_STENCIL_SIZE = 7; + SDL_GL_ACCUM_RED_SIZE = 8; + SDL_GL_ACCUM_GREEN_SIZE = 9; + SDL_GL_ACCUM_BLUE_SIZE = 10; + SDL_GL_ACCUM_ALPHA_SIZE = 11; + SDL_GL_STEREO = 12; + SDL_GL_MULTISAMPLEBUFFERS = 13; + SDL_GL_MULTISAMPLESAMPLES = 14; + SDL_GL_ACCELERATED_VISUAL = 15; + SDL_GL_RETAINED_BACKING = 16; + SDL_GL_CONTEXT_MAJOR_VERSION = 17; + SDL_GL_CONTEXT_MINOR_VERSION = 18; + SDL_GL_CONTEXT_EGL = 19; + SDL_GL_CONTEXT_FLAGS = 20; + SDL_GL_CONTEXT_PROFILE_MASK = 21; + SDL_GL_SHARE_WITH_CURRENT_CONTEXT = 22; + SDL_GL_FRAMEBUFFER_SRGB_CAPABLE = 23; + + type + TSDL_GLattr = DWord; + + const + SDL_INIT_TIMER = $00000001; + SDL_INIT_AUDIO = $00000010; + SDL_INIT_VIDEO = $00000020; + SDL_INIT_JOYSTICK = $00000200; + SDL_INIT_HAPTIC = $00001000; + SDL_INIT_GAMECONTROLLER = $00002000; //turn on game controller also implicitly does JOYSTICK + SDL_INIT_NOPARACHUTE = $00100000; //Don't catch fatal signals + SDL_INIT_EVERYTHING = SDL_INIT_TIMER or SDL_INIT_AUDIO or + SDL_INIT_VIDEO or SDL_INIT_JOYSTICK or + SDL_INIT_HAPTIC or SDL_INIT_GAMECONTROLLER; + + SDL_HINT_ACCELEROMETER_AS_JOYSTICK = 'SDL_ACCELEROMETER_AS_JOYSTICK'; + + /// MACRO /// + function SDL_BITSPERPIXEL(X: Cardinal): Cardinal; + + /// FUNCTIONS /// + + function SDL_SetWindowGammaRamp(window: PSDL_Window; const red: PUInt16; const green: PUInt16; const blue: PUInt16): SInt32; + function SDL_GetWindowGammaRamp(window: PSDL_Window; red: PUInt16; green: PUInt16; blue: PUInt16): SInt32; + + function SDL_NumJoysticks: SInt32; + function SDL_JoystickOpen(device_index: SInt32): PSDL_Joystick; + function SDL_JoystickName(joystick: PSDL_Joystick): PAnsiChar; + function SDL_JoystickNumAxes(joystick: PSDL_Joystick): SInt32; + function SDL_JoystickNumButtons(joystick: PSDL_Joystick): SInt32; + function SDL_JoystickNumHats(joystick: PSDL_Joystick): SInt32; + procedure SDL_JoystickClose(joystick: PSDL_Joystick); + procedure SDL_JoystickUpdate; + function SDL_JoystickGetButton(joystick: PSDL_Joystick; button: SInt32): UInt8; + function SDL_JoystickGetAxis(joystick: PSDL_Joystick; axis: SInt32): SInt16; + function SDL_JoystickGetHat(joystick: PSDL_Joystick; hat: SInt32): UInt8; + + function SDL_GetScancodeName(scancode: TSDL_ScanCode): PAnsiChar; + + function SDL_GetPerformanceCounter: UInt64; + function SDL_GetPerformanceFrequency: UInt64; + + function SDL_RWFromFile(const _file: PAnsiChar; const mode: PAnsiChar): PSDL_RWops; + function SDL_RWFromConstMem(const mem: Pointer; size: SInt32): PSDL_RWops; + + function SDL_GetDisplayDPI(displayIndex: SInt32; ddpi, hdpi, vdpi: PFloat): SInt32; + function SDL_IsTextInputActive: TSDL_Bool; + procedure SDL_StartTextInput; + procedure SDL_StopTextInput; + function SDL_GetNumTouchDevices: SInt32; + + function SDL_GetDesktopDisplayMode(displayIndex: SInt32; mode: PSDL_DisplayMode): SInt32; + function SDL_GetClosestDisplayMode(displayIndex: SInt32; const mode: PSDL_DisplayMode; closest: PSDL_DisplayMode): PSDL_DisplayMode; + + procedure SDL_DestroyWindow(window: PSDL_Window); + procedure SDL_GL_DeleteContext(context: TSDL_GLContext); + procedure SDL_RestoreWindow(window: PSDL_Window); + procedure SDL_SetWindowSize(window: PSDL_Window; w: SInt32; h: SInt32); + function SDL_CreateWindow(const title: PAnsiChar; x: SInt32; y: SInt32; w: SInt32; h: SInt32; flags: UInt32): PSDL_Window; + function SDL_SetWindowFullscreen(window: PSDL_Window; flags: UInt32): SInt32; + function SDL_GL_MakeCurrent(window: PSDL_Window; context: TSDL_GLContext): SInt32; + procedure SDL_GetWindowSize(window: PSDL_Window; w: PInt; h: PInt); + function SDL_GetNumDisplayModes(displayIndex: SInt32): SInt32; + function SDL_GetDisplayMode(displayIndex: SInt32; modeIndex: SInt32; mode: PSDL_DisplayMode): SInt32; + + function SDL_ShowCursor(toggle: SInt32): SInt32; + procedure SDL_Delay(ms: UInt32); + procedure SDL_GL_SwapWindow(window: PSDL_Window); + + function SDL_GL_CreateContext(window: PSDL_Window): TSDL_GLContext; + function SDL_GetTicks: UInt32; + + function SDL_PushEvent(event: PSDL_Event): SInt32; + function SDL_PollEvent(event: PSDL_Event): SInt32; + function SDL_GL_SetSwapInterval(interval: SInt32): SInt32; + function SDL_GL_SetAttribute(attr: TSDL_GLattr; value: SInt32): SInt32; + function SDL_GL_GetAttribute(attr: TSDL_GLattr; value: PInt): SInt32; + + function SDL_GetError: PAnsiChar; + + function SDL_Init(flags: UInt32): SInt32; + procedure SDL_Quit(); + function SDL_SetHint( const name: PChar; const value: PChar) : boolean; + +implementation + /// MACRO /// + + function SDL_BITSPERPIXEL(X: Cardinal): Cardinal; + begin + Result := (X shr 8) and $FF; + end; + + /// FUNCTIONS //// + + function SDL_SetWindowGammaRamp(window: PSDL_Window; const red: PUInt16; const green: PUInt16; const blue: PUInt16): SInt32; + begin + result := 0 + end; + + function SDL_GetWindowGammaRamp(window: PSDL_Window; red: PUInt16; green: PUInt16; blue: PUInt16): SInt32; + begin + result := 0 + end; + + + function SDL_NumJoysticks: SInt32; + begin + result := 0 + end; + + function SDL_JoystickOpen(device_index: SInt32): PSDL_Joystick; + begin + result := nil + end; + + function SDL_JoystickName(joystick: PSDL_Joystick): PAnsiChar; + begin + result := '' + end; + + function SDL_JoystickNumAxes(joystick: PSDL_Joystick): SInt32; + begin + result := 0 + end; + + function SDL_JoystickNumButtons(joystick: PSDL_Joystick): SInt32; + begin + result := 0 + end; + + function SDL_JoystickNumHats(joystick: PSDL_Joystick): SInt32; + begin + result := 0 + end; + + procedure SDL_JoystickClose(joystick: PSDL_Joystick); + begin + end; + + procedure SDL_JoystickUpdate; + begin + end; + + function SDL_JoystickGetButton(joystick: PSDL_Joystick; button: SInt32): UInt8; + begin + result := 0 + end; + + function SDL_JoystickGetAxis(joystick: PSDL_Joystick; axis: SInt32): SInt16; + begin + result := 0 + end; + + function SDL_JoystickGetHat(joystick: PSDL_Joystick; hat: SInt32): UInt8; + begin + result := 0 + end; + + + + + function SDL_GetScancodeName(scancode: TSDL_ScanCode): PAnsiChar; + begin + result := '' + end; + + + + + function SDL_GetPerformanceCounter: UInt64; + begin + result := 0 + end; + + function SDL_GetPerformanceFrequency: UInt64; + begin + result := 0 + end; + + + + function SDL_RWFromFile(const _file: PAnsiChar; const mode: PAnsiChar): PSDL_RWops; + begin + result := nil + end; + + function SDL_RWFromConstMem(const mem: Pointer; size: SInt32): PSDL_RWops; + begin + result := nil + end; + + + + + function SDL_GetDisplayDPI(displayIndex: SInt32; ddpi, hdpi, vdpi: PFloat): SInt32; + begin + result := 0 + end; + + function SDL_IsTextInputActive: TSDL_Bool; + begin + result := SDL_FALSE + end; + + procedure SDL_StartTextInput; + begin + end; + + procedure SDL_StopTextInput; + begin + end; + + function SDL_GetNumTouchDevices: SInt32; + begin + result := 0 + end; + + + + function SDL_GetDesktopDisplayMode(displayIndex: SInt32; mode: PSDL_DisplayMode): SInt32; + begin + result := 0 + end; + + function SDL_GetClosestDisplayMode(displayIndex: SInt32; const mode: PSDL_DisplayMode; closest: PSDL_DisplayMode): PSDL_DisplayMode; + begin + result := nil + end; + + procedure SDL_DestroyWindow(window: PSDL_Window); + begin + end; + + procedure SDL_GL_DeleteContext(context: TSDL_GLContext); + begin + end; + + procedure SDL_RestoreWindow(window: PSDL_Window); + begin + end; + + procedure SDL_SetWindowSize(window: PSDL_Window; w: SInt32; h: SInt32); + begin + end; + + function SDL_CreateWindow(const title: PAnsiChar; x: SInt32; y: SInt32; w: SInt32; h: SInt32; flags: UInt32): PSDL_Window; + begin + result := nil + end; + + function SDL_SetWindowFullscreen(window: PSDL_Window; flags: UInt32): SInt32; + begin + result := 0 + end; + + function SDL_GL_MakeCurrent(window: PSDL_Window; context: TSDL_GLContext): SInt32; + begin + result := 0 + end; + + procedure SDL_GetWindowSize(window: PSDL_Window; w: PInt; h: PInt); + begin + end; + + function SDL_GetNumDisplayModes(displayIndex: SInt32): SInt32; + begin + result := 0 + end; + + function SDL_GetDisplayMode(displayIndex: SInt32; modeIndex: SInt32; mode: PSDL_DisplayMode): SInt32; + begin + result := 0 + end; + + function SDL_ShowCursor(toggle: SInt32): SInt32; + begin + result := 0 + end; + + procedure SDL_Delay(ms: UInt32); + begin + end; + + procedure SDL_GL_SwapWindow(window: PSDL_Window); + begin + end; + + function SDL_GL_CreateContext(window: PSDL_Window): TSDL_GLContext; + begin + result := nil + end; + + function SDL_GetTicks: UInt32; + begin + result := 0 + end; + + function SDL_PushEvent(event: PSDL_Event): SInt32; + begin + result := 0 + end; + + function SDL_PollEvent(event: PSDL_Event): SInt32; + begin + result := 0 + end; + + function SDL_GL_SetSwapInterval(interval: SInt32): SInt32; + begin + result := 0 + end; + + function SDL_GL_SetAttribute(attr: TSDL_GLattr; value: SInt32): SInt32; + begin + result := 0 + end; + + function SDL_GL_GetAttribute(attr: TSDL_GLattr; value: PInt): SInt32; + begin + result := 0 + end; + + function SDL_GetError: PAnsiChar; + begin + result := '' + end; + + function SDL_Init(flags: UInt32): SInt32; + begin + result := 0 + end; + + procedure SDL_Quit(); + begin + end; + + function SDL_SetHint( const name: PChar; const value: PChar) : boolean; + begin + result := false + end; + +end. diff --git a/src/wrappers/sdl2/sdlscancode.inc b/src/wrappers/sdl2/sdlscancode.inc new file mode 100644 index 0000000..d9d0d68 --- /dev/null +++ b/src/wrappers/sdl2/sdlscancode.inc @@ -0,0 +1,662 @@ +//from "sdl_scancode.h" + + {** + * The SDL keyboard scancode representation. + * + * Values of this type are used to represent keyboard keys, among other places + * in the SDL_Keysym.scancode key.keysym.scancode \endlink field of the + * SDL_Event structure. + * + * The values in this enumeration are based on the USB usage page standard: + * http://www.usb.org/developers/devclass_docs/Hut1_12v2.pdf + *} + +const + SDL_SCANCODE_UNKNOWN = 0; + + {** + * Usage page $07 + * + * These values are from usage page $07 (USB keyboard page). + *} + + SDL_SCANCODE_A = 4; + SDL_SCANCODE_B = 5; + SDL_SCANCODE_C = 6; + SDL_SCANCODE_D = 7; + SDL_SCANCODE_E = 8; + SDL_SCANCODE_F = 9; + SDL_SCANCODE_G = 10; + SDL_SCANCODE_H = 11; + SDL_SCANCODE_I = 12; + SDL_SCANCODE_J = 13; + SDL_SCANCODE_K = 14; + SDL_SCANCODE_L = 15; + SDL_SCANCODE_M = 16; + SDL_SCANCODE_N = 17; + SDL_SCANCODE_O = 18; + SDL_SCANCODE_P = 19; + SDL_SCANCODE_Q = 20; + SDL_SCANCODE_R = 21; + SDL_SCANCODE_S = 22; + SDL_SCANCODE_T = 23; + SDL_SCANCODE_U = 24; + SDL_SCANCODE_V = 25; + SDL_SCANCODE_W = 26; + SDL_SCANCODE_X = 27; + SDL_SCANCODE_Y = 28; + SDL_SCANCODE_Z = 29; + + SDL_SCANCODE_1 = 30; + SDL_SCANCODE_2 = 31; + SDL_SCANCODE_3 = 32; + SDL_SCANCODE_4 = 33; + SDL_SCANCODE_5 = 34; + SDL_SCANCODE_6 = 35; + SDL_SCANCODE_7 = 36; + SDL_SCANCODE_8 = 37; + SDL_SCANCODE_9 = 38; + SDL_SCANCODE_0 = 39; + + SDL_SCANCODE_RETURN = 40; + SDL_SCANCODE_ESCAPE = 41; + SDL_SCANCODE_BACKSPACE = 42; + SDL_SCANCODE_TAB = 43; + SDL_SCANCODE_SPACE = 44; + + SDL_SCANCODE_MINUS = 45; + SDL_SCANCODE_EQUALS = 46; + SDL_SCANCODE_LEFTBRACKET = 47; + SDL_SCANCODE_RIGHTBRACKET = 48; + SDL_SCANCODE_BACKSLASH = 49; {**< Located at the lower left of the return + * key on ISO keyboards and at the right end + * of the QWERTY row on ANSI keyboards. + * Produces REVERSE SOLIDUS (backslash) and + * VERTICAL LINE in a US layout; REVERSE + * SOLIDUS and VERTICAL LINE in a UK Mac + * layout; NUMBER SIGN and TILDE in a UK + * Windows layout; DOLLAR SIGN and POUND SIGN + * in a Swiss German layout; NUMBER SIGN and + * APOSTROPHE in a German layout; GRAVE + * ACCENT and POUND SIGN in a French Mac + * layout; and ASTERISK and MICRO SIGN in a + * French Windows layout. + *} + SDL_SCANCODE_NONUSHASH = 50; {**< ISO USB keyboards actually use this code + * instead of 49 for the same key; but all + * OSes I've seen treat the two codes + * identically. So; as an implementor; unless + * your keyboard generates both of those + * codes and your OS treats them differently; + * you should generate SDL_SCANCODE_BACKSLASH + * instead of this code. As a user; you + * should not rely on this code because SDL + * will never generate it with most (all?) + * keyboards. + *} + SDL_SCANCODE_SEMICOLON = 51; + SDL_SCANCODE_APOSTROPHE = 52; + SDL_SCANCODE_GRAVE = 53; {**< Located in the top left corner (on both ANSI + * and ISO keyboards). Produces GRAVE ACCENT and + * TILDE in a US Windows layout and in US and UK + * Mac layouts on ANSI keyboards; GRAVE ACCENT + * and NOT SIGN in a UK Windows layout; SECTION + * SIGN and PLUS-MINUS SIGN in US and UK Mac + * layouts on ISO keyboards; SECTION SIGN and + * DEGREE SIGN in a Swiss German layout (Mac: + * only on ISO keyboards); CIRCUMFLEX ACCENT and + * DEGREE SIGN in a German layout (Mac: only on + * ISO keyboards); SUPERSCRIPT TWO and TILDE in a + * French Windows layout; COMMERCIAL AT and + * NUMBER SIGN in a French Mac layout on ISO + * keyboards; and LESS-THAN SIGN and GREATER-THAN + * SIGN in a Swiss German; German; or French Mac + * layout on ANSI keyboards. + *} + SDL_SCANCODE_COMMA = 54; + SDL_SCANCODE_PERIOD = 55; + SDL_SCANCODE_SLASH = 56; + + SDL_SCANCODE_CAPSLOCK = 57; + + SDL_SCANCODE_F1 = 58; + SDL_SCANCODE_F2 = 59; + SDL_SCANCODE_F3 = 60; + SDL_SCANCODE_F4 = 61; + SDL_SCANCODE_F5 = 62; + SDL_SCANCODE_F6 = 63; + SDL_SCANCODE_F7 = 64; + SDL_SCANCODE_F8 = 65; + SDL_SCANCODE_F9 = 66; + SDL_SCANCODE_F10 = 67; + SDL_SCANCODE_F11 = 68; + SDL_SCANCODE_F12 = 69; + + SDL_SCANCODE_PRINTSCREEN = 70; + SDL_SCANCODE_SCROLLLOCK = 71; + SDL_SCANCODE_PAUSE = 72; + SDL_SCANCODE_INSERT = 73; {**< insert on PC; help on some Mac keyboards (but + does send code 73; not 117) *} + SDL_SCANCODE_HOME = 74; + SDL_SCANCODE_PAGEUP = 75; + SDL_SCANCODE_DELETE = 76; + SDL_SCANCODE_END = 77; + SDL_SCANCODE_PAGEDOWN = 78; + SDL_SCANCODE_RIGHT = 79; + SDL_SCANCODE_LEFT = 80; + SDL_SCANCODE_DOWN = 81; + SDL_SCANCODE_UP = 82; + + SDL_SCANCODE_NUMLOCKCLEAR = 83; {**< num lock on PC; clear on Mac keyboards + *} + SDL_SCANCODE_KP_DIVIDE = 84; + SDL_SCANCODE_KP_MULTIPLY = 85; + SDL_SCANCODE_KP_MINUS = 86; + SDL_SCANCODE_KP_PLUS = 87; + SDL_SCANCODE_KP_ENTER = 88; + SDL_SCANCODE_KP_1 = 89; + SDL_SCANCODE_KP_2 = 90; + SDL_SCANCODE_KP_3 = 91; + SDL_SCANCODE_KP_4 = 92; + SDL_SCANCODE_KP_5 = 93; + SDL_SCANCODE_KP_6 = 94; + SDL_SCANCODE_KP_7 = 95; + SDL_SCANCODE_KP_8 = 96; + SDL_SCANCODE_KP_9 = 97; + SDL_SCANCODE_KP_0 = 98; + SDL_SCANCODE_KP_PERIOD = 99; + + SDL_SCANCODE_NONUSBACKSLASH = 100; {**< This is the additional key that ISO + * keyboards have over ANSI ones; + * located between left shift and Y. + * Produces GRAVE ACCENT and TILDE in a + * US or UK Mac layout; REVERSE SOLIDUS + * (backslash) and VERTICAL LINE in a + * US or UK Windows layout; and + * LESS-THAN SIGN and GREATER-THAN SIGN + * in a Swiss German; German; or French + * layout. *} + SDL_SCANCODE_APPLICATION = 101; {**< windows contextual menu; compose *} + SDL_SCANCODE_POWER = 102; {**< The USB document says this is a status flag; + * not a physical key - but some Mac keyboards + * do have a power key. *} + SDL_SCANCODE_KP_EQUALS = 103; + SDL_SCANCODE_F13 = 104; + SDL_SCANCODE_F14 = 105; + SDL_SCANCODE_F15 = 106; + SDL_SCANCODE_F16 = 107; + SDL_SCANCODE_F17 = 108; + SDL_SCANCODE_F18 = 109; + SDL_SCANCODE_F19 = 110; + SDL_SCANCODE_F20 = 111; + SDL_SCANCODE_F21 = 112; + SDL_SCANCODE_F22 = 113; + SDL_SCANCODE_F23 = 114; + SDL_SCANCODE_F24 = 115; + SDL_SCANCODE_EXECUTE = 116; + SDL_SCANCODE_HELP = 117; + SDL_SCANCODE_MENU = 118; + SDL_SCANCODE_SELECT = 119; + SDL_SCANCODE_STOP = 120; + SDL_SCANCODE_AGAIN = 121; {**< redo *} + SDL_SCANCODE_UNDO = 122; + SDL_SCANCODE_CUT = 123; + SDL_SCANCODE_COPY = 124; + SDL_SCANCODE_PASTE = 125; + SDL_SCANCODE_FIND = 126; + SDL_SCANCODE_MUTE = 127; + SDL_SCANCODE_VOLUMEUP = 128; + SDL_SCANCODE_VOLUMEDOWN = 129; + {* not sure whether there's a reason to enable these *} + {* SDL_SCANCODE_LOCKINGCAPSLOCK = 130; *} + {* SDL_SCANCODE_LOCKINGNUMLOCK = 131; *} + {* SDL_SCANCODE_LOCKINGSCROLLLOCK = 132; *} + SDL_SCANCODE_KP_COMMA = 133; + SDL_SCANCODE_KP_EQUALSAS400 = 134; + + SDL_SCANCODE_INTERNATIONAL1 = 135; {**< used on Asian keyboards; see footnotes in USB doc *} + SDL_SCANCODE_INTERNATIONAL2 = 136; + SDL_SCANCODE_INTERNATIONAL3 = 137; {**< Yen *} + SDL_SCANCODE_INTERNATIONAL4 = 138; + SDL_SCANCODE_INTERNATIONAL5 = 139; + SDL_SCANCODE_INTERNATIONAL6 = 140; + SDL_SCANCODE_INTERNATIONAL7 = 141; + SDL_SCANCODE_INTERNATIONAL8 = 142; + SDL_SCANCODE_INTERNATIONAL9 = 143; + SDL_SCANCODE_LANG1 = 144; {**< Hangul{English toggle *} + SDL_SCANCODE_LANG2 = 145; {**< Hanja conversion *} + SDL_SCANCODE_LANG3 = 146; {**< Katakana *} + SDL_SCANCODE_LANG4 = 147; {**< Hiragana *} + SDL_SCANCODE_LANG5 = 148; {**< Zenkaku{Hankaku *} + SDL_SCANCODE_LANG6 = 149; {**< reserved *} + SDL_SCANCODE_LANG7 = 150; {**< reserved *} + SDL_SCANCODE_LANG8 = 151; {**< reserved *} + SDL_SCANCODE_LANG9 = 152; {**< reserved *} + + SDL_SCANCODE_ALTERASE = 153; {**< Erase-Eaze *} + SDL_SCANCODE_SYSREQ = 154; + SDL_SCANCODE_CANCEL = 155; + SDL_SCANCODE_CLEAR = 156; + SDL_SCANCODE_PRIOR = 157; + SDL_SCANCODE_RETURN2 = 158; + SDL_SCANCODE_SEPARATOR = 159; + SDL_SCANCODE_OUT = 160; + SDL_SCANCODE_OPER = 161; + SDL_SCANCODE_CLEARAGAIN = 162; + SDL_SCANCODE_CRSEL = 163; + SDL_SCANCODE_EXSEL = 164; + + SDL_SCANCODE_KP_00 = 176; + SDL_SCANCODE_KP_000 = 177; + SDL_SCANCODE_THOUSANDSSEPARATOR = 178; + SDL_SCANCODE_DECIMALSEPARATOR = 179; + SDL_SCANCODE_CURRENCYUNIT = 180; + SDL_SCANCODE_CURRENCYSUBUNIT = 181; + SDL_SCANCODE_KP_LEFTPAREN = 182; + SDL_SCANCODE_KP_RIGHTPAREN = 183; + SDL_SCANCODE_KP_LEFTBRACE = 184; + SDL_SCANCODE_KP_RIGHTBRACE = 185; + SDL_SCANCODE_KP_TAB = 186; + SDL_SCANCODE_KP_BACKSPACE = 187; + SDL_SCANCODE_KP_A = 188; + SDL_SCANCODE_KP_B = 189; + SDL_SCANCODE_KP_C = 190; + SDL_SCANCODE_KP_D = 191; + SDL_SCANCODE_KP_E = 192; + SDL_SCANCODE_KP_F = 193; + SDL_SCANCODE_KP_XOR = 194; + SDL_SCANCODE_KP_POWER = 195; + SDL_SCANCODE_KP_PERCENT = 196; + SDL_SCANCODE_KP_LESS = 197; + SDL_SCANCODE_KP_GREATER = 198; + SDL_SCANCODE_KP_AMPERSAND = 199; + SDL_SCANCODE_KP_DBLAMPERSAND = 200; + SDL_SCANCODE_KP_VERTICALBAR = 201; + SDL_SCANCODE_KP_DBLVERTICALBAR = 202; + SDL_SCANCODE_KP_COLON = 203; + SDL_SCANCODE_KP_HASH = 204; + SDL_SCANCODE_KP_SPACE = 205; + SDL_SCANCODE_KP_AT = 206; + SDL_SCANCODE_KP_EXCLAM = 207; + SDL_SCANCODE_KP_MEMSTORE = 208; + SDL_SCANCODE_KP_MEMRECALL = 209; + SDL_SCANCODE_KP_MEMCLEAR = 210; + SDL_SCANCODE_KP_MEMADD = 211; + SDL_SCANCODE_KP_MEMSUBTRACT = 212; + SDL_SCANCODE_KP_MEMMULTIPLY = 213; + SDL_SCANCODE_KP_MEMDIVIDE = 214; + SDL_SCANCODE_KP_PLUSMINUS = 215; + SDL_SCANCODE_KP_CLEAR = 216; + SDL_SCANCODE_KP_CLEARENTRY = 217; + SDL_SCANCODE_KP_BINARY = 218; + SDL_SCANCODE_KP_OCTAL = 219; + SDL_SCANCODE_KP_DECIMAL = 220; + SDL_SCANCODE_KP_HEXADECIMAL = 221; + + SDL_SCANCODE_LCTRL = 224; + SDL_SCANCODE_LSHIFT = 225; + SDL_SCANCODE_LALT = 226; {**< alt; option *} + SDL_SCANCODE_LGUI = 227; {**< windows; command (apple); meta *} + SDL_SCANCODE_RCTRL = 228; + SDL_SCANCODE_RSHIFT = 229; + SDL_SCANCODE_RALT = 230; {**< alt gr; option *} + SDL_SCANCODE_RGUI = 231; {**< windows; command (apple); meta *} + + SDL_SCANCODE_MODE = 257; {**< I'm not sure if this is really not covered + * by any of the above; but since there's a + * special KMOD_MODE for it I'm adding it here + *} + + {*Usage page $07*} + + {** + * Usage page $0C + * + * These values are mapped from usage page $0C (USB consumer page). + *} + + SDL_SCANCODE_AUDIONEXT = 258; + SDL_SCANCODE_AUDIOPREV = 259; + SDL_SCANCODE_AUDIOSTOP = 260; + SDL_SCANCODE_AUDIOPLAY = 261; + SDL_SCANCODE_AUDIOMUTE = 262; + SDL_SCANCODE_MEDIASELECT = 263; + SDL_SCANCODE_WWW = 264; + SDL_SCANCODE_MAIL = 265; + SDL_SCANCODE_CALCULATOR = 266; + SDL_SCANCODE_COMPUTER = 267; + SDL_SCANCODE_AC_SEARCH = 268; + SDL_SCANCODE_AC_HOME = 269; + SDL_SCANCODE_AC_BACK = 270; + SDL_SCANCODE_AC_FORWARD = 271; + SDL_SCANCODE_AC_STOP = 272; + SDL_SCANCODE_AC_REFRESH = 273; + SDL_SCANCODE_AC_BOOKMARKS = 274; + + {*Usage page $0C*} + + {** + * Walther keys + * + * These are values that Christian Walther added (for mac keyboard?). + *} + + SDL_SCANCODE_BRIGHTNESSDOWN = 275; + SDL_SCANCODE_BRIGHTNESSUP = 276; + SDL_SCANCODE_DISPLAYSWITCH = 277; {**< display mirroring{dual display + switch; video mode switch *} + SDL_SCANCODE_KBDILLUMTOGGLE = 278; + SDL_SCANCODE_KBDILLUMDOWN = 279; + SDL_SCANCODE_KBDILLUMUP = 280; + SDL_SCANCODE_EJECT = 281; + SDL_SCANCODE_SLEEP = 282; + + SDL_SCANCODE_APP1 = 283; + SDL_SCANCODE_APP2 = 284; + + {*Walther keys*} + + {* Add any other keys here. *} + + SDL_NUM_SCANCODES = 512; {**< not a key, just marks the number of scancodes + for array bounds *} + +type + PSDL_ScanCode = ^TSDL_ScanCode; + TSDL_ScanCode = DWord; + + //from "sdl_keycode.h" + + {** + * The SDL virtual key representation. + * + * Values of this type are used to represent keyboard keys using the current + * layout of the keyboard. These values include Unicode values representing + * the unmodified character that would be generated by pressing the key, or + * an SDLK_* constant for those keys that do not generate characters. + *} + PSDL_KeyCode = ^TSDL_KeyCode; + TSDL_KeyCode = SInt32; + +const + SDLK_SCANCODE_MASK = 1 shl 30; + + SDLK_UNKNOWN = 0; + + SDLK_RETURN = SInt32(#13); // C: '\r' + SDLK_ESCAPE = SInt32(#27); // C: '\033' + SDLK_BACKSPACE = SInt32(#8); // C: '\b' + SDLK_TAB = SInt32(#9); // C: '\t' + SDLK_SPACE = SInt32(' '); + SDLK_EXCLAIM = SInt32('!'); + SDLK_QUOTEDBL = SInt32('"'); + SDLK_HASH = SInt32('#'); + SDLK_PERCENT = SInt32('%'); + SDLK_DOLLAR = SInt32('$'); + SDLK_AMPERSAND = SInt32('&'); + SDLK_QUOTE = SInt32('\'); + SDLK_LEFTPAREN = SInt32('('); + SDLK_RIGHTPAREN = SInt32(')'); + SDLK_ASTERISK = SInt32('*'); + SDLK_PLUS = SInt32('+'); + SDLK_COMMA = SInt32(','); + SDLK_MINUS = SInt32('-'); + SDLK_PERIOD = SInt32('.'); + SDLK_SLASH = SInt32('/'); + SDLK_0 = SInt32('0'); + SDLK_1 = SInt32('1'); + SDLK_2 = SInt32('2'); + SDLK_3 = SInt32('3'); + SDLK_4 = SInt32('4'); + SDLK_5 = SInt32('5'); + SDLK_6 = SInt32('6'); + SDLK_7 = SInt32('7'); + SDLK_8 = SInt32('8'); + SDLK_9 = SInt32('9'); + SDLK_COLON = SInt32(':'); + SDLK_SEMICOLON = SInt32(';'); + SDLK_LESS = SInt32('<'); + SDLK_EQUALS = SInt32('='); + SDLK_GREATER = SInt32('>'); + SDLK_QUESTION = SInt32('?'); + SDLK_AT = SInt32('@'); + {* + Skip uppercase letters + *} + SDLK_LEFTBRACKET = SInt32('['); + SDLK_BACKSLASH = SInt32('\'); + SDLK_RIGHTBRACKET = SInt32(']'); + SDLK_CARET = SInt32('^'); + SDLK_UNDERSCORE = SInt32('_'); + SDLK_BACKQUOTE = SInt32('`'); + SDLK_a = SInt32('a'); + SDLK_b = SInt32('b'); + SDLK_c = SInt32('c'); + SDLK_d = SInt32('d'); + SDLK_e = SInt32('e'); + SDLK_f = SInt32('f'); + SDLK_g = SInt32('g'); + SDLK_h = SInt32('h'); + SDLK_i = SInt32('i'); + SDLK_j = SInt32('j'); + SDLK_k = SInt32('k'); + SDLK_l = SInt32('l'); + SDLK_m = SInt32('m'); + SDLK_n = SInt32('n'); + SDLK_o = SInt32('o'); + SDLK_p = SInt32('p'); + SDLK_q = SInt32('q'); + SDLK_r = SInt32('r'); + SDLK_s = SInt32('s'); + SDLK_t = SInt32('t'); + SDLK_u = SInt32('u'); + SDLK_v = SInt32('v'); + SDLK_w = SInt32('w'); + SDLK_x = SInt32('x'); + SDLK_y = SInt32('y'); + SDLK_z = SInt32('z'); + + SDLK_CAPSLOCK = SDL_SCANCODE_CAPSLOCK or SDLK_SCANCODE_MASK; + + SDLK_F1 = SDL_SCANCODE_F1 or SDLK_SCANCODE_MASK; + SDLK_F2 = SDL_SCANCODE_F2 or SDLK_SCANCODE_MASK; + SDLK_F3 = SDL_SCANCODE_F3 or SDLK_SCANCODE_MASK; + SDLK_F4 = SDL_SCANCODE_F4 or SDLK_SCANCODE_MASK; + SDLK_F5 = SDL_SCANCODE_F5 or SDLK_SCANCODE_MASK; + SDLK_F6 = SDL_SCANCODE_F6 or SDLK_SCANCODE_MASK; + SDLK_F7 = SDL_SCANCODE_F7 or SDLK_SCANCODE_MASK; + SDLK_F8 = SDL_SCANCODE_F8 or SDLK_SCANCODE_MASK; + SDLK_F9 = SDL_SCANCODE_F9 or SDLK_SCANCODE_MASK; + SDLK_F10 = SDL_SCANCODE_F10 or SDLK_SCANCODE_MASK; + SDLK_F11 = SDL_SCANCODE_F11 or SDLK_SCANCODE_MASK; + SDLK_F12 = SDL_SCANCODE_F12 or SDLK_SCANCODE_MASK; + + SDLK_PRINTSCREEN = SDL_SCANCODE_PRINTSCREEN or SDLK_SCANCODE_MASK; + SDLK_SCROLLLOCK = SDL_SCANCODE_SCROLLLOCK or SDLK_SCANCODE_MASK; + SDLK_PAUSE = SDL_SCANCODE_PAUSE or SDLK_SCANCODE_MASK; + SDLK_INSERT = SDL_SCANCODE_INSERT or SDLK_SCANCODE_MASK; + SDLK_HOME = SDL_SCANCODE_HOME or SDLK_SCANCODE_MASK; + SDLK_PAGEUP = SDL_SCANCODE_PAGEUP or SDLK_SCANCODE_MASK; + SDLK_DELETE = SInt32(#127); // C: '\177' + SDLK_END = SDL_SCANCODE_END or SDLK_SCANCODE_MASK; + SDLK_PAGEDOWN = SDL_SCANCODE_PAGEDOWN or SDLK_SCANCODE_MASK; + SDLK_RIGHT = SDL_SCANCODE_RIGHT or SDLK_SCANCODE_MASK; + SDLK_LEFT = SDL_SCANCODE_LEFT or SDLK_SCANCODE_MASK; + SDLK_DOWN = SDL_SCANCODE_DOWN or SDLK_SCANCODE_MASK; + SDLK_UP = SDL_SCANCODE_UP or SDLK_SCANCODE_MASK; + + SDLK_NUMLOCKCLEAR = SDL_SCANCODE_NUMLOCKCLEAR or SDLK_SCANCODE_MASK; + SDLK_KP_DIVIDE = SDL_SCANCODE_KP_DIVIDE or SDLK_SCANCODE_MASK; + SDLK_KP_MULTIPLY = SDL_SCANCODE_KP_MULTIPLY or SDLK_SCANCODE_MASK; + SDLK_KP_MINUS = SDL_SCANCODE_KP_MINUS or SDLK_SCANCODE_MASK; + SDLK_KP_PLUS = SDL_SCANCODE_KP_PLUS or SDLK_SCANCODE_MASK; + SDLK_KP_ENTER = SDL_SCANCODE_KP_ENTER or SDLK_SCANCODE_MASK; + SDLK_KP_1 = SDL_SCANCODE_KP_1 or SDLK_SCANCODE_MASK; + SDLK_KP_2 = SDL_SCANCODE_KP_2 or SDLK_SCANCODE_MASK; + SDLK_KP_3 = SDL_SCANCODE_KP_3 or SDLK_SCANCODE_MASK; + SDLK_KP_4 = SDL_SCANCODE_KP_4 or SDLK_SCANCODE_MASK; + SDLK_KP_5 = SDL_SCANCODE_KP_5 or SDLK_SCANCODE_MASK; + SDLK_KP_6 = SDL_SCANCODE_KP_6 or SDLK_SCANCODE_MASK; + SDLK_KP_7 = SDL_SCANCODE_KP_7 or SDLK_SCANCODE_MASK; + SDLK_KP_8 = SDL_SCANCODE_KP_8 or SDLK_SCANCODE_MASK; + SDLK_KP_9 = SDL_SCANCODE_KP_9 or SDLK_SCANCODE_MASK; + SDLK_KP_0 = SDL_SCANCODE_KP_0 or SDLK_SCANCODE_MASK; + SDLK_KP_PERIOD = SDL_SCANCODE_KP_PERIOD or SDLK_SCANCODE_MASK; + + SDLK_APPLICATION = SDL_SCANCODE_APPLICATION or SDLK_SCANCODE_MASK; + SDLK_POWER = SDL_SCANCODE_POWER or SDLK_SCANCODE_MASK; + SDLK_KP_EQUALS = SDL_SCANCODE_KP_EQUALS or SDLK_SCANCODE_MASK; + SDLK_F13 = SDL_SCANCODE_F13 or SDLK_SCANCODE_MASK; + SDLK_F14 = SDL_SCANCODE_F14 or SDLK_SCANCODE_MASK; + SDLK_F15 = SDL_SCANCODE_F15 or SDLK_SCANCODE_MASK; + SDLK_F16 = SDL_SCANCODE_F16 or SDLK_SCANCODE_MASK; + SDLK_F17 = SDL_SCANCODE_F17 or SDLK_SCANCODE_MASK; + SDLK_F18 = SDL_SCANCODE_F18 or SDLK_SCANCODE_MASK; + SDLK_F19 = SDL_SCANCODE_F19 or SDLK_SCANCODE_MASK; + SDLK_F20 = SDL_SCANCODE_F20 or SDLK_SCANCODE_MASK; + SDLK_F21 = SDL_SCANCODE_F21 or SDLK_SCANCODE_MASK; + SDLK_F22 = SDL_SCANCODE_F22 or SDLK_SCANCODE_MASK; + SDLK_F23 = SDL_SCANCODE_F23 or SDLK_SCANCODE_MASK; + SDLK_F24 = SDL_SCANCODE_F24 or SDLK_SCANCODE_MASK; + SDLK_EXECUTE = SDL_SCANCODE_EXECUTE or SDLK_SCANCODE_MASK; + SDLK_HELP = SDL_SCANCODE_HELP or SDLK_SCANCODE_MASK; + SDLK_MENU = SDL_SCANCODE_MENU or SDLK_SCANCODE_MASK; + SDLK_SELECT = SDL_SCANCODE_SELECT or SDLK_SCANCODE_MASK; + SDLK_STOP = SDL_SCANCODE_STOP or SDLK_SCANCODE_MASK; + SDLK_AGAIN = SDL_SCANCODE_AGAIN or SDLK_SCANCODE_MASK; + SDLK_UNDO = SDL_SCANCODE_UNDO or SDLK_SCANCODE_MASK; + SDLK_CUT = SDL_SCANCODE_CUT or SDLK_SCANCODE_MASK; + SDLK_COPY = SDL_SCANCODE_COPY or SDLK_SCANCODE_MASK; + SDLK_PASTE = SDL_SCANCODE_PASTE or SDLK_SCANCODE_MASK; + SDLK_FIND = SDL_SCANCODE_FIND or SDLK_SCANCODE_MASK; + SDLK_MUTE = SDL_SCANCODE_MUTE or SDLK_SCANCODE_MASK; + SDLK_VOLUMEUP = SDL_SCANCODE_VOLUMEUP or SDLK_SCANCODE_MASK; + SDLK_VOLUMEDOWN = SDL_SCANCODE_VOLUMEDOWN or SDLK_SCANCODE_MASK; + SDLK_KP_COMMA = SDL_SCANCODE_KP_COMMA or SDLK_SCANCODE_MASK; + SDLK_KP_EQUALSAS400 = SDL_SCANCODE_KP_EQUALSAS400 or SDLK_SCANCODE_MASK; + + SDLK_ALTERASE = SDL_SCANCODE_ALTERASE or SDLK_SCANCODE_MASK; + SDLK_SYSREQ = SDL_SCANCODE_SYSREQ or SDLK_SCANCODE_MASK; + SDLK_CANCEL = SDL_SCANCODE_CANCEL or SDLK_SCANCODE_MASK; + SDLK_CLEAR = SDL_SCANCODE_CLEAR or SDLK_SCANCODE_MASK; + SDLK_PRIOR = SDL_SCANCODE_PRIOR or SDLK_SCANCODE_MASK; + SDLK_RETURN2 = SDL_SCANCODE_RETURN2 or SDLK_SCANCODE_MASK; + SDLK_SEPARATOR = SDL_SCANCODE_SEPARATOR or SDLK_SCANCODE_MASK; + SDLK_OUT = SDL_SCANCODE_OUT or SDLK_SCANCODE_MASK; + SDLK_OPER = SDL_SCANCODE_OPER or SDLK_SCANCODE_MASK; + SDLK_CLEARAGAIN = SDL_SCANCODE_CLEARAGAIN or SDLK_SCANCODE_MASK; + SDLK_CRSEL = SDL_SCANCODE_CRSEL or SDLK_SCANCODE_MASK; + SDLK_EXSEL = SDL_SCANCODE_EXSEL or SDLK_SCANCODE_MASK; + + SDLK_KP_00 = SDL_SCANCODE_KP_00 or SDLK_SCANCODE_MASK; + SDLK_KP_000 = SDL_SCANCODE_KP_000 or SDLK_SCANCODE_MASK; + SDLK_THOUSANDSSEPARATOR = SDL_SCANCODE_THOUSANDSSEPARATOR or SDLK_SCANCODE_MASK; + SDLK_DECIMALSEPARATOR = SDL_SCANCODE_DECIMALSEPARATOR or SDLK_SCANCODE_MASK; + SDLK_CURRENCYUNIT = SDL_SCANCODE_CURRENCYUNIT or SDLK_SCANCODE_MASK; + SDLK_CURRENCYSUBUNIT = SDL_SCANCODE_CURRENCYSUBUNIT or SDLK_SCANCODE_MASK; + SDLK_KP_LEFTPAREN = SDL_SCANCODE_KP_LEFTPAREN or SDLK_SCANCODE_MASK; + SDLK_KP_RIGHTPAREN = SDL_SCANCODE_KP_RIGHTPAREN or SDLK_SCANCODE_MASK; + SDLK_KP_LEFTBRACE = SDL_SCANCODE_KP_LEFTBRACE or SDLK_SCANCODE_MASK; + SDLK_KP_RIGHTBRACE = SDL_SCANCODE_KP_RIGHTBRACE or SDLK_SCANCODE_MASK; + SDLK_KP_TAB = SDL_SCANCODE_KP_TAB or SDLK_SCANCODE_MASK; + SDLK_KP_BACKSPACE = SDL_SCANCODE_KP_BACKSPACE or SDLK_SCANCODE_MASK; + SDLK_KP_A = SDL_SCANCODE_KP_A or SDLK_SCANCODE_MASK; + SDLK_KP_B = SDL_SCANCODE_KP_B or SDLK_SCANCODE_MASK; + SDLK_KP_C = SDL_SCANCODE_KP_C or SDLK_SCANCODE_MASK; + SDLK_KP_D = SDL_SCANCODE_KP_D or SDLK_SCANCODE_MASK; + SDLK_KP_E = SDL_SCANCODE_KP_E or SDLK_SCANCODE_MASK; + SDLK_KP_F = SDL_SCANCODE_KP_F or SDLK_SCANCODE_MASK; + SDLK_KP_XOR = SDL_SCANCODE_KP_XOR or SDLK_SCANCODE_MASK; + SDLK_KP_POWER = SDL_SCANCODE_KP_POWER or SDLK_SCANCODE_MASK; + SDLK_KP_PERCENT = SDL_SCANCODE_KP_PERCENT or SDLK_SCANCODE_MASK; + SDLK_KP_LESS = SDL_SCANCODE_KP_LESS or SDLK_SCANCODE_MASK; + SDLK_KP_GREATER = SDL_SCANCODE_KP_GREATER or SDLK_SCANCODE_MASK; + SDLK_KP_AMPERSAND = SDL_SCANCODE_KP_AMPERSAND or SDLK_SCANCODE_MASK; + SDLK_KP_DBLAMPERSAND = SDL_SCANCODE_KP_DBLAMPERSAND or SDLK_SCANCODE_MASK; + SDLK_KP_VERTICALBAR = SDL_SCANCODE_KP_VERTICALBAR or SDLK_SCANCODE_MASK; + SDLK_KP_DBLVERTICALBAR = SDL_SCANCODE_KP_DBLVERTICALBAR or SDLK_SCANCODE_MASK; + SDLK_KP_COLON = SDL_SCANCODE_KP_COLON or SDLK_SCANCODE_MASK; + SDLK_KP_HASH = SDL_SCANCODE_KP_HASH or SDLK_SCANCODE_MASK; + SDLK_KP_SPACE = SDL_SCANCODE_KP_SPACE or SDLK_SCANCODE_MASK; + SDLK_KP_AT = SDL_SCANCODE_KP_AT or SDLK_SCANCODE_MASK; + SDLK_KP_EXCLAM = SDL_SCANCODE_KP_EXCLAM or SDLK_SCANCODE_MASK; + SDLK_KP_MEMSTORE = SDL_SCANCODE_KP_MEMSTORE or SDLK_SCANCODE_MASK; + SDLK_KP_MEMRECALL = SDL_SCANCODE_KP_MEMRECALL or SDLK_SCANCODE_MASK; + SDLK_KP_MEMCLEAR = SDL_SCANCODE_KP_MEMCLEAR or SDLK_SCANCODE_MASK; + SDLK_KP_MEMADD = SDL_SCANCODE_KP_MEMADD or SDLK_SCANCODE_MASK; + SDLK_KP_MEMSUBTRACT = SDL_SCANCODE_KP_MEMSUBTRACT or SDLK_SCANCODE_MASK; + SDLK_KP_MEMMULTIPLY = SDL_SCANCODE_KP_MEMMULTIPLY or SDLK_SCANCODE_MASK; + SDLK_KP_MEMDIVIDE = SDL_SCANCODE_KP_MEMDIVIDE or SDLK_SCANCODE_MASK; + SDLK_KP_PLUSMINUS = SDL_SCANCODE_KP_PLUSMINUS or SDLK_SCANCODE_MASK; + SDLK_KP_CLEAR = SDL_SCANCODE_KP_CLEAR or SDLK_SCANCODE_MASK; + SDLK_KP_CLEARENTRY = SDL_SCANCODE_KP_CLEARENTRY or SDLK_SCANCODE_MASK; + SDLK_KP_BINARY = SDL_SCANCODE_KP_BINARY or SDLK_SCANCODE_MASK; + SDLK_KP_OCTAL = SDL_SCANCODE_KP_OCTAL or SDLK_SCANCODE_MASK; + SDLK_KP_DECIMAL = SDL_SCANCODE_KP_DECIMAL or SDLK_SCANCODE_MASK; + SDLK_KP_HEXADECIMAL = SDL_SCANCODE_KP_HEXADECIMAL or SDLK_SCANCODE_MASK; + + SDLK_LCTRL = SDL_SCANCODE_LCTRL or SDLK_SCANCODE_MASK; + SDLK_LSHIFT = SDL_SCANCODE_LSHIFT or SDLK_SCANCODE_MASK; + SDLK_LALT = SDL_SCANCODE_LALT or SDLK_SCANCODE_MASK; + SDLK_LGUI = SDL_SCANCODE_LGUI or SDLK_SCANCODE_MASK; + SDLK_RCTRL = SDL_SCANCODE_RCTRL or SDLK_SCANCODE_MASK; + SDLK_RSHIFT = SDL_SCANCODE_RSHIFT or SDLK_SCANCODE_MASK; + SDLK_RALT = SDL_SCANCODE_RALT or SDLK_SCANCODE_MASK; + SDLK_RGUI = SDL_SCANCODE_RGUI or SDLK_SCANCODE_MASK; + + SDLK_MODE = SDL_SCANCODE_MODE or SDLK_SCANCODE_MASK; + + SDLK_AUDIONEXT = SDL_SCANCODE_AUDIONEXT or SDLK_SCANCODE_MASK; + SDLK_AUDIOPREV = SDL_SCANCODE_AUDIOPREV or SDLK_SCANCODE_MASK; + SDLK_AUDIOSTOP = SDL_SCANCODE_AUDIOSTOP or SDLK_SCANCODE_MASK; + SDLK_AUDIOPLAY = SDL_SCANCODE_AUDIOPLAY or SDLK_SCANCODE_MASK; + SDLK_AUDIOMUTE = SDL_SCANCODE_AUDIOMUTE or SDLK_SCANCODE_MASK; + SDLK_MEDIASELECT = SDL_SCANCODE_MEDIASELECT or SDLK_SCANCODE_MASK; + SDLK_WWW = SDL_SCANCODE_WWW or SDLK_SCANCODE_MASK; + SDLK_MAIL = SDL_SCANCODE_MAIL or SDLK_SCANCODE_MASK; + SDLK_CALCULATOR = SDL_SCANCODE_CALCULATOR or SDLK_SCANCODE_MASK; + SDLK_COMPUTER = SDL_SCANCODE_COMPUTER or SDLK_SCANCODE_MASK; + SDLK_AC_SEARCH = SDL_SCANCODE_AC_SEARCH or SDLK_SCANCODE_MASK; + SDLK_AC_HOME = SDL_SCANCODE_AC_HOME or SDLK_SCANCODE_MASK; + SDLK_AC_BACK = SDL_SCANCODE_AC_BACK or SDLK_SCANCODE_MASK; + SDLK_AC_FORWARD = SDL_SCANCODE_AC_FORWARD or SDLK_SCANCODE_MASK; + SDLK_AC_STOP = SDL_SCANCODE_AC_STOP or SDLK_SCANCODE_MASK; + SDLK_AC_REFRESH = SDL_SCANCODE_AC_REFRESH or SDLK_SCANCODE_MASK; + SDLK_AC_BOOKMARKS = SDL_SCANCODE_AC_BOOKMARKS or SDLK_SCANCODE_MASK; + + SDLK_BRIGHTNESSDOWN = SDL_SCANCODE_BRIGHTNESSDOWN or SDLK_SCANCODE_MASK; + SDLK_BRIGHTNESSUP = SDL_SCANCODE_BRIGHTNESSUP or SDLK_SCANCODE_MASK; + SDLK_DISPLAYSWITCH = SDL_SCANCODE_DISPLAYSWITCH or SDLK_SCANCODE_MASK; + SDLK_KBDILLUMTOGGLE = SDL_SCANCODE_KBDILLUMTOGGLE or SDLK_SCANCODE_MASK; + SDLK_KBDILLUMDOWN = SDL_SCANCODE_KBDILLUMDOWN or SDLK_SCANCODE_MASK; + SDLK_KBDILLUMUP = SDL_SCANCODE_KBDILLUMUP or SDLK_SCANCODE_MASK; + SDLK_EJECT = SDL_SCANCODE_EJECT or SDLK_SCANCODE_MASK; + SDLK_SLEEP = SDL_SCANCODE_SLEEP or SDLK_SCANCODE_MASK; + + {** + * Enumeration of valid key mods (possibly OR'd together). + *} + + KMOD_NONE = $0000; + KMOD_LSHIFT = $0001; + KMOD_RSHIFT = $0002; + KMOD_LCTRL = $0040; + KMOD_RCTRL = $0080; + KMOD_LALT = $0100; + KMOD_RALT = $0200; + KMOD_LGUI = $0400; + KMOD_RGUI = $0800; + KMOD_NUM = $1000; + KMOD_CAPS = $2000; + KMOD_MODE = $4000; + KMOD_RESERVED = $8000; + +type + PSDL_KeyMod = ^TSDL_KeyMod; + TSDL_KeyMod = Word; + +const + KMOD_CTRL = KMOD_LCTRL or KMOD_RCTRL; + KMOD_SHIFT = KMOD_LSHIFT or KMOD_RSHIFT; + KMOD_ALT = KMOD_LALT or KMOD_RALT; + KMOD_GUI = KMOD_LGUI or KMOD_RGUI; diff --git a/src/wrappers/sdl2/sdltype.inc b/src/wrappers/sdl2/sdltype.inc new file mode 100644 index 0000000..3db4bd8 --- /dev/null +++ b/src/wrappers/sdl2/sdltype.inc @@ -0,0 +1,52 @@ +//types from SDLtype_s.h / SDL_stdinc.h +type + + TSDL_Bool = (SDL_FALSE,SDL_TRUE); + + DWord = LongWord; + + PUInt8Array = ^TUInt8Array; + PUInt8 = ^UInt8; + PPUInt8 = ^PUInt8; + UInt8 = Byte; + TUInt8Array = array [0..MAXINT shr 1] of UInt8; + + PUInt16 = ^UInt16; + UInt16 = word; + + PSInt8 = ^SInt8; + SInt8 = Shortint; + + PSInt16 = ^SInt16; + SInt16 = smallint; + + PUInt32 = ^UInt32; + UInt32 = Cardinal; + + PSInt32 = ^SInt32; + SInt32 = LongInt; + + PFloat = ^Float; + PInt = ^LongInt; + + PShortInt = ^ShortInt; + + PUInt64 = ^UInt64; + UInt64 = QWord; + + PInt64 = ^Int64; +// Int64 = record +// hi: UInt32; +// lo: UInt32; +// end; + + PSInt64 = ^SInt64; + SInt64 = Int64; + + {$IFNDEF WIN64} + size_t = UInt32; + {$ELSE} + size_t = UInt64; + {$ENDIF} + + Float = Single;