2018-10-21 22:52:14 +02:00
|
|
|
/*
|
|
|
|
platform.h - common platform-dependent function defines
|
|
|
|
Copyright (C) 2018 a1batross
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#ifndef PLATFORM_H
|
|
|
|
#define PLATFORM_H
|
|
|
|
|
2018-11-16 14:32:16 +01:00
|
|
|
#include "common.h"
|
|
|
|
#include "system.h"
|
|
|
|
#include "defaults.h"
|
2022-04-22 19:31:10 +02:00
|
|
|
#include "cursor_type.h"
|
2022-04-22 19:33:07 +02:00
|
|
|
#include "key_modifiers.h"
|
2018-11-16 14:32:16 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
SYSTEM UTILS
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
*/
|
2020-02-08 17:00:39 +01:00
|
|
|
|
|
|
|
void Platform_Init( void );
|
|
|
|
void Platform_Shutdown( void );
|
2018-11-16 14:32:16 +01:00
|
|
|
double Platform_DoubleTime( void );
|
|
|
|
void Platform_Sleep( int msec );
|
2019-05-01 18:21:47 +02:00
|
|
|
void Platform_ShellExecute( const char *path, const char *parms );
|
2019-05-01 18:44:48 +02:00
|
|
|
void Platform_MessageBox( const char *title, const char *message, qboolean parentMainWindow );
|
2018-11-16 14:32:16 +01:00
|
|
|
// commented out, as this is an optional feature or maybe implemented in system API directly
|
|
|
|
// see system.c
|
|
|
|
// qboolean Sys_DebuggerPresent( void );
|
|
|
|
|
2019-11-24 01:52:08 +01:00
|
|
|
#if XASH_ANDROID
|
2019-05-02 17:07:03 +02:00
|
|
|
const char *Android_GetAndroidID( void );
|
|
|
|
const char *Android_LoadID( void );
|
|
|
|
void Android_SaveID( const char *id );
|
|
|
|
#endif
|
|
|
|
|
2022-04-06 14:06:16 +02:00
|
|
|
#if XASH_WIN32
|
|
|
|
void Platform_UpdateStatusLine( void );
|
|
|
|
#else
|
|
|
|
static inline void Platform_UpdateStatusLine( void ) { }
|
|
|
|
#endif
|
|
|
|
|
2021-01-03 02:28:45 +01:00
|
|
|
/*
|
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
MOBILE API
|
|
|
|
|
|
|
|
==============================================================================
|
2018-10-21 22:52:14 +02:00
|
|
|
*/
|
|
|
|
void Platform_Vibrate( float life, char flags );
|
2018-10-21 23:21:05 +02:00
|
|
|
void*Platform_GetNativeObject( const char *name );
|
2018-10-21 22:52:14 +02:00
|
|
|
|
2021-01-03 02:28:45 +01:00
|
|
|
/*
|
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
INPUT
|
|
|
|
|
|
|
|
==============================================================================
|
2018-10-21 22:52:14 +02:00
|
|
|
*/
|
|
|
|
// Gamepad support
|
|
|
|
int Platform_JoyInit( int numjoy ); // returns number of connected gamepads, negative if error
|
|
|
|
// Text input
|
|
|
|
void Platform_EnableTextInput( qboolean enable );
|
2022-04-22 19:33:07 +02:00
|
|
|
key_modifier_t Platform_GetKeyModifiers( void );
|
2018-10-21 22:52:14 +02:00
|
|
|
// System events
|
|
|
|
void Platform_RunEvents( void );
|
2018-10-22 00:09:43 +02:00
|
|
|
// Mouse
|
|
|
|
void Platform_GetMousePos( int *x, int *y );
|
|
|
|
void Platform_SetMousePos( int x, int y );
|
2019-09-26 21:14:47 +02:00
|
|
|
void Platform_PreCreateMove( void );
|
2020-02-08 17:00:39 +01:00
|
|
|
void Platform_MouseMove( float *x, float *y );
|
2022-04-27 20:32:20 +02:00
|
|
|
void Platform_SetCursorType( VGUI_DefaultCursor type );
|
2018-10-22 00:25:29 +02:00
|
|
|
// Clipboard
|
2022-04-22 19:28:19 +02:00
|
|
|
int Platform_GetClipboardText( char *buffer, size_t size );
|
|
|
|
void Platform_SetClipboardText( const char *buffer );
|
2019-05-02 17:07:03 +02:00
|
|
|
|
2019-10-26 03:36:43 +02:00
|
|
|
#if XASH_SDL == 12
|
|
|
|
#define SDL_SetWindowGrab( wnd, state ) SDL_WM_GrabInput( (state) )
|
|
|
|
#define SDL_MinimizeWindow( wnd ) SDL_WM_IconifyWindow()
|
|
|
|
#define SDL_IsTextInputActive() host.textmode
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !XASH_SDL
|
|
|
|
#define SDL_VERSION_ATLEAST( x, y, z ) 0
|
|
|
|
#endif
|
|
|
|
|
2019-11-24 01:52:08 +01:00
|
|
|
#if XASH_ANDROID
|
2019-05-02 17:07:03 +02:00
|
|
|
void Android_ShowMouse( qboolean show );
|
|
|
|
void Android_MouseMove( float *x, float *y );
|
|
|
|
#endif
|
2018-10-21 22:52:14 +02:00
|
|
|
|
2021-01-03 02:28:45 +01:00
|
|
|
/*
|
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
WINDOW MANAGEMENT
|
|
|
|
|
|
|
|
==============================================================================
|
2018-10-21 22:52:14 +02:00
|
|
|
*/
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
rserr_ok,
|
|
|
|
rserr_invalid_fullscreen,
|
|
|
|
rserr_invalid_mode,
|
|
|
|
rserr_unknown
|
|
|
|
} rserr_t;
|
|
|
|
|
2019-10-26 14:42:00 +02:00
|
|
|
struct vidmode_s;
|
2018-10-21 22:52:14 +02:00
|
|
|
// Window
|
2019-03-22 14:36:46 +01:00
|
|
|
qboolean R_Init_Video( const int type );
|
2018-10-21 22:52:14 +02:00
|
|
|
void R_Free_Video( void );
|
|
|
|
qboolean VID_SetMode( void );
|
|
|
|
rserr_t R_ChangeDisplaySettings( int width, int height, qboolean fullscreen );
|
2019-10-05 01:07:49 +02:00
|
|
|
int R_MaxVideoModes( void );
|
2019-10-26 14:42:00 +02:00
|
|
|
struct vidmode_s *R_GetVideoMode( int num );
|
2018-10-21 22:52:14 +02:00
|
|
|
void* GL_GetProcAddress( const char *name ); // RenderAPI requirement
|
2019-03-11 15:37:58 +01:00
|
|
|
void GL_UpdateSwapInterval( void );
|
2019-03-16 03:15:32 +01:00
|
|
|
int GL_SetAttribute( int attr, int val );
|
|
|
|
int GL_GetAttribute( int attr, int *val );
|
2019-10-05 01:07:49 +02:00
|
|
|
void GL_SwapBuffers( void );
|
|
|
|
void *SW_LockBuffer( void );
|
|
|
|
void SW_UnlockBuffer( void );
|
2019-03-24 21:24:31 +01:00
|
|
|
qboolean SW_CreateBuffer( int width, int height, uint *stride, uint *bpp, uint *r, uint *g, uint *b );
|
2018-10-21 22:52:14 +02:00
|
|
|
|
2019-10-21 20:41:44 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// in_evdev.c
|
|
|
|
//
|
|
|
|
#ifdef XASH_USE_EVDEV
|
|
|
|
void Evdev_SetGrab( qboolean grab );
|
|
|
|
void Evdev_Shutdown( void );
|
|
|
|
void Evdev_Init( void );
|
|
|
|
void IN_EvdevMove( float *yaw, float *pitch );
|
|
|
|
void IN_EvdevFrame ( void );
|
|
|
|
#endif // XASH_USE_EVDEV
|
2019-01-07 02:07:01 +01:00
|
|
|
/*
|
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
AUDIO INPUT/OUTPUT
|
2018-10-21 22:52:14 +02:00
|
|
|
|
2019-01-07 02:07:01 +01:00
|
|
|
==============================================================================
|
|
|
|
*/
|
|
|
|
// initializes cycling through a DMA buffer and returns information on it
|
2019-07-11 23:32:09 +02:00
|
|
|
qboolean SNDDMA_Init( void );
|
2019-01-07 02:07:01 +01:00
|
|
|
void SNDDMA_Shutdown( void );
|
|
|
|
void SNDDMA_BeginPainting( void );
|
|
|
|
void SNDDMA_Submit( void );
|
|
|
|
void SNDDMA_Activate( qboolean active ); // pause audio
|
|
|
|
// void SNDDMA_PrintDeviceName( void ); // unused
|
|
|
|
// void SNDDMA_LockSound( void ); // unused
|
|
|
|
// void SNDDMA_UnlockSound( void ); // unused
|
2018-10-21 22:52:14 +02:00
|
|
|
|
|
|
|
#endif // PLATFORM_H
|