Browse Source

Merge branch 'love2d:12.0-development' into 12.0-development

nikeinikei 2 years ago
parent
commit
2adc0070e4

+ 2 - 1
CMakeLists.txt

@@ -174,7 +174,7 @@ Please see https://github.com/love2d/megasource
 	endif()
 	endif()
 
 
 	find_package(Freetype REQUIRED)
 	find_package(Freetype REQUIRED)
-	find_package(harfbuzz REQUIRED)
+	find_package(Harfbuzz REQUIRED)
 	find_package(ModPlug REQUIRED)
 	find_package(ModPlug REQUIRED)
 	find_package(OpenAL REQUIRED)
 	find_package(OpenAL REQUIRED)
 	find_package(OpenGL REQUIRED)
 	find_package(OpenGL REQUIRED)
@@ -190,6 +190,7 @@ Please see https://github.com/love2d/megasource
 	set(LOVE_INCLUDE_DIRS
 	set(LOVE_INCLUDE_DIRS
 		${SDL2_INCLUDE_DIR}
 		${SDL2_INCLUDE_DIR}
 		${FREETYPE_INCLUDE_DIRS}
 		${FREETYPE_INCLUDE_DIRS}
+		${HARFBUZZ_INCLUDE_DIR}
 		${VORBIS_INCLUDE_DIR}
 		${VORBIS_INCLUDE_DIR}
 		${OPENAL_INCLUDE_DIR}
 		${OPENAL_INCLUDE_DIR}
 		${ZLIB_INCLUDE_DIRS}
 		${ZLIB_INCLUDE_DIRS}

+ 43 - 8
changes.txt

@@ -4,6 +4,7 @@ LOVE 12.0 [N/A]
 Released: N/A
 Released: N/A
 
 
 * Added support for launching a specific .lua file as the main file.
 * Added support for launching a specific .lua file as the main file.
+* Added basic usage instructions printed to the console when '--help' is used as a command-line parameter, and when the no-game screen is run.
 * Added love.parsedGameArguments and love.rawGameArguments tables, in the main thread.
 * Added love.parsedGameArguments and love.rawGameArguments tables, in the main thread.
 * Added love.markDeprecated.
 * Added love.markDeprecated.
 * Added HTTPS Lua module.
 * Added HTTPS Lua module.
@@ -24,10 +25,10 @@ Released: N/A
 * Added love.audio.getPlaybackDevice, love.audio.getPlaybackDevices, and love.audio.setPlaybackDevice.
 * Added love.audio.getPlaybackDevice, love.audio.getPlaybackDevices, and love.audio.setPlaybackDevice.
 * Added love.keyboard.isModifierActive.
 * Added love.keyboard.isModifierActive.
 * Added Joystick:setPlayerIndex and Joystick:getPlayerIndex.
 * Added Joystick:setPlayerIndex and Joystick:getPlayerIndex.
+* Added Joystick:getJoystickType.
 * Added Joystick:getGamepadType.
 * Added Joystick:getGamepadType.
 * Added Joystick:hasSensor.
 * Added Joystick:hasSensor.
-* Added Joystick:isSensorEnabled.
-* Added Joystick:setSensorEnabled.
+* Added Joystick:isSensorEnabled and Joystick:setSensorEnabled.
 * Added Joystick:getSensorData.
 * Added Joystick:getSensorData.
 * Added new Gamepad API buttons: "misc1", "paddle1", "paddle2", "paddle3", "paddle4". and "touchpad".
 * Added new Gamepad API buttons: "misc1", "paddle1", "paddle2", "paddle3", "paddle4". and "touchpad".
 * Added World:getFixturesInArea().
 * Added World:getFixturesInArea().
@@ -41,21 +42,28 @@ Released: N/A
 * Added per-shader opt in support for the GLSL 4.30 (desktop) and GLSL ES 3.20 (mobile) shading languages, via #pragma language glsl4.
 * Added per-shader opt in support for the GLSL 4.30 (desktop) and GLSL ES 3.20 (mobile) shading languages, via #pragma language glsl4.
 * Added compile options table parameter to love.graphics.newShader. Allows setting #define values via newShader.
 * Added compile options table parameter to love.graphics.newShader. Allows setting #define values via newShader.
 * Added love.graphics.newTexture. newImage and newCanvas still exist as convenience constructor functions.
 * Added love.graphics.newTexture. newImage and newCanvas still exist as convenience constructor functions.
+* Added optional 'mipmapcount' field to the settings table in newTexture/newImage/newCanvas.
+* Added optional 'computewrite' boolean field to the settings table in newTexture/newImage/newCanvas.
 * Added love.graphics.getTextureFormats, which replaces getImageFormats and getCanvasFormats.
 * Added love.graphics.getTextureFormats, which replaces getImageFormats and getCanvasFormats.
+* Added Texture:isCanvas and Texture:isComputeWritable.
+* Added Texture:isFormatLinear, Texture:getMSAA, Texture:generateMipmaps, Texture:replacePixels, and Texture:renderTo (moved from old Canvas and Image subclasses).
 * Added integer pixel formats for Textures and ImageData.
 * Added integer pixel formats for Textures and ImageData.
-* Added Graphics Buffer objects, including vertex, index, texel, and shader storage buffers.
+* Added Graphics Buffer objects, including vertex, index, texel, shader storage, and indirect draw/dispatch argument buffers.
 * Added love.graphics.copyBuffer, copyBufferToTexture, and copyTextureToBuffer.
 * Added love.graphics.copyBuffer, copyBufferToTexture, and copyTextureToBuffer.
 * Added APIs for interacting with the Buffer objects owned by Meshes.
 * Added APIs for interacting with the Buffer objects owned by Meshes.
 * Added Mesh:getAttachedAttributes.
 * Added Mesh:getAttachedAttributes.
+* Added an optional start array index parameter to Mesh:attachAttribute.
 * Added integer buffer data formats.
 * Added integer buffer data formats.
 * Added love.graphics.readbackTexture and love.graphics.readbackTextureAsync (replaces Texture:newImageData).
 * Added love.graphics.readbackTexture and love.graphics.readbackTextureAsync (replaces Texture:newImageData).
 * Added love.graphics.readbackBuffer and love.graphics.readbackBufferAsync.
 * Added love.graphics.readbackBuffer and love.graphics.readbackBufferAsync.
 * Added 'readback' buffer data usage enum, useful for advanced memory optimization when using love.graphics.readbackBuffer.
 * Added 'readback' buffer data usage enum, useful for advanced memory optimization when using love.graphics.readbackBuffer.
 * Added new lower level 'vertexmain' and 'pixelmain' shader entry points.
 * Added new lower level 'vertexmain' and 'pixelmain' shader entry points.
-* Added Compute Shader support via new 'computemain' shader entry point.
-* Added love.graphics.dispatchThreadgroups for running compute shaders.
+* Added Compute Shader support via love.graphics.newComputeShader and a new 'computemain' shader entry point.
+* Added love.graphics.dispatchThreadgroups and love.graphics.dispatchIndirect for running compute shaders.
 * Added Shader:hasStage.
 * Added Shader:hasStage.
 * Added love.graphics.drawFromShader.
 * Added love.graphics.drawFromShader.
+* Added love.graphics.drawFromShaderIndirect.
+* Added love.graphics.drawIndirect.
 * Added love.graphics.getQuadIndexBuffer.
 * Added love.graphics.getQuadIndexBuffer.
 * Added variants of love.graphics.applyTransform and replaceTransform which accept x,y,angle,sx,sy,ox,oy parameters.
 * Added variants of love.graphics.applyTransform and replaceTransform which accept x,y,angle,sx,sy,ox,oy parameters.
 * Added APIs to override the default orthographic projection: love.graphics.setOrthoProjection, setPerspectiveProjection, and resetProjection.
 * Added APIs to override the default orthographic projection: love.graphics.setOrthoProjection, setPerspectiveProjection, and resetProjection.
@@ -64,27 +72,37 @@ Released: N/A
 * Added love.graphics.setStencilMode and getStencilMode. Replaces love.graphics.stencil as well as setStencilTest.
 * Added love.graphics.setStencilMode and getStencilMode. Replaces love.graphics.stencil as well as setStencilTest.
 * Added a variant of love.graphics.setColorMask which accepts a single boolean.
 * Added a variant of love.graphics.setColorMask which accepts a single boolean.
 * Added new 'clampone' wrap mode.
 * Added new 'clampone' wrap mode.
+* Added 'clampone', 'texelbuffer', 'indexbuffer32bit', 'mipmaprange', and 'indirectdraw' graphics feature enums.
+* Added 'copybuffer', 'copybuffertotexture', 'copytexturetobuffer', and 'copyrendertargettobuffer' graphics feature enums.
+* Added initial support for right-to-left (RTL) text when using TrueType and OpenType fonts.
 * Added a variant of Font:getWidth which takes a codepoint number argument.
 * Added a variant of Font:getWidth which takes a codepoint number argument.
+* Added love.graphics.newTextBatch (renamed from love.graphics.newText).
 * Added love.sensor module.
 * Added love.sensor module.
 * Added love.sensorupdated callback.
 * Added love.sensorupdated callback.
 * Added love.joysticksensorupdated callback.
 * Added love.joysticksensorupdated callback.
 
 
+* Changed love.filesystem.exists to no longer be deprecated.
 * Changed the default font from Vera size 12 to Noto Sans size 13.
 * Changed the default font from Vera size 12 to Noto Sans size 13.
+* Changed TrueType and OpenType font handling to have improved kerning and character combining support.
 * Changed the Texture class and implementation to no longer have separate Canvas and Image subclasses.
 * Changed the Texture class and implementation to no longer have separate Canvas and Image subclasses.
 * Changed Images to no longer hold onto a CPU copy of their pixel data after creation.
 * Changed Images to no longer hold onto a CPU copy of their pixel data after creation.
 * Changed love.graphics.newImage to error instead of loading a placeholder texture, when the image dimensions are too large for the system.
 * Changed love.graphics.newImage to error instead of loading a placeholder texture, when the image dimensions are too large for the system.
+* Changed love.graphics.newImage to allow creating a mipmapped texture with less than the full mipmap range, instead of erroring.
 * Changed love.graphics.newMesh to no longer default to the "fan" Mesh draw mode.
 * Changed love.graphics.newMesh to no longer default to the "fan" Mesh draw mode.
 * Changed the behaviour of Meshes to no longer allow a vertex map or index buffer when the "fan" mesh draw mode is used.
 * Changed the behaviour of Meshes to no longer allow a vertex map or index buffer when the "fan" mesh draw mode is used.
 * Changed love.window.setMode to no longer clear the contents of Canvases or otherwise recreate OpenGL resources.
 * Changed love.window.setMode to no longer clear the contents of Canvases or otherwise recreate OpenGL resources.
 * Changed love.graphics.points to require 'love_PointSize' to be set in the vertex shader, if a custom shader is used.
 * Changed love.graphics.points to require 'love_PointSize' to be set in the vertex shader, if a custom shader is used.
+* Changed love.graphics.setCanvas to always clear auto-generated temporary depth and stencil buffers when they're used.
+* Changed shader code parsing to ignore shader entry point functions inside comments.
 * Changed audio file decoding to choose the most appropriate decoder based on file contents instead of the file extension.
 * Changed audio file decoding to choose the most appropriate decoder based on file contents instead of the file extension.
 * Changed Videos to stream audio from the file instead of loading all the video file into memory for use with audio decoding.
 * Changed Videos to stream audio from the file instead of loading all the video file into memory for use with audio decoding.
 * Changed love.filesystem.exists to no longer be deprecated.
 * Changed love.filesystem.exists to no longer be deprecated.
-* Changed RevoluteJoint:getMotorTorque to take 'dt' as a parameter instead of 'inverse_dt'.
+* Changed RevoluteJoint:getMotorTorque and WheelJoint:getMotorTorque to take 'dt' as a parameter instead of 'inverse_dt'.
 * Changed love.math.perlinNoise and simplexNoise to use higher precision numbers for its internal calculations.
 * Changed love.math.perlinNoise and simplexNoise to use higher precision numbers for its internal calculations.
 * Changed t.accelerometerjoystick startup flag in love.conf to unset by default.
 * Changed t.accelerometerjoystick startup flag in love.conf to unset by default.
 
 
 * Renamed 'display' field to 'displayindex' in love.window.setMode/updateMode/getMode and love.conf.
 * Renamed 'display' field to 'displayindex' in love.window.setMode/updateMode/getMode and love.conf.
+* Renamed love.graphics Text objects to TextBatch.
 
 
 * Updated Box2D from 2.3 to 2.4.1.
 * Updated Box2D from 2.3 to 2.4.1.
 * Updated LuaSocket from 3.0-rc1 to 3.1.0.
 * Updated LuaSocket from 3.0-rc1 to 3.1.0.
@@ -92,7 +110,11 @@ Released: N/A
 * Deprecated usage of slashes instead of dots for module separators in require.
 * Deprecated usage of slashes instead of dots for module separators in require.
 * Deprecated love.filesystem.newFile (replaced by openFile).
 * Deprecated love.filesystem.newFile (replaced by openFile).
 * Deprecated love.math.noise (replaced by perlinNoise and simplexNoise).
 * Deprecated love.math.noise (replaced by perlinNoise and simplexNoise).
+* Deprecated love.graphics.setNewFont (use love.graphics.newFont and love.graphics.setFont instead).
+* Deprecated love.graphics.newText (renamed to love.graphics.newTextBatch).
 * Deprecated love.graphics.getImageFormats and love.graphics.getCanvasFormats (replaced by getTextureFormats).
 * Deprecated love.graphics.getImageFormats and love.graphics.getCanvasFormats (replaced by getTextureFormats).
+* Deprecated love.graphics.stencil (replaced by love.graphics.setStencilMode).
+* Deprecated love.graphics.setStencilTest and love.graphics.getStencilTest (replaced by love.graphics.setStencilMode and getStencilMode).
 * Deprecated t.window.highdpi in love.conf and the highdpi flag of love.window.setMode (replaced by t.highdpi in love.conf).
 * Deprecated t.window.highdpi in love.conf and the highdpi flag of love.window.setMode (replaced by t.highdpi in love.conf).
 * Deprecated t.accelerometerjoystick in love.conf (replaced by love.sensor module).
 * Deprecated t.accelerometerjoystick in love.conf (replaced by love.sensor module).
 * Deprecated the variants of Mesh:attachAttribute and SpriteBatch:attachAttribute which accept a Mesh (replaced by variants which accept a Buffer).
 * Deprecated the variants of Mesh:attachAttribute and SpriteBatch:attachAttribute which accept a Mesh (replaced by variants which accept a Buffer).
@@ -100,8 +122,21 @@ Released: N/A
 
 
 * Removed the variant of SpriteBatch:setColor() which turns off all previously set colors.
 * Removed the variant of SpriteBatch:setColor() which turns off all previously set colors.
 * Removed the no-argument variant of love.graphics.setColorMask.
 * Removed the no-argument variant of love.graphics.setColorMask.
-* Removed love.graphics.stencil (replaced by love.graphics.setStencilMode).
-* Removed love.graphics.setStencilTest and getStencilTest (replaced by love.graphics.setStencilMode and getStencilMode).
+* Removed functions deprecated in LOVE 11:
+	* Removed love.audio.getSourceCount (renamed to love.audio.getActiveSourceCount).
+	* Removed Source:getChannels (renamed to Source:getChannelCount).
+	* Removed Decoder:getChannels (renamed to Decoder:getChannelCount).
+	* Removed love.filesystem.isDirectory (replaced by love.filesystem.getInfo).
+	* Removed love.filesystem.isFile (replaced by love.filesystem.getInfo).
+	* Removed love.filesystem.isSymlink (replaced by love.filesystem.getInfo).
+	* Removed love.filesystem.getLastModified (replaced by love.filesystem.getInfo).
+	* Removed love.filesystem.getSize (replaced by love.filesystem.getInfo).
+	* Removed ParticleSystem:setAreaSpread and ParticleSystem:getAreaSpread (renamed to ParticleSystem:setEmissionArea and getEmissionArea).
+	* Removed love.math.compress and love.math.decompress (replaced by love.data.compress and love.data.decompress).
+	* Removed World:getBodyList, World:getJointList, and World:getContactList (renamed to World:getBodies, World:getJoints, and World:getContacts).
+	* Removed Body:getFixtureList, Body:getJointList, and Body:getContactList (renamed to Body:getFixtures, Body:getJoints, and Body:getContacts).
+	* Removed PrismaticJoint:hasLimitsEnabled (renamed to PrismaticJoint:areLimitsEnabled).
+	* Removed RevoluteJoint:hasLimitsEnabled (renamed to RevoluteJoint:areLimitsEnabled).
 
 
 * Fixed BezierCurve:render adding collinear points in some situations.
 * Fixed BezierCurve:render adding collinear points in some situations.
 * Fixed line rendering when the line has duplicate points.
 * Fixed line rendering when the line has duplicate points.

+ 25 - 0
extra/cmake/FindHarfbuzz.cmake

@@ -0,0 +1,25 @@
+# Sets the following variables:
+#
+#  HARFBUZZ_FOUND
+#  HARFBUZZ_INCLUDE_DIR
+#  HARFBUZZ_LIBRARY
+
+set(HARFBUZZ_SEARCH_PATHS
+	/usr/local
+	/usr
+	)
+
+find_path(HARFBUZZ_INCLUDE_DIR
+	NAMES hb.h
+	PATH_SUFFIXES include include/harfbuzz
+	PATHS ${HARFBUZZ_SEARCH_PATHS})
+
+find_library(HARFBUZZ_LIBRARY
+	NAMES harfbuzz
+	PATH_SUFFIXES lib
+	PATHS ${HARFBUZZ_SEARCH_PATHS})
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(Harfbuzz DEFAULT_MSG HARFBUZZ_LIBRARY HARFBUZZ_INCLUDE_DIR)
+
+mark_as_advanced(HARFBUZZ_INCLUDE_DIR HARFBUZZ_LIBRARY)

+ 45 - 2
src/modules/graphics/wrap_Graphics.lua

@@ -24,8 +24,10 @@ misrepresented as being the original software.
 
 
 local table_concat = table.concat
 local table_concat = table.concat
 local ipairs = ipairs
 local ipairs = ipairs
+local pcall = pcall
+local graphics = love.graphics
 
 
-function love.graphics.newVideo(file, settings)
+function graphics.newVideo(file, settings)
 	settings = settings == nil and {} or settings
 	settings = settings == nil and {} or settings
 	if type(settings) ~= "table" then error("bad argument #2 to newVideo (expected table)", 2) end
 	if type(settings) ~= "table" then error("bad argument #2 to newVideo (expected table)", 2) end
 
 
@@ -50,7 +52,48 @@ function love.graphics.newVideo(file, settings)
 	return video
 	return video
 end
 end
 
 
-function love.graphics._transformGLSLErrorMessages(message)
+function graphics.stencil(func, action, value, keepvalues)
+	love.markDeprecated(2, "love.graphics.stencil", "function", "replaced", "love.graphics.setStencilMode")
+
+	if not keepvalues then
+		graphics.clear(false, true, false)
+	end
+
+	if value == nil then value = 1 end
+
+	graphics.setStencilMode(action, "always", value)
+
+	local mr, mg, mb, ma = graphics.getColorMask()
+	graphics.setColorMask(false)
+
+	local success, err = pcall(func)
+
+	graphics.setColorMask(mr, mg, mb, ma)
+	graphics.setStencilMode()
+
+	if not success then
+		error(err, 2)
+	end
+end
+
+function graphics.setStencilTest(mode, value)
+	love.markDeprecated(2, "love.graphics.setStencilTest", "function", "replaced", "love.graphics.setStencilMode")
+
+	if mode ~= nil then
+		graphics.setStencilMode("keep", mode, value)
+	else
+		graphics.setStencilMode()
+	end
+end
+
+function graphics.getStencilTest()
+	love.markDeprecated(2, "love.graphics.getStencilTest", "function", "replaced", "love.graphics.getStencilMode")
+
+	local action, mode, value = graphics.getStencilMode()
+	return mode, value
+end
+
+function graphics._transformGLSLErrorMessages(message)
 	local shadertype = message:match("Cannot compile (%a+) shader code")
 	local shadertype = message:match("Cannot compile (%a+) shader code")
 	local compiling = shadertype ~= nil
 	local compiling = shadertype ~= nil
 	if not shadertype then
 	if not shadertype then

+ 15 - 0
src/modules/joystick/Joystick.cpp

@@ -56,6 +56,21 @@ STRINGMAP_CLASS_BEGIN(Joystick, Joystick::Hat, Joystick::HAT_MAX_ENUM, hat)
 }
 }
 STRINGMAP_CLASS_END(Joystick, Joystick::Hat, Joystick::HAT_MAX_ENUM, hat)
 STRINGMAP_CLASS_END(Joystick, Joystick::Hat, Joystick::HAT_MAX_ENUM, hat)
 
 
+STRINGMAP_CLASS_BEGIN(Joystick, Joystick::JoystickType, Joystick::JOYSTICK_TYPE_MAX_ENUM, joystickType)
+{
+	{ "unknown",     Joystick::JOYSTICK_TYPE_UNKNOWN      },
+	{ "gamepad",     Joystick::JOYSTICK_TYPE_GAMEPAD      },
+	{ "wheel",       Joystick::JOYSTICK_TYPE_WHEEL        },
+	{ "arcadestick", Joystick::JOYSTICK_TYPE_ARCADE_STICK },
+	{ "flightstick", Joystick::JOYSTICK_TYPE_FLIGHT_STICK },
+	{ "dancepad",    Joystick::JOYSTICK_TYPE_DANCE_PAD    },
+	{ "guitar",      Joystick::JOYSTICK_TYPE_GUITAR       },
+	{ "drumkit",     Joystick::JOYSTICK_TYPE_DRUM_KIT     },
+	{ "arcadepad",   Joystick::JOYSTICK_TYPE_ARCADE_PAD   },
+	{ "throttle",    Joystick::JOYSTICK_TYPE_THROTTLE     },
+}
+STRINGMAP_CLASS_END(Joystick, Joystick::JoystickType, Joystick::JOYSTICK_TYPE_MAX_ENUM, joystickType)
+
 STRINGMAP_CLASS_BEGIN(Joystick, Joystick::GamepadType, Joystick::GAMEPAD_TYPE_MAX_ENUM, gamepadType)
 STRINGMAP_CLASS_BEGIN(Joystick, Joystick::GamepadType, Joystick::GAMEPAD_TYPE_MAX_ENUM, gamepadType)
 {
 {
 	{ "unknown",      Joystick::GAMEPAD_TYPE_UNKNOWN             },
 	{ "unknown",      Joystick::GAMEPAD_TYPE_UNKNOWN             },

+ 18 - 0
src/modules/joystick/Joystick.h

@@ -59,6 +59,21 @@ public:
 		HAT_MAX_ENUM = 16
 		HAT_MAX_ENUM = 16
 	};
 	};
 
 
+	enum JoystickType
+	{
+		JOYSTICK_TYPE_UNKNOWN,
+		JOYSTICK_TYPE_GAMEPAD,
+		JOYSTICK_TYPE_WHEEL,
+		JOYSTICK_TYPE_ARCADE_STICK,
+		JOYSTICK_TYPE_FLIGHT_STICK,
+		JOYSTICK_TYPE_DANCE_PAD,
+		JOYSTICK_TYPE_GUITAR,
+		JOYSTICK_TYPE_DRUM_KIT,
+		JOYSTICK_TYPE_ARCADE_PAD,
+		JOYSTICK_TYPE_THROTTLE,
+		JOYSTICK_TYPE_MAX_ENUM
+	};
+
 	enum GamepadType
 	enum GamepadType
 	{
 	{
 		GAMEPAD_TYPE_UNKNOWN,
 		GAMEPAD_TYPE_UNKNOWN,
@@ -164,6 +179,8 @@ public:
 
 
 	virtual const char *getName() const = 0;
 	virtual const char *getName() const = 0;
 
 
+	virtual JoystickType getJoystickType() const = 0;
+
 	virtual int getAxisCount() const = 0;
 	virtual int getAxisCount() const = 0;
 	virtual int getButtonCount() const = 0;
 	virtual int getButtonCount() const = 0;
 	virtual int getHatCount() const = 0;
 	virtual int getHatCount() const = 0;
@@ -207,6 +224,7 @@ public:
 	virtual std::vector<float> getSensorData(Sensor::SensorType type) const = 0;
 	virtual std::vector<float> getSensorData(Sensor::SensorType type) const = 0;
 
 
 	STRINGMAP_CLASS_DECLARE(Hat);
 	STRINGMAP_CLASS_DECLARE(Hat);
+	STRINGMAP_CLASS_DECLARE(JoystickType);
 	STRINGMAP_CLASS_DECLARE(GamepadType);
 	STRINGMAP_CLASS_DECLARE(GamepadType);
 	STRINGMAP_CLASS_DECLARE(GamepadAxis);
 	STRINGMAP_CLASS_DECLARE(GamepadAxis);
 	STRINGMAP_CLASS_DECLARE(GamepadButton);
 	STRINGMAP_CLASS_DECLARE(GamepadButton);

+ 40 - 0
src/modules/joystick/sdl/Joystick.cpp

@@ -46,6 +46,7 @@ Joystick::Joystick(int id)
 	: joyhandle(nullptr)
 	: joyhandle(nullptr)
 	, controller(nullptr)
 	, controller(nullptr)
 	, haptic(nullptr)
 	, haptic(nullptr)
+	, joystickType(JOYSTICK_TYPE_UNKNOWN)
 	, instanceid(-1)
 	, instanceid(-1)
 	, id(id)
 	, id(id)
 	, vibration()
 	, vibration()
@@ -96,6 +97,40 @@ bool Joystick::open(int deviceindex)
 
 
 		if (joyname)
 		if (joyname)
 			name = joyname;
 			name = joyname;
+
+		switch (SDL_JoystickGetType(joyhandle))
+		{
+		case SDL_JOYSTICK_TYPE_GAMECONTROLLER:
+			joystickType = JOYSTICK_TYPE_GAMEPAD;
+			break;
+		case SDL_JOYSTICK_TYPE_WHEEL:
+			joystickType = JOYSTICK_TYPE_WHEEL;
+			break;
+		case SDL_JOYSTICK_TYPE_ARCADE_STICK:
+			joystickType = JOYSTICK_TYPE_ARCADE_STICK;
+			break;
+		case SDL_JOYSTICK_TYPE_FLIGHT_STICK:
+			joystickType = JOYSTICK_TYPE_FLIGHT_STICK;
+			break;
+		case SDL_JOYSTICK_TYPE_DANCE_PAD:
+			joystickType = JOYSTICK_TYPE_DANCE_PAD;
+			break;
+		case SDL_JOYSTICK_TYPE_GUITAR:
+			joystickType = JOYSTICK_TYPE_GUITAR;
+			break;
+		case SDL_JOYSTICK_TYPE_DRUM_KIT:
+			joystickType = JOYSTICK_TYPE_DRUM_KIT;
+			break;
+		case SDL_JOYSTICK_TYPE_ARCADE_PAD:
+			joystickType = JOYSTICK_TYPE_ARCADE_PAD;
+			break;
+		case SDL_JOYSTICK_TYPE_THROTTLE:
+			joystickType = JOYSTICK_TYPE_THROTTLE;
+			break;
+		default:
+			joystickType = JOYSTICK_TYPE_UNKNOWN;
+			break;
+		}
 	}
 	}
 
 
 	return isConnected();
 	return isConnected();
@@ -129,6 +164,11 @@ const char *Joystick::getName() const
 	return name.c_str();
 	return name.c_str();
 }
 }
 
 
+Joystick::JoystickType Joystick::getJoystickType() const
+{
+	return joystickType;
+}
+
 int Joystick::getAxisCount() const
 int Joystick::getAxisCount() const
 {
 {
 	return isConnected() ? SDL_JoystickNumAxes(joyhandle) : 0;
 	return isConnected() ? SDL_JoystickNumAxes(joyhandle) : 0;

+ 4 - 0
src/modules/joystick/sdl/Joystick.h

@@ -51,6 +51,8 @@ public:
 
 
 	const char *getName() const override;
 	const char *getName() const override;
 
 
+	JoystickType getJoystickType() const override;
+
 	int getAxisCount() const override;
 	int getAxisCount() const override;
 	int getButtonCount() const override;
 	int getButtonCount() const override;
 	int getHatCount() const override;
 	int getHatCount() const override;
@@ -113,6 +115,8 @@ private:
 	SDL_GameController *controller;
 	SDL_GameController *controller;
 	SDL_Haptic *haptic;
 	SDL_Haptic *haptic;
 
 
+	JoystickType joystickType;
+
 	SDL_JoystickID instanceid;
 	SDL_JoystickID instanceid;
 	std::string pguid;
 	std::string pguid;
 	int id;
 	int id;

+ 10 - 0
src/modules/joystick/wrap_Joystick.cpp

@@ -86,6 +86,15 @@ int w_Joystick_getDeviceInfo(lua_State *L)
 	return 3;
 	return 3;
 }
 }
 
 
+int w_Joystick_getJoystickType(lua_State *L)
+{
+	Joystick *j = luax_checkjoystick(L, 1);
+	const char* str = "unknown";
+	Joystick::getConstant(j->getJoystickType(), str);
+	lua_pushstring(L, str);
+	return 1;
+}
+
 int w_Joystick_getAxisCount(lua_State *L)
 int w_Joystick_getAxisCount(lua_State *L)
 {
 {
 	Joystick *j = luax_checkjoystick(L, 1);
 	Joystick *j = luax_checkjoystick(L, 1);
@@ -448,6 +457,7 @@ static const luaL_Reg w_Joystick_functions[] =
 	{ "getID", w_Joystick_getID },
 	{ "getID", w_Joystick_getID },
 	{ "getGUID", w_Joystick_getGUID },
 	{ "getGUID", w_Joystick_getGUID },
 	{ "getDeviceInfo", w_Joystick_getDeviceInfo },
 	{ "getDeviceInfo", w_Joystick_getDeviceInfo },
+	{ "getJoystickType", w_Joystick_getJoystickType },
 	{ "getAxisCount", w_Joystick_getAxisCount },
 	{ "getAxisCount", w_Joystick_getAxisCount },
 	{ "getButtonCount", w_Joystick_getButtonCount },
 	{ "getButtonCount", w_Joystick_getButtonCount },
 	{ "getHatCount", w_Joystick_getHatCount },
 	{ "getHatCount", w_Joystick_getHatCount },