Compare commits

..

5 Commits
1.1 ... master

Author SHA1 Message Date
JCash
f14e2b85be Use constructor for dmScript::LuaHBuffer 2021-12-15 11:45:59 +01:00
JCash
a883244505 removed redundant include 2020-07-19 12:11:27 +02:00
JCash
6cbbd5b049 doc fix 2020-07-19 10:22:56 +02:00
JCash
28c53e740d Disable SCAN button on platforms that the extension-camera doesn't support 2020-07-19 10:20:51 +02:00
Björn Ritzl
7e02edcc85
Create LICENSE 2020-05-20 13:49:05 +02:00
4 changed files with 39 additions and 10 deletions

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020 Defold Foundation
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.

View File

@ -29,7 +29,7 @@ Scans an image buffer for any qrcode.
`height` The height of the image, in texels
`flip_x` A boolean flag that tells the decoder to flip the image in X first.
`flip_x` A boolean flag (1 or 0) that tells the decoder to flip the image in X first.
-> `string` Returns a the text from the qrcode if successful. Returns nil otherwise

View File

@ -13,9 +13,17 @@ function init(self)
gui.set_position(bg, vmath.vector3(screen_width/2, screen_height/2, 0))
gui.set_size(bg, vmath.vector3(screen_width, screen_height, 0))
local camera = gui.get_node("camera")
gui.set_position(camera, vmath.vector3(screen_width/2, screen_height/2, 0))
gui.set_size(camera, vmath.vector3(screen_width/2, screen_height/2, 0))
local cameranode = gui.get_node("camera")
gui.set_position(cameranode, vmath.vector3(screen_width/2, screen_height/2, 0))
gui.set_size(cameranode, vmath.vector3(screen_width/2, screen_height/2, 0))
self.camera_enabled = camera ~= nil
if not self.camera_enabled then
local labelnode = gui.get_node("scan_bn/larrylabel")
local iconnode = gui.get_node("camera_icon")
gui.set_color(labelnode, vmath.vector4(0.5,0.5,0.5,1))
gui.set_color(iconnode, vmath.vector4(0.5,0.5,0.5,1))
end
local qrcode = gui.get_node("qrcode")
gui.set_position(qrcode, vmath.vector3(screen_width/2, screen_height/2, 0))
@ -54,9 +62,11 @@ local function isempty(s)
end
function on_input(self, action_id, action)
dirtylarry:button("scan_bn", action_id, action, function ()
msg.post("controller", "click", {mode="SCAN"})
end)
if self.camera_enabled then
dirtylarry:button("scan_bn", action_id, action, function ()
msg.post("controller", "click", {mode="SCAN"})
end)
end
dirtylarry:button("generate_bn", action_id, action, function ()
local text = sys.get_sys_info().device_ident
if isempty(text) then

View File

@ -1,14 +1,12 @@
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#define EXTENSION_NAME QRCode
#define LIB_NAME "QRCode"
#define MODULE_NAME "qrcode"
// Defold SDK
#define DLIB_LOG_DOMAIN LIB_NAME
#include <dmsdk/sdk.h>
#include "quirc/quirc.h"
@ -167,7 +165,7 @@ static int Generate(lua_State* L)
free(qr); // free the qr code
// Transfer ownership to Lua
dmScript::LuaHBuffer luabuffer = {buffer, true};
dmScript::LuaHBuffer luabuffer(buffer, dmScript::OWNER_LUA);
dmScript::PushBuffer(L, luabuffer);
lua_pushinteger(L, outsize);
return 2;