GODOT IS OPEN SOURCE
This commit is contained in:
parent
0e49da1687
commit
0b806ee0fc
3138 changed files with 1294441 additions and 0 deletions
13
platform/windows/SCsub
Normal file
13
platform/windows/SCsub
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
Import('env')
|
||||
|
||||
|
||||
common_win=[
|
||||
"context_gl_win.cpp",
|
||||
"os_windows.cpp",
|
||||
"ctxgl_procaddr.cpp",
|
||||
"key_mapping_win.cpp",
|
||||
"tcp_server_winsock.cpp",
|
||||
"stream_peer_winsock.cpp",
|
||||
]
|
||||
|
||||
env.Program('#bin/godot.exe',['godot_win.cpp']+common_win)
|
||||
205
platform/windows/context_gl_win.cpp
Normal file
205
platform/windows/context_gl_win.cpp
Normal file
|
|
@ -0,0 +1,205 @@
|
|||
/*************************************************************************/
|
||||
/* context_gl_win.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
#if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED) || defined(GLES2_ENABLED)
|
||||
|
||||
//
|
||||
// C++ Implementation: context_gl_x11
|
||||
//
|
||||
// Description:
|
||||
//
|
||||
//
|
||||
// Author: Juan Linietsky <reduzio@gmail.com>, (C) 2008
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
|
||||
#define WINVER 0x0500
|
||||
#include "context_gl_win.h"
|
||||
|
||||
//#include "drivers/opengl/glwrapper.h"
|
||||
//#include "ctxgl_procaddr.h"
|
||||
|
||||
#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
|
||||
#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
|
||||
#define WGL_CONTEXT_FLAGS_ARB 0x2094
|
||||
#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
|
||||
|
||||
typedef HGLRC (APIENTRY* PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC, HGLRC, const int*);
|
||||
|
||||
|
||||
void ContextGL_Win::release_current() {
|
||||
|
||||
|
||||
wglMakeCurrent(hDC,NULL);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ContextGL_Win::make_current() {
|
||||
|
||||
wglMakeCurrent(hDC,hRC);
|
||||
}
|
||||
|
||||
int ContextGL_Win::get_window_width() {
|
||||
|
||||
return OS::get_singleton()->get_video_mode().width;
|
||||
}
|
||||
|
||||
int ContextGL_Win::get_window_height() {
|
||||
|
||||
return OS::get_singleton()->get_video_mode().height;
|
||||
}
|
||||
|
||||
void ContextGL_Win::swap_buffers() {
|
||||
|
||||
SwapBuffers(hDC);
|
||||
}
|
||||
|
||||
/*
|
||||
static GLWrapperFuncPtr wrapper_get_proc_address(const char* p_function) {
|
||||
|
||||
print_line(String()+"getting proc of: "+p_function);
|
||||
GLWrapperFuncPtr func=(GLWrapperFuncPtr)get_gl_proc_address(p_function);
|
||||
if (!func) {
|
||||
print_line("Couldn't find function: "+String(p_function));
|
||||
print_line("error: "+itos(GetLastError()));
|
||||
}
|
||||
return func;
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
Error ContextGL_Win::initialize() {
|
||||
|
||||
static PIXELFORMATDESCRIPTOR pfd= {
|
||||
sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
|
||||
1,
|
||||
PFD_DRAW_TO_WINDOW | // Format Must Support Window
|
||||
PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
|
||||
PFD_DOUBLEBUFFER,
|
||||
PFD_TYPE_RGBA,
|
||||
24,
|
||||
0, 0, 0, 0, 0, 0, // Color Bits Ignored
|
||||
0,// No Alpha Buffer
|
||||
0,// Shift Bit Ignored
|
||||
0,// No Accumulation Buffer
|
||||
0, 0, 0, 0,// Accumulation Bits Ignored
|
||||
24,// 24Bit Z-Buffer (Depth Buffer)
|
||||
0,// No Stencil Buffer
|
||||
0,// No Auxiliary Buffer
|
||||
PFD_MAIN_PLANE, // Main Drawing Layer
|
||||
0,// Reserved
|
||||
0, 0, 0 // Layer Masks Ignored
|
||||
};
|
||||
|
||||
if (!(hDC=GetDC(hWnd))) {
|
||||
MessageBox(NULL,"Can't Create A GL Device Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
|
||||
return ERR_CANT_CREATE; // Return FALSE
|
||||
}
|
||||
|
||||
if (!(pixel_format=ChoosePixelFormat(hDC,&pfd))) // Did Windows Find A Matching Pixel Format?
|
||||
{
|
||||
MessageBox(NULL,"Can't Find A Suitable pixel_format.","ERROR",MB_OK|MB_ICONEXCLAMATION);
|
||||
return ERR_CANT_CREATE; // Return FALSE
|
||||
}
|
||||
|
||||
if(!SetPixelFormat(hDC,pixel_format,&pfd)) // Are We Able To Set The Pixel Format?
|
||||
{
|
||||
MessageBox(NULL,"Can't Set The pixel_format.","ERROR",MB_OK|MB_ICONEXCLAMATION);
|
||||
return ERR_CANT_CREATE; // Return FALSE
|
||||
}
|
||||
|
||||
if (!(hRC=wglCreateContext(hDC))) // Are We Able To Get A Rendering Context?
|
||||
{
|
||||
MessageBox(NULL,"Can't Create A Temporary GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
|
||||
return ERR_CANT_CREATE; // Return FALSE
|
||||
}
|
||||
|
||||
wglMakeCurrent(hDC,hRC);
|
||||
|
||||
if (opengl_3_context) {
|
||||
|
||||
int attribs[] = {
|
||||
WGL_CONTEXT_MAJOR_VERSION_ARB, 3,//we want a 3.1 context
|
||||
WGL_CONTEXT_MINOR_VERSION_ARB, 2,
|
||||
//and it shall be forward compatible so that we can only use up to date functionality
|
||||
WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
|
||||
0}; //zero indicates the end of the array
|
||||
|
||||
PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = NULL; //pointer to the method
|
||||
wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC) wglGetProcAddress("wglCreateContextAttribsARB");
|
||||
|
||||
if(wglCreateContextAttribsARB == NULL) //OpenGL 3.0 is not supported
|
||||
{
|
||||
MessageBox(NULL,"Cannot get Proc Adress for CreateContextAttribs", "ERROR",MB_OK|MB_ICONEXCLAMATION);
|
||||
wglDeleteContext(hRC);
|
||||
return ERR_CANT_CREATE;
|
||||
}
|
||||
|
||||
HGLRC new_hRC;
|
||||
if (!(new_hRC=wglCreateContextAttribsARB(hDC,0, attribs)))
|
||||
{
|
||||
wglDeleteContext(hRC);
|
||||
MessageBox(NULL,"Can't Create An OpenGL 3.1 Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
|
||||
return ERR_CANT_CREATE; // Return false
|
||||
}
|
||||
wglMakeCurrent(hDC,NULL);
|
||||
wglDeleteContext(hRC);
|
||||
hRC=new_hRC;
|
||||
|
||||
if (!wglMakeCurrent(hDC,hRC)) // Try To Activate The Rendering Context
|
||||
{
|
||||
MessageBox(NULL,"Can't Activate The GL 3.1 Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
|
||||
return ERR_CANT_CREATE; // Return FALSE
|
||||
}
|
||||
|
||||
printf("Activated GL 3.1 context");
|
||||
}
|
||||
|
||||
|
||||
// glWrapperInit(wrapper_get_proc_address);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
ContextGL_Win::ContextGL_Win(HWND hwnd,bool p_opengl_3_context) {
|
||||
|
||||
opengl_3_context=p_opengl_3_context;
|
||||
hWnd=hwnd;
|
||||
}
|
||||
|
||||
ContextGL_Win::~ContextGL_Win() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
79
platform/windows/context_gl_win.h
Normal file
79
platform/windows/context_gl_win.h
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
/*************************************************************************/
|
||||
/* context_gl_win.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
#if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED) || defined(GLES2_ENABLED)
|
||||
//
|
||||
// C++ Interface: context_gl_x11
|
||||
//
|
||||
// Description:
|
||||
//
|
||||
//
|
||||
// Author: Juan Linietsky <reduzio@gmail.com>, (C) 2008
|
||||
//
|
||||
// Copyright: See COPYING file that comes with this distribution
|
||||
//
|
||||
//
|
||||
|
||||
#ifndef CONTEXT_GL_WIN_H
|
||||
#define CONTEXT_GL_WIN_H
|
||||
|
||||
|
||||
#include "os/os.h"
|
||||
#include "drivers/gl_context/context_gl.h"
|
||||
#include "error_list.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
class ContextGL_Win : public ContextGL {
|
||||
|
||||
HDC hDC;
|
||||
HGLRC hRC;
|
||||
unsigned int pixel_format;
|
||||
HWND hWnd;
|
||||
bool opengl_3_context;
|
||||
public:
|
||||
|
||||
|
||||
virtual void release_current();
|
||||
|
||||
virtual void make_current();
|
||||
|
||||
virtual int get_window_width();
|
||||
virtual int get_window_height();
|
||||
virtual void swap_buffers();
|
||||
|
||||
virtual Error initialize();
|
||||
|
||||
|
||||
ContextGL_Win(HWND hwnd,bool p_opengl_3_context);
|
||||
~ContextGL_Win();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
186
platform/windows/ctxgl_procaddr.cpp
Normal file
186
platform/windows/ctxgl_procaddr.cpp
Normal file
|
|
@ -0,0 +1,186 @@
|
|||
/*************************************************************************/
|
||||
/* ctxgl_procaddr.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
#ifdef OPENGL_ENABLED
|
||||
#include "ctxgl_procaddr.h"
|
||||
#include <GL/gl.h>
|
||||
#include <stdio.h>
|
||||
|
||||
static PROC _gl_procs[]={
|
||||
(PROC)glCullFace,
|
||||
(PROC)glFrontFace,
|
||||
(PROC)glHint,
|
||||
(PROC)glLineWidth,
|
||||
(PROC)glPointSize,
|
||||
(PROC)glPolygonMode,
|
||||
(PROC)glScissor,
|
||||
(PROC)glTexParameterf,
|
||||
(PROC)glTexParameterfv,
|
||||
(PROC)glTexParameteri,
|
||||
(PROC)glTexParameteriv,
|
||||
(PROC)glTexImage1D,
|
||||
(PROC)glTexImage2D,
|
||||
(PROC)glDrawBuffer,
|
||||
(PROC)glClear,
|
||||
(PROC)glClearColor,
|
||||
(PROC)glClearStencil,
|
||||
(PROC)glClearDepth,
|
||||
(PROC)glStencilMask,
|
||||
(PROC)glColorMask,
|
||||
(PROC)glDepthMask,
|
||||
(PROC)glDisable,
|
||||
(PROC)glEnable,
|
||||
(PROC)glFinish,
|
||||
(PROC)glFlush,
|
||||
(PROC)glBlendFunc,
|
||||
(PROC)glLogicOp,
|
||||
(PROC)glStencilFunc,
|
||||
(PROC)glStencilOp,
|
||||
(PROC)glDepthFunc,
|
||||
(PROC)glPixelStoref,
|
||||
(PROC)glPixelStorei,
|
||||
(PROC)glReadBuffer,
|
||||
(PROC)glReadPixels,
|
||||
(PROC)glGetBooleanv,
|
||||
(PROC)glGetDoublev,
|
||||
(PROC)glGetError,
|
||||
(PROC)glGetFloatv,
|
||||
(PROC)glGetIntegerv,
|
||||
(PROC)glGetString,
|
||||
(PROC)glGetTexImage,
|
||||
(PROC)glGetTexParameterfv,
|
||||
(PROC)glGetTexParameteriv,
|
||||
(PROC)glGetTexLevelParameterfv,
|
||||
(PROC)glGetTexLevelParameteriv,
|
||||
(PROC)glIsEnabled,
|
||||
(PROC)glDepthRange,
|
||||
(PROC)glViewport,
|
||||
/* not detected in ATI */
|
||||
(PROC)glDrawArrays,
|
||||
(PROC)glDrawElements,
|
||||
(PROC)glGetPointerv,
|
||||
(PROC)glPolygonOffset,
|
||||
(PROC)glCopyTexImage1D,
|
||||
(PROC)glCopyTexImage2D,
|
||||
(PROC)glCopyTexSubImage1D,
|
||||
(PROC)glCopyTexSubImage2D,
|
||||
(PROC)glTexSubImage1D,
|
||||
(PROC)glTexSubImage2D,
|
||||
(PROC)glBindTexture,
|
||||
(PROC)glDeleteTextures,
|
||||
(PROC)glGenTextures,
|
||||
(PROC)glIsTexture,
|
||||
|
||||
0
|
||||
};
|
||||
|
||||
static const char* _gl_proc_names[]={
|
||||
"glCullFace",
|
||||
"glFrontFace",
|
||||
"glHint",
|
||||
"glLineWidth",
|
||||
"glPointSize",
|
||||
"glPolygonMode",
|
||||
"glScissor",
|
||||
"glTexParameterf",
|
||||
"glTexParameterfv",
|
||||
"glTexParameteri",
|
||||
"glTexParameteriv",
|
||||
"glTexImage1D",
|
||||
"glTexImage2D",
|
||||
"glDrawBuffer",
|
||||
"glClear",
|
||||
"glClearColor",
|
||||
"glClearStencil",
|
||||
"glClearDepth",
|
||||
"glStencilMask",
|
||||
"glColorMask",
|
||||
"glDepthMask",
|
||||
"glDisable",
|
||||
"glEnable",
|
||||
"glFinish",
|
||||
"glFlush",
|
||||
"glBlendFunc",
|
||||
"glLogicOp",
|
||||
"glStencilFunc",
|
||||
"glStencilOp",
|
||||
"glDepthFunc",
|
||||
"glPixelStoref",
|
||||
"glPixelStorei",
|
||||
"glReadBuffer",
|
||||
"glReadPixels",
|
||||
"glGetBooleanv",
|
||||
"glGetDoublev",
|
||||
"glGetError",
|
||||
"glGetFloatv",
|
||||
"glGetIntegerv",
|
||||
"glGetString",
|
||||
"glGetTexImage",
|
||||
"glGetTexParameterfv",
|
||||
"glGetTexParameteriv",
|
||||
"glGetTexLevelParameterfv",
|
||||
"glGetTexLevelParameteriv",
|
||||
"glIsEnabled",
|
||||
"glDepthRange",
|
||||
"glViewport",
|
||||
/* not detected in ati */
|
||||
"glDrawArrays",
|
||||
"glDrawElements",
|
||||
"glGetPointerv",
|
||||
"glPolygonOffset",
|
||||
"glCopyTexImage1D",
|
||||
"glCopyTexImage2D",
|
||||
"glCopyTexSubImage1D",
|
||||
"glCopyTexSubImage2D",
|
||||
"glTexSubImage1D",
|
||||
"glTexSubImage2D",
|
||||
"glBindTexture",
|
||||
"glDeleteTextures",
|
||||
"glGenTextures",
|
||||
"glIsTexture",
|
||||
|
||||
0
|
||||
};
|
||||
|
||||
PROC get_gl_proc_address(const char* p_address) {
|
||||
|
||||
PROC proc = wglGetProcAddress((const CHAR*)p_address);
|
||||
if (!proc) {
|
||||
|
||||
int i=0;
|
||||
while(_gl_procs[i]) {
|
||||
|
||||
if (strcmp(p_address,_gl_proc_names[i])==0) {
|
||||
return _gl_procs[i];
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return proc;
|
||||
}
|
||||
#endif
|
||||
38
platform/windows/ctxgl_procaddr.h
Normal file
38
platform/windows/ctxgl_procaddr.h
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/*************************************************************************/
|
||||
/* ctxgl_procaddr.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
#ifndef CTXGL_PROCADDR_H
|
||||
#define CTXGL_PROCADDR_H
|
||||
|
||||
#ifdef OPENGL_ENABLED
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
PROC get_gl_proc_address(const char* p_address);
|
||||
#endif
|
||||
#endif // CTXGL_PROCADDR_H
|
||||
208
platform/windows/detect.py
Normal file
208
platform/windows/detect.py
Normal file
|
|
@ -0,0 +1,208 @@
|
|||
|
||||
|
||||
import os
|
||||
|
||||
import sys
|
||||
|
||||
|
||||
def is_active():
|
||||
return True
|
||||
|
||||
def get_name():
|
||||
return "Windows"
|
||||
|
||||
def can_build():
|
||||
|
||||
|
||||
if (os.name=="nt"):
|
||||
#building natively on windows!
|
||||
if (os.getenv("VSINSTALLDIR")):
|
||||
return True
|
||||
else:
|
||||
print("MSVC Not detected, attempting mingw.")
|
||||
return True
|
||||
|
||||
|
||||
|
||||
if (os.name=="posix"):
|
||||
|
||||
if os.system("i586-mingw32msvc-gcc --version") == 0:
|
||||
return True
|
||||
|
||||
|
||||
return False
|
||||
|
||||
def get_opts():
|
||||
|
||||
mwp=""
|
||||
mwp64=""
|
||||
if (os.name!="nt"):
|
||||
mwp="i586-mingw32msvc-"
|
||||
mwp64="x86_64-w64-mingw32-"
|
||||
|
||||
return [
|
||||
('force_64_bits','Force 64 bits binary','no'),
|
||||
('force_32_bits','Force 32 bits binary','no'),
|
||||
('mingw_prefix','Mingw Prefix',mwp),
|
||||
('mingw_prefix_64','Mingw Prefix 64 bits',mwp64),
|
||||
]
|
||||
|
||||
def get_flags():
|
||||
|
||||
return [
|
||||
('freetype','builtin'), #use builtin freetype
|
||||
]
|
||||
|
||||
|
||||
|
||||
def configure(env):
|
||||
|
||||
if os.name == "posix":
|
||||
env['OBJSUFFIX'] = ".win"+env['OBJSUFFIX']
|
||||
env['LIBSUFFIX'] = ".win"+env['LIBSUFFIX']
|
||||
|
||||
env.Append(CPPPATH=['#platform/windows'])
|
||||
|
||||
if (env["tools"]=="no"):
|
||||
#no tools suffix
|
||||
env['OBJSUFFIX'] = ".nt"+env['OBJSUFFIX']
|
||||
env['LIBSUFFIX'] = ".nt"+env['LIBSUFFIX']
|
||||
|
||||
|
||||
if (os.name=="nt" and os.getenv("VSINSTALLDIR")!=None):
|
||||
#build using visual studio
|
||||
env['ENV']['TMP'] = os.environ['TMP']
|
||||
env.Append(CPPPATH=['#platform/windows/include'])
|
||||
env.Append(LIBPATH=['#platform/windows/lib'])
|
||||
|
||||
if (env["freetype"]!="no"):
|
||||
env.Append(CCFLAGS=['/DFREETYPE_ENABLED'])
|
||||
env.Append(CPPPATH=['#tools/freetype'])
|
||||
env.Append(CPPPATH=['#tools/freetype/freetype/include'])
|
||||
|
||||
if (env["target"]=="release"):
|
||||
|
||||
env.Append(CCFLAGS=['/O2'])
|
||||
env.Append(LINKFLAGS=['/SUBSYSTEM:WINDOWS'])
|
||||
|
||||
elif (env["target"]=="test"):
|
||||
|
||||
env.Append(CCFLAGS=['/O2','/DDEBUG_ENABLED','/DD3D_DEBUG_INFO'])
|
||||
env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE'])
|
||||
|
||||
elif (env["target"]=="debug"):
|
||||
|
||||
env.Append(CCFLAGS=['/Zi','/DDEBUG_ENABLED','/DD3D_DEBUG_INFO','/O1'])
|
||||
env.Append(LINKFLAGS=['/SUBSYSTEM:CONSOLE'])
|
||||
|
||||
elif (env["target"]=="profile"):
|
||||
|
||||
env.Append(CCFLAGS=['-g','-pg'])
|
||||
env.Append(LINKFLAGS=['-pg'])
|
||||
|
||||
env.Append(CCFLAGS=['/MT','/Gd','/GR','/nologo'])
|
||||
env.Append(CXXFLAGS=['/TP'])
|
||||
env.Append(CPPFLAGS=['/DMSVC', '/GR', ])
|
||||
env.Append(CCFLAGS=['/I'+os.getenv("WindowsSdkDir")+"/Include"])
|
||||
env.Append(CCFLAGS=['/DWINDOWS_ENABLED'])
|
||||
env.Append(CCFLAGS=['/DRTAUDIO_ENABLED'])
|
||||
env.Append(CCFLAGS=['/DWIN32'])
|
||||
env.Append(CCFLAGS=['/DTYPED_METHOD_BIND'])
|
||||
|
||||
#env.Append(CCFLAGS=['/DLEGACYGL_ENABLED'])
|
||||
env.Append(CCFLAGS=['/DGLES_ENABLED'])
|
||||
#env.Append(CCFLAGS=['/DGLES1_ENABLED'])
|
||||
env.Append(CCFLAGS=['/DGLEW_ENABLED'])
|
||||
env.Append(LIBS=['winmm','opengl32','dsound','kernel32','ole32','user32','gdi32','wsock32'])
|
||||
env.Append(LINKFLAGS=['/DEBUG'])
|
||||
|
||||
env.Append(LIBPATH=[os.getenv("WindowsSdkDir")+"/Lib"])
|
||||
if (os.getenv("DXSDK_DIR")):
|
||||
DIRECTX_PATH=os.getenv("DXSDK_DIR")
|
||||
else:
|
||||
DIRECTX_PATH="C:/Program Files/Microsoft DirectX SDK (March 2009)"
|
||||
|
||||
if (os.getenv("VCINSTALLDIR")):
|
||||
VC_PATH=os.getenv("VCINSTALLDIR")
|
||||
else:
|
||||
VC_PATH=""
|
||||
|
||||
env.Append(CCFLAGS=["/I"+VC_PATH+"/Include"])
|
||||
env.Append(LIBPATH=[VC_PATH+"/Lib"])
|
||||
env.Append(CCFLAGS=["/I"+DIRECTX_PATH+"/Include"])
|
||||
env.Append(LIBPATH=[DIRECTX_PATH+"/Lib/x86"])
|
||||
env['ENV'] = os.environ;
|
||||
else:
|
||||
#build using mingw
|
||||
if (os.name=="nt"):
|
||||
env['ENV']['TMP'] = os.environ['TMP'] #way to go scons, you can be so stupid sometimes
|
||||
|
||||
mingw_prefix=""
|
||||
|
||||
if (env["force_32_bits"]!="no"):
|
||||
env['OBJSUFFIX'] = ".32"+env['OBJSUFFIX']
|
||||
env['LIBSUFFIX'] = ".32"+env['LIBSUFFIX']
|
||||
env.Append(CCFLAGS=['-m32'])
|
||||
env.Append(LINKFLAGS=['-m32'])
|
||||
|
||||
|
||||
|
||||
|
||||
if (env["force_64_bits"]!="no"):
|
||||
mingw_prefix=env["mingw_prefix_64"];
|
||||
env['OBJSUFFIX'] = ".64"+env['OBJSUFFIX']
|
||||
env['LIBSUFFIX'] = ".64"+env['LIBSUFFIX']
|
||||
env.Append(LINKFLAGS=['-static'])
|
||||
else:
|
||||
mingw_prefix=env["mingw_prefix"];
|
||||
|
||||
if (env["target"]=="release"):
|
||||
|
||||
env.Append(CCFLAGS=['-O3','-ffast-math','-fomit-frame-pointer','-msse2'])
|
||||
env['OBJSUFFIX'] = "_opt"+env['OBJSUFFIX']
|
||||
env['LIBSUFFIX'] = "_opt"+env['LIBSUFFIX']
|
||||
elif (env["target"]=="release_debug"):
|
||||
|
||||
env.Append(CCFLAGS=['-O2','-DDEBUG_ENABLED'])
|
||||
env['OBJSUFFIX'] = "_optd"+env['OBJSUFFIX']
|
||||
env['LIBSUFFIX'] = "_optd"+env['LIBSUFFIX']
|
||||
|
||||
elif (env["target"]=="debug"):
|
||||
|
||||
env.Append(CCFLAGS=['-g', '-Wall','-DDEBUG_ENABLED'])
|
||||
elif (env["target"]=="release_tools"):
|
||||
|
||||
env.Append(CCFLAGS=['-O2','-Wall','-DDEBUG_ENABLED'])
|
||||
|
||||
|
||||
if (env["freetype"]!="no"):
|
||||
env.Append(CCFLAGS=['-DFREETYPE_ENABLED'])
|
||||
env.Append(CPPPATH=['#tools/freetype'])
|
||||
env.Append(CPPPATH=['#tools/freetype/freetype/include'])
|
||||
|
||||
env["CC"]=mingw_prefix+"gcc"
|
||||
env['AS']=mingw_prefix+"as"
|
||||
env['CXX'] = mingw_prefix+"g++"
|
||||
env['AR'] = mingw_prefix+"ar"
|
||||
env['RANLIB'] = mingw_prefix+"ranlib"
|
||||
env['LD'] = mingw_prefix+"g++"
|
||||
|
||||
#env['CC'] = "winegcc"
|
||||
#env['CXX'] = "wineg++"
|
||||
|
||||
env.Append(CCFLAGS=['-DWINDOWS_ENABLED','-mwindows'])
|
||||
env.Append(CPPFLAGS=['-DRTAUDIO_ENABLED'])
|
||||
env.Append(CCFLAGS=['-DGLES2_ENABLED','-DGLES1_ENABLED','-DGLEW_ENABLED'])
|
||||
env.Append(LIBS=['mingw32','opengl32', 'dsound', 'ole32', 'd3d9','winmm','gdi32','wsock32','kernel32'])
|
||||
#'d3dx9d'
|
||||
env.Append(CPPFLAGS=['-DMINGW_ENABLED'])
|
||||
env.Append(LINKFLAGS=['-g'])
|
||||
|
||||
import methods
|
||||
env.Append( BUILDERS = { 'GLSL120' : env.Builder(action = methods.build_legacygl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } )
|
||||
env.Append( BUILDERS = { 'GLSL' : env.Builder(action = methods.build_glsl_headers, suffix = 'glsl.h',src_suffix = '.glsl') } )
|
||||
env.Append( BUILDERS = { 'HLSL9' : env.Builder(action = methods.build_hlsl_dx9_headers, suffix = 'hlsl.h',src_suffix = '.hlsl') } )
|
||||
env.Append( BUILDERS = { 'GLSL120GLES' : env.Builder(action = methods.build_gles2_headers, suffix = 'glsl.h',src_suffix = '.glsl') } )
|
||||
|
||||
|
||||
|
||||
24
platform/windows/export/export.cpp
Normal file
24
platform/windows/export/export.cpp
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#include "export.h"
|
||||
#include "platform/windows/logo.h"
|
||||
#include "tools/editor/editor_import_export.h"
|
||||
|
||||
void register_windows_exporter() {
|
||||
|
||||
Image img(_windows_logo);
|
||||
Ref<ImageTexture> logo = memnew( ImageTexture );
|
||||
logo->create_from_image(img);
|
||||
|
||||
{
|
||||
Ref<EditorExportPlatformPC> exporter = Ref<EditorExportPlatformPC>( memnew(EditorExportPlatformPC) );
|
||||
exporter->set_binary_extension("exe");
|
||||
exporter->set_release_binary32("windows_32_release.exe");
|
||||
exporter->set_debug_binary32("windows_32_debug.exe");
|
||||
exporter->set_release_binary64("windows_64_release.exe");
|
||||
exporter->set_debug_binary64("windows_64_debug.exe");
|
||||
exporter->set_name("Windows Desktop");
|
||||
exporter->set_logo(logo);
|
||||
EditorImportExport::get_singleton()->add_export_platform(exporter);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
3
platform/windows/export/export.h
Normal file
3
platform/windows/export/export.h
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
|
||||
void register_windows_exporter();
|
||||
|
||||
207
platform/windows/godot_win.cpp
Normal file
207
platform/windows/godot_win.cpp
Normal file
|
|
@ -0,0 +1,207 @@
|
|||
/*************************************************************************/
|
||||
/* godot_win.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
#include "os_windows.h"
|
||||
#include "main/main.h"
|
||||
#include <stdio.h>
|
||||
|
||||
PCHAR*
|
||||
CommandLineToArgvA(
|
||||
PCHAR CmdLine,
|
||||
int* _argc
|
||||
)
|
||||
{
|
||||
PCHAR* argv;
|
||||
PCHAR _argv;
|
||||
ULONG len;
|
||||
ULONG argc;
|
||||
CHAR a;
|
||||
ULONG i, j;
|
||||
|
||||
BOOLEAN in_QM;
|
||||
BOOLEAN in_TEXT;
|
||||
BOOLEAN in_SPACE;
|
||||
|
||||
len = strlen(CmdLine);
|
||||
i = ((len+2)/2)*sizeof(PVOID) + sizeof(PVOID);
|
||||
|
||||
argv = (PCHAR*)GlobalAlloc(GMEM_FIXED,
|
||||
i + (len+2)*sizeof(CHAR));
|
||||
|
||||
_argv = (PCHAR)(((PUCHAR)argv)+i);
|
||||
|
||||
argc = 0;
|
||||
argv[argc] = _argv;
|
||||
in_QM = FALSE;
|
||||
in_TEXT = FALSE;
|
||||
in_SPACE = TRUE;
|
||||
i = 0;
|
||||
j = 0;
|
||||
|
||||
while( (a = CmdLine[i]) ) {
|
||||
if(in_QM) {
|
||||
if(a == '\"') {
|
||||
in_QM = FALSE;
|
||||
} else {
|
||||
_argv[j] = a;
|
||||
j++;
|
||||
}
|
||||
} else {
|
||||
switch(a) {
|
||||
case '\"':
|
||||
in_QM = TRUE;
|
||||
in_TEXT = TRUE;
|
||||
if(in_SPACE) {
|
||||
argv[argc] = _argv+j;
|
||||
argc++;
|
||||
}
|
||||
in_SPACE = FALSE;
|
||||
break;
|
||||
case ' ':
|
||||
case '\t':
|
||||
case '\n':
|
||||
case '\r':
|
||||
if(in_TEXT) {
|
||||
_argv[j] = '\0';
|
||||
j++;
|
||||
}
|
||||
in_TEXT = FALSE;
|
||||
in_SPACE = TRUE;
|
||||
break;
|
||||
default:
|
||||
in_TEXT = TRUE;
|
||||
if(in_SPACE) {
|
||||
argv[argc] = _argv+j;
|
||||
argc++;
|
||||
}
|
||||
_argv[j] = a;
|
||||
j++;
|
||||
in_SPACE = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
_argv[j] = '\0';
|
||||
argv[argc] = NULL;
|
||||
|
||||
(*_argc) = argc;
|
||||
return argv;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
OS_Windows os(NULL);
|
||||
|
||||
Main::setup(argv[0], argc - 1, &argv[1]);
|
||||
if (Main::start())
|
||||
os.run();
|
||||
Main::cleanup();
|
||||
|
||||
return os.get_exit_code();
|
||||
};
|
||||
|
||||
HINSTANCE godot_hinstance = NULL;
|
||||
|
||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
|
||||
|
||||
int argc;
|
||||
char** argv;
|
||||
|
||||
char* arg;
|
||||
int index;
|
||||
int result;
|
||||
|
||||
// count the arguments
|
||||
|
||||
argc = 1;
|
||||
arg = lpCmdLine;
|
||||
|
||||
while (arg[0] != 0) {
|
||||
|
||||
while (arg[0] != 0 && arg[0] == ' ') {
|
||||
arg++;
|
||||
}
|
||||
|
||||
if (arg[0] != 0) {
|
||||
|
||||
argc++;
|
||||
|
||||
while (arg[0] != 0 && arg[0] != ' ') {
|
||||
arg++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// tokenize the arguments
|
||||
|
||||
argv = (char**)malloc(argc * sizeof(char*));
|
||||
|
||||
arg = lpCmdLine;
|
||||
index = 1;
|
||||
|
||||
while (arg[0] != 0) {
|
||||
|
||||
while (arg[0] != 0 && arg[0] == ' ') {
|
||||
arg++;
|
||||
}
|
||||
|
||||
if (arg[0] != 0) {
|
||||
|
||||
argv[index] = arg;
|
||||
index++;
|
||||
|
||||
while (arg[0] != 0 && arg[0] != ' ') {
|
||||
arg++;
|
||||
}
|
||||
|
||||
if (arg[0] != 0) {
|
||||
arg[0] = 0;
|
||||
arg++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// put the program name into argv[0]
|
||||
|
||||
char filename[_MAX_PATH];
|
||||
|
||||
GetModuleFileName(NULL, filename, _MAX_PATH);
|
||||
argv[0] = filename;
|
||||
|
||||
// call the user specified main function
|
||||
|
||||
result = main(argc, argv);
|
||||
|
||||
free(argv);
|
||||
return result;
|
||||
}
|
||||
256
platform/windows/key_mapping_win.cpp
Normal file
256
platform/windows/key_mapping_win.cpp
Normal file
|
|
@ -0,0 +1,256 @@
|
|||
/*************************************************************************/
|
||||
/* key_mapping_win.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
#define WINVER 0x0500
|
||||
#include "key_mapping_win.h"
|
||||
#include <stdio.h>
|
||||
|
||||
struct _WinTranslatePair {
|
||||
|
||||
unsigned int keysym;
|
||||
unsigned int keycode;
|
||||
};
|
||||
|
||||
|
||||
static _WinTranslatePair _vk_to_keycode[]={
|
||||
|
||||
{ KEY_BACKSPACE, VK_BACK },// (0x08) // backspace
|
||||
{ KEY_TAB, VK_TAB },//(0x09)
|
||||
|
||||
//VK_CLEAR (0x0C)
|
||||
|
||||
{ KEY_RETURN, VK_RETURN },//(0x0D)
|
||||
|
||||
{ KEY_SHIFT, VK_SHIFT },//(0x10)
|
||||
|
||||
{ KEY_CONTROL, VK_CONTROL },//(0x11)
|
||||
|
||||
{ KEY_MENU, VK_MENU },//(0x12)
|
||||
|
||||
{ KEY_PAUSE, VK_PAUSE },//(0x13)
|
||||
|
||||
{ KEY_CAPSLOCK, VK_CAPITAL },//(0x14)
|
||||
|
||||
{ KEY_ESCAPE, VK_ESCAPE },//(0x1B)
|
||||
|
||||
{ KEY_SPACE, VK_SPACE },//(0x20)
|
||||
|
||||
{ KEY_PAGEUP,VK_PRIOR },//(0x21)
|
||||
|
||||
{ KEY_PAGEDOWN, VK_NEXT },//(0x22)
|
||||
|
||||
{ KEY_END, VK_END },//(0x23)
|
||||
|
||||
{ KEY_HOME, VK_HOME },//(0x24)
|
||||
|
||||
{ KEY_LEFT, VK_LEFT },//(0x25)
|
||||
|
||||
{ KEY_UP, VK_UP },//(0x26)
|
||||
|
||||
{ KEY_RIGHT,VK_RIGHT },//(0x27)
|
||||
|
||||
{ KEY_DOWN, VK_DOWN},// (0x28)
|
||||
|
||||
//VK_SELECT (0x29)
|
||||
|
||||
{ KEY_PRINT, VK_PRINT},// (0x2A)
|
||||
|
||||
//VK_EXECUTE (0x2B)
|
||||
|
||||
{ KEY_PRINT, VK_SNAPSHOT},// (0x2C)
|
||||
|
||||
{ KEY_INSERT, VK_INSERT},// (0x2D)
|
||||
|
||||
{ KEY_DELETE, VK_DELETE},// (0x2E)
|
||||
|
||||
{ KEY_HELP, VK_HELP},// (0x2F)
|
||||
|
||||
|
||||
{ KEY_0, (0x30) },////0 key
|
||||
{ KEY_1, (0x31) },////1 key
|
||||
{ KEY_2, (0x32) },////2 key
|
||||
{ KEY_3, (0x33) },////3 key
|
||||
{ KEY_4, (0x34) },////4 key
|
||||
{ KEY_5, (0x35) },////5 key
|
||||
{ KEY_6, (0x36) },////6 key
|
||||
{ KEY_7, (0x37) },////7 key
|
||||
{ KEY_8, (0x38) },////8 key
|
||||
{ KEY_9, (0x39) },////9 key
|
||||
{ KEY_A, (0x41) },////A key
|
||||
{ KEY_B, (0x42) },////B key
|
||||
{ KEY_C, (0x43) },////C key
|
||||
{ KEY_D, (0x44) },////D key
|
||||
{ KEY_E, (0x45) },////E key
|
||||
{ KEY_F, (0x46) },////F key
|
||||
{ KEY_G, (0x47) },////G key
|
||||
{ KEY_H, (0x48) },////H key
|
||||
{ KEY_I, (0x49) },////I key
|
||||
{ KEY_J, (0x4A) },////J key
|
||||
{ KEY_K, (0x4B) },////K key
|
||||
{ KEY_L, (0x4C) },////L key
|
||||
{ KEY_M, (0x4D) },////M key
|
||||
{ KEY_N, (0x4E) },////N key
|
||||
{ KEY_O, (0x4F) },////O key
|
||||
{ KEY_P, (0x50) },////P key
|
||||
{ KEY_Q, (0x51) },////Q key
|
||||
{ KEY_R, (0x52) },////R key
|
||||
{ KEY_S, (0x53) },////S key
|
||||
{ KEY_T, (0x54) },////T key
|
||||
{ KEY_U, (0x55) },////U key
|
||||
{ KEY_V, (0x56) },////V key
|
||||
{ KEY_W, (0x57) },////W key
|
||||
{ KEY_X, (0x58) },////X key
|
||||
{ KEY_Y, (0x59) },////Y key
|
||||
{ KEY_Z, (0x5A) },////Z key
|
||||
|
||||
{ KEY_MASK_META, VK_LWIN },//(0x5B)
|
||||
{ KEY_MASK_META, VK_RWIN },//(0x5C)
|
||||
//VK_APPS (0x5D)
|
||||
{ KEY_STANDBY,VK_SLEEP },//(0x5F)
|
||||
{ KEY_KP_0,VK_NUMPAD0 },//(0x60)
|
||||
{ KEY_KP_1,VK_NUMPAD1 },//(0x61)
|
||||
{ KEY_KP_2,VK_NUMPAD2 },//(0x62)
|
||||
{ KEY_KP_3,VK_NUMPAD3 },//(0x63)
|
||||
{ KEY_KP_4,VK_NUMPAD4 },//(0x64)
|
||||
{ KEY_KP_5,VK_NUMPAD5 },//(0x65)
|
||||
{ KEY_KP_6,VK_NUMPAD6 },//(0x66)
|
||||
{ KEY_KP_7,VK_NUMPAD7 },//(0x67)
|
||||
{ KEY_KP_8,VK_NUMPAD8 },//(0x68)
|
||||
{ KEY_KP_9,VK_NUMPAD9 },//(0x69)
|
||||
{ KEY_KP_MULTIPLY,VK_MULTIPLY},// (0x6A)
|
||||
{ KEY_KP_ADD,VK_ADD},// (0x6B)
|
||||
//VK_SEPARATOR (0x6C)
|
||||
{ KEY_KP_SUBSTRACT,VK_SUBTRACT},// (0x6D)
|
||||
{ KEY_KP_PERIOD,VK_DECIMAL},// (0x6E)
|
||||
{ KEY_KP_DIVIDE,VK_DIVIDE},// (0x6F)
|
||||
{ KEY_F1,VK_F1},// (0x70)
|
||||
{ KEY_F2,VK_F2},// (0x71)
|
||||
{ KEY_F3,VK_F3},// (0x72)
|
||||
{ KEY_F4,VK_F4},// (0x73)
|
||||
{ KEY_F5,VK_F5},// (0x74)
|
||||
{ KEY_F6,VK_F6},// (0x75)
|
||||
{ KEY_F7,VK_F7},// (0x76)
|
||||
{ KEY_F8,VK_F8},// (0x77)
|
||||
{ KEY_F9,VK_F9},// (0x78)
|
||||
{ KEY_F10,VK_F10},// (0x79)
|
||||
{ KEY_F11,VK_F11},// (0x7A)
|
||||
{ KEY_F12,VK_F12},// (0x7B)
|
||||
{ KEY_F13,VK_F13},// (0x7C)
|
||||
{ KEY_F14,VK_F14},// (0x7D)
|
||||
{ KEY_F15,VK_F15},// (0x7E)
|
||||
{ KEY_F16,VK_F16},// (0x7F)
|
||||
{ KEY_NUMLOCK,VK_NUMLOCK},// (0x90)
|
||||
{ KEY_SCROLLLOCK,VK_SCROLL},// (0x91)
|
||||
{ KEY_SHIFT,VK_LSHIFT},// (0xA0)
|
||||
{ KEY_SHIFT,VK_RSHIFT},// (0xA1)
|
||||
{ KEY_CONTROL,VK_LCONTROL},// (0xA2)
|
||||
{ KEY_CONTROL,VK_RCONTROL},// (0xA3)
|
||||
{ KEY_MENU,VK_LMENU},// (0xA4)
|
||||
{ KEY_MENU,VK_RMENU},// (0xA5)
|
||||
|
||||
|
||||
{ KEY_BACK,VK_BROWSER_BACK},// (0xA6)
|
||||
|
||||
{ KEY_FORWARD,VK_BROWSER_FORWARD},// (0xA7)
|
||||
|
||||
{ KEY_REFRESH,VK_BROWSER_REFRESH},// (0xA8)
|
||||
|
||||
{ KEY_STOP,VK_BROWSER_STOP},// (0xA9)
|
||||
|
||||
{ KEY_SEARCH,VK_BROWSER_SEARCH},// (0xAA)
|
||||
|
||||
{ KEY_FAVORITES, VK_BROWSER_FAVORITES},// (0xAB)
|
||||
|
||||
{ KEY_HOMEPAGE,VK_BROWSER_HOME},// (0xAC)
|
||||
|
||||
{ KEY_VOLUMEMUTE,VK_VOLUME_MUTE},// (0xAD)
|
||||
|
||||
{ KEY_VOLUMEDOWN,VK_VOLUME_DOWN},// (0xAE)
|
||||
|
||||
{ KEY_VOLUMEUP,VK_VOLUME_UP},// (0xAF)
|
||||
|
||||
|
||||
{ KEY_MEDIANEXT,VK_MEDIA_NEXT_TRACK},// (0xB0)
|
||||
|
||||
{ KEY_MEDIAPREVIOUS,VK_MEDIA_PREV_TRACK},// (0xB1)
|
||||
|
||||
{ KEY_MEDIASTOP,VK_MEDIA_STOP},// (0xB2)
|
||||
|
||||
//VK_MEDIA_PLAY_PAUSE (0xB3)
|
||||
|
||||
{ KEY_LAUNCHMAIL, VK_LAUNCH_MAIL},// (0xB4)
|
||||
|
||||
{ KEY_LAUNCHMEDIA,VK_LAUNCH_MEDIA_SELECT},// (0xB5)
|
||||
|
||||
{ KEY_LAUNCH0,VK_LAUNCH_APP1},// (0xB6)
|
||||
|
||||
{ KEY_LAUNCH1,VK_LAUNCH_APP2},// (0xB7)
|
||||
|
||||
{ KEY_SEMICOLON,VK_OEM_1},// (0xBA)
|
||||
|
||||
|
||||
{ KEY_EQUAL, VK_OEM_PLUS},// (0xBB) // Windows 2000/XP: For any country/region, the '+' key
|
||||
{ KEY_COLON,VK_OEM_COMMA},// (0xBC) // Windows 2000/XP: For any country/region, the ',' key
|
||||
{ KEY_MINUS,VK_OEM_MINUS},// (0xBD) // Windows 2000/XP: For any country/region, the '-' key
|
||||
{ KEY_PERIOD,VK_OEM_PERIOD},// (0xBE) // Windows 2000/XP: For any country/region, the '.' key
|
||||
{ KEY_SLASH,VK_OEM_2},// (0xBF) //Windows 2000/XP: For the US standard keyboard, the '/?' key
|
||||
|
||||
{KEY_QUOTELEFT, VK_OEM_3},// (0xC0)
|
||||
{KEY_BRACELEFT,VK_OEM_4},// (0xDB)
|
||||
{KEY_BACKSLASH,VK_OEM_5},// (0xDC)
|
||||
{KEY_BRACERIGHT,VK_OEM_6},// (0xDD)
|
||||
{KEY_APOSTROPHE, VK_OEM_7},// (0xDE)
|
||||
/*
|
||||
{VK_OEM_8 (0xDF)
|
||||
{VK_OEM_102 (0xE2) // Windows 2000/XP: Either the angle bracket key or the backslash key on the RT 102-key keyboard
|
||||
*/
|
||||
//{ KEY_PLAY, VK_PLAY},// (0xFA)
|
||||
|
||||
{KEY_UNKNOWN, 0} };
|
||||
|
||||
/*
|
||||
VK_ZOOM (0xFB)
|
||||
VK_NONAME (0xFC)
|
||||
VK_PA1 (0xFD)
|
||||
VK_OEM_CLEAR (0xFE)
|
||||
*/
|
||||
|
||||
unsigned int KeyMappingWindows::get_keysym(unsigned int p_code) {
|
||||
|
||||
for(int i=0;_vk_to_keycode[i].keysym!=KEY_UNKNOWN;i++) {
|
||||
|
||||
if (_vk_to_keycode[i].keycode==p_code) {
|
||||
//printf("outcode: %x\n",_vk_to_keycode[i].keysym);
|
||||
|
||||
return _vk_to_keycode[i].keysym;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return KEY_UNKNOWN;
|
||||
}
|
||||
51
platform/windows/key_mapping_win.h
Normal file
51
platform/windows/key_mapping_win.h
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/*************************************************************************/
|
||||
/* key_mapping_win.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
#ifndef KEY_MAPPING_WINDOWS_H
|
||||
#define KEY_MAPPING_WINDOWS_H
|
||||
|
||||
|
||||
#include "os/keyboard.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <winuser.h>
|
||||
|
||||
|
||||
class KeyMappingWindows {
|
||||
|
||||
KeyMappingWindows() {};
|
||||
public:
|
||||
|
||||
static unsigned int get_keysym(unsigned int p_code);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
190
platform/windows/lang_table.h
Normal file
190
platform/windows/lang_table.h
Normal file
|
|
@ -0,0 +1,190 @@
|
|||
/*************************************************************************/
|
||||
/* lang_table.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
#ifndef LANG_TABLE_H
|
||||
#define LANG_TABLE_H
|
||||
|
||||
//#include <windows.h>
|
||||
|
||||
struct _WinLocale {
|
||||
const char *locale;
|
||||
int main_lang;
|
||||
int sublang;
|
||||
};
|
||||
|
||||
static const _WinLocale _win_locales[]={
|
||||
{"ar", LANG_ARABIC,SUBLANG_NEUTRAL},
|
||||
{"ar_AE", LANG_ARABIC,SUBLANG_ARABIC_UAE},
|
||||
{"ar_BH", LANG_ARABIC,SUBLANG_ARABIC_BAHRAIN},
|
||||
{"ar_DZ", LANG_ARABIC,SUBLANG_ARABIC_ALGERIA},
|
||||
{"ar_EG", LANG_ARABIC,SUBLANG_ARABIC_EGYPT},
|
||||
{"ar_IQ", LANG_ARABIC,SUBLANG_ARABIC_IRAQ},
|
||||
{"ar_JO", LANG_ARABIC,SUBLANG_ARABIC_JORDAN},
|
||||
{"ar_KW", LANG_ARABIC,SUBLANG_ARABIC_KUWAIT},
|
||||
{"ar_LB", LANG_ARABIC,SUBLANG_ARABIC_LEBANON},
|
||||
{"ar_LY", LANG_ARABIC,SUBLANG_ARABIC_LIBYA},
|
||||
{"ar_MA", LANG_ARABIC,SUBLANG_ARABIC_MOROCCO},
|
||||
{"ar_OM", LANG_ARABIC,SUBLANG_ARABIC_OMAN},
|
||||
{"ar_QA", LANG_ARABIC,SUBLANG_ARABIC_QATAR},
|
||||
{"ar_SA", LANG_ARABIC,SUBLANG_ARABIC_SAUDI_ARABIA},
|
||||
//no sudan
|
||||
{"ar_SY", LANG_ARABIC,SUBLANG_ARABIC_SYRIA},
|
||||
{"ar_TN", LANG_ARABIC,SUBLANG_ARABIC_TUNISIA},
|
||||
{"ar_YE", LANG_ARABIC,SUBLANG_ARABIC_YEMEN},
|
||||
{"be", LANG_BELARUSIAN,SUBLANG_NEUTRAL},
|
||||
{"be_BY", LANG_BELARUSIAN,SUBLANG_BELARUSIAN_BELARUS},
|
||||
{"bg", LANG_BULGARIAN,SUBLANG_NEUTRAL},
|
||||
{"bg_BG", LANG_BULGARIAN,SUBLANG_BULGARIAN_BULGARIA},
|
||||
{"ca", LANG_CATALAN,SUBLANG_NEUTRAL},
|
||||
{"ca_ES", LANG_CATALAN,SUBLANG_CATALAN_CATALAN},
|
||||
{"cs", LANG_CZECH,SUBLANG_NEUTRAL},
|
||||
{"cs_CZ", LANG_CZECH,SUBLANG_CZECH_CZECH_REPUBLIC},
|
||||
{"da", LANG_DANISH,SUBLANG_NEUTRAL},
|
||||
{"da_DK", LANG_DANISH,SUBLANG_DANISH_DENMARK},
|
||||
{"de", LANG_GERMAN,SUBLANG_NEUTRAL},
|
||||
{"de_AT", LANG_GERMAN,SUBLANG_GERMAN_AUSTRIAN},
|
||||
{"de_CH", LANG_GERMAN,SUBLANG_GERMAN_SWISS},
|
||||
{"de_DE", LANG_GERMAN,SUBLANG_GERMAN},
|
||||
{"de_LU", LANG_GERMAN,SUBLANG_GERMAN_LUXEMBOURG},
|
||||
{"el", LANG_GREEK,SUBLANG_NEUTRAL},
|
||||
{"el_GR", LANG_GREEK,SUBLANG_GREEK_GREECE},
|
||||
//{"en_029", LANG_ENGLISH,SUBLANG_ENGLISH_CARIBBEAN},
|
||||
{"en", LANG_ENGLISH,SUBLANG_NEUTRAL},
|
||||
{"en_AU", LANG_ENGLISH,SUBLANG_ENGLISH_AUS},
|
||||
{"en_CA", LANG_ENGLISH,SUBLANG_ENGLISH_CAN},
|
||||
{"en_GB", LANG_ENGLISH,SUBLANG_ENGLISH_UK},
|
||||
//{"en_IE", LANG_ENGLISH,SUBLANG_ENGLISH_IRELAND},
|
||||
{"en_IN", LANG_ENGLISH,SUBLANG_ENGLISH_INDIA},
|
||||
//MT
|
||||
{"en_NZ", LANG_ENGLISH,SUBLANG_ENGLISH_NZ},
|
||||
{"en_PH", LANG_ENGLISH,SUBLANG_ENGLISH_PHILIPPINES},
|
||||
{"en_SG", LANG_ENGLISH,SUBLANG_ENGLISH_SINGAPORE},
|
||||
{"en_US", LANG_ENGLISH,SUBLANG_ENGLISH_US},
|
||||
{"en_ZA", LANG_ENGLISH,SUBLANG_ENGLISH_SOUTH_AFRICA},
|
||||
{"es", LANG_SPANISH,SUBLANG_NEUTRAL},
|
||||
{"es_AR", LANG_SPANISH,SUBLANG_SPANISH_ARGENTINA},
|
||||
{"es_BO", LANG_SPANISH,SUBLANG_SPANISH_BOLIVIA},
|
||||
{"es_CL", LANG_SPANISH,SUBLANG_SPANISH_CHILE},
|
||||
{"es_CO", LANG_SPANISH,SUBLANG_SPANISH_COLOMBIA},
|
||||
{"es_CR", LANG_SPANISH,SUBLANG_SPANISH_COSTA_RICA},
|
||||
{"es_DO", LANG_SPANISH,SUBLANG_SPANISH_DOMINICAN_REPUBLIC},
|
||||
{"es_EC", LANG_SPANISH,SUBLANG_SPANISH_ECUADOR},
|
||||
{"es_ES", LANG_SPANISH,SUBLANG_SPANISH},
|
||||
{"es_GT", LANG_SPANISH,SUBLANG_SPANISH_GUATEMALA},
|
||||
{"es_HN", LANG_SPANISH,SUBLANG_SPANISH_HONDURAS},
|
||||
{"es_MX", LANG_SPANISH,SUBLANG_SPANISH_MEXICAN},
|
||||
{"es_NI", LANG_SPANISH,SUBLANG_SPANISH_NICARAGUA},
|
||||
{"es_PA", LANG_SPANISH,SUBLANG_SPANISH_PANAMA},
|
||||
{"es_PE", LANG_SPANISH,SUBLANG_SPANISH_PERU},
|
||||
{"es_PR", LANG_SPANISH,SUBLANG_SPANISH_PUERTO_RICO},
|
||||
{"es_PY", LANG_SPANISH,SUBLANG_SPANISH_PARAGUAY},
|
||||
{"es_SV", LANG_SPANISH,SUBLANG_SPANISH_EL_SALVADOR},
|
||||
{"es_US", LANG_SPANISH,SUBLANG_SPANISH_US},
|
||||
{"es_UY", LANG_SPANISH,SUBLANG_SPANISH_URUGUAY},
|
||||
{"es_VE", LANG_SPANISH,SUBLANG_SPANISH_VENEZUELA},
|
||||
{"et", LANG_ESTONIAN,SUBLANG_NEUTRAL},
|
||||
{"et_EE", LANG_ESTONIAN,SUBLANG_ESTONIAN_ESTONIA},
|
||||
{"fi", LANG_FINNISH,SUBLANG_NEUTRAL},
|
||||
{"fi_FI", LANG_FINNISH,SUBLANG_FINNISH_FINLAND},
|
||||
{"fr", LANG_FRENCH,SUBLANG_NEUTRAL},
|
||||
{"fr_BE", LANG_FRENCH,SUBLANG_FRENCH_BELGIAN},
|
||||
{"fr_CA", LANG_FRENCH,SUBLANG_FRENCH_CANADIAN},
|
||||
{"fr_CH", LANG_FRENCH,SUBLANG_FRENCH_SWISS},
|
||||
{"fr_FR", LANG_FRENCH,SUBLANG_FRENCH},
|
||||
{"fr_LU", LANG_FRENCH,SUBLANG_FRENCH_LUXEMBOURG},
|
||||
{"ga", LANG_IRISH,SUBLANG_NEUTRAL},
|
||||
{"ga_IE", LANG_IRISH,SUBLANG_IRISH_IRELAND},
|
||||
{"hi", LANG_HINDI,SUBLANG_NEUTRAL},
|
||||
{"hi_IN", LANG_HINDI,SUBLANG_HINDI_INDIA},
|
||||
{"hr", LANG_CROATIAN,SUBLANG_NEUTRAL},
|
||||
{"hr_HR", LANG_CROATIAN,SUBLANG_CROATIAN_CROATIA},
|
||||
{"hu", LANG_HUNGARIAN,SUBLANG_NEUTRAL},
|
||||
{"hu_HU", LANG_HUNGARIAN,SUBLANG_HUNGARIAN_HUNGARY},
|
||||
{"in", LANG_ARMENIAN,SUBLANG_NEUTRAL},
|
||||
{"in_ID", LANG_INDONESIAN,SUBLANG_INDONESIAN_INDONESIA},
|
||||
{"is", LANG_ICELANDIC,SUBLANG_NEUTRAL},
|
||||
{"is_IS", LANG_ICELANDIC,SUBLANG_ICELANDIC_ICELAND},
|
||||
{"it", LANG_ITALIAN,SUBLANG_NEUTRAL},
|
||||
{"it_CH", LANG_ITALIAN,SUBLANG_ITALIAN_SWISS},
|
||||
{"it_IT", LANG_ITALIAN,SUBLANG_ITALIAN},
|
||||
{"iw", LANG_HEBREW,SUBLANG_NEUTRAL},
|
||||
{"iw_IL", LANG_HEBREW,SUBLANG_HEBREW_ISRAEL},
|
||||
{"ja", LANG_JAPANESE,SUBLANG_NEUTRAL},
|
||||
{"ja_JP", LANG_JAPANESE,SUBLANG_JAPANESE_JAPAN},
|
||||
{"ko", LANG_KOREAN,SUBLANG_NEUTRAL},
|
||||
{"ko_KR", LANG_KOREAN,SUBLANG_KOREAN},
|
||||
{"lt", LANG_LITHUANIAN,SUBLANG_NEUTRAL},
|
||||
//{"lt_LT", LANG_LITHUANIAN,SUBLANG_LITHUANIAN_LITHUANIA},
|
||||
{"lv", LANG_LATVIAN,SUBLANG_NEUTRAL},
|
||||
{"lv_LV", LANG_LATVIAN,SUBLANG_LATVIAN_LATVIA},
|
||||
{"mk", LANG_MACEDONIAN,SUBLANG_NEUTRAL},
|
||||
{"mk_MK", LANG_MACEDONIAN,SUBLANG_MACEDONIAN_MACEDONIA},
|
||||
{"ms", LANG_MALAY,SUBLANG_NEUTRAL},
|
||||
{"ms_MY", LANG_MALAY,SUBLANG_MALAY_MALAYSIA},
|
||||
{"mt", LANG_MALTESE,SUBLANG_NEUTRAL},
|
||||
{"mt_MT", LANG_MALTESE,SUBLANG_MALTESE_MALTA},
|
||||
{"nl", LANG_DUTCH,SUBLANG_NEUTRAL},
|
||||
{"nl_BE", LANG_DUTCH,SUBLANG_DUTCH_BELGIAN},
|
||||
{"nl_NL", LANG_DUTCH,SUBLANG_DUTCH},
|
||||
{"no", LANG_NORWEGIAN,SUBLANG_NEUTRAL},
|
||||
{"no_NO", LANG_NORWEGIAN,SUBLANG_NORWEGIAN_BOKMAL},
|
||||
{"no_NO_NY", LANG_NORWEGIAN,SUBLANG_NORWEGIAN_NYNORSK},
|
||||
{"pl", LANG_POLISH,SUBLANG_NEUTRAL},
|
||||
{"pl_PL", LANG_POLISH,SUBLANG_POLISH_POLAND},
|
||||
{"pt", LANG_PORTUGUESE,SUBLANG_NEUTRAL},
|
||||
{"pt_BR", LANG_PORTUGUESE,SUBLANG_PORTUGUESE_BRAZILIAN},
|
||||
{"pt_PT", LANG_PORTUGUESE,SUBLANG_PORTUGUESE},
|
||||
{"ro", LANG_ROMANIAN,SUBLANG_NEUTRAL},
|
||||
{"ro_RO", LANG_ROMANIAN,SUBLANG_ROMANIAN_ROMANIA},
|
||||
{"ru", LANG_RUSSIAN,SUBLANG_NEUTRAL},
|
||||
{"ru_RU", LANG_RUSSIAN,SUBLANG_RUSSIAN_RUSSIA},
|
||||
{"sk", LANG_SLOVAK,SUBLANG_NEUTRAL},
|
||||
{"sk_SK", LANG_SLOVAK,SUBLANG_SLOVAK_SLOVAKIA},
|
||||
{"sl", LANG_SLOVENIAN,SUBLANG_NEUTRAL},
|
||||
{"sl_SI", LANG_SLOVENIAN,SUBLANG_SLOVENIAN_SLOVENIA},
|
||||
{"sq", LANG_ALBANIAN,SUBLANG_NEUTRAL},
|
||||
{"sq_AL", LANG_ALBANIAN,SUBLANG_ALBANIAN_ALBANIA},
|
||||
{"sr", LANG_SERBIAN_NEUTRAL,SUBLANG_NEUTRAL},
|
||||
{"sv", LANG_SWEDISH,SUBLANG_NEUTRAL},
|
||||
{"sv_SE", LANG_SWEDISH,SUBLANG_SWEDISH},
|
||||
{"th", LANG_THAI,SUBLANG_NEUTRAL},
|
||||
{"th_TH", LANG_THAI,SUBLANG_THAI_THAILAND},
|
||||
{"tr", LANG_TURKISH,SUBLANG_NEUTRAL},
|
||||
{"tr_TR", LANG_TURKISH,SUBLANG_TURKISH_TURKEY},
|
||||
{"uk", LANG_UKRAINIAN,SUBLANG_NEUTRAL},
|
||||
{"uk_UA", LANG_UKRAINIAN,SUBLANG_UKRAINIAN_UKRAINE},
|
||||
{"vi", LANG_VIETNAMESE,SUBLANG_NEUTRAL},
|
||||
{"vi_VN", LANG_VIETNAMESE,SUBLANG_VIETNAMESE_VIETNAM},
|
||||
{"zh", LANG_CHINESE,SUBLANG_NEUTRAL},
|
||||
{"zh_CN", LANG_CHINESE,SUBLANG_CHINESE_SIMPLIFIED},
|
||||
{"zh_HK", LANG_CHINESE,SUBLANG_CHINESE_HONGKONG},
|
||||
{"zh_SG", LANG_CHINESE,SUBLANG_CHINESE_SINGAPORE},
|
||||
{0, 0,0},
|
||||
};
|
||||
|
||||
#endif // LANG_TABLE_H
|
||||
BIN
platform/windows/logo.png
Normal file
BIN
platform/windows/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
1732
platform/windows/os_windows.cpp
Normal file
1732
platform/windows/os_windows.cpp
Normal file
File diff suppressed because it is too large
Load diff
257
platform/windows/os_windows.h
Normal file
257
platform/windows/os_windows.h
Normal file
|
|
@ -0,0 +1,257 @@
|
|||
/*************************************************************************/
|
||||
/* os_windows.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
#ifndef OS_WINDOWS_H
|
||||
#define OS_WINDOWS_H
|
||||
|
||||
#define WINVER 0x0500
|
||||
|
||||
#include "os/input.h"
|
||||
#include "os/os.h"
|
||||
#include "context_gl_win.h"
|
||||
#include "servers/visual_server.h"
|
||||
#include "servers/visual/rasterizer.h"
|
||||
#include "servers/physics/physics_server_sw.h"
|
||||
|
||||
#include "servers/audio/audio_server_sw.h"
|
||||
#include "servers/audio/sample_manager_sw.h"
|
||||
#include "drivers/rtaudio/audio_driver_rtaudio.h"
|
||||
#include "servers/spatial_sound/spatial_sound_server_sw.h"
|
||||
#include "servers/spatial_sound_2d/spatial_sound_2d_server_sw.h"
|
||||
#include "drivers/unix/ip_unix.h"
|
||||
#include "servers/physics_2d/physics_2d_server_sw.h"
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "key_mapping_win.h"
|
||||
#include <windowsx.h>
|
||||
#include <io.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
/**
|
||||
@author Juan Linietsky <reduzio@gmail.com>
|
||||
*/
|
||||
class OS_Windows : public OS {
|
||||
|
||||
enum {
|
||||
JOYSTICKS_MAX = 8,
|
||||
JOY_AXIS_COUNT = 6,
|
||||
MAX_JOY_AXIS = 32768, // I've no idea
|
||||
KEY_EVENT_BUFFER_SIZE=512
|
||||
};
|
||||
|
||||
FILE *stdo;
|
||||
|
||||
|
||||
struct KeyEvent {
|
||||
|
||||
InputModifierState mod_state;
|
||||
UINT uMsg;
|
||||
WPARAM wParam;
|
||||
LPARAM lParam;
|
||||
|
||||
};
|
||||
|
||||
KeyEvent key_event_buffer[KEY_EVENT_BUFFER_SIZE];
|
||||
int key_event_pos;
|
||||
|
||||
|
||||
uint64_t ticks_start;
|
||||
uint64_t ticks_per_second;
|
||||
|
||||
bool minimized;
|
||||
bool old_invalid;
|
||||
bool outside;
|
||||
int old_x,old_y;
|
||||
Point2i center;
|
||||
unsigned int last_id;
|
||||
#if defined(OPENGL_ENABLED) || defined(LEGACYGL_ENABLED) || defined(GLES2_ENABLED)
|
||||
ContextGL_Win *gl_context;
|
||||
#endif
|
||||
VisualServer *visual_server;
|
||||
Rasterizer *rasterizer;
|
||||
PhysicsServer *physics_server;
|
||||
Physics2DServer *physics_2d_server;
|
||||
int pressrc;
|
||||
HDC hDC; // Private GDI Device Context
|
||||
HINSTANCE hInstance; // Holds The Instance Of The Application
|
||||
HWND hWnd;
|
||||
|
||||
struct Joystick {
|
||||
|
||||
bool attached;
|
||||
|
||||
DWORD last_axis[JOY_AXIS_COUNT];
|
||||
DWORD last_buttons;
|
||||
DWORD last_pov;
|
||||
|
||||
Joystick() {
|
||||
attached = false;
|
||||
for (int i=0; i<JOY_AXIS_COUNT; i++) {
|
||||
|
||||
last_axis[i] = 0;
|
||||
};
|
||||
last_buttons = 0;
|
||||
last_pov = 0;
|
||||
};
|
||||
};
|
||||
|
||||
int joystick_count;
|
||||
Joystick joysticks[JOYSTICKS_MAX];
|
||||
|
||||
VideoMode video_mode;
|
||||
|
||||
MainLoop *main_loop;
|
||||
|
||||
WNDPROC user_proc;
|
||||
|
||||
AudioServerSW *audio_server;
|
||||
SampleManagerMallocSW *sample_manager;
|
||||
SpatialSoundServerSW *spatial_sound_server;
|
||||
SpatialSound2DServerSW *spatial_sound_2d_server;
|
||||
|
||||
MouseMode mouse_mode;
|
||||
bool alt_mem;
|
||||
bool gr_mem;
|
||||
bool shift_mem;
|
||||
bool control_mem;
|
||||
bool meta_mem;
|
||||
bool force_quit;
|
||||
uint32_t last_button_state;
|
||||
|
||||
CursorShape cursor_shape;
|
||||
|
||||
InputDefault *input;
|
||||
|
||||
#ifdef RTAUDIO_ENABLED
|
||||
AudioDriverRtAudio driver_rtaudio;
|
||||
#endif
|
||||
|
||||
void _post_dpad(DWORD p_dpad, int p_device, bool p_pressed);
|
||||
|
||||
// functions used by main to initialize/deintialize the OS
|
||||
protected:
|
||||
virtual int get_video_driver_count() const;
|
||||
virtual const char * get_video_driver_name(int p_driver) const;
|
||||
|
||||
virtual VideoMode get_default_video_mode() const;
|
||||
|
||||
virtual int get_audio_driver_count() const;
|
||||
virtual const char * get_audio_driver_name(int p_driver) const;
|
||||
|
||||
virtual void initialize_core();
|
||||
virtual void initialize(const VideoMode& p_desired,int p_video_driver,int p_audio_driver);
|
||||
|
||||
virtual void set_main_loop( MainLoop * p_main_loop );
|
||||
virtual void delete_main_loop();
|
||||
|
||||
virtual void finalize();
|
||||
virtual void finalize_core();
|
||||
|
||||
void process_events();
|
||||
|
||||
void probe_joysticks();
|
||||
void process_joysticks();
|
||||
void process_key_events();
|
||||
|
||||
struct ProcessInfo {
|
||||
|
||||
STARTUPINFO si;
|
||||
PROCESS_INFORMATION pi;
|
||||
};
|
||||
Map<ProcessID, ProcessInfo>* process_map;
|
||||
|
||||
public:
|
||||
LRESULT WndProc(HWND hWnd,UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
|
||||
void print_error(const char* p_function,const char* p_file,int p_line,const char *p_code,const char*p_rationale,ErrorType p_type);
|
||||
|
||||
virtual void vprint(const char *p_format, va_list p_list, bool p_stderr=false);
|
||||
virtual void alert(const String& p_alert,const String& p_title="ALERT!");
|
||||
String get_stdin_string(bool p_block);
|
||||
|
||||
void set_mouse_mode(MouseMode p_mode);
|
||||
MouseMode get_mouse_mode() const;
|
||||
|
||||
virtual Point2 get_mouse_pos() const;
|
||||
virtual int get_mouse_button_state() const;
|
||||
virtual void set_window_title(const String& p_title);
|
||||
|
||||
virtual void set_video_mode(const VideoMode& p_video_mode,int p_screen=0);
|
||||
virtual VideoMode get_video_mode(int p_screen=0) const;
|
||||
virtual void get_fullscreen_mode_list(List<VideoMode> *p_list,int p_screen=0) const;
|
||||
|
||||
virtual MainLoop *get_main_loop() const;
|
||||
|
||||
virtual String get_name();
|
||||
|
||||
virtual Date get_date() const;
|
||||
virtual Time get_time() const;
|
||||
virtual uint64_t get_unix_time() const;
|
||||
|
||||
virtual bool can_draw() const;
|
||||
virtual Error set_cwd(const String& p_cwd);
|
||||
|
||||
virtual void delay_usec(uint32_t p_usec) const;
|
||||
virtual uint64_t get_ticks_usec() const;
|
||||
|
||||
virtual Error execute(const String& p_path, const List<String>& p_arguments,bool p_blocking,ProcessID *r_child_id=NULL,String* r_pipe=NULL,int *r_exitcode=NULL);
|
||||
virtual Error kill(const ProcessID& p_pid);
|
||||
|
||||
virtual bool has_environment(const String& p_var) const;
|
||||
virtual String get_environment(const String& p_var) const;
|
||||
|
||||
virtual void set_clipboard(const String& p_text);
|
||||
virtual String get_clipboard() const;
|
||||
|
||||
void set_cursor_shape(CursorShape p_shape);
|
||||
void set_icon(const Image& p_icon);
|
||||
|
||||
|
||||
virtual String get_locale() const;
|
||||
|
||||
virtual void move_window_to_foreground();
|
||||
virtual String get_data_dir() const;
|
||||
|
||||
virtual void release_rendering_thread();
|
||||
virtual void make_rendering_thread();
|
||||
virtual void swap_buffers();
|
||||
|
||||
void run();
|
||||
|
||||
virtual bool get_swap_ok_cancel() { return true; }
|
||||
|
||||
OS_Windows(HINSTANCE _hInstance);
|
||||
~OS_Windows();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
35
platform/windows/platform_config.h
Normal file
35
platform/windows/platform_config.h
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/*************************************************************************/
|
||||
/* platform_config.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
#include <malloc.h>
|
||||
//#else
|
||||
//#include <alloca.h>
|
||||
//#endif
|
||||
#define GLES2_INCLUDE_H "gl_context/glew.h"
|
||||
#define GLES1_INCLUDE_H "gl_context/glew.h"
|
||||
|
||||
368
platform/windows/stream_peer_winsock.cpp
Normal file
368
platform/windows/stream_peer_winsock.cpp
Normal file
|
|
@ -0,0 +1,368 @@
|
|||
/*************************************************************************/
|
||||
/* stream_peer_winsock.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
#ifdef WINDOWS_ENABLED
|
||||
|
||||
#include "stream_peer_winsock.h"
|
||||
|
||||
#include <winsock2.h>
|
||||
|
||||
int winsock_refcount = 0;
|
||||
|
||||
static void set_addr_in(struct sockaddr_in& their_addr, const IP_Address& p_host, uint16_t p_port) {
|
||||
|
||||
their_addr.sin_family = AF_INET; // host byte order
|
||||
their_addr.sin_port = htons(p_port); // short, network byte order
|
||||
their_addr.sin_addr = *((struct in_addr*)&p_host.host);
|
||||
memset(&(their_addr.sin_zero), '\0', 8);
|
||||
};
|
||||
|
||||
StreamPeerTCP* StreamPeerWinsock::_create() {
|
||||
|
||||
return memnew(StreamPeerWinsock);
|
||||
};
|
||||
|
||||
void StreamPeerWinsock::make_default() {
|
||||
|
||||
StreamPeerTCP::_create = StreamPeerWinsock::_create;
|
||||
|
||||
if (winsock_refcount == 0) {
|
||||
WSADATA data;
|
||||
WSAStartup(MAKEWORD(2,2), &data);
|
||||
};
|
||||
++winsock_refcount;
|
||||
};
|
||||
|
||||
void StreamPeerWinsock::cleanup() {
|
||||
|
||||
--winsock_refcount;
|
||||
if (winsock_refcount == 0) {
|
||||
|
||||
WSACleanup();
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Error StreamPeerWinsock::_block(int p_sockfd, bool p_read, bool p_write) const {
|
||||
|
||||
fd_set read, write;
|
||||
FD_ZERO(&read);
|
||||
FD_ZERO(&write);
|
||||
|
||||
if (p_read)
|
||||
FD_SET(p_sockfd, &read);
|
||||
if (p_write)
|
||||
FD_SET(p_sockfd, &write);
|
||||
|
||||
int ret = select(p_sockfd + 1, &read, &write, NULL, NULL); // block forever
|
||||
return ret < 0 ? FAILED : OK;
|
||||
};
|
||||
|
||||
Error StreamPeerWinsock::_poll_connection(bool p_block) const {
|
||||
|
||||
ERR_FAIL_COND_V(status != STATUS_CONNECTING || sockfd == INVALID_SOCKET, FAILED);
|
||||
|
||||
if (p_block) {
|
||||
|
||||
_block(sockfd, false, true);
|
||||
};
|
||||
|
||||
struct sockaddr_in their_addr;
|
||||
set_addr_in(their_addr, peer_host, peer_port);
|
||||
|
||||
if (::connect(sockfd, (struct sockaddr *)&their_addr,sizeof(struct sockaddr)) == SOCKET_ERROR) {
|
||||
|
||||
int err = WSAGetLastError();
|
||||
if (err == WSAEISCONN) {
|
||||
status = STATUS_CONNECTED;
|
||||
return OK;
|
||||
};
|
||||
|
||||
return OK;
|
||||
} else {
|
||||
|
||||
status = STATUS_CONNECTED;
|
||||
return OK;
|
||||
};
|
||||
|
||||
return OK;
|
||||
};
|
||||
|
||||
Error StreamPeerWinsock::write(const uint8_t* p_data,int p_bytes, int &r_sent, bool p_block) {
|
||||
|
||||
if (status == STATUS_NONE || status == STATUS_ERROR) {
|
||||
|
||||
return FAILED;
|
||||
};
|
||||
|
||||
if (status != STATUS_CONNECTED) {
|
||||
|
||||
if (_poll_connection(p_block) != OK) {
|
||||
|
||||
return FAILED;
|
||||
};
|
||||
|
||||
if (status != STATUS_CONNECTED) {
|
||||
r_sent = 0;
|
||||
return OK;
|
||||
};
|
||||
};
|
||||
|
||||
int data_to_send = p_bytes;
|
||||
const uint8_t *offset = p_data;
|
||||
if (sockfd == -1) return FAILED;
|
||||
errno = 0;
|
||||
int total_sent = 0;
|
||||
|
||||
while (data_to_send) {
|
||||
|
||||
int sent_amount = send(sockfd, (const char*)offset, data_to_send, 0);
|
||||
//printf("Sent TCP data of %d bytes, errno %d\n", sent_amount, errno);
|
||||
|
||||
if (sent_amount == -1) {
|
||||
|
||||
if (WSAGetLastError() != WSAEWOULDBLOCK) {
|
||||
|
||||
perror("shit?");
|
||||
disconnect();
|
||||
ERR_PRINT("Server disconnected!\n");
|
||||
return FAILED;
|
||||
};
|
||||
|
||||
if (!p_block) {
|
||||
r_sent = total_sent;
|
||||
return OK;
|
||||
};
|
||||
|
||||
_block(sockfd, false, true);
|
||||
} else {
|
||||
|
||||
data_to_send -= sent_amount;
|
||||
offset += sent_amount;
|
||||
total_sent += sent_amount;
|
||||
};
|
||||
}
|
||||
|
||||
r_sent = total_sent;
|
||||
|
||||
return OK;
|
||||
};
|
||||
|
||||
Error StreamPeerWinsock::read(uint8_t* p_buffer, int p_bytes,int &r_received, bool p_block) {
|
||||
|
||||
if (!is_connected()) {
|
||||
|
||||
return FAILED;
|
||||
};
|
||||
|
||||
if (status != STATUS_CONNECTED) {
|
||||
|
||||
if (_poll_connection(p_block) != OK) {
|
||||
|
||||
return FAILED;
|
||||
};
|
||||
|
||||
if (status != STATUS_CONNECTED) {
|
||||
r_received = 0;
|
||||
return OK;
|
||||
};
|
||||
};
|
||||
|
||||
int to_read = p_bytes;
|
||||
int total_read = 0;
|
||||
errno = 0;
|
||||
|
||||
while (to_read) {
|
||||
|
||||
int read = recv(sockfd, (char*)p_buffer + total_read, to_read, 0);
|
||||
|
||||
if (read == -1) {
|
||||
|
||||
if (WSAGetLastError() != WSAEWOULDBLOCK) {
|
||||
|
||||
perror("shit?");
|
||||
disconnect();
|
||||
ERR_PRINT("Server disconnected!\n");
|
||||
return FAILED;
|
||||
};
|
||||
|
||||
if (!p_block) {
|
||||
|
||||
r_received = total_read;
|
||||
return OK;
|
||||
};
|
||||
_block(sockfd, true, false);
|
||||
} else if (read == 0) {
|
||||
disconnect();
|
||||
return ERR_FILE_EOF;
|
||||
} else {
|
||||
|
||||
to_read -= read;
|
||||
total_read += read;
|
||||
};
|
||||
};
|
||||
|
||||
r_received = total_read;
|
||||
|
||||
return OK;
|
||||
};
|
||||
|
||||
Error StreamPeerWinsock::put_data(const uint8_t* p_data,int p_bytes) {
|
||||
|
||||
int total;
|
||||
return write(p_data, p_bytes, total, true);
|
||||
};
|
||||
|
||||
Error StreamPeerWinsock::put_partial_data(const uint8_t* p_data,int p_bytes, int &r_sent) {
|
||||
|
||||
return write(p_data, p_bytes, r_sent, false);
|
||||
};
|
||||
|
||||
Error StreamPeerWinsock::get_data(uint8_t* p_buffer, int p_bytes) {
|
||||
|
||||
int total;
|
||||
return read(p_buffer, p_bytes, total, true);
|
||||
};
|
||||
|
||||
Error StreamPeerWinsock::get_partial_data(uint8_t* p_buffer, int p_bytes,int &r_received) {
|
||||
|
||||
return read(p_buffer, p_bytes, r_received, false);
|
||||
};
|
||||
|
||||
StreamPeerTCP::Status StreamPeerWinsock::get_status() const {
|
||||
|
||||
if (status == STATUS_CONNECTING) {
|
||||
_poll_connection(false);
|
||||
};
|
||||
|
||||
return status;
|
||||
};
|
||||
|
||||
|
||||
bool StreamPeerWinsock::is_connected() const {
|
||||
|
||||
if (status == STATUS_NONE || status == STATUS_ERROR) {
|
||||
|
||||
return false;
|
||||
};
|
||||
if (status != STATUS_CONNECTED) {
|
||||
return true;
|
||||
};
|
||||
|
||||
return (sockfd!=INVALID_SOCKET);
|
||||
};
|
||||
|
||||
void StreamPeerWinsock::disconnect() {
|
||||
|
||||
if (sockfd != INVALID_SOCKET)
|
||||
closesocket(sockfd);
|
||||
sockfd=INVALID_SOCKET;
|
||||
|
||||
status = STATUS_NONE;
|
||||
|
||||
peer_host = IP_Address();
|
||||
peer_port = 0;
|
||||
};
|
||||
|
||||
void StreamPeerWinsock::set_socket(int p_sockfd, IP_Address p_host, int p_port) {
|
||||
|
||||
sockfd = p_sockfd;
|
||||
status = STATUS_CONNECTING;
|
||||
peer_host = p_host;
|
||||
peer_port = p_port;
|
||||
};
|
||||
|
||||
Error StreamPeerWinsock::connect(const IP_Address& p_host, uint16_t p_port) {
|
||||
|
||||
ERR_FAIL_COND_V( p_host.host == 0, ERR_INVALID_PARAMETER);
|
||||
|
||||
if ((sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) {
|
||||
ERR_PRINT("Socket creation failed!");
|
||||
disconnect();
|
||||
//perror("socket");
|
||||
return FAILED;
|
||||
};
|
||||
|
||||
unsigned long par = 1;
|
||||
if (ioctlsocket(sockfd, FIONBIO, &par)) {
|
||||
perror("setting non-block mode");
|
||||
disconnect();
|
||||
return FAILED;
|
||||
};
|
||||
|
||||
struct sockaddr_in their_addr;
|
||||
set_addr_in(their_addr, p_host, p_port);
|
||||
|
||||
if (::connect(sockfd, (struct sockaddr *)&their_addr,sizeof(struct sockaddr)) == SOCKET_ERROR) {
|
||||
|
||||
if (WSAGetLastError() != WSAEWOULDBLOCK) {
|
||||
ERR_PRINT("Connection to remote host failed!");
|
||||
disconnect();
|
||||
return FAILED;
|
||||
};
|
||||
status = STATUS_CONNECTING;
|
||||
} else {
|
||||
status = STATUS_CONNECTED;
|
||||
};
|
||||
|
||||
peer_host = p_host;
|
||||
peer_port = p_port;
|
||||
|
||||
return OK;
|
||||
};
|
||||
|
||||
void StreamPeerWinsock::set_nodelay(bool p_enabled) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
IP_Address StreamPeerWinsock::get_connected_host() const {
|
||||
|
||||
return peer_host;
|
||||
};
|
||||
|
||||
uint16_t StreamPeerWinsock::get_connected_port() const {
|
||||
|
||||
return peer_port;
|
||||
};
|
||||
|
||||
StreamPeerWinsock::StreamPeerWinsock() {
|
||||
|
||||
sockfd = INVALID_SOCKET;
|
||||
status = STATUS_NONE;
|
||||
peer_port = 0;
|
||||
};
|
||||
|
||||
StreamPeerWinsock::~StreamPeerWinsock() {
|
||||
|
||||
disconnect();
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
90
platform/windows/stream_peer_winsock.h
Normal file
90
platform/windows/stream_peer_winsock.h
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
/*************************************************************************/
|
||||
/* stream_peer_winsock.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
#ifdef WINDOWS_ENABLED
|
||||
|
||||
#ifndef STREAM_PEER_WINSOCK_H
|
||||
#define STREAM_PEER_WINSOCK_H
|
||||
|
||||
#include "error_list.h"
|
||||
|
||||
#include "core/io/ip_address.h"
|
||||
#include "core/io/stream_peer_tcp.h"
|
||||
|
||||
class StreamPeerWinsock : public StreamPeerTCP {
|
||||
|
||||
protected:
|
||||
|
||||
mutable Status status;
|
||||
|
||||
int sockfd;
|
||||
|
||||
Error _block(int p_sockfd, bool p_read, bool p_write) const;
|
||||
|
||||
Error _poll_connection(bool p_block) const;
|
||||
|
||||
IP_Address peer_host;
|
||||
int peer_port;
|
||||
|
||||
Error write(const uint8_t* p_data,int p_bytes, int &r_sent, bool p_block);
|
||||
Error read(uint8_t* p_buffer, int p_bytes,int &r_received, bool p_block);
|
||||
|
||||
static StreamPeerTCP* _create();
|
||||
|
||||
public:
|
||||
|
||||
virtual Error connect(const IP_Address& p_host, uint16_t p_port);
|
||||
|
||||
virtual Error put_data(const uint8_t* p_data,int p_bytes);
|
||||
virtual Error put_partial_data(const uint8_t* p_data,int p_bytes, int &r_sent);
|
||||
|
||||
virtual Error get_data(uint8_t* p_buffer, int p_bytes);
|
||||
virtual Error get_partial_data(uint8_t* p_buffer, int p_bytes,int &r_received);
|
||||
|
||||
void set_socket(int p_sockfd, IP_Address p_host, int p_port);
|
||||
|
||||
virtual IP_Address get_connected_host() const;
|
||||
virtual uint16_t get_connected_port() const;
|
||||
|
||||
virtual bool is_connected() const;
|
||||
virtual Status get_status() const;
|
||||
virtual void disconnect();
|
||||
|
||||
static void make_default();
|
||||
static void cleanup();
|
||||
|
||||
virtual void set_nodelay(bool p_enabled);
|
||||
|
||||
|
||||
StreamPeerWinsock();
|
||||
~StreamPeerWinsock();
|
||||
};
|
||||
|
||||
#endif // TCP_SOCKET_POSIX_H
|
||||
|
||||
#endif
|
||||
166
platform/windows/tcp_server_winsock.cpp
Normal file
166
platform/windows/tcp_server_winsock.cpp
Normal file
|
|
@ -0,0 +1,166 @@
|
|||
/*************************************************************************/
|
||||
/* tcp_server_winsock.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
#include "tcp_server_winsock.h"
|
||||
|
||||
#include "stream_peer_winsock.h"
|
||||
|
||||
#include <winsock2.h>
|
||||
|
||||
extern int winsock_refcount;
|
||||
|
||||
TCP_Server* TCPServerWinsock::_create() {
|
||||
|
||||
return memnew(TCPServerWinsock);
|
||||
};
|
||||
|
||||
void TCPServerWinsock::make_default() {
|
||||
|
||||
TCP_Server::_create = TCPServerWinsock::_create;
|
||||
|
||||
if (winsock_refcount == 0) {
|
||||
WSADATA data;
|
||||
WSAStartup(MAKEWORD(2,2), &data);
|
||||
};
|
||||
++winsock_refcount;
|
||||
};
|
||||
|
||||
void TCPServerWinsock::cleanup() {
|
||||
|
||||
--winsock_refcount;
|
||||
if (winsock_refcount == 0) {
|
||||
|
||||
WSACleanup();
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Error TCPServerWinsock::listen(uint16_t p_port,const List<String> *p_accepted_hosts) {
|
||||
|
||||
int sockfd;
|
||||
sockfd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
ERR_FAIL_COND_V(sockfd == INVALID_SOCKET, FAILED);
|
||||
|
||||
unsigned long par = 1;
|
||||
if (ioctlsocket(sockfd, FIONBIO, &par)) {
|
||||
perror("setting non-block mode");
|
||||
stop();
|
||||
return FAILED;
|
||||
};
|
||||
|
||||
struct sockaddr_in my_addr;
|
||||
my_addr.sin_family = AF_INET; // host byte order
|
||||
my_addr.sin_port = htons(p_port); // short, network byte order
|
||||
my_addr.sin_addr.s_addr = INADDR_ANY; // automatically fill with my IP TODO: use p_accepted_hosts
|
||||
memset(my_addr.sin_zero, '\0', sizeof my_addr.sin_zero);
|
||||
|
||||
if (bind(sockfd, (struct sockaddr *)&my_addr, sizeof my_addr) != SOCKET_ERROR) {
|
||||
|
||||
if (::listen(sockfd, SOMAXCONN) == SOCKET_ERROR) {
|
||||
|
||||
closesocket(sockfd);
|
||||
ERR_FAIL_V(FAILED);
|
||||
};
|
||||
};
|
||||
|
||||
if (listen_sockfd != INVALID_SOCKET) {
|
||||
|
||||
stop();
|
||||
};
|
||||
|
||||
listen_sockfd = sockfd;
|
||||
|
||||
return OK;
|
||||
};
|
||||
|
||||
bool TCPServerWinsock::is_connection_available() const {
|
||||
|
||||
if (listen_sockfd == -1) {
|
||||
return false;
|
||||
};
|
||||
|
||||
timeval timeout;
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
fd_set pfd;
|
||||
FD_ZERO(&pfd);
|
||||
FD_SET(listen_sockfd, &pfd);
|
||||
|
||||
int ret = select(listen_sockfd + 1, &pfd, NULL, NULL, &timeout);
|
||||
ERR_FAIL_COND_V(ret < 0, 0);
|
||||
|
||||
if (ret && (FD_ISSET(listen_sockfd, &pfd))) {
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
|
||||
Ref<StreamPeerTCP> TCPServerWinsock::take_connection() {
|
||||
|
||||
if (!is_connection_available()) {
|
||||
return NULL;
|
||||
};
|
||||
|
||||
struct sockaddr_in their_addr;
|
||||
int sin_size = sizeof(their_addr);
|
||||
int fd = accept(listen_sockfd, (struct sockaddr *)&their_addr, &sin_size);
|
||||
ERR_FAIL_COND_V(fd == INVALID_SOCKET, NULL);
|
||||
|
||||
Ref<StreamPeerWinsock> conn = memnew(StreamPeerWinsock);
|
||||
IP_Address ip;
|
||||
ip.host = (uint32_t)their_addr.sin_addr.s_addr;
|
||||
|
||||
conn->set_socket(fd, ip, ntohs(their_addr.sin_port));
|
||||
|
||||
return conn;
|
||||
};
|
||||
|
||||
void TCPServerWinsock::stop() {
|
||||
|
||||
if (listen_sockfd != INVALID_SOCKET) {
|
||||
closesocket(listen_sockfd);
|
||||
};
|
||||
|
||||
listen_sockfd = -1;
|
||||
};
|
||||
|
||||
|
||||
TCPServerWinsock::TCPServerWinsock() {
|
||||
|
||||
listen_sockfd = INVALID_SOCKET;
|
||||
};
|
||||
|
||||
TCPServerWinsock::~TCPServerWinsock() {
|
||||
|
||||
stop();
|
||||
};
|
||||
|
||||
55
platform/windows/tcp_server_winsock.h
Normal file
55
platform/windows/tcp_server_winsock.h
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/*************************************************************************/
|
||||
/* tcp_server_winsock.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* http://www.godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
#ifndef TCP_SERVER_WINSOCK_H
|
||||
#define TCP_SERVER_WINSOCK_H
|
||||
|
||||
#include "core/io/tcp_server.h"
|
||||
|
||||
class TCPServerWinsock : public TCP_Server {
|
||||
|
||||
int listen_sockfd;
|
||||
|
||||
static TCP_Server* _create();
|
||||
|
||||
public:
|
||||
|
||||
virtual Error listen(uint16_t p_port,const List<String> *p_accepted_hosts=NULL);
|
||||
virtual bool is_connection_available() const;
|
||||
virtual Ref<StreamPeerTCP> take_connection();
|
||||
|
||||
virtual void stop(); //stop listening
|
||||
|
||||
static void make_default();
|
||||
static void cleanup();
|
||||
|
||||
TCPServerWinsock();
|
||||
~TCPServerWinsock();
|
||||
};
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue