Init
This commit is contained in:
@ -0,0 +1,131 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
|
||||
|
||||
#ifndef LINUX_SAMPLE_PLATFORM_H
|
||||
#define LINUX_SAMPLE_PLATFORM_H
|
||||
|
||||
#include <SamplePlatform.h>
|
||||
#include <linux/LinuxSampleUserInput.h>
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/extensions/xf86vmode.h>
|
||||
|
||||
#if defined(RENDERER_ENABLE_OPENGL)
|
||||
#define GLEW_STATIC
|
||||
#include <GL/glew.h>
|
||||
#endif
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glx.h>
|
||||
#include <GL/glu.h>
|
||||
|
||||
namespace SampleFramework
|
||||
{
|
||||
class LinuxPlatform : public SamplePlatform
|
||||
{
|
||||
public:
|
||||
explicit LinuxPlatform(SampleRenderer::RendererWindow* _app);
|
||||
// System
|
||||
virtual void showCursor(bool);
|
||||
virtual void setCWDToEXE(void);
|
||||
const char* getPathSeparator();
|
||||
bool makeSureDirectoryPathExists(const char* dirPath);
|
||||
void showMessage(const char* title, const char* message);
|
||||
// Rendering
|
||||
virtual void initializeOGLDisplay(const SampleRenderer::RendererDesc& desc,
|
||||
physx::PxU32& width,
|
||||
physx::PxU32& height);
|
||||
virtual void postInitializeOGLDisplay();
|
||||
virtual void postRendererSetup(SampleRenderer::Renderer* renderer);
|
||||
virtual void setupRendererDescription(SampleRenderer::RendererDesc& renDesc);
|
||||
virtual bool hasFocus() const;
|
||||
virtual void setFocus(bool b);
|
||||
virtual void getTitle(char *title, physx::PxU32 maxLength) const;
|
||||
virtual void setTitle(const char *title);
|
||||
virtual bool updateWindow();
|
||||
virtual bool openWindow(physx::PxU32& width,
|
||||
physx::PxU32& height,
|
||||
const char* title,
|
||||
bool fullscreen);
|
||||
virtual void getWindowSize(physx::PxU32& width, physx::PxU32& height);
|
||||
virtual void update();
|
||||
virtual bool closeWindow();
|
||||
virtual void freeDisplay();
|
||||
virtual void swapBuffers();
|
||||
|
||||
virtual void* compileProgram(void * context,
|
||||
const char* assetDir,
|
||||
const char *programPath,
|
||||
physx::PxU64 profile,
|
||||
const char* passString,
|
||||
const char *entry,
|
||||
const char **args);
|
||||
|
||||
// Input
|
||||
virtual void doInput();
|
||||
|
||||
virtual const SampleUserInput* getSampleUserInput() const { return &m_linuxSampleUserInput; }
|
||||
virtual SampleUserInput* getSampleUserInput() { return &m_linuxSampleUserInput; }
|
||||
|
||||
virtual const char* getPlatformName() const { return "linux"; }
|
||||
|
||||
virtual void setMouseCursorRecentering(bool val);
|
||||
virtual bool getMouseCursorRecentering() const;
|
||||
|
||||
physx::PxVec2 getMouseCursorPos() const { return m_mouseCursorPos; }
|
||||
void setMouseCursorPos(const physx::PxVec2& pos) { m_mouseCursorPos = pos; }
|
||||
void recenterMouseCursor(bool generateEvent);
|
||||
|
||||
LinuxSampleUserInput& getLinuxSampleUserInput() { return m_linuxSampleUserInput; }
|
||||
const LinuxSampleUserInput& getLinuxSampleUserInput() const { return m_linuxSampleUserInput; }
|
||||
|
||||
protected:
|
||||
bool filterKeyRepeat(const XEvent& keyReleaseEvent);
|
||||
void handleMouseEvent(const XEvent& event);
|
||||
void showCursorInternal(bool show);
|
||||
|
||||
protected:
|
||||
Display* m_display;
|
||||
XVisualInfo* m_visualInfo;
|
||||
Window m_window;
|
||||
Atom m_wmDelete;
|
||||
GLXContext m_glxContext;
|
||||
XF86VidModeModeInfo m_desktopMode;
|
||||
int m_screen;
|
||||
bool m_isFullScreen;
|
||||
bool m_hasFocus;
|
||||
bool m_hasContentFocus;
|
||||
physx::PxU32 m_windowWidth;
|
||||
physx::PxU32 m_windowHeight;
|
||||
LinuxSampleUserInput m_linuxSampleUserInput;
|
||||
physx::PxVec2 m_mouseCursorPos;
|
||||
bool m_recenterMouseCursor;
|
||||
bool m_showCursor;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,76 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
|
||||
|
||||
#ifndef LINUX_SAMPLE_USER_INPUT_H
|
||||
#define LINUX_SAMPLE_USER_INPUT_H
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <SampleUserInput.h>
|
||||
#include <linux/LinuxSampleUserInputIds.h>
|
||||
#include <set>
|
||||
|
||||
|
||||
namespace SampleFramework
|
||||
{
|
||||
class LinuxSampleUserInput: public SampleUserInput
|
||||
{
|
||||
public:
|
||||
|
||||
LinuxSampleUserInput();
|
||||
~LinuxSampleUserInput();
|
||||
|
||||
void doOnMouseMove( physx::PxU32 x, physx::PxU32 y, physx::PxReal dx, physx::PxReal dy, physx::PxU16 button);
|
||||
void doOnMouseDown( physx::PxU32 x, physx::PxU32 y, physx::PxU16 button);
|
||||
void doOnMouseUp( physx::PxU32 x, physx::PxU32 y, physx::PxU16 button);
|
||||
void doOnKeyDown( KeySym keySym, physx::PxU16 keyCode, physx::PxU8 ascii);
|
||||
void doOnKeyUp( KeySym keySym, physx::PxU16 keyCode, physx::PxU8 ascii);
|
||||
|
||||
virtual void updateInput();
|
||||
|
||||
virtual void shutdown();
|
||||
|
||||
virtual bool keyboardSupported() const { return true; }
|
||||
virtual bool gamepadSupported() const { return false; }
|
||||
virtual bool mouseSupported() const { return true; }
|
||||
|
||||
virtual bool getDigitalInputEventState(physx::PxU16 inputEventId) const;
|
||||
virtual float getAnalogInputEventState(physx::PxU16 inputEventId) const;
|
||||
|
||||
protected:
|
||||
|
||||
void registerScanCode(LinuxSampleUserInputIds scanCodeId, physx::PxU16 scanCode, LinuxSampleUserInputIds nameId, const char* name);
|
||||
LinuxSampleUserInputIds getInputIdFromKeySym(const KeySym keySym) const;
|
||||
LinuxSampleUserInputIds getInputIdFromMouseButton(const physx::PxU16 button) const;
|
||||
const UserInput* getUserInputFromId(LinuxSampleUserInputIds id) const;
|
||||
|
||||
std::map<physx::PxU16, physx::PxU16> m_ScanCodesMap;
|
||||
std::map<physx::PxU16,float> m_AnalogStates;
|
||||
std::map<physx::PxU16,bool> m_DigitalStates;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,141 @@
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions
|
||||
// are met:
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
// * Neither the name of NVIDIA CORPORATION nor the names of its
|
||||
// contributors may be used to endorse or promote products derived
|
||||
// from this software without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
|
||||
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
|
||||
|
||||
#ifndef LINUX_SAMPLE_USER_INPUT_IDS_H
|
||||
#define LINUX_SAMPLE_USER_INPUT_IDS_H
|
||||
|
||||
namespace SampleFramework
|
||||
{
|
||||
enum LinuxSampleUserInputIds
|
||||
{
|
||||
LINUXKEY_UNKNOWN = 0,
|
||||
|
||||
// the following keys are keyboard layout dependent
|
||||
// its not a complete list
|
||||
LINUXKEY_A,
|
||||
LINUXKEY_B,
|
||||
LINUXKEY_C,
|
||||
LINUXKEY_D,
|
||||
LINUXKEY_E,
|
||||
LINUXKEY_F,
|
||||
LINUXKEY_G,
|
||||
LINUXKEY_H,
|
||||
LINUXKEY_I,
|
||||
LINUXKEY_J,
|
||||
LINUXKEY_K,
|
||||
LINUXKEY_L,
|
||||
LINUXKEY_M,
|
||||
LINUXKEY_N,
|
||||
LINUXKEY_O,
|
||||
LINUXKEY_P,
|
||||
LINUXKEY_Q,
|
||||
LINUXKEY_R,
|
||||
LINUXKEY_S,
|
||||
LINUXKEY_T,
|
||||
LINUXKEY_U,
|
||||
LINUXKEY_V,
|
||||
LINUXKEY_W,
|
||||
LINUXKEY_X,
|
||||
LINUXKEY_Y,
|
||||
LINUXKEY_Z,
|
||||
|
||||
LINUXKEY_0,
|
||||
LINUXKEY_1,
|
||||
LINUXKEY_2,
|
||||
LINUXKEY_3,
|
||||
LINUXKEY_4,
|
||||
LINUXKEY_5,
|
||||
LINUXKEY_6,
|
||||
LINUXKEY_7,
|
||||
LINUXKEY_8,
|
||||
LINUXKEY_9,
|
||||
|
||||
LINUXKEY_NUMPAD0,
|
||||
LINUXKEY_NUMPAD1,
|
||||
LINUXKEY_NUMPAD2,
|
||||
LINUXKEY_NUMPAD3,
|
||||
LINUXKEY_NUMPAD4,
|
||||
LINUXKEY_NUMPAD5,
|
||||
LINUXKEY_NUMPAD6,
|
||||
LINUXKEY_NUMPAD7,
|
||||
LINUXKEY_NUMPAD8,
|
||||
LINUXKEY_NUMPAD9,
|
||||
|
||||
LINUXKEY_SHIFT,
|
||||
LINUXKEY_CONTROL,
|
||||
LINUXKEY_SPACE,
|
||||
LINUXKEY_RETURN,
|
||||
LINUXKEY_ESCAPE,
|
||||
LINUXKEY_COMMA,
|
||||
LINUXKEY_DIVIDE,
|
||||
LINUXKEY_SUBTRACT,
|
||||
LINUXKEY_ADD,
|
||||
|
||||
LINUXKEY_F1,
|
||||
LINUXKEY_F2,
|
||||
LINUXKEY_F3,
|
||||
LINUXKEY_F4,
|
||||
LINUXKEY_F5,
|
||||
LINUXKEY_F6,
|
||||
LINUXKEY_F7,
|
||||
LINUXKEY_F8,
|
||||
LINUXKEY_F9,
|
||||
LINUXKEY_F10,
|
||||
LINUXKEY_F11,
|
||||
LINUXKEY_F12,
|
||||
|
||||
LINUXKEY_TAB,
|
||||
LINUXKEY_BACKSPACE,
|
||||
LINUXKEY_PRIOR,
|
||||
LINUXKEY_NEXT,
|
||||
LINUXKEY_UP,
|
||||
LINUXKEY_DOWN,
|
||||
LINUXKEY_LEFT,
|
||||
LINUXKEY_RIGHT,
|
||||
|
||||
MOUSE_BUTTON_LEFT,
|
||||
MOUSE_BUTTON_RIGHT,
|
||||
MOUSE_BUTTON_CENTER,
|
||||
|
||||
MOUSE_MOVE,
|
||||
|
||||
SCAN_CODE_UP ,
|
||||
SCAN_CODE_DOWN ,
|
||||
SCAN_CODE_LEFT,
|
||||
SCAN_CODE_RIGHT,
|
||||
SCAN_CODE_FORWARD,
|
||||
SCAN_CODE_BACKWARD,
|
||||
SCAN_CODE_L,
|
||||
SCAN_CODE_9,
|
||||
SCAN_CODE_0,
|
||||
|
||||
NUM_KEY_CODES,
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user