Browse Source

Better error message when running on Android or WebVR

Also compatibility note in README
mcc 6 years ago
parent
commit
67d11c5df7
2 changed files with 11 additions and 1 deletions
  1. 8 0
      README.md
  2. 3 1
      lovr-keyboard.lua

+ 8 - 0
README.md

@@ -16,6 +16,14 @@ function lovr.update(dt)
 end
 ```
 
+lovr-keyboard can only run on systems where LÖVR uses both LuaJIT and GLFW. If your project needs to be compatible with Android or WebVR, you can optionally include lovr-keyboard with:
+
+```lua
+if type(jit) == 'table' and lovr.getOS() ~= 'Android' and lovr.getOS() ~= 'Web' then
+	lovr.keyboard = require 'lovr-keyboard'
+end
+```
+
 API
 ---
 

+ 3 - 1
lovr-keyboard.lua

@@ -1,4 +1,6 @@
-local ffi = require 'ffi'
+local ffi = assert(type(jit) == 'table' and               -- Only run if we have LuaJIT
+  lovr.getOS() ~= 'Android' and lovr.getOS() ~= 'Web' and -- and also GLFW
+  require 'ffi', "lovr-keyboard cannot run on this platform")
 local C = ffi.os == 'Windows' and ffi.load('glfw3') or ffi.C
 
 ffi.cdef [[