Changeset 121332 in webkit


Ignore:
Timestamp:
Jun 27, 2012 2:19:15 AM (12 years ago)
Author:
zandobersek@gmail.com
Message:

[Gtk] Add support for the Gamepad API
https://bugs.webkit.org/show_bug.cgi?id=87503

Reviewed by Carlos Garcia Campos.

.:

Only enable the Gamepad feature on Linux as support
for other operating systems is not present.

Check for the GIO Unix and GUdev dependencies when the
Gamepad feature is enabled.

  • configure.ac:

Source/WebCore:

Add support for the Gamepad feature on the GTK port.

The support is available only on Linux, with each gamepad device being presented
through a GamepadDeviceLinux object. The implementation of this class relies on
the Linux kernel joystick API.

Gamepad devices are recognized through the GamepadsGtk class, of which implementation
is based on GUdev. This way devices are properly registered on connection as objects of
the GamepadDeviceGtk class which inherits GamepadDeviceLinux. GamepadDeviceGtk reads the
joystick data through GIO pollable streams and updates the device state accordingly. The
GamepadsGtk object is then polled for gamepads data through the sampleGamepads method.

No new tests - tests already exist but require additional testing infrastructure.

  • GNUmakefile.am:
  • GNUmakefile.list.am:
  • bindings/gobject/GNUmakefile.am:
  • bindings/js/JSDOMBinding.h: Add the jsArray method that operates on a Vector of floats.

(WebCore):
(WebCore::jsArray):

  • platform/gtk/GamepadsGtk.cpp: Added.

(WebCore):
(GamepadDeviceGtk):
(WebCore::GamepadDeviceGtk::create):
(WebCore::GamepadDeviceGtk::GamepadDeviceGtk):
(WebCore::GamepadDeviceGtk::~GamepadDeviceGtk):
(WebCore::GamepadDeviceGtk::readCallback):
(GamepadsGtk):
(WebCore::GamepadsGtk::GamepadsGtk):
(WebCore::GamepadsGtk::~GamepadsGtk):
(WebCore::GamepadsGtk::registerDevice):
(WebCore::GamepadsGtk::unregisterDevice):
(WebCore::GamepadsGtk::updateGamepadList):
(WebCore::GamepadsGtk::onUEventCallback):
(WebCore::GamepadsGtk::isGamepadDevice):
(WebCore::sampleGamepads):

  • platform/linux/GamepadDeviceLinux.cpp: Added.

(WebCore):
(WebCore::GamepadDeviceLinux::GamepadDeviceLinux):
(WebCore::GamepadDeviceLinux::~GamepadDeviceLinux):
(WebCore::GamepadDeviceLinux::updateForEvent):
(WebCore::GamepadDeviceLinux::normalizeAxisValue):
(WebCore::GamepadDeviceLinux::normalizeButtonValue):

  • platform/linux/GamepadDeviceLinux.h: Added.

(WebCore):
(GamepadDeviceLinux):
(WebCore::GamepadDeviceLinux::connected):
(WebCore::GamepadDeviceLinux::id):
(WebCore::GamepadDeviceLinux::timestamp):
(WebCore::GamepadDeviceLinux::axesCount):
(WebCore::GamepadDeviceLinux::axesData):
(WebCore::GamepadDeviceLinux::buttonsCount):
(WebCore::GamepadDeviceLinux::buttonsData):

Source/WebKit/gtk:

Add the Gamepad feature dependencies libraries to the LIBADD
list for the libwebkitgtk library.

  • GNUmakefile.am:

Source/WebKit2:

Add the Gamepad feature dependencies libraries to the LIBADD
list for the libwebkitgtk2 library.

  • GNUmakefile.am:

Tools:

Enable the gamepad support for the GTK port.

  • Scripts/webkitperl/FeatureList.pm:
Location:
trunk
Files:
4 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r121228 r121332  
     12012-06-27  Zan Dobersek  <zandobersek@gmail.com>
     2
     3        [Gtk] Add support for the Gamepad API
     4        https://bugs.webkit.org/show_bug.cgi?id=87503
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        Only enable the Gamepad feature on Linux as support
     9        for other operating systems is not present.
     10
     11        Check for the GIO Unix and GUdev dependencies when the
     12        Gamepad feature is enabled.
     13
     14        * configure.ac:
     15
    1162012-06-25  Simon Hausmann  <simon.hausmann@nokia.com>
    217
  • trunk/Source/WebCore/ChangeLog

    r121330 r121332  
     12012-06-27  Zan Dobersek  <zandobersek@gmail.com>
     2
     3        [Gtk] Add support for the Gamepad API
     4        https://bugs.webkit.org/show_bug.cgi?id=87503
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        Add support for the Gamepad feature on the GTK port.
     9
     10        The support is available only on Linux, with each gamepad device being presented
     11        through a GamepadDeviceLinux object. The implementation of this class relies on
     12        the Linux kernel joystick API.
     13
     14        Gamepad devices are recognized through the GamepadsGtk class, of which implementation
     15        is based on GUdev. This way devices are properly registered on connection as objects of
     16        the GamepadDeviceGtk class which inherits GamepadDeviceLinux. GamepadDeviceGtk reads the
     17        joystick data through GIO pollable streams and updates the device state accordingly. The
     18        GamepadsGtk object is then polled for gamepads data through the sampleGamepads method.
     19
     20        No new tests - tests already exist but require additional testing infrastructure.
     21
     22        * GNUmakefile.am:
     23        * GNUmakefile.list.am:
     24        * bindings/gobject/GNUmakefile.am:
     25        * bindings/js/JSDOMBinding.h: Add the jsArray method that operates on a Vector of floats.
     26        (WebCore):
     27        (WebCore::jsArray):
     28        * platform/gtk/GamepadsGtk.cpp: Added.
     29        (WebCore):
     30        (GamepadDeviceGtk):
     31        (WebCore::GamepadDeviceGtk::create):
     32        (WebCore::GamepadDeviceGtk::GamepadDeviceGtk):
     33        (WebCore::GamepadDeviceGtk::~GamepadDeviceGtk):
     34        (WebCore::GamepadDeviceGtk::readCallback):
     35        (GamepadsGtk):
     36        (WebCore::GamepadsGtk::GamepadsGtk):
     37        (WebCore::GamepadsGtk::~GamepadsGtk):
     38        (WebCore::GamepadsGtk::registerDevice):
     39        (WebCore::GamepadsGtk::unregisterDevice):
     40        (WebCore::GamepadsGtk::updateGamepadList):
     41        (WebCore::GamepadsGtk::onUEventCallback):
     42        (WebCore::GamepadsGtk::isGamepadDevice):
     43        (WebCore::sampleGamepads):
     44        * platform/linux/GamepadDeviceLinux.cpp: Added.
     45        (WebCore):
     46        (WebCore::GamepadDeviceLinux::GamepadDeviceLinux):
     47        (WebCore::GamepadDeviceLinux::~GamepadDeviceLinux):
     48        (WebCore::GamepadDeviceLinux::updateForEvent):
     49        (WebCore::GamepadDeviceLinux::normalizeAxisValue):
     50        (WebCore::GamepadDeviceLinux::normalizeButtonValue):
     51        * platform/linux/GamepadDeviceLinux.h: Added.
     52        (WebCore):
     53        (GamepadDeviceLinux):
     54        (WebCore::GamepadDeviceLinux::connected):
     55        (WebCore::GamepadDeviceLinux::id):
     56        (WebCore::GamepadDeviceLinux::timestamp):
     57        (WebCore::GamepadDeviceLinux::axesCount):
     58        (WebCore::GamepadDeviceLinux::axesData):
     59        (WebCore::GamepadDeviceLinux::buttonsCount):
     60        (WebCore::GamepadDeviceLinux::buttonsData):
     61
    1622012-06-27  Kentaro Hara  <haraken@chromium.org>
    263
  • trunk/Source/WebCore/GNUmakefile.am

    r120957 r121332  
    1313        -I$(srcdir)/Source/WebCore \
    1414        -I$(srcdir)/Source/WebCore/Modules/filesystem \
     15        -I$(srcdir)/Source/WebCore/Modules/gamepad \
    1516        -I$(srcdir)/Source/WebCore/Modules/geolocation \
    1617        -I$(srcdir)/Source/WebCore/Modules/indexeddb \
     
    6869        -I$(srcdir)/Source/WebCore/platform/image-decoders/png \
    6970        -I$(srcdir)/Source/WebCore/platform/leveldb \
     71        -I$(srcdir)/Source/WebCore/platform/linux \
    7072        -I$(srcdir)/Source/WebCore/platform/mediastream \
    7173        -I$(srcdir)/Source/WebCore/platform/mediastream/gstreamer \
     
    867869IDL_PATH := \
    868870    $(WebCore)/Modules/filesystem \
     871    $(WebCore)/Modules/gamepad \
    869872    $(WebCore)/Modules/geolocation \
    870873    $(WebCore)/Modules/indexeddb \
     
    962965        $(COVERAGE_CFLAGS) \
    963966        $(ENCHANT_CFLAGS) \
     967        $(GAMEPAD_CFLAGS) \
    964968        $(GEOCLUE_CFLAGS) \
    965969        $(GLIB_CFLAGS) \
     
    10331037EXTRA_DIST += \
    10341038        $(shell ls $(srcdir)/Source/WebCore/Modules/filesystem/*.idl) \
     1039        $(shell ls $(srcdir)/Source/WebCore/Modules/gamepad/*.idl) \
    10351040        $(shell ls $(srcdir)/Source/WebCore/Modules/geolocation/*.idl) \
    10361041        $(shell ls $(srcdir)/Source/WebCore/Modules/indexeddb/*.idl) \
  • trunk/Source/WebCore/GNUmakefile.list.am

    r121164 r121332  
    193193        DerivedSources/WebCore/JSFloat64Array.cpp \
    194194        DerivedSources/WebCore/JSFloat64Array.h \
     195        DerivedSources/WebCore/JSGamepad.cpp \
     196        DerivedSources/WebCore/JSGamepad.h \
     197        DerivedSources/WebCore/JSGamepadList.cpp \
     198        DerivedSources/WebCore/JSGamepadList.h \
    195199        DerivedSources/WebCore/JSGeolocation.cpp \
    196200        DerivedSources/WebCore/JSGeolocation.h \
     
    678682
    679683dom_binding_idls += \
     684        $(WebCore)/Modules/gamepad/Gamepad.idl \
     685        $(WebCore)/Modules/gamepad/GamepadList.idl \
     686        $(WebCore)/Modules/gamepad/NavigatorGamepad.idl \
    680687        $(WebCore)/Modules/geolocation/Geolocation.idl \
    681688        $(WebCore)/Modules/geolocation/Geoposition.idl \
     
    10541061        Source/WebCore/Modules/filesystem/WorkerContextFileSystem.cpp \
    10551062        Source/WebCore/Modules/filesystem/WorkerContextFileSystem.h \
     1063        Source/WebCore/Modules/gamepad/Gamepad.cpp \
     1064        Source/WebCore/Modules/gamepad/Gamepad.h \
     1065        Source/WebCore/Modules/gamepad/GamepadList.cpp \
     1066        Source/WebCore/Modules/gamepad/GamepadList.h \
     1067        Source/WebCore/Modules/gamepad/NavigatorGamepad.cpp \
     1068        Source/WebCore/Modules/gamepad/NavigatorGamepad.h \
    10561069        Source/WebCore/Modules/geolocation/Geolocation.cpp \
    10571070        Source/WebCore/Modules/geolocation/Geolocation.h \
     
    31613174        Source/WebCore/platform/FloatConversion.h \
    31623175        Source/WebCore/platform/FractionalLayoutUnit.h \
     3176        Source/WebCore/platform/Gamepads.h \
    31633177        Source/WebCore/platform/HashTools.h \
    31643178        Source/WebCore/platform/HistogramSupport.cpp \
     
    34093423        Source/WebCore/platform/gtk/ErrorsGtk.cpp \
    34103424        Source/WebCore/platform/gtk/ErrorsGtk.h \
     3425        Source/WebCore/platform/gtk/GamepadsGtk.cpp \
    34113426        Source/WebCore/platform/gtk/KURLGtk.cpp \
    34123427        Source/WebCore/platform/gtk/LanguageGtk.cpp \
     
    34693484        Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp \
    34703485        Source/WebCore/platform/image-decoders/png/PNGImageDecoder.h \
     3486        Source/WebCore/platform/linux/GamepadDeviceLinux.cpp \
     3487        Source/WebCore/platform/linux/GamepadDeviceLinux.h \
    34713488        Source/WebCore/platform/mediastream/DeprecatedPeerConnectionHandler.h \
    34723489        Source/WebCore/platform/mediastream/DeprecatedPeerConnectionHandlerClient.h \
  • trunk/Source/WebCore/bindings/gobject/GNUmakefile.am

    r117368 r121332  
    6767        DerivedSources/webkit/WebKitDOMFileListPrivate.h \
    6868        DerivedSources/webkit/WebKitDOMFilePrivate.h \
     69        DerivedSources/webkit/WebKitDOMGamepad.cpp \
     70        DerivedSources/webkit/WebKitDOMGamepadList.cpp \
     71        DerivedSources/webkit/WebKitDOMGamepadListPrivate.h \
     72        DerivedSources/webkit/WebKitDOMGamepadPrivate.h \
    6973        DerivedSources/webkit/WebKitDOMGeolocation.cpp \
    7074        DerivedSources/webkit/WebKitDOMGeolocationPrivate.h \
     
    296300        DerivedSources/webkit/WebKitDOMFile.h \
    297301        DerivedSources/webkit/WebKitDOMFileList.h \
     302        DerivedSources/webkit/WebKitDOMGamepad.h \
     303        DerivedSources/webkit/WebKitDOMGamepadList.h \
    298304        DerivedSources/webkit/WebKitDOMGeolocation.h \
    299305        DerivedSources/webkit/WebKitDOMHTMLAnchorElement.h \
     
    429435endif
    430436
    431 
    432437if ENABLE_WEB_TIMING
    433438webkitgtk_built_h_api += \
  • trunk/Source/WebCore/bindings/js/JSDOMBinding.h

    r120304 r121332  
    308308    }
    309309
     310    template<>
     311    inline JSC::JSValue jsArray(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, const Vector<float>& iterator)
     312    {
     313        JSC::MarkedArgumentBuffer array;
     314        Vector<float>::const_iterator end = iterator.end();
     315
     316        for (Vector<float>::const_iterator it = iterator.begin(); it != end; ++it)
     317            array.append(JSC::jsNumber(*it));
     318
     319        return JSC::constructArray(exec, globalObject, array);
     320    }
     321
    310322    template <class T>
    311323    Vector<T> toNativeArray(JSC::ExecState* exec, JSC::JSValue value)
  • trunk/Source/WebKit/gtk/ChangeLog

    r121152 r121332  
     12012-06-27  Zan Dobersek  <zandobersek@gmail.com>
     2
     3        [Gtk] Add support for the Gamepad API
     4        https://bugs.webkit.org/show_bug.cgi?id=87503
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        Add the Gamepad feature dependencies libraries to the LIBADD
     9        list for the libwebkitgtk library.
     10
     11        * GNUmakefile.am:
     12
    1132012-06-25  Carlos Garcia Campos  <cgarcia@igalia.com>
    214
  • trunk/Source/WebKit/gtk/GNUmakefile.am

    r120918 r121332  
    8888        $(FREETYPE_LIBS) \
    8989        $(GAIL_LIBS) \
     90        $(GAMEPAD_LIBS) \
    9091        $(GEOCLUE_LIBS) \
    9192        $(GLIB_LIBS) \
  • trunk/Source/WebKit2/ChangeLog

    r121323 r121332  
     12012-06-27  Zan Dobersek  <zandobersek@gmail.com>
     2
     3        [Gtk] Add support for the Gamepad API
     4        https://bugs.webkit.org/show_bug.cgi?id=87503
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        Add the Gamepad feature dependencies libraries to the LIBADD
     9        list for the libwebkitgtk2 library.
     10
     11        * GNUmakefile.am:
     12
    1132012-06-26  Simon Hausmann  <simon.hausmann@nokia.com>
    214
  • trunk/Source/WebKit2/GNUmakefile.am

    r119837 r121332  
    161161        $(ENCHANT_LIBS) \
    162162        $(GAIL_LIBS) \
     163        $(GAMEPAD_LIBS) \
    163164        $(GEOCLUE_LIBS) \
    164165        $(GLIB_LIBS) \
  • trunk/Tools/ChangeLog

    r121331 r121332  
     12012-06-27  Zan Dobersek  <zandobersek@gmail.com>
     2
     3        [Gtk] Add support for the Gamepad API
     4        https://bugs.webkit.org/show_bug.cgi?id=87503
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        Enable the gamepad support for the GTK port.
     9
     10        * Scripts/webkitperl/FeatureList.pm:
     11
    1122012-06-27  Ryosuke Niwa  <rniwa@webkit.org>
    213
  • trunk/Tools/Scripts/webkitperl/FeatureList.pm

    r121135 r121332  
    215215
    216216    { option => "gamepad", desc => "Toggle Gamepad support",
    217       define => "ENABLE_GAMEPAD", default => 0, value => \$gamepadSupport },
     217      define => "ENABLE_GAMEPAD", default => isGtk(), value => \$gamepadSupport },
    218218
    219219    { option => "geolocation", desc => "Toggle Geolocation support",
  • trunk/configure.ac

    r121152 r121332  
    654654AC_MSG_RESULT([$enable_gamepad])
    655655
     656if test "$enable_gamepad" = "yes" && test "$os_linux" = no; then
     657   AC_MSG_WARN([Gamepad support is only available on Linux. Disabling Gamepad support.])
     658   enable_gamepad=no;
     659fi
     660
    656661# check whether to build with data transfer items support
    657662AC_MSG_CHECKING([whether to enable HTML5 data transfer items support])
     
    12751280   AC_SUBST([ATSPI2_CFLAGS])
    12761281   AC_SUBST([ATSPI2_LIBS])
     1282fi
     1283
     1284if test "$enable_gamepad" = "yes"; then
     1285   PKG_CHECK_MODULES([GAMEPAD], [gio-unix-2.0 gudev-1.0])
     1286
     1287   AC_SUBST(GAMEPAD_CFLAGS)
     1288   AC_SUBST(GAMEPAD_LIBS)
    12771289fi
    12781290
Note: See TracChangeset for help on using the changeset viewer.