Skip to content

Commit

Permalink
Mega push!
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-spataru committed Jun 3, 2016
0 parents commit 49ef1c3
Show file tree
Hide file tree
Showing 101 changed files with 33,328 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE.MIT
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2015-2016 WinT 3794

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.
39 changes: 39 additions & 0 deletions QJoysticks.pri
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#
# Copyright (c) 2015-2016 Alex Spataru <[email protected]>
#
# 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 ($$PWD/lib/SDL/SDL.pri)

INCLUDEPATH += $$PWD/src

HEADERS += \
$$PWD/src/QJoysticks.h \
$$PWD/src/QJoysticks/JoysticksCommon.h \
$$PWD/src/QJoysticks/SDL_Joysticks.h \
$$PWD/src/QJoysticks/VirtualJoystick.h

SOURCES += \
$$PWD/src/QJoysticks.cpp \
$$PWD/src/QJoysticks/SDL_Joysticks.cpp \
$$PWD/src/QJoysticks/VirtualJoystick.cpp

RESOURCES += \
$$PWD/etc/resources/qjoysticks-res.qrc

22 changes: 22 additions & 0 deletions QJoysticks.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#
# Copyright (c) 2015-2016 Alex Spataru <[email protected]>
#
# 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 ($$PWD/QJoysticks.pri)
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# QJoysticks library

The QJoysticks library allows your Qt application to read input from both real joysticks/gamepads (using SDL) and a virtual joystick (using the keyboard).

SDL binaries and headers for Windows and OS X are already included in this library. Linux uses will need to install libsdl2-dev using the package manager of their distro of choice.
110 changes: 110 additions & 0 deletions etc/resources/SDL/Database.txt

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions etc/resources/SDL/GenericMappings/Linux.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Linux,
1 change: 1 addition & 0 deletions etc/resources/SDL/GenericMappings/OSX.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,platform:Mac OS X,
1 change: 1 addition & 0 deletions etc/resources/SDL/GenericMappings/Windows.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,platform:Windows,
8 changes: 8 additions & 0 deletions etc/resources/qjoysticks-res.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<RCC>
<qresource prefix="/QJoysticks">
<file>SDL/Database.txt</file>
<file>SDL/GenericMappings/Linux.txt</file>
<file>SDL/GenericMappings/OSX.txt</file>
<file>SDL/GenericMappings/Windows.txt</file>
</qresource>
</RCC>
20 changes: 20 additions & 0 deletions etc/scripts/format-code.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
:: Description: This script changes the style format of
:: all the source code of the project.

:: Setup the command line
@echo off
title Code Formatter

:: Go to the directory where the script is run
cd /d %~dp0

:: Style and format the source code recursively
astyle --style=linux --indent=spaces --align-pointer=type --remove-brackets --convert-tabs --close-templates --max-code-length=80 --max-instatement-indent=50 --lineend=windows --suffix=none --recursive ../../*.h ../../*.cpp ../../*.c

:: Notify the user that we have finished
echo.
echo Code styling complete!
echo.

:: Let the user see the output
pause
2 changes: 2 additions & 0 deletions etc/scripts/format-code.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Style and format recursively
astyle --style=linux --indent=spaces --align-pointer=type --remove-brackets --convert-tabs --close-templates --max-code-length=80 --max-instatement-indent=50 --lineend=windows --suffix=none --recursive ../../*.h ../../*.cpp ../../*.c
32 changes: 32 additions & 0 deletions examples/JoystickList/JoystickList.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#
# Copyright (c) 2015-2016 Alex Spataru <[email protected]>
#
# 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.


TEMPLATE = app
TARGET = "JoystickList Example"

QT += qml quick widgets

SOURCES += $$PWD/main.cpp
RESOURCES += $$PWD/qml.qrc
OTHER_FILES += $$PWD/main.qml

include ($$PWD/../../QJoysticks.pri)
84 changes: 84 additions & 0 deletions examples/JoystickList/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* Copyright (c) 2015-2016 Alex Spataru <[email protected]>
*
* 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 <QPalette>
#include <QQmlContext>
#include <QApplication>
#include <QStyleFactory>
#include <QQmlApplicationEngine>

#include <QJoysticks.h>

void configureDarkStyle()
{
qApp->setStyle (QStyleFactory::create ("Fusion"));
QPalette darkPalette;
darkPalette.setColor (QPalette::BrightText, Qt::red);
darkPalette.setColor (QPalette::WindowText, Qt::white);
darkPalette.setColor (QPalette::ToolTipBase, Qt::white);
darkPalette.setColor (QPalette::ToolTipText, Qt::white);
darkPalette.setColor (QPalette::Text, Qt::white);
darkPalette.setColor (QPalette::ButtonText, Qt::white);
darkPalette.setColor (QPalette::HighlightedText, Qt::black);
darkPalette.setColor (QPalette::Window, QColor (53, 53, 53));
darkPalette.setColor (QPalette::Base, QColor (25, 25, 25));
darkPalette.setColor (QPalette::AlternateBase, QColor (53, 53, 53));
darkPalette.setColor (QPalette::Button, QColor (53, 53, 53));
darkPalette.setColor (QPalette::Link, QColor (42, 130, 218));
darkPalette.setColor (QPalette::Highlight, QColor (42, 130, 218));
qApp->setPalette(darkPalette);
}

int main (int argc, char* argv[])
{
QApplication app (argc, argv);
QQmlApplicationEngine qmlEngine;

/*
* Make the application use the Fusion style + dark palette
*/
configureDarkStyle();

/*
* QJoysticks is single instance, you can use the "getInstance()" function
* directly if you want, or you can create a pointer to it to make code
* easier to read;
*/
QJoysticks* instance = QJoysticks::getInstance();

/* Enable the virtual joystick */
instance->setVirtualJoystickRange (1);
instance->setVirtualJoystickEnabled (true);

/*
* Register the QJoysticks with the QML engine, so that the QML interface
* can easilly use it.
*/
qmlEngine.rootContext()->setContextProperty ("QJoysticks", instance);

/*
* Load main.qml and run the application.
*/
qmlEngine.load (QUrl (QStringLiteral("qrc:/main.qml")));

return app.exec();
}
Loading

0 comments on commit 49ef1c3

Please sign in to comment.