On Thu, Apr 20, 2017 at 2:48 PM, Jason Gerecke <killert...@gmail.com> wrote:
> This patch adds support for Solaris 10 and is based on code produced
> in 2010 by Sun Microsystems. The original code was targeted at OpenSolaris
> snv_115 - snv_129 and was based on linuxwacom 0.8.4. The original patches
> don't appear to be available online [1] anymore, except in our out-of-date
> 'solaris' branch.
>
> [1]: 
> http://hub.opensolaris.org/bin/view/Community+Group+device_drivers/wacomtablet
>
> Signed-off-by: Jason Gerecke <jason.gere...@wacom.com>

It was a few developers' effort to get this far. Let's keep the code
for those who still need it.

Acked-by: Ping Cheng <ping.ch...@wacom.com>

Thank you Jason for maintaining the code.

Ping
> ---
>  README.solaris.md            | 179 ++++++++++++++++++++
>  THIRDPARTYLICENSEREADME.txt  |   8 +
>  configure.in                 |  26 ++-
>  solaris-build.sh             | 387 
> +++++++++++++++++++++++++++++++++++++++++++
>  src/include/usbwcm_build.h   | 110 ++++++++++++
>  src/util/10-linuxwacom.fdi   |  25 +++
>  src/util/Makefile.am         |   6 +
>  src/util/hal-setup-wacom.c   | 127 +++++++++++++-
>  src/util/wactablet.c         |  28 ++++
>  src/util/wacusb.c            |  28 +++-
>  src/xdrv/Makefile.am         |   2 +-
>  src/xdrv/wcmUSB.c            |  29 ++++
>  src/xdrv/wcmValidateDevice.c |  10 +-
>  src/xdrv/xf86Wacom.h         |   5 +
>  src/xdrv/xf86WacomDefs.h     |   8 +
>  15 files changed, 968 insertions(+), 10 deletions(-)
>  create mode 100644 README.solaris.md
>  create mode 100644 THIRDPARTYLICENSEREADME.txt
>  create mode 100755 solaris-build.sh
>  create mode 100644 src/include/usbwcm_build.h
>
> diff --git a/README.solaris.md b/README.solaris.md
> new file mode 100644
> index 0000000..47238e2
> --- /dev/null
> +++ b/README.solaris.md
> @@ -0,0 +1,179 @@
> +**Solaris Notes For linuxwacom**
> +
> +
> +# Overview  ###########################################################
> +
> +[usbwcm STREAMS module]:
> +    https://github.com/linuxwacom/usbwcm/
> +
> +Version 0.12.0 of the linuxwacom driver introduced support for the Solaris
> +operating system. This code is minimally tested and regressions may occur
> +without warning. At the time of writing, only Solaris 10 U9 and U11
> +("5/10" and "1/13") have been explicitly tested for compatibility. Please
> +contact the linuxwacom project maintainers through SourceForge or Github
> +if you have specific concerns or issues using this driver on Solaris.
> +
> +Note that these sources do not contain any Solaris kernel code. License
> +incompatibilities prevent us from distributing both as a combined work.
> +Please be sure to install the [usbwcm STREAMS module][] in addition to
> +this driver.
> +
> +
> +# Usage  ##############################################################
> +
> +[configuring X11]:
> +    http://linuxwacom.sourceforge.net/index_old.php/howto/x11
> +
> +The Xorg server must be manually configured to make use of connected
> +tablets in Solaris 10. Please see the [configuring X11][] section of
> +the linuxwacom manual for details on the modifications that must be
> +made to the `/etc/X11/xorg.conf` file. The appropriate device node
> +(e.g. `/dev/usb/hid0`) will need to be determined based on the output
> +of `dmesg`. See the Troubleshooting section below if you encounter
> +problems. The mouse pointer should move in response to pen input once
> +the X server is properly configured.
> +
> +Some applications require additional configuration to make full use
> +of tablet data. For example, GIMP must have the "stylus" and "eraser"
> +tools set to "Screen" mode in its Extended Input Devices preferences.
> +It is impossible to provide instructions for each application. Please
> +see your application documentation for details if the tablet does not
> +appear to be automatically detected.
> +
> +The linuxwacom driver provides a pair of configuration utilities
> +that can be used to modify or tune the behavior of connected tablets.
> +The `xsetwacom` utility provides a scriptable command-line interface,
> +while `wacomcpl` is a graphical Tcl/Tk application. Debug utilities
> +such as `wacdump` and `xidump` are also included should issues arise.
> +
> +
> +# Build, Install, and Uninstall #######################################
> +
> +## Solaris 10 ##
> +
> +Although the linuxwacom driver can be built for Solaris 10, the process
> +is non-obvious largely due to a lack of Xorg SDK development headers. An
> +interactive script which takes care of the entire build process (from
> +obtaining prerequisites to setting up environment variables) should have
> +been distributed alongside this file. Please note that the final command
> +may warn you that the `wacom_drv.so` file is already present on the system
> +and ask what you would like to do. This is normal: the SUNWxorg-server
> +package installs an out-of-date version of this file and you should tell the
> +system to replace it.
> +
> +    # ./solaris-build.sh
> +    # cp workdir/WAClinuxwacom_<version>_<arch>.pkg.tar.gz /tmp
> +    # cd /tmp
> +    # gzcat WAClinuxwacom_<version>_<arch>.pkg.tar.gz | tar xf -
> +    # pkgadd -d .
> +
> +Once the linuxwacom (and usbwcm) driver has been installed, you will need
> +to edit your `/etc/X11/xorg.conf` file as outlined above in the **Usage**
> +section. If no `xorg.conf` file exists, it may be necessary to first
> +generate one by running `/usr/X11/bin/xorgcfg` as root.
> +
> +Reboot, and the screen cursor should follow the pen motion if everything has
> +been properly installed and configured.
> +
> +Uninstalling the package can be achieved with the following commands:
> +
> +    # pkgrm WAClinuxwacom
> +
> +## Other Solaris Versions ##
> +
> +Building the linuxwacom driver on other Solaris versions has not been
> +tested. Build instructions that work on vanilla OS installations would
> +be appreciated.
> +
> +
> +# Troubleshooting  ####################################################
> +
> +
> +## Is the tablet recognized by the kernel?
> +
> +Examine the output of the `dmesg` command to ensure that the kernel detects
> +the tablet. After connecting the tablet, run the following commands:
> +
> +    # dmesg | egrep -i "usba|hid|usbwcm|wacom"
> +    # ls -l /dev/usb/hid*
> +
> +The tablet should have "Wacom" in its name or have a USB identifier
> +beginning with "usb56a". For example, the following example `dmesg`
> +output lists a "usb56a,59" device which is probed as "mouse@2, hid1".
> +The "hid1" device is later clarified to be "/pci@0,0/pci106b,3f@6/mouse@2"
> +which we see is the same as `/dev/usb/hid1`:
> +
> +    $ dmesg | egrep -i "usba|hid|usbwcm|wacom"
> +    [...]
> +    usba: [ID 912658 kern.info] USB 2.0 device (usb56a,59) operating at full 
> speed (USB 1.x) on USB 1.10 root hub: mouse@2, hid1 at bus address 3
> +    usba: [ID 349649 kern.info]     Tablet DTH-2241 Tablet
> +    genunix: [ID 936769 kern.info] hid1 is /pci@0,0/pci106b,3f@6/mouse@2
> +    genunix: [ID 408114 kern.info] /pci@0,0/pci106b,3f@6/mouse@2 (hid1) 
> online
> +    [...]
> +
> +    $ ls -l /dev/usb/hid*
> +    lrwxrwxrwx   1 root     root          48 Apr 17 15:31 /dev/usb/hid1 -> 
> ../../devices/pci@0,0/pci106b,3f@6/mouse@2:mouse
> +
> +
> +## Is the STREAMS module installed?
> +
> +The linuxwacom driver requires the `usbwcm` STREAMS module to be installed
> +and functional. Please see the instructions above for information about
> +where the module may be found. Follow the troubleshooting steps that it
> +suggests if the module has already been installed.
> +
> +
> +## Is the device node configured correctly?
> +
> +Devices which appear under the `/dev/usb` directory may change their
> +name depending on the order the kernel discovers them. Moving the tablet
> +to a different USB port may result in it getting renamed. Follow the
> +instructions in the **"Is the tablet recognized by the kernel?"**
> +troubleshooting section above to determine which device is associated with
> +the tablet. Ensure that the `/etc/X11/xorg.conf` file is configured to use
> +this device.
> +
> +
> +## Are there any errors logged by Xorg?
> +
> +The Xorg server generates log files under the `/var/log` directory which
> +can provide insight into possible configuration errors. The 
> `/var/log/Xorg.0.log`
> +file and `/etc/Xorg.0.log.old` files contain information about the current
> +and last X server runs, respectively.
> +
> +
> +## Is the server not starting?
> +
> +Some configuration errors can prevent the X server from starting at all.
> +If you are stuck at a console (or an SSH connection), the display server
> +can be restarted with the following command. If the problem is resolved
> +the login screen should appear once again.
> +
> +    # svcadm restart cde-login
> +
> +
> +## Does your application not recognize the tablet?
> +
> +Some applications (e.g. GIMP) require additional setup beyond the
> +`/etc/X11/xorg.conf` file in order to recognize the tablet. This
> +situation will typically present itself as the tablet working
> +properly on the desktop, but not providing pressure or other data
> +to the desired application. Unfortunately, it is not possible to
> +provide a guide to all the different ways an application may need
> +to be configured before it starts working with the tablet. Please
> +see the documenation provided by the software for more information.
> +
> +
> +## Driver debug logs
> +
> +When debugging issues with the driver, it may be useful to have it
> +log additional debug information to the `/var/log/Xorg.0.log` file.
> +This can be achived by adding the two following options to any or
> +all of the Wacom devices in `/etc/X11/xorg.conf`.
> +
> +    Option "DebugLevel" "<number>"
> +    Option "CommonDBG" "<number>"
> +
> +The number specified indicates the log verbosity. A value of 0
> +(default) disables debug logging. Higher values -- up to 12 --
> +provide additional information about the driver's inner workings.
> diff --git a/THIRDPARTYLICENSEREADME.txt b/THIRDPARTYLICENSEREADME.txt
> new file mode 100644
> index 0000000..1daeb44
> --- /dev/null
> +++ b/THIRDPARTYLICENSEREADME.txt
> @@ -0,0 +1,8 @@
> +GPLv2 Disclaimer
> +For the avoidance of doubt, except that if any license choice other
> +than GPL or LGPL is available it will apply instead, Sun elects to
> +use only the General Public License version 2 (GPLv2) at this time
> +for any software where a choice of GPL license versions is made
> +available with the language indicating that GPLv2 or any later
> +version may be used, or where a choice of which version of the GPL
> +is applied is otherwise unspecified.
> diff --git a/configure.in b/configure.in
> index a18f8de..91de29a 100644
> --- a/configure.in
> +++ b/configure.in
> @@ -75,12 +75,23 @@ if echo $WCM_KERNEL | grep -i linux >/dev/null; then
>  fi
>  AC_MSG_RESULT($WCM_ISLINUX)
>
> +dnl =======================================================
> +dnl Check if we should be compiling for Solaris
> +AC_MSG_CHECKING(for Solaris kernel)
> +WCM_ISSOLARIS=no
> +if echo $WCM_KERNEL | grep -i SunOS >/dev/null; then
> +       WCM_ISSOLARIS=yes
> +       CFLAGS="$CFLAGS -Dsun"
> +fi
> +AC_MSG_RESULT($WCM_ISSOLARIS)
> +AM_CONDITIONAL(WCM_ENV_SOLARIS, [test "$WCM_ISSOLARIS" = yes])
> +
>  dnl Check for 64bit XServer
>  WCM_OPTION_XSERVER64=no
>  AC_ARG_ENABLE(xserver64,
>         AC_HELP_STRING([--enable-xserver64], [Use 64bit XServer 
> [[default=usually]]]),
>         [ WCM_OPTION_XSERVER64=$enableval ],
> -       [ echo $WCM_ARCHITECTURE | grep "64" >/dev/null && 
> WCM_OPTION_XSERVER64=yes ])
> +       [ echo $WCM_ARCHITECTURE | egrep "64|sparc" >/dev/null && 
> WCM_OPTION_XSERVER64=yes ])
>
>  dnl Check for linux kernel override
>  AC_ARG_WITH(linux,
> @@ -96,14 +107,16 @@ WCM_ENV_KERNEL=no
>  WCM_KERNEL_DIR=
>  WCM_KERNEL_VER=
>  WCM_KSTACK=
> -if test "$WCM_ISLINUX" != yes; then
> +if test "$WCM_ISLINUX" != yes -a "$WCM_ISSOLARIS" != yes; then
>         WCM_PATCH_WACDUMP="(no USB)"
>         WCM_PATCH_WACOMDRV="(no USB)"
>  else
>         AC_DEFINE(WCM_ENABLE_LINUXINPUT,,[Enable the Linux Input subsystem])
>         WCM_PATCH_WACDUMP=
>         WCM_PATCH_WACOMDRV=
> +fi
>
> +if test "$WCM_ISLINUX" = yes; then
>         dnl Check for kernel build environment
>         AC_ARG_WITH(kernel,
>                 AS_HELP_STRING([--with-kernel=dir], [Specify kernel source 
> directory]),
> @@ -282,8 +295,10 @@ else
>  fi
>  if test "$WCM_ENV_XLIB" = yes; then
>         if test "$WCM_OPTION_XSERVER64" = "yes"; then
> -               CFLAGS="$CFLAGS -D__amd64__"
> -               WCM_XSERVER64="-D_XSERVER64"
> +               WCM_XSERVER64="-D_XSERVER64 -m64"
> +               if test "$WCM_ARCH" != sparc; then
> +                       WCM_XSERVER64="$WCM_XSERVER64 -D__amd64__"
> +               fi
>         fi
>  fi
>
> @@ -911,6 +926,9 @@ if test -z "$WCM_MODDIR"; then
>          elif test -d $WCM_XLIB_DIR/modules/input; then
>                 WCM_MODDIR=$WCM_XLIB_DIR/modules/input
>          fi
> +       if test "$WCM_ISSOLARIS" = yes -a "$WCM_ARCH" != sparc -a 
> "$WCM_OPTION_XSERVER64" = yes; then
> +               WCM_MODDIR=$WCM_MODDIR/amd64
> +       fi
>  fi
>  AC_MSG_RESULT($WCM_MODDIR)
>
> diff --git a/solaris-build.sh b/solaris-build.sh
> new file mode 100755
> index 0000000..d873b7f
> --- /dev/null
> +++ b/solaris-build.sh
> @@ -0,0 +1,387 @@
> +#!/bin/bash
> +
> +set -e
> +
> +
> +#
> +# Produce a version number from the output of `git describe` which
> +# is then massaged into the format used by semantic versioning.
> +#
> +function generate_linuxwacom_version() {
> +    local SRCDIR="$1"
> +    local SUFFIX="$2"
> +    if [[ -n "$SUFFIX" ]]; then
> +        SUFFIX="-$SUFFIX"
> +    fi
> +    git -C "$SRCDIR" describe | \
> +    sed -e "s/^release-\(.*\)/\1/" \
> +        -e "s/^\(.*\)-\([0-9]*\)-\(g[0-9a-f]\{7,7\}\)\$/\1${SUFFIX}+r\2.\3/"
> +}
> +
> +
> +#
> +# Return the value associated with a given key in a line-separated
> +# list of key="value" or key=value pairs.
> +#
> +function key_to_value() {
> +    local KEY="$1"
> +    local LIST="$2"
> +    sed -n -e 's%^'"$KEY"'="\(.*\)"%\1%p' -e 's%^'"$KEY"'=\(.*\)%\1%p' 
> <<<"$LIST" | head -n1
> +}
> +
> +
> +#
> +# Create a Solaris ".pkg.tar.gz" package from the contents of a
> +# working directory which contains finalized Prototype and pkginfo
> +# files.
> +#
> +function create_package() {
> +    local PKGDIR="$1"
> +    local PKGINFO=$(cat "$PKGDIR/pkginfo")
> +    local PKG=$(key_to_value "PKG" "$PKGINFO")
> +    local ARCH=$(key_to_value "ARCH" "$PKGINFO")
> +    local VERSION=$(key_to_value "VERSION" "$PKGINFO")
> +
> +    pkgmk -o -d "$PKGDIR" -f "$PKGDIR/Prototype"
> +    tar -cf - -C "$PKGDIR" $PKG | gzip -9 -c > 
> "$PKGDIR/${PKG}_${VERSION}_${ARCH}.pkg.tar.gz"
> +}
> +
> +
> +#
> +# Create "prototype" information about the files that are to be
> +# package. This function performs basic transformation of the
> +# raw output provided by the `pkgproto` command but will likely
> +# need further modification on a case-by-case basis to ensure
> +# permissions are set properly.
> +#
> +# See `man -s4 prototype`, [1], and [2] for more information.
> +#
> +# [1]: 
> http://www.ibiblio.org/pub/packages/solaris/i86pc/html/creating.solaris.packages.html
> +# [2]: http://www.garex.net/sun/packaging/pkginfo.html
> +#
> +function generate_prototype() {
> +    local DESTDIR="$1"
> +    local PROTO
> +    PROTO=$(pkgproto "$DESTDIR=/")
> +    PROTO=$(echo 'i pkginfo'; echo '!default 0755 root bin'; echo "$PROTO")
> +    PROTO=$(sed '/^d none \/ /d' <<<"$PROTO")
> +    PROTO=$(sed 's/^\(d .*\) [0-7]\{4\} .* .*$/\1 ? ? ?/' <<<"$PROTO")
> +    PROTO=$(sed 's/^\(f .*\) [0-7]\{4\} .* .*$/\1/' <<<"$PROTO")
> +    echo "$PROTO"
> +}
> +
> +
> +#
> +# Creates a linuxwacom driver package from files installed to an
> +# alternate (non-root) directory.
> +#
> +# NOTE! When installing this package, Solaris will likely complain
> +# that wacom_drv.so is already installed on the system as part of
> +# the SUNWxorg-server package. This is normal and the file should
> +# be overwritten.
> +#
> +function package_linuxwacom() {
> +    local DESTDIR="$1"
> +    local PKGDIR="$2"
> +    local VERSION="$3"
> +    local PROTO=$(generate_prototype "$DESTDIR")
> +
> +    # Remove "?" permissions on "wacomcfg" and "TkXinput" directories
> +    PROTO=$(sed 's/^\(d .*wacomcfg.*\) ? ? ?$/\1/' <<<"$PROTO")
> +    PROTO=$(sed 's/^\(d .*TkXinput.*\) ? ? ?$/\1/' <<<"$PROTO")
> +
> +    PKGINFO=$(cat <<EOF
> +PKG=WAClinuxwacom
> +NAME="Xorg driver for Wacom tablets"
> +VERSION="$VERSION"
> +ARCH="$(isainfo -n)"
> +CLASSES="system none"
> +CATEGORY="system"
> +VENDOR="linuxwacom Project"
> +EMAIL="linuxwacom-disc...@lists.sourceforge.net"
> +EOF
> +)
> +    echo "$PKGINFO" > "$PKGDIR/pkginfo"
> +    echo "$PROTO" > "$PKGDIR/Prototype"
> +
> +    create_package "$PKGDIR"
> +}
> +
> +
> +#
> +# Installs the linuxwacom driver to a specified destination
> +# directory.
> +#
> +function install_linuxwacom() {
> +    local SRCDIR="$1"
> +    local DESTDIR="$2"
> +
> +    pushd "$SRCDIR"
> +    gmake install DESTDIR="$DESTDIR"
> +    popd
> +}
> +
> +
> +#
> +# Compiles the linuxwacom driver, setting up the environment along the
> +# way to comply with the unique needs of Solaris 10. The function requires
> +# that your provide it with a path to the "/usr/src/uts/common" directory
> +# of the usbwcm source tree. Additional configuration options (e.g.
> +# "--with-tcl=/opt/csw --with-tk=/opt/csw" can also be provided in order
> +# to change how the driver is built.
> +#
> +function compile_linuxwacom() {
> +    local SRCDIR="$1"
> +    local HEADERS_KERNEL="$2"
> +    local CONFIGOPTS="$3"
> +    local XORG_ALTERNATE="$4"
> +
> +    pushd "$SRCDIR"
> +
> +    export CFLAGS="$CFLAGS -I${HEADERS_KERNEL} -fPIC"
> +
> +    if [[ -n "$XORG_ALTERNATE" ]]; then
> +        # Solaris 10 does not have the necessary Xorg SDK headers available
> +        # for installation, so this script has to download them into an
> +        # alternate root directory. If an alternate root was provided to
> +        # this function, then update CFLAGS and PKG_CONFIG_PATH so that
> +        # everything can be found...
> +        export CFLAGS="$CFLAGS -I${XORG_ALTERNATE}/usr/X11/include"
> +        export 
> PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$XORG_ALTERNATE/usr/lib/pkgconfig"
> +    fi
> +
> +    # Note that PATH should have already been set up at this point to
> +    # contain the following important paths:
> +    #   * /usr/ccs/bin contains development tools (ar, ranlib)
> +    #   * /usr/sfw/bin contains third-party software (gcc, gmake, gar, 
> granlib)
> +    #   * /opt/csw/bin contains OpenCSW software (libtool, autoconf, etc.)
> +    ./bootstrap
> +    ./configure --prefix="/usr" --with-linux \
> +                --with-xmoduledir=/usr/X11/lib/modules/input \
> +                --with-xorg-sdk="$XORG_ALTERNATE/usr/X11/include/xorg" 
> $CONFIGOPTS
> +    gmake
> +
> +    popd
> +}
> +
> +
> +#
> +# Download the latest code from an appropriate location.
> +# At the moment, grab it from my Github repository.
> +#
> +function get_source() {
> +    local SRCDIR="$1"
> +    local REPO="$2"
> +    local COMMIT="$3"
> +
> +    if [[ "$REPO" == "linuxwacom" ]]; then
> +        # Legacy linuxwacom repo is named "code" on SourceForge...
> +        REPO="code"
> +    fi
> +
> +    local URL="http://git.code.sf.net/p/linuxwacom/${REPO}.git";
> +
> +    if [[ ! -d "$SRCDIR" ]]; then
> +        git clone -b "$COMMIT" "$URL" "$SRCDIR"
> +    fi
> +}
> +
> +
> +#
> +# The Xorg SDK and other required headers must be installed for linuxwacom
> +# to build. In theory, installing SUNWxorg-headers and its dependencies
> +# should be sufficient. In reality, the version of SUNWxorg-headers
> +# contained on the Solaris 10 DVD does *not* contain the full SDK. We
> +# need to manually get everything from the OpenIndiana legacy archive.
> +# This requires a bit of futzing because OpenIndiana assumes the presence
> +# of an IPS package manager which isn't present on my Solaris 10 installs.
> +# See [1] ("How to manually download individual files from the OpenIndiana
> +# (or Solaris) pkg repo?") for an overview of what we're doing to emulate
> +# one.
> +#
> +# [1]: https://serverfault.com/questions/348139/
> +#
> +function get_xorg_sdk() {
> +    local WORKDIR="$1"
> +    local SVR="http://pkg.openindiana.org/legacy";
> +    local X11_PKG="SUNWxwinc@0.5.11,5.11-0.101:20081119T231501Z"
> +    local XORG_PKG="SUNWxorg-headers@0.5.11,5.11-0.101:20081119T231341Z"
> +
> +    # Download package manifests
> +    wget -cP "$WORKDIR" "$SVR/manifest/0/$X11_PKG" 
> "$SVR/manifest/0/$XORG_PKG"
> +
> +    # Download gzipped package contents
> +    cat "$WORKDIR/$X11_PKG" "$WORKDIR/$XORG_PKG" | \
> +      sed -n "s%^file \([^ ]*\).*%$SVR/file/0/\1%p" | xargs wget -cP 
> "$WORKDIR"
> +
> +    # Create destination directories
> +    cat "$WORKDIR/$X11_PKG" "$WORKDIR/$XORG_PKG" | \
> +      sed -n "s%^dir.*path=\([^ ]*\).*%mkdir -p \"$WORKDIR/\1\"%p" | sh -s
> +
> +    # Extract gzipped files to destinations
> +    cat "$WORKDIR/$X11_PKG" "$WORKDIR/$XORG_PKG" | \
> +      sed -n "s%^file \([^ ]*\).* path=\([^ ]*\).*%\1|\2%p" | \
> +      sed "s%\([^|]*\)|\(.*\)%gzcat \"$WORKDIR/\1\" > \"$WORKDIR/\2\"%" | sh 
> -s
> +
> +    # Set up symlinks
> +    cat "$WORKDIR/$X11_PKG" "$WORKDIR/$XORG_PKG" | \
> +      sed -n "s%^link.*path=\([^ ]*\).*target=\([^ ]*\).*%\1|\2%p" | \
> +      sed "s%\([^|]*\)|\(.*\)%ln -s \"\2\" \"$WORKDIR/\1\"%" | sh -s
> +
> +    # Remove temporary files
> +    rm -f "$WORKDIR"/* 2> /dev/null || true
> +}
> +
> +
> +#
> +# The linuxwacom driver has a few build dependencies that must be
> +# satisfied before the code can compile. In theory, we might be
> +# able to find official Oracle/Sun packages that fit the bill; in
> +# reality its just easier to get them from the OpenCSW Software
> +# Archive. Ask before actually installing anything to be courteous.
> +#
> +function install_build_deps() {
> +    local PACKAGES="$@"
> +    local INSTALL=0
> +
> +    if [[ ! -d /opt/csw || ! -e /opt/csw/bin/pkgutil ]]; then
> +        echo "OpenCSW not found. It must be installed to obtain build 
> dependencies."
> +        echo "Do you wish to proceed and install the OpenCSW package 
> manager?"
> +        select yn in "Yes" "No"; do
> +            case $yn in
> +                Yes ) INSTALL=1; break;;
> +                No ) exit;;
> +                * ) echo "Please answer 'Yes' or 'No'.";;
> +            esac
> +        done
> +    elif [[ ! -x /opt/csw/bin/pkgutil ]]; then
> +        echo "OpenCSW pkgutil found, but not executable. Exiting."
> +        exit 1
> +    fi
> +
> +    if [[ $INSTALL -ne 0 ]]; then
> +        yes | pkgadd -a <(echo setuid=nocheck) -d http://get.opencsw.org/now 
> CSWpkgutil
> +    fi
> +    /opt/csw/bin/pkgutil -U
> +    yes | /opt/csw/bin/pkgutil -i $PACKAGES
> +}
> +
> +
> +#
> +# Ensure that the system has everything that it needs to perform a
> +# build. If prerequisites are not satisfied, ask the user if they
> +# would like to install them.
> +#
> +function check_prerequisites() {
> +    while true ; do
> +        local SYS=""
> +        local CSW=""
> +        local PATHMOD=""
> +
> +        command -v "gcc"        >/dev/null 2>&1 || SYS="$SYS gcc"
> +        command -v "gmake"      >/dev/null 2>&1 || SYS="$SYS gmake"
> +        command -v "wget"       >/dev/null 2>&1 || SYS="$SYS wget"
> +
> +        command -v "libtoolize" >/dev/null 2>&1 || CSW="$CSW libtool"
> +        command -v "autoconf"   >/dev/null 2>&1 || CSW="$CSW autoconf"
> +        command -v "automake"   >/dev/null 2>&1 || CSW="$CSW automake"
> +        command -v "gsed"       >/dev/null 2>&1 || CSW="$CSW gsed"
> +        command -v "git"        >/dev/null 2>&1 || CSW="$CSW git"
> +        command -v "/opt/csw/bin/pkg-config" >/dev/null 2>&1 || CSW="$CSW 
> pkgconfig"
> +
> +        if [[ -z "$SYS" && -z "$CSW" ]]; then
> +            break
> +        fi
> +
> +        echo "Unable to find the following dependencies in the current PATH."
> +        echo "  ==> $SYS $CSW"
> +        echo
> +
> +        if [[ "$PATH" != *"/usr/ccs/bin"* ]]; then
> +            PATHMOD="$PATHMOD:/usr/ccs/bin"
> +        fi
> +        if [[ "$PATH" != *"/usr/sfw/bin"* ]]; then
> +            PATHMOD="$PATHMOD:/usr/sfw/bin"
> +        fi
> +        if [[ "$PATH" != *"/opt/csw/bin"* ]]; then
> +            PATHMOD="$PATHMOD:/opt/csw/bin"
> +        fi
> +
> +        if [[ -n "$PATHMOD" ]]; then
> +            echo "Would you like me to update PATH to \"\$PATH$PATHMOD\"?"
> +            select yn in "Yes" "No"; do
> +                case $yn in
> +                    Yes ) export PATH="$PATH$PATHMOD"; break;;
> +                    No ) exit 1;;
> +                    * ) echo "Please answer 'Yes' or 'No'.";;
> +                esac
> +            done
> +            continue
> +        elif [[ -n "$CSW" ]]; then
> +            echo "Would you like me to install packages from OpenCSW?"
> +            select yn in "Yes" "No"; do
> +                case $yn in
> +                    Yes ) install_build_deps $CSW; break;;
> +                    No ) exit 1;;
> +                    * ) echo "Please answer 'Yes' or 'No'.";;
> +                esac
> +            done
> +            continue
> +        else
> +            echo "Still unable to find necessary packages. Aborting."
> +            exit 1
> +        fi
> +    done
> +
> +    if [[ ! -f "$XORGDIR/usr/X11/include/xorg/xorgVersion.h" ]]; then
> +        echo "You seem to be missing the Xorg SDK. Download?"
> +        select yn in "Yes" "No"; do
> +            case $yn in
> +                Yes ) get_xorg_sdk "$XORGDIR"; break;;
> +                No ) exit 1;;
> +                * ) echo "Please answer 'Yes' or 'No'.";;
> +            esac
> +        done
> +    fi
> +
> +    return 0
> +}
> +
> +
> +WORKDIR="$(pwd)/workdir"
> +XORGDIR="$WORKDIR/xorg-sdk"
> +USBWCMDIR="$WORKDIR/usbwcm_src"
> +
> +LINUXWACOM_SRCDIR="$WORKDIR/linuxwacom_src"
> +LINUXWACOM_DSTDIR="$WORKDIR/linuxwacom_dst"
> +LINUXWACOM_PKGDIR="$WORKDIR"
> +
> +
> +if [[ $EUID -ne 0 ]]; then
> +    echo "This script must be run as root."
> +    exit 1
> +fi
> +
> +mkdir -p $WORKDIR || true
> +
> +check_prerequisites
> +
> +get_source "$USBWCMDIR" usbwcm master
> +
> +if [[ -f "README.solaris.md" ]]; then
> +       LINUXWACOM_SRCDIR="$(pwd)"
> +else
> +       get_source "$LINUXWACOM_SRCDIR" linuxwacom master
> +fi
> +
> +compile_linuxwacom "$LINUXWACOM_SRCDIR" "$USBWCMDIR/usr/src/uts/common/" "" 
> "$XORGDIR"
> +install_linuxwacom "$LINUXWACOM_SRCDIR" "$LINUXWACOM_DSTDIR"
> +
> +LINUXWACOM_VERSION=$(generate_linuxwacom_version "$LINUXWACOM_SRCDIR" "")
> +while [[ -z "$LINUXWACOM_VERSION" ]]; do
> +       echo "Unable to determine linuxwacom version for packaging."
> +       echo -n "Please provide version (e.g. 0.12.0): "
> +       read LINUXWACOM_VERSION
> +done
> +
> +package_linuxwacom "$LINUXWACOM_DSTDIR" "$LINUXWACOM_PKGDIR" 
> "$LINUXWACOM_VERSION"
> diff --git a/src/include/usbwcm_build.h b/src/include/usbwcm_build.h
> new file mode 100644
> index 0000000..e18c694
> --- /dev/null
> +++ b/src/include/usbwcm_build.h
> @@ -0,0 +1,110 @@
> +/*
> + * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
> + * Copyright 2017 Jason Gerecke, Wacom. <jason.gere...@wacom.com>
> + * Use is subject to license terms.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation; either version 2
> + * of the License, or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
> + */
> +#ifndef        _USBWCM_BUILD_H
> +#define        _USBWCM_BUILD_H
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +#define        EVIOCGVERSION   EVTIOCGVERSION
> +#define        EVIOCGID        EVTIOCGDEVID
> +#define        EVIOCGBIT       EVTIOCGBM
> +#define        EVIOCGABS       EVTIOCGABS
> +
> +#define        input_event     event_input
> +
> +/* The structures 'event_abs_axis' and 'event_dev_id'
> + * from usbwcm.h correspond to 'input_absinfo' and
> + * 'input_id', but cannot be simply redfined like we
> + * do above for 'event_input' since the member names
> + * differ as  well (e.g. "min" instead of "minimum").
> + * To allow the code to compile, we copy the structure
> + * definitions from usbwcm.h, changing only the names.
> + * Unless those upstream definitions change, we should
> + * be fine...
> + */
> +struct input_absinfo {
> +       int32_t value;
> +       int32_t minimum;
> +       int32_t maximum;
> +       int32_t fuzz;
> +       int32_t flat;
> +};
> +struct input_id {
> +       uint16_t bustype;
> +       uint16_t vendor;
> +       uint16_t product;
> +       uint16_t version;
> +};
> +
> +#define        EV_KEY          EVT_BTN
> +#define        EV_REL          EVT_REL
> +#define        EV_ABS          EVT_ABS
> +#define        EV_SYN          EVT_SYN
> +#define        EV_MSC          EVT_MSC
> +#define        EV_MAX          EVT_MAX
> +
> +#define        KEY_MAX         BTN_MAX
> +
> +#define        BTN_0           BTN_MISC_0
> +#define        BTN_1           BTN_MISC_1
> +#define        BTN_2           BTN_MISC_2
> +#define        BTN_3           BTN_MISC_3
> +#define        BTN_4           BTN_MISC_4
> +#define        BTN_5           BTN_MISC_5
> +#define        BTN_6           BTN_MISC_6
> +#define        BTN_7           BTN_MISC_7
> +#define        BTN_8           BTN_MISC_8
> +#define        BTN_9           BTN_MISC_9
> +
> +#define        BTN_STYLUS      BTN_STYLUS_1
> +#define        BTN_STYLUS2     BTN_STYLUS_2
> +
> +#define        BTN_TOOL_RUBBER BTN_TOOL_ERASER
> +#define        BTN_TOOL_LENS   BTN_TOOL_MOUSE
> +
> +#define        BTN_TOOL_PENCIL         BTN_TOOL_PEN
> +#define        BTN_TOOL_BRUSH          BTN_TOOL_PEN
> +#define        BTN_TOOL_AIRBRUSH       BTN_TOOL_PEN
> +#define        BTN_TOOL_FINGER         BTN_TOOL_PAD
> +#define        BTN_TOUCH               BTN_TIP
> +#define        BTN_TOOL_TRIPLETAP      BTN_TIP
> +
> +#define        BTN_BASE3       BTN_MISC_UND
> +#define        BTN_BASE4       BTN_MISC_UND
> +#define        BTN_BASE5       BTN_MISC_UND
> +#define        BTN_BASE6       BTN_MISC_UND
> +
> +#define        BTN_TL          BTN_MISC_UND
> +#define        BTN_TR          BTN_MISC_UND
> +#define        BTN_TL2         BTN_MISC_UND
> +#define        BTN_TR2         BTN_MISC_UND
> +#define        BTN_SELECT      BTN_MISC_UND
> +
> +#define        KEY_PROG1       BTN_MISC_UND
> +#define        KEY_PROG2       BTN_MISC_UND
> +#define        KEY_PROG3       BTN_MISC_UND
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
> +#endif /* _USBWCM_BUILD_H */
> diff --git a/src/util/10-linuxwacom.fdi b/src/util/10-linuxwacom.fdi
> index 4f63f2c..de67aa6 100644
> --- a/src/util/10-linuxwacom.fdi
> +++ b/src/util/10-linuxwacom.fdi
> @@ -2,6 +2,7 @@
>  <!-- this is probably a bit imprecise -->
>  <deviceinfo version="0.2">
>    <device>
> +  <match key="/org/freedesktop/Hal/devices/computer:system.kernel.name" 
> string="Linux">
>      <match key="info.category" contains="input">
>        <match key="info.product" contains_outof="Wacom">
>         <merge key="input.x11_driver" type="string">wacom</merge>
> @@ -28,9 +29,11 @@
>         </match>
>        </match>
>      </match>
> +  </match>
>    </device>
>    <!-- Match the Wacom Bluetooth A5 pen tablet -->
>    <device>
> +  <match key="/org/freedesktop/Hal/devices/computer:system.kernel.name" 
> string="Linux">
>      <match key="info.capabilities" contains="input.mouse">
>        <match key="info.product" contains="WACOM">
>          <match key="info.product" contains="Tablet">
> @@ -43,6 +46,28 @@
>          </match>
>        </match>
>      </match>
> +  </match>
> +  </device>
> +
> +  <device>
> +  <match key="/org/freedesktop/Hal/devices/computer:system.kernel.name" 
> string="SunOS">
> +    <match key="info.capabilities" contains="input.mouse">
> +    <match key="@info.parent:usb.vendor_id" int="0x56a">
> +      <merge key="info.product" type="string">Wacom_Tablet</merge>
> +      <append key="info.callouts.add" type="strlist">hal-setup-wacom</append>
> +
> +      <merge key="input.x11_driver" type="string">wacom</merge>
> +      <merge key="input.x11_options.Type" type="string">eraser</merge>
> +      <merge key="input.x11_options.USB" type="bool">true</merge>
> +
> +      <remove key="input.x11_options.StreamsModule" type="string"></remove>
> +      <remove key="input.x11_options.Protocol" type="string"></remove>
> +
> +      <append key="wacom.types" type="strlist">stylus</append>
> +      <append key="wacom.types" type="strlist">pad</append>
> +    </match>
> +    </match>
> +  </match>
>    </device>
>  </deviceinfo>
>
> diff --git a/src/util/Makefile.am b/src/util/Makefile.am
> index 0aaedc2..8577f0b 100755
> --- a/src/util/Makefile.am
> +++ b/src/util/Makefile.am
> @@ -25,7 +25,13 @@ endif
>
>  if WCM_HAVE_HAL
>  libexec_PROGRAMS = hal-setup-wacom
> +
> +if WCM_ENV_SOLARIS
> +fdidir = /etc/hal/fdi/policy/20thirdparty
> +else
>  fdidir = $(prefix)/share/hal/fdi/policy/20thirdparty
> +endif
> +
>  fdi_SCRIPTS = 10-linuxwacom.fdi
>  endif
>
> diff --git a/src/util/hal-setup-wacom.c b/src/util/hal-setup-wacom.c
> index dd6183c..1724bc4 100644
> --- a/src/util/hal-setup-wacom.c
> +++ b/src/util/hal-setup-wacom.c
> @@ -2,6 +2,8 @@
>   * Licensed under the GNU General Public License Version 2
>   *
>   * Copyright (C) 2009 Red Hat <m...@redhat.com>
> + * Copyright (C) 2010 Sun Microsystems, Inc.  All rights reserved.
> + * Copyright (C) 2017 Jason Gerecke, Wacom. <jason.gere...@wacom.com>
>   *
>   * This program is free software; you can redistribute it and/or
>   * modify it under the terms of the GNU General Public License
> @@ -33,6 +35,98 @@
>  static LibHalContext *ctx = NULL;
>  static char* udi;
>
> +#ifdef sun
> +static char wacom_x11_options[] = "wacom.%s.x11_options.";
> +static char x11_options[] = "input.x11_options.%s";
> +
> +static int
> +copy_x11_options (LibHalContext *hal_ctx, const char *parent, char *child,
> +            const char *namespace, DBusError *error)
> +{
> +       LibHalPropertySet *properties;
> +       LibHalPropertySetIterator it;
> +
> +       if(hal_ctx == 0) {
> +               fprintf (stderr,"%s %d : LibHalContext *ctx is 
> NULL\n",__FILE__, __LINE__);
> +               return 1;
> +       }
> +
> +       dbus_error_init (error);
> +
> +       /* first collect from root computer device */
> +       properties = libhal_device_get_all_properties (hal_ctx, parent, 
> error);
> +       if (properties == NULL ) {
> +               LIBHAL_FREE_DBUS_ERROR(error);
> +               return 1;
> +       }
> +
> +       for (libhal_psi_init (&it, properties); libhal_psi_has_more (&it); 
> libhal_psi_next (&it)) {
> +               LibHalPropertyType type = libhal_psi_get_type (&it);
> +               char *key = libhal_psi_get_key (&it);
> +               char *newkey;
> +               char *str_prop;
> +               dbus_bool_t bool_prop;
> +               dbus_int32_t int32_prop;
> +               dbus_uint64_t uint64_prop;
> +               double double_prop;
> +               int len = strlen(namespace);
> +
> +               dbus_error_init (error);
> +
> +               if (strncmp(namespace, key, len) != 0)
> +                       continue;
> +
> +               asprintf(&newkey, x11_options, key + len);
> +
> +
> +               switch (type) {
> +               case LIBHAL_PROPERTY_TYPE_INT32:
> +                       int32_prop = libhal_device_get_property_int(ctx, 
> parent,
> +                                                                   key, 
> error);
> +                       libhal_device_set_property_int(ctx, child, newkey,
> +                                                      int32_prop, error);
> +                       break;
> +               case LIBHAL_PROPERTY_TYPE_UINT64:
> +                       uint64_prop = libhal_device_get_property_uint64(ctx, 
> parent,
> +                                                                       key, 
> error);
> +                       libhal_device_set_property_uint64(ctx, child, newkey,
> +                                                         uint64_prop, error);
> +                       break;
> +               case LIBHAL_PROPERTY_TYPE_DOUBLE:
> +                       double_prop = libhal_device_get_property_double(ctx, 
> parent, key,
> +                                                                       
> error);
> +                       libhal_device_set_property_double(ctx, child, newkey,
> +                                                         double_prop, error);
> +                       break;
> +               case LIBHAL_PROPERTY_TYPE_BOOLEAN:
> +                       bool_prop = libhal_device_get_property_bool (ctx, 
> parent, key,
> +                                                        error);
> +                       libhal_device_set_property_bool(ctx, child, newkey,
> +                                                       bool_prop, error);
> +
> +                       break;
> +               case LIBHAL_PROPERTY_TYPE_STRING:
> +                       str_prop = libhal_device_get_property_string (ctx, 
> parent, key,
> +                                                                 error);
> +                       if (str_prop == NULL)
> +                               continue;
> +
> +                       libhal_device_set_property_string (ctx, child, newkey,
> +                                                          str_prop, error);
> +                       break;
> +               case LIBHAL_PROPERTY_TYPE_STRLIST:
> +               default:
> +                       break;
> +               }
> +       }
> +
> +       libhal_free_property_set (properties);
> +       LIBHAL_FREE_DBUS_ERROR(error);
> +
> +       return 0;
> +}
> +#endif /* sun */
> +
>  int
>  main (int argc, char **argv)
>  {
> @@ -44,6 +138,11 @@ main (int argc, char **argv)
>         char **types;
>         int i;
>         DBusError error;
> +#ifdef sun
> +       char *rename = NULL;
> +       char *type;
> +       char *options;
> +#endif
>
>         udi = getenv ("UDI");
>         if (udi == NULL) {
> @@ -84,6 +183,22 @@ main (int argc, char **argv)
>         dbus_error_init (&error);
>         name = libhal_device_get_property_string (ctx, udi, "info.product",
>                                                   &error);
> +#ifdef sun
> +       dbus_error_init (&error);
> +       type = libhal_device_get_property_string (ctx, udi,
> +                                                "input.x11_options.Type",
> +                                                 &error);
> +       if (name && type) {
> +               asprintf(&rename, "%s", name);
> +               asprintf (&subname, "%s_%s", rename, type);
> +
> +               dbus_error_init (&error);
> +               libhal_device_set_property_string (ctx, udi,
> +                                                  "info.product",
> +                                                  subname, &error);
> +               free (subname);
> +       }
> +#endif /* sun */
>
>         dbus_error_init (&error);
>         types = libhal_device_get_property_strlist (ctx, udi, "wacom.types",
> @@ -134,12 +249,23 @@ main (int argc, char **argv)
>                 }
>                 if (name) {
>                         dbus_error_init (&error);
> +#ifdef sun
> +                       asprintf (&subname, "%s_%s", rename, types[i]);
> +#else /* !sun */
>                         asprintf (&subname, "%s %s", name, types[i]);
> +#endif
>                         libhal_device_set_property_string (ctx, tmpdev,
>                                                            "info.product",
>                                                            subname, &error);
>                         free (subname);
>                 }
> +
> +#ifdef sun
> +               asprintf(&options, wacom_x11_options, types[i]);
> +               copy_x11_options (ctx, udi, tmpdev, options, &error);
> +               free(options);
> +#endif
> +
>                 dbus_error_init (&error);
>                 libhal_device_commit_to_gdl (ctx, tmpdev, newudi, &error);
>
> @@ -153,4 +279,3 @@ main (int argc, char **argv)
>
>         return 0;
>  }
> -
> diff --git a/src/util/wactablet.c b/src/util/wactablet.c
> index 2df8e37..891260d 100755
> --- a/src/util/wactablet.c
> +++ b/src/util/wactablet.c
> @@ -3,6 +3,8 @@
>  **
>  ** Copyright (C) 2002 - 2003 - John E. Joganic
>  ** Copyright (C) 2004 - 2005 - Ping Cheng
> +** Copyright (C) 2010 Sun Microsystems, Inc.  All rights reserved.
> +** Copyright (C) 2017 Jason Gerecke, Wacom. <jason.gere...@wacom.com>
>  **
>  ** This program is free software; you can redistribute it and/or
>  ** modify it under the terms of the GNU General Public License
> @@ -35,8 +37,20 @@
>  #include <assert.h>
>  #include <stdarg.h>
>
> +#ifdef sun
> +#include <strings.h>
> +#endif
> +
>  #ifdef WCM_ENABLE_LINUXINPUT
> +
> +#ifdef sun
> +#include <sys/stropts.h>
> +#include <sys/usb/clients/usbinput/usbwcm/usbwcm.h>
> +#include "../include/usbwcm_build.h"
> +#else /* !sun */
>  #include <linux/input.h>
> +#endif /* sun */
> +
>  #endif
>
>  typedef void (*FREEFUNC)(void* pv);
> @@ -274,7 +288,21 @@ static int WacomIsUSB(int fd)
>  {
>  #ifdef WCM_ENABLE_LINUXINPUT
>         short sID[4];
> +#ifdef sun
> +       int retval;
> +
> +       retval = ioctl(fd, I_FIND, "usbwcm");
> +       if (retval == 0)
> +               retval = ioctl(fd, I_PUSH, "usbwcm");
> +       if (retval < 0)
> +       {
> +               perror("WacomIsUSB");
> +               return 0;
> +       }
> +#endif /* sun */
> +
>         if (ioctl(fd,EVIOCGID,sID) < 0) return 0;
> +
>         return 1;
>  #else
>         return 0;
> diff --git a/src/util/wacusb.c b/src/util/wacusb.c
> index 06217d7..f0ba02f 100755
> --- a/src/util/wacusb.c
> +++ b/src/util/wacusb.c
> @@ -3,6 +3,8 @@
>  **
>  ** Copyright (C) 2002 - 2004 - John E. Joganic
>  ** Copyright (C) 2003 - 2014 - Ping Cheng
> +** Copyright (C) 2010 Sun Microsystems, Inc.  All rights reserved.
> +** Copyright (C) 2017 Jason Gerecke, Wacom. <jason.gere...@wacom.com>
>  **
>  ** This program is free software; you can redistribute it and/or
>  ** modify it under the terms of the GNU General Public License
> @@ -38,6 +40,12 @@
>  
> *****************************************************************************/
>
>  #ifdef WCM_ENABLE_LINUXINPUT
> +
> +#ifdef sun
> +#include <sys/usb/clients/usbinput/usbwcm/usbwcm.h>
> +#include "../include/usbwcm_build.h"
> +
> +#else /* !sun */
>  #include <linux/input.h>
>
>  #ifndef EV_MSC
> @@ -52,6 +60,8 @@
>  #define BTN_TOOL_DOUBLETAP 0x14d
>  #endif
>
> +#endif /* sun */
> +
>  
> /*****************************************************************************
>  ** Defines
>  
> *****************************************************************************/
> @@ -621,8 +631,12 @@ static int USBIdentifyModel(USBTABLET* pUSB)
>                         
> USBGetRange(pUSB,absbits,ABS_PRESSURE,WACOMFIELD_PRESSURE) ||
>                         
> USBGetRange(pUSB,absbits,ABS_TILT_X,WACOMFIELD_TILT_X) ||
>                         
> USBGetRange(pUSB,absbits,ABS_TILT_Y,WACOMFIELD_TILT_Y) ||
> +#ifdef sun
> +                       
> USBGetRange(pUSB,absbits,ABS_WHEEL,WACOMFIELD_ABSWHEEL))
> +#else
>                         
> USBGetRange(pUSB,absbits,ABS_WHEEL,WACOMFIELD_ABSWHEEL) ||
>                         
> USBGetRange(pUSB,absbits,ABS_THROTTLE,WACOMFIELD_THROTTLE))
> +#endif
>                         return 1;
>
>         }
> @@ -676,8 +690,12 @@ static int USBIdentifyModel(USBTABLET* pUSB)
>                                 ISBITSET(keybits,BTN_TOOL_AIRBRUSH) ||
>                                 ISBITSET(keybits,BTN_TOOL_FINGER) ||
>                                 ISBITSET(keybits,BTN_TOOL_MOUSE) ||
> +#ifdef sun
> +                               ISBITSET(keybits,BTN_TOOL_LENS))
> +#else /* !sun */
>                                 ISBITSET(keybits,BTN_TOOL_LENS) ||
>                                 ISBITSET(keybits,BTN_TOOL_DOUBLETAP))
> +#endif
>                         pUSB->state[0].uValid |= BIT(WACOMFIELD_PROXIMITY) |
>                                         BIT(WACOMFIELD_TOOLTYPE);
>
> @@ -820,14 +838,16 @@ static int USBParseKEY(USBTABLET* pUSB, struct 
> input_event* pEv)
>                 case BTN_STYLUS: button = WACOMBUTTON_STYLUS; break;
>                 case BTN_STYLUS2: button = WACOMBUTTON_STYLUS2; break;
>                 case BTN_TOOL_PEN: tool = WACOMTOOLTYPE_PEN; break;
> -               case BTN_TOOL_PENCIL: tool = WACOMTOOLTYPE_PENCIL; break;
> -               case BTN_TOOL_BRUSH: tool = WACOMTOOLTYPE_BRUSH; break;
>                 case BTN_TOOL_RUBBER: tool = WACOMTOOLTYPE_ERASER; break;
> -               case BTN_TOOL_AIRBRUSH: tool = WACOMTOOLTYPE_AIRBRUSH; break;
>                 case BTN_TOOL_MOUSE: tool = WACOMTOOLTYPE_MOUSE; break;
>                 case BTN_TOOL_FINGER: tool = WACOMTOOLTYPE_PAD; break;
> +#ifndef sun /* !sun */
> +               case BTN_TOOL_PENCIL: tool = WACOMTOOLTYPE_PENCIL; break;
> +               case BTN_TOOL_BRUSH: tool = WACOMTOOLTYPE_BRUSH; break;
> +               case BTN_TOOL_AIRBRUSH: tool = WACOMTOOLTYPE_AIRBRUSH; break;
>                 case BTN_TOOL_LENS: tool = WACOMTOOLTYPE_LENS; break;
>                 case BTN_TOOL_DOUBLETAP: tool = WACOMTOOLTYPE_TOUCH; break;
> +#endif
>                 default:
>                         for (i = 0; i < gNumPadKeys; i++)
>                                 if (pEv->code == gPadKeys [i])
> @@ -914,7 +934,9 @@ static int USBParseABS(USBTABLET* pUSB, struct 
> input_event* pEv)
>                 case ABS_TILT_X: field = WACOMFIELD_TILT_X; break;
>                 case ABS_TILT_Y: field = WACOMFIELD_TILT_Y; break;
>                 case ABS_WHEEL: field = WACOMFIELD_ABSWHEEL; break;
> +#ifndef sun /* !sun */
>                 case ABS_THROTTLE: field = WACOMFIELD_THROTTLE; break;
> +#endif
>         }
>
>         if (field)
> diff --git a/src/xdrv/Makefile.am b/src/xdrv/Makefile.am
> index 4cb3efa..71ff43b 100755
> --- a/src/xdrv/Makefile.am
> +++ b/src/xdrv/Makefile.am
> @@ -68,7 +68,7 @@ depend: .depend
>
>  .depend: Makefile
>         @rm -f .depend
> -       $(CC) -MM $(CFLAGS) $(DEPFLAGS) $(DRIVER_INCLUDES) 
> $(XF86OBJS:%.o=$(srcdir)/%.c) > .depend
> +       $(CC) -MM $(CFLAGS) $(DEPFLAGS) $(DRIVER_INCLUDES) $(XSERVER_CFLAGS) 
> $(XF86OBJS:%.o=$(srcdir)/%.c) > .depend
>
>  -include .depend
>
> diff --git a/src/xdrv/wcmUSB.c b/src/xdrv/wcmUSB.c
> index 196bc14..0eb7096 100755
> --- a/src/xdrv/wcmUSB.c
> +++ b/src/xdrv/wcmUSB.c
> @@ -1,6 +1,8 @@
>  /*
>   * Copyright 1995-2002 by Frederic Lepied, France. <lep...@xfree86.org>
>   * Copyright 2002-2013 by Ping Cheng, Wacom Technology. <pi...@wacom.com>
> + * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
> + * Copyright 2017 Jason Gerecke, Wacom. <jason.gere...@wacom.com>
>   *
>   * This program is free software; you can redistribute it and/or
>   * modify it under the terms of the GNU General Public License
> @@ -24,6 +26,10 @@
>
>  #include <sys/utsname.h>
>
> +#ifdef sun
> +#include <sys/stropts.h>
> +#endif /* sun */
> +
>  /* Defines on newer kernels */
>  #ifndef BTN_TASK
>  #define BTN_TASK 0x117
> @@ -409,6 +415,19 @@ static Bool usbDetect(LocalDevicePtr local)
>
>         DBG(1, priv->debugLevel, ErrorF("usbDetect\n"));
>
> +#ifdef sun
> +       int retval;
> +
> +       retval = ioctl(local->fd, I_FIND, "usbwcm");
> +       if (retval == 0)
> +               retval = ioctl(local->fd, I_PUSH, "usbwcm");
> +       if (retval < 0)
> +       {
> +               ErrorF("usbDetect: can not find/push STREAMS module\n");
> +               return 0;
> +       }
> +#endif /* sun */
> +
>         SYSCALL(err = ioctl(local->fd, EVIOCGVERSION, &version));
>
>         if (err < 0)
> @@ -566,6 +585,9 @@ static void usbRetrieveKeys(WacomCommonPtr common)
>                 if (ISBITSET (common->wcmKeys, padkey_codes [i]))
>                         common->padkey_code [common->npadkeys++] = 
> padkey_codes [i];
>         /* set default nbuttons */
> +#ifdef sun
> +       if (ISBITSET (common->wcmKeys, BTN_EXTRA))
> +#else /* !sun */
>         if (ISBITSET (common->wcmKeys, BTN_TASK))
>                 common->nbuttons = 10;
>         else if (ISBITSET (common->wcmKeys, BTN_BACK))
> @@ -573,6 +595,7 @@ static void usbRetrieveKeys(WacomCommonPtr common)
>         else if (ISBITSET (common->wcmKeys, BTN_FORWARD))
>                 common->nbuttons = 8;
>         else if (ISBITSET (common->wcmKeys, BTN_EXTRA))
> +#endif /* sun */
>                 common->nbuttons = 7;
>         else if (ISBITSET (common->wcmKeys, BTN_SIDE))
>                 common->nbuttons = 6;
> @@ -589,8 +612,10 @@ Bool usbWcmInit(LocalDevicePtr local, char* id, size_t 
> id_len, float *version)
>         DBG(1, priv->debugLevel, ErrorF("initializing USB tablet\n"));
>         *version = 0.0;
>
> +#ifndef sun /* !sun */
>         /* fetch model name */
>         ioctl(local->fd, EVIOCGNAME(id_len), id);
> +#endif
>
>
>  #ifndef WCM_XORG_XSERVER_1_4
> @@ -1213,6 +1238,7 @@ static void usbParseChannel(LocalDevicePtr local, int 
> channel)
>                                 ds->abswheel = event->value - MIN_ROTATION;
>                                 ds->abswheel *= FILTER_PRESSURE_RES;
>                                 ds->abswheel /= (MAX_ROTATION - MIN_ROTATION);
> +#ifndef sun /* !sun */
>                         } else if (event->code == ABS_THROTTLE) {
>                                 if (common->tablet_id == 0xF4)
>                                 {
> @@ -1226,6 +1252,7 @@ static void usbParseChannel(LocalDevicePtr local, int 
> channel)
>                                         ds->throttle *= FILTER_PRESSURE_RES;
>                                         ds->throttle /= (2 * MAX_ABS_WHEEL);
>                                 }
> +#endif /* !sun */
>                         } else if (event->code == ABS_MISC) {
>                                 ds->proximity = (event->value != 0);
>                                 if (event->value) {
> @@ -1301,6 +1328,7 @@ static void usbParseChannel(LocalDevicePtr local, int 
> channel)
>                                 ds->device_id = PAD_DEVICE_ID;
>                                 ds->proximity = (event->value != 0);
>                         }
> +#ifndef sun /* !sun */
>                         else if (event->code == BTN_TOOL_DOUBLETAP)
>                         {
>                                 DBG(6, common->debugLevel, ErrorF(
> @@ -1335,6 +1363,7 @@ static void usbParseChannel(LocalDevicePtr local, int 
> channel)
>                                 /* Second finger events will be considered in
>                                  * combination with the first finger data */
>                         }
> +#endif /* !sun */
>                         else if ((event->code == BTN_STYLUS) ||
>                                 (event->code == BTN_MIDDLE))
>                         {
> diff --git a/src/xdrv/wcmValidateDevice.c b/src/xdrv/wcmValidateDevice.c
> index 11c5dd5..346d3a1 100755
> --- a/src/xdrv/wcmValidateDevice.c
> +++ b/src/xdrv/wcmValidateDevice.c
> @@ -1,5 +1,6 @@
>  /*
>   * Copyright 2009- 2010 by Ping Cheng, Wacom. <pi...@wacom.com>
> + * Copyright 2017 Jason Gerecke, Wacom. <jason.gere...@wacom.com>
>   *
>   * This program is free software; you can redistribute it and/or
>   * modify it under the terms of the GNU General Public License
> @@ -18,7 +19,10 @@
>
>  #include "xf86Wacom.h"
>  #include "wcmFilter.h"
> +
> +#ifndef sun
>  #include <linux/serial.h>
> +#endif
>
>  #ifdef WCM_XORG_XSERVER_1_4
>      #ifndef _XF86_ANSIC_H
> @@ -120,7 +124,7 @@ ret:
>  static struct
>  {
>         const char* type;
> -       __u16 tool;
> +       int tool;
>  } wcmType [] =
>  {
>         { "stylus", BTN_TOOL_PEN       },
> @@ -161,7 +165,9 @@ int wcmDeviceTypeKeys(LocalDevicePtr local, unsigned 
> long* keys, size_t nkeys, i
>         int ret = 1, fd = -1;
>         unsigned int id = 0;
>         char* device, *stopstring;
> +#ifndef sun
>         struct serial_struct tmp;
> +#endif
>
>         device = xf86SetStrOption(local->options, "Device", NULL);
>         SYSCALL(fd = open(device, O_RDONLY));
> @@ -175,6 +181,7 @@ int wcmDeviceTypeKeys(LocalDevicePtr local, unsigned 
> long* keys, size_t nkeys, i
>         memset(keys, 0, nkeys);
>         *tablet_id = 0;
>
> +#ifndef sun
>         /* serial ISDV4 devices */
>         if (ioctl(fd, TIOCGSERIAL, &tmp) == 0)
>         {
> @@ -243,6 +250,7 @@ int wcmDeviceTypeKeys(LocalDevicePtr local, unsigned 
> long* keys, size_t nkeys, i
>                 }
>         }
>         else /* USB devices */
> +#endif
>         {
>                 struct input_id wacom_id;
>
> diff --git a/src/xdrv/xf86Wacom.h b/src/xdrv/xf86Wacom.h
> index e3cd49d..5c8cbaf 100755
> --- a/src/xdrv/xf86Wacom.h
> +++ b/src/xdrv/xf86Wacom.h
> @@ -1,6 +1,8 @@
>  /*
>   * Copyright 1995-2002 by Frederic Lepied, France. <lep...@xfree86.org>
>   * Copyright 2002-2009 by Ping Cheng, Wacom Technology. <pi...@wacom.com>
> + * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
> + * Copyright 2017 Jason Gerecke, Wacom. <jason.gere...@wacom.com>
>   *
>   * This program is free software; you can redistribute it and/or
>   * modify it under the terms of the GNU General Public License
> @@ -36,8 +38,11 @@
>   
> ****************************************************************************/
>
>  #ifdef WCM_ENABLE_LINUXINPUT
> +
> +#ifndef sun /* !sun */
>  #include <asm/types.h>
>  #include <linux/input.h>
> +#endif
>
>  /* keithp - a hack to avoid redefinitions of these in xf86str.h */
>  #ifdef BUS_PCI
> diff --git a/src/xdrv/xf86WacomDefs.h b/src/xdrv/xf86WacomDefs.h
> index 2b6c291..b099ef7 100755
> --- a/src/xdrv/xf86WacomDefs.h
> +++ b/src/xdrv/xf86WacomDefs.h
> @@ -1,6 +1,8 @@
>  /*
>   * Copyright 1995-2002 by Frederic Lepied, France. <lep...@xfree86.org>
>   * Copyright 2002-2011 by Ping Cheng, Wacom. <pi...@wacom.com>
> + * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
> + * Copyright 2017 Jason Gerecke, Wacom. <jason.gere...@wacom.com>
>   *
>   * This program is free software; you can redistribute it and/or
>   * modify it under the terms of the GNU General Public License
> @@ -24,8 +26,14 @@
>   * General Defines
>   
> ****************************************************************************/
>  #ifdef WCM_ENABLE_LINUXINPUT
> +    #ifdef sun
> +     #include <sys/usb/clients/usbinput/usbwcm/usbwcm.h>
> +     #include "../include/usbwcm_build.h"
> +    #else
>       #include <asm/types.h>
>       #include <linux/input.h>
> +    #endif
> +
>       #define MAX_USB_EVENTS 32
>
>      /* for access TOOL, BTN, and key codes of USB tablets */
> --
> 2.12.2
>

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to