B4J Library jSD_Wacom

I was asked by a customer to connect to wacom devices for signing.
At first I thought some wrapping would be needed and not being java savvy I would commission someone capable to do it for me.

At the end of last month I found myself with a few more coins in my pocket and I bought a wacom on an offer and started playing with it.
I started using their sw by calling it from B4J. Everything worked but I was not satisfied.
So I started testing the sample sources in VB.NET, C#, JAVA and I managed to get them to work perfectly. But the idea of having a library in B4J appealed to me.

So for 2 weeks I've been starting to transport the code in B4J. I was able to connect and send the images and other commands but still couldn't capture the signature. Then a lighting and banging the nose of JAVA (I've learned a lot about java these days) I produced the first library.

Unfortunately I can't share it for free, but I would like to share a DEMO version that you can find in this post. However, you can ask for all the information you need.

jSD_Wacom

Author:
Star-Dust
Version: 1.07
  • PenRoute
    • Fields:
      • IsInitialized As Boolean
        Verifica se l'oggetto sia stato inizializzato.
      • Pressure As Int
      • Rdy As Int
      • Sw As Int
      • X As Int
      • Y As Int
    • Functions:
      • Initialize
        Inizializza i campi al loro valore predefinito.
  • wacom
    • Events:
      • ButtonClick (Name As String)
      • CaptureSign (bmp As B4XBitmap)
      • CaptureStart (Success As Boolean)
      • PenPoint (PenData As PenRoute)
    • Functions:
      • CaptureClearScreen As String
      • CaptureStart (background As B4XBitmap, ButtonName As String()) As String
        wacom.CaptureStart(xui.LoadBitmap(path,file),array As String ("OK","CLEAR","CANCEL"))
        wacom.CaptureStart(null,null)
      • CaptureStop
      • Class_Globals As String
      • ClearScreen As String
      • Info As InfoType
      • Initialize (CallBack As Object, EventName As String) As String
        Initializes the object. You can add parameters to this method if needed.
      • isConnect As Boolean
      • IsInitialized As Boolean
        Verifica se l'oggetto sia stato inizializzato.
      • SetBackground (bmp As B4XBitmap) As String
    • Properties:
      • PenWrite



ezgif.com-gif-maker.gif
 

Attachments

  • TestWacom.zip
    13.7 KB · Views: 191
  • jSD_WacomDemo 1.07.zip
    20.1 KB · Views: 196
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
A little explanation

How to do? Start by downloading the wacom SDK as shown in the image


1670703422552.png



I suggest downloading the drivers as well


Finally, also download the tools to check the device and its functions
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
Sample
B4X:
Private Sub ButtonCapture_Click
    If wr.isConnect=False Then
        wr.CaptureStart(xui.LoadBitmap(File.DirAssets,"sd.png"),Array As String("Ok","Clear","Cancel"))
        Wait For wr_CaptureStart(Success As Boolean)
        Log("Start capture: " & Success)
        If Success Then
            'wr.PenWrite=false
           Log("Connectyed")
        Else
            Log("Fail")
        End If
    End If
End Sub

Private Sub ButtonCaptureStop_Click
    wr.CaptureStop
End Sub

Private Sub ButtonClear_Click
    If wr.isConnect Then wr.CaptureClearScreen
End Sub

Private Sub wr_PenPoint (PenData As PenRoute)
    Log($"${PenData.Sw} - ${PenData.Rdy} ${PenData.Pressure} X:${PenData.x} y:${PenData.y} "$)
    Dim x As Int = (PenData.X/wr.Info.ScreenWidth)*CanTablet.TargetRect.Width
    Dim y As Int = (PenData.y/wr.Info.ScreenHeight)*CanTablet.TargetRect.Height
   
    If PenData.Sw=1 And PenData.Rdy=1 Then ' pen down
        CanTablet.DrawCircle(X,Y,1dip,xui.Color_Black,False,3dip)
        CanTablet.Invalidate
    End If
End Sub

Private Sub wr_ButtonClick(Name As String)
    Log("Click: " & Name)
    Select Name
        Case "Ok"
            wr.CaptureStop
        Case "Clear"
            wr.CaptureClearScreen
        Case "Cancel"
            wr.CaptureStop
    End Select
End Sub

Private Sub wr_CapturedSign (bmp As B4XBitmap)
    'ImageSign.SetBitmap(bmp)
End Sub


Customized

1670610889880.png
2.gif
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
I bought the wacom stu-430 (black and white) for 169€. The list price is normally around €240.

It seems like an important price if you consider it a device that only collects the signature, but it does much more. I'm still studying it
 

Star-Dust

Expert
Licensed User
Longtime User
Update 1.02
  • added event CaptureRoute (PenDataList As List)

B4X:
Private Sub wacom_CaptureRoute (PenDataList As List)
    For Each P As PenRoute In PenDataList
        Log($"X:${P.x}  Y:${P.y}  Pressure:${P.Pressure}  Sw:${P.Sw} Rdy:${P.Rdy}"$)
    Next
End Sub

It is very interesting that it perceives the position of the pen at a distance of 2 centimeters from the sensitive surface. In addition, a centimeter indicates the proximity of the pen. Finally, if it is supported, it also indicates the pressure of the pen.
 

Star-Dust

Expert
Licensed User
Longtime User
Update 1.03

I have created a more powerful class that allows me to feel the stylus when it is still at least 2cm away from the tablet and feel as it gets closer. It also measures pen pressure.

In the example you see, the nib points orange if it is distant, red if it is near and gray if it is resting on the surface. The stronger the pressure, the greater the intensity of the gray, up to black.


ezgif.com-gif-maker.gif


As soon as I can I'll make an example to use the pen for graphic applications
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
Published the first DEMO version of the library and an EXAMPLE. (See post#1)
 

Star-Dust

Expert
Licensed User
Longtime User
An example of how to use the wacom tablet differently. The coordinates and height are used to rotate a CUBE3D
(The Demo version of the library will not give the expected results)

#Dependence: SD_XUI_View3D

ezgif.com-gif-maker.gif
 

Attachments

  • SampleWacom2.zip
    3.1 KB · Views: 186
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
release 1.04
  • Now works from java 8+
  • The wacomSing class has been removed
  • The wacom class has been improved
  • Can customize your screen by adding a background image and buttons that raise events.
    SAMPLE:
    wr.CaptureStart(xui.LoadBitmap(File.DirAssets,"BackgrounbdImage.png"),Array As String("Ok","Clear","Cancel"))
    wr.CaptureStart(null,null)
    wr.CaptureStart(xui.LoadBitmap(null,Array As String("Prev","Next"))
I grouped everything in one class to make it easier to use the library. So the wacomSign class no longer exists and the signature will be captured from the wacom class.

In the next updates it will also be possible to customize it by inserting text and finally it will automatically produce the image of the layout (as for example in the case of the sign) and it is not necessary to create it by code.
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
I would like to do something like this but it seems that it can only be done with STU-540 which has sufficient speed

 

Star-Dust

Expert
Licensed User
Longtime User
Update 1.05
  • Added CaptureSign (bmp As B4XBitmap) event
When the CaptureStop method is called the CaptureSign event will be raised with the trace image
 

Star-Dust

Expert
Licensed User
Longtime User
Update 1.06 (The demo version will not be updated)
  • improved sending of images

I finally managed to get the movement. The next step will be to make a game

ezgif.com-gif-maker.gif
 
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
it's the only reason i bought a wacom tablet, to make the snake game
 

Star-Dust

Expert
Licensed User
Longtime User
For Black Friday 2023 this is the offer on wacom library - €. 10

Valid from 20th to 26th November (GMT+1)
 
Top