JoystickInfo.lua 915 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. class "JoystickInfo"
  2. function JoystickInfo:__getvar(name)
  3. if name == "deviceID" then
  4. return Polycore.JoystickInfo_get_deviceID(self.__ptr)
  5. elseif name == "deviceIndex" then
  6. return Polycore.JoystickInfo_get_deviceIndex(self.__ptr)
  7. end
  8. end
  9. function JoystickInfo:__setvar(name,value)
  10. if name == "deviceID" then
  11. Polycore.JoystickInfo_set_deviceID(self.__ptr, value)
  12. return true
  13. elseif name == "deviceIndex" then
  14. Polycore.JoystickInfo_set_deviceIndex(self.__ptr, value)
  15. return true
  16. end
  17. return false
  18. end
  19. function JoystickInfo:JoystickInfo(...)
  20. local arg = {...}
  21. for k,v in pairs(arg) do
  22. if type(v) == "table" then
  23. if v.__ptr ~= nil then
  24. arg[k] = v.__ptr
  25. end
  26. end
  27. end
  28. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  29. self.__ptr = Polycore.JoystickInfo(unpack(arg))
  30. end
  31. end
  32. function JoystickInfo:__delete()
  33. if self then Polycore.delete_JoystickInfo(self.__ptr) end
  34. end