php-sdl patched (docker/ext/php-sdl-events.patch, in every build: desktop, async, wasm, standalone, Android, Apple): SDL_MOUSEWHEEL, SDL_TEXTINPUT, SDL_TEXTEDITING and the button of SDL_MOUSEBUTTONUP reach PHP. Mouse::wheelX/Y, Keyboard::getText()/getComposition(). JumPHP\Gui: the wheel scrolls lists, open drop-down lists and scrolled areas; text boxes take the system's text (layout, dead keys, input methods: the composition underlined at the cursor, the input method's window placed there); older engines fall back to the key codes. Video: src may be a film of assets/videos/ (bin/jumphp cuts it into pictures + sound before run / test / shot / builds / exports, packages leave the film out); the visual editor offers films and sounds. webshot: text:, wheel: and click: steps. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01X3cUrsDZg7JngzTEgWW6Nj
70 lines
2.5 KiB
Diff
70 lines
2.5 KiB
Diff
diff --git a/src/event.c b/src/event.c
|
|
index 29fa842..c0e2e38 100644
|
|
--- a/src/event.c
|
|
+++ b/src/event.c
|
|
@@ -70,6 +70,7 @@ zend_bool sdl_event_to_zval(SDL_Event *event, zval *value)
|
|
}
|
|
break;
|
|
case SDL_MOUSEBUTTONDOWN:
|
|
+ case SDL_MOUSEBUTTONUP:
|
|
{
|
|
zval button;
|
|
object_init(&button);
|
|
@@ -80,6 +81,47 @@ zend_bool sdl_event_to_zval(SDL_Event *event, zval *value)
|
|
zval_ptr_dtor(&button);
|
|
}
|
|
break;
|
|
+ case SDL_MOUSEWHEEL:
|
|
+ {
|
|
+ /* JumPHP: the wheel (x / y in notches, flipped when the system says so; precise: fractions of notches) */
|
|
+ zval wheel;
|
|
+ int flip = event->wheel.direction == SDL_MOUSEWHEEL_FLIPPED ? -1 : 1;
|
|
+ object_init(&wheel);
|
|
+ add_property_long(&wheel, "x", event->wheel.x * flip);
|
|
+ add_property_long(&wheel, "y", event->wheel.y * flip);
|
|
+#if SDL_VERSION_ATLEAST(2, 0, 18)
|
|
+ add_property_double(&wheel, "preciseX", event->wheel.preciseX * flip);
|
|
+ add_property_double(&wheel, "preciseY", event->wheel.preciseY * flip);
|
|
+#else
|
|
+ add_property_double(&wheel, "preciseX", (double)(event->wheel.x * flip));
|
|
+ add_property_double(&wheel, "preciseY", (double)(event->wheel.y * flip));
|
|
+#endif
|
|
+ add_property_zval(value, "wheel", &wheel);
|
|
+ zval_ptr_dtor(&wheel);
|
|
+ }
|
|
+ break;
|
|
+ case SDL_TEXTINPUT:
|
|
+ {
|
|
+ /* JumPHP: typed text in UTF-8 (dead keys and input methods already composed) */
|
|
+ zval text;
|
|
+ object_init(&text);
|
|
+ add_property_string(&text, "text", event->text.text);
|
|
+ add_property_zval(value, "text", &text);
|
|
+ zval_ptr_dtor(&text);
|
|
+ }
|
|
+ break;
|
|
+ case SDL_TEXTEDITING:
|
|
+ {
|
|
+ /* JumPHP: the text an input method is composing, not typed yet */
|
|
+ zval edit;
|
|
+ object_init(&edit);
|
|
+ add_property_string(&edit, "text", event->edit.text);
|
|
+ add_property_long(&edit, "start", event->edit.start);
|
|
+ add_property_long(&edit, "length", event->edit.length);
|
|
+ add_property_zval(value, "edit", &edit);
|
|
+ zval_ptr_dtor(&edit);
|
|
+ }
|
|
+ break;
|
|
case SDL_KEYDOWN:
|
|
case SDL_KEYUP:
|
|
{
|
|
@@ -305,6 +347,9 @@ PHP_MINIT_FUNCTION(sdl_event)
|
|
zend_declare_property_null(php_sdl_event_ce, ZEND_STRL("motion"), ZEND_ACC_PUBLIC);
|
|
zend_declare_property_null(php_sdl_event_ce, ZEND_STRL("window"), ZEND_ACC_PUBLIC);
|
|
zend_declare_property_null(php_sdl_event_ce, ZEND_STRL("button"), ZEND_ACC_PUBLIC);
|
|
+ zend_declare_property_null(php_sdl_event_ce, ZEND_STRL("wheel"), ZEND_ACC_PUBLIC);
|
|
+ zend_declare_property_null(php_sdl_event_ce, ZEND_STRL("text"), ZEND_ACC_PUBLIC);
|
|
+ zend_declare_property_null(php_sdl_event_ce, ZEND_STRL("edit"), ZEND_ACC_PUBLIC);
|
|
|
|
|
|
// touchpad
|