- Image: expose newImageData(newImageDataFromFile)/newEmptyImageData/isCompressed and a full ImageData script class (getWidth/Height/Format/Size, pixel get/set, paste, clone, rotate). ImageData is now registered once by the Image module; drop the duplicate minimal registrations in Font and Model3D that could overwrite each other. - Joystick: expose getJoystick/getJoystickFromID/getIndex/addJoystick/removeJoystick and a Pad class with raw axes/buttons/hats, GameController axis/button names, device info, and vibration. Pads stay owned by the module (non-owning script handles). - Mouse: expose setRelativeMode/getRelativeMode plus setVisible/setPosition/setX/setY/ setGrabbed/isGrabbed (SDL backend already implemented them). - Tests: add image.nut/image_script.cpp and joystick.nut/joystick_script.cpp script tests, extend mouse.nut with relative-mode/visibility checks, wire into test CMake and the nut embed template. - Docs: update image/joystick/mouse user chapters, MODULES.md and the REVIEW log.
40 lines
1.1 KiB
Plaintext
40 lines
1.1 KiB
Plaintext
|
|
function basic() {
|
|
if (eve.Mouse == null) {
|
|
print("can not find Mouse");
|
|
return false;
|
|
}
|
|
|
|
local p = eve.Mouse();
|
|
if (p.getName() != "Mouse") {
|
|
print("Mouse name is not right: ");
|
|
print(p.getName());
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
function relativeMode() {
|
|
if (eve.Mouse == null) return false;
|
|
local m = eve.Mouse();
|
|
if (m.setRelativeMode == null || m.getRelativeMode == null) return false;
|
|
// SDL may reject relative mode without a focused window; only verify the
|
|
// round trip when the backend accepts the request.
|
|
if (!m.setRelativeMode(true)) return true;
|
|
if (!m.getRelativeMode()) return false;
|
|
m.setRelativeMode(false);
|
|
if (m.getRelativeMode()) return false;
|
|
return true;
|
|
}
|
|
|
|
function visibility() {
|
|
local m = eve.Mouse();
|
|
if (m.setVisible == null || m.isVisible == null) return false;
|
|
m.setVisible(true);
|
|
local visible = m.isVisible();
|
|
m.setVisible(false);
|
|
local hidden = m.isVisible();
|
|
m.setVisible(true);
|
|
return visible && !hidden;
|
|
}
|