Samsung Galaxy Book discussion thread

Discussion in 'Samsung' started by JoeS, Feb 26, 2017.

  1. LeoZappa

    LeoZappa Pen Pal - Newbie

    Messages:
    39
    Likes Received:
    39
    Trophy Points:
    26
    Piton812 likes this.
  2. Piton812

    Piton812 Pen Pal - Newbie

    Messages:
    16
    Likes Received:
    17
    Trophy Points:
    6
    To be able to colibrate the pen we should have this coordinates.
    For now we don't know how to get the coordinates of the pen.
    If somebody can explain how to get ALL raw data from pen then we can figure out and convert this information to coordinates.
    For now we don't understand what is ALL data from pen becouse we can see only part of data from pen (as I think).
    The script I published is based on script for MS Surface device. The original script did not work as holding right click it worked as just click.
    To find out why the script not works as holding click we modified the script to make it write the log of commands goes from pen. After that we saw the pen activity but we can't say is it ALL data from pen or not becouse we don't know is ALL the commands wich goes from pen logging or just part of commands logging.
    From log we determine what commands and how we have to process to be able to get the holding right mouse button function. Using this conclusion we modfied the script get the right mouse holding click works. For now this script does not take into accaunt requirements of another users discribed above. To modify the script taking into accaunt those requirements we have to understand ALL the commands goes from pen, include the coordinate information. For now I don't see the coordinate data from the pen activity information I logged.
     
    LeoZappa likes this.
  3. Piton812

    Piton812 Pen Pal - Newbie

    Messages:
    16
    Likes Received:
    17
    Trophy Points:
    6
    Thanx! I think thats what will help us to figure out the coordinate data. I'll try it and tell about the result in the evening.
     
    WillAdams and LeoZappa like this.
  4. yodamiked

    yodamiked Scribbler - Standard Member

    Messages:
    141
    Likes Received:
    88
    Trophy Points:
    41
    @dstrauss In regards to your quest to make the folio keyboard more stable, I wonder how stiff a re-purposed Lenovo Yoga hinge would be. I'm envisioning attaching it to the outside of the case along the seam near where the keyboard connects (but on the outside), with the back of the case laying flat against the device as it does when it's closed (essentially turning it into a standard laptop, but allowing you to still disconnect the GB from the keyboard when wanted). Kinda doubt the yoga hinge is stiff enough to support the weight, but you never know.

    https://www.ebay.com/itm/Original-f...h=item2cd9e5552f:g:KzIAAOSwISNbfWfV:rk:4:pf:0

    The other option would be to take the entire hinge and kickstand from one of the miix line, and attach it to the back of the case, but that would obviously add a bit of bulk.

    https://www.ebay.com/itm/Lenovo-Ide...dbAKr~:sc:USPSPriority!10044!US!-1:rk:38:pf:0

    I imagine neither would be the prettiest solution, but I'm curious if you could make something functional out of it. Either way, you'd probably want to experiment on an extra keyboard case, rather than your own.

    https://www.ebay.com/itm/Samsung-Ga...lPaddedFlatRateEnvelope!10044!US!-1:rk:1:pf:0
     
    wytn and dstrauss like this.
  5. Piton812

    Piton812 Pen Pal - Newbie

    Messages:
    16
    Likes Received:
    17
    Trophy Points:
    6
    Yes that was what we need. I managed to decrypt and calculate the coordinates of cursor from the pens information flow... and now we modifing the script... so tomorrow I'll publish new one...
     
    LeoZappa likes this.
  6. dstrauss

    dstrauss Comic Relief Senior Member

    Messages:
    10,064
    Likes Received:
    8,276
    Trophy Points:
    331
    Yoda - you are the Jedi master. I have one of the Best Buy (harder) covers I plan to experiment with but I went ahead and bought the one above as a spare - it's the weak link in the GB12 chain anyway. The Lenovo hinge could be the answer, but attachment and stiffness are a concern, especially not knowing the electronics inside the existing keyboard. It may be hopeless in trying to fashion something to support that floppy hinge, but I'll keep the tribe posted.
     
    DRTigerlilly and yodamiked like this.
  7. Piton812

    Piton812 Pen Pal - Newbie

    Messages:
    16
    Likes Received:
    17
    Trophy Points:
    6
    The script of the right mouse button for SGB12 was rewrited. Now script works using the coordinates of the cursor position and after S-pen click force the position of the cursor to the place where the click was. So maybe in some apps the problem you discribe can be solve (let know please). For example (from my tests) previuos script did not work correctly when you click on the icons in start menu (click happend somewhere out of the start windows where the cursor was before it goes in Start menu area). In this script this problem solved. But still there is some apps where right click not working. Based on my observation emulation of the right button mouse using the autohotscript works well in apps designed to work excluding with mouse. But If we try to use autohotkey scripts in apps designed to work with tablet pens then those apps will ignore the mouse buttons emulation of autohotkey script (For example Krita works with this script but not in all windows, namely it's not work in main window of Krita in canvas). When there is the pen activity those apps require the pens commands not mouse commands . So to emulate the right mouse button in this case we have to understand how those apps (for example Krita) read the commands.

    The link for new "ready to use" script is here:

    https://yadi.sk/d/mO4qYrFefpzdVw

    The content of the script is here:
    SendMode Input
    SetWorkingDir %A_ScriptDir%

    ; Set up our pen constants
    global PEN_HOVERING := 0 ; Pen is inside the area where screen see the pen and pen and don't touch the screen.
    global PEN_TOUCHING := 1 ; Pen is touching screen.
    global PEN_BTN_HOVERING := 8 ; Button is pressed with pen is inside the area where screen see the pen and pen and don't touch the screen.
    global PEN_BTN_TOUCHING := 12 ; Button is pressed with pen is touching screen.

    /*
    The package from pen data flow
    Package consist of 26 blocks
    00 0 0 0000 0011 1111 11 1122 2222 ; Blocks address with size 4 bits
    01 2 3 4567 8901 2345 67 8901 2345 ;

    02 2 0 0000 0000 0000 20 0000 0000 ; Left Up of the screen
    02 0 0 0000 0000 0000 20 0000 0000 ; Out of screen

    02 2 0 B662 CC41 0000 20 0000 0000 ; Right Down of the screen
    02 0 0 B662 CC41 0000 20 0000 0000 ; Out of screen

    02 2 0 0000 0000 0000 58 0000 0000 ; Almost out of the screen (but screen still see the pen)
    02 2 0 0000 0000 0000 00 0000 0000 ; Almost touching the screen (but not touching)
    02 2 1 0000 0000 0100 00 6400 8403 ; Touching the screen

    Resume:
    xx x x xxxx xxxx xxxx xx #### #### ; ????
    xx x x xxxx xxxx xxxx ## xxxx xxxx ; Z position
    xx x x xxxx xxxx #### xx xxxx xxxx ; ????
    xx x x xxxx #### xxxx xx xxxx xxxx ; Y position
    xx x x #### xxxx xxxx xx xxxx xxxx ; X position
    xx x # xxxx xxxx xxxx xx xxxx xxxx ; Using mode
    xx # x xxxx xxxx xxxx xx xxxx xxxx ; Connection mode
    ## x x xxxx xxxx xxxx xx xxxx xxxx ; ????

    Connection mode:
    2 - Connection with pen exists
    0 - Lose connection with pen

    Using mode:
    0x00 ( 0) - Hovering
    0x01 ( 1) - Touching (after touching button will not be active)
    0x08 ( 8) - Button is pressed when hovering
    0x0C (12) - Touching with button pressed (after touching button will not be active)

    X position pen:
    0000 - minimum = 0
    (B862) 0x62B8 - about maximum = 25272 (2160 points) 12 pen points in 1 screen point
    Cursor X position = X position pen / 12

    Y position pen:
    0000 - minimum = 0
    (D041) 0x41D0 - about maximum = 16848 (1440 points) 12 pen points in 1 screen point
    Cursor Y position = Y position pen / 12
    */
    /*
    Convert blocks of package to date structure from variables

    Package consist of 26 blocks
    00 0 0 0000 0011 1111 11 1122 2222 ; Blocks address with size 4 bits
    01 2 3 4567 8901 2345 67 8901 2345 ;

    Data structure from variables:
    UInt (32 bits) (variables 1)
    00000000 ; Blocks address with size 4 bits
    67452301 ;

    UInt (32 bits) (variables 2)
    11111100 ; Blocks address with size 4 bits
    45230189 ;

    UInt (32 bits) (variables 3)
    22221111 ; Blocks address with size 4 bits
    23018967 ;

    UInt (32 bits) (variables 4)
    33222222 ; Blocks address with size 4 bits
    01896745 ;

    */

    ; Send Alt, Ctrl and Shift keys along with the right-click if
    ; necessary
    SendModifierKeys() {
    static lastAlt := 0
    static lastCtrl := 0
    static lastShift := 0
    AltState := GetKeyState("Alt")
    CtrlState := GetKeyState("Ctrl")
    ShiftState := GetKeyState("Shift")
    if (AltState <> lastAlt) {
    if (AltState)
    {
    Send {Alt Down}
    } else {
    Send {Alt Up}
    }
    lastAlt := AltState
    }

    if (CtrlState <> lastCtrl) {
    if (CtrlState) {
    Send {Ctrl Down}
    } else {
    Send {Ctrl Up}
    }
    lastCtrl := CtrlState
    }

    if (ShiftState <> lastShift) {
    if (ShiftState) {
    Send {Shift Down}
    } else {
    Send {Shift Up}
    }
    lastShift := ShiftState
    }
    }

    ; Calucation radius offset cursor mouse
    RadiusMouseOffset(mouseXpos_Old, mouseXpos, mouseYpos_Old, mouseYpos){
    Local RadiusTrimerDisableOnMouse := 100
    Local dX := mouseXpos_Old - mouseXpos
    Local dY := mouseYpos_Old - mouseYpos
    if (sqrt(dX * dX + dY * dY) < RadiusTrimerDisableOnMouse){
    MouseMove %mouseXpos_Old%, %mouseYpos_Old%, 0 ;Send to system cursor old position of mouse/pen
    }else{
    MouseMove %mouseXpos%, %mouseYpos%, 0 ;Send to system cursor new position of mouse/pen
    }
    }

    #include AHKHID.ahk

    WM_INPUT := 0xFF
    USAGE_PAGE := 13
    USAGE := 2

    AHKHID_UseConstants()

    AHKHID_AddRegister(1)
    AHKHID_AddRegister(USAGE_PAGE, USAGE, A_ScriptHwnd, RIDEV_INPUTSINK)
    AHKHID_Register()

    OnMessage(WM_INPUT, "Work")

    Work(wParam, lParam) {

    Local type, inputInfo, inputData, raw, UsingMode, ConnectionMode
    ; static iii := 0
    static lastInput := -1 ; Last code for compare with constants
    static sPen_RBtn := 0 ;Last state of pen
    Local sPen_Xpos ;X position cursor of pen
    Local sPen_Ypos ;Y position cursor of pen
    ; Local sPen_Zpos ;Z position cursor of pen
    Local mouseXpos ;X position cursor of mouse
    Local mouseYpos ;Y position cursor of mouse
    Local mouseXpos_Old ;X position cursor of mouse
    Local mouseYpos_Old ;Y position cursor of mouse
    Critical

    ;Get device type
    type := AHKHID_GetInputInfo(lParam, II_DEVTYPE) ;Connect to device
    if (type = RIM_TYPEHID) { ;if type device is "pen"
    inputData := AHKHID_GetInputData(lParam, uData) ;Connect to commands flow of pen

    sPen_Xpos := NumGet(uData, 2, "WORD") ;Read X position cursor of pen (offset on 2 bytes in package, size in 16 bits (2 bytes))
    sPen_Ypos := NumGet(uData, 4, "WORD") ;Read Y position cursor of pen (offset on 4 bytes in package, size in 16 bits (2 bytes))
    sPen_Xpos := (sPen_Xpos & 0xFFFF)
    sPen_Ypos := (sPen_Ypos & 0xFFFF)
    mouseXpos := sPen_Xpos / 12 ; Convert to X position cursor for mouse
    mouseYpos := sPen_Ypos / 12 ; Convert to Y position cursor for mouse
    /*
    sPen_Zpos := NumGet(uData, 8, "UChar") ;Read Z position cursor of pen (offset on 8 bytes in package, size in 8 bits (1 byte))
    */
    raw := NumGet(uData, 1, "UChar") ;Read Z position cursor of pen (offset on 8 bytes in package, size in 8 bits (1 byte))
    UsingMode := raw & 0x1F ;Decode command to code using mode for compare with constants
    ConnectionMode := raw & 0x20 ; Decode command to code connection mode for tracking the information flow from pen till screen see the pen

    ; iii++
    ; if (mod(iii,2) = 0){
    ; FileAppend, >[%sPen_Xpos%][%sPen_Ypos%].[%mouseXpos%][%mouseYpos%].[%UsingMode%].[%ConnectionMode%]`n, *C:\draw\777.txt
    ; }else{
    ; FileAppend, >[%sPen_Xpos%][%sPen_Ypos%].[%mouseXpos%][%mouseYpos%].[%UsingMode%].[%ConnectionMode%], *C:\draw\777.txt
    ; }

    if (ConnectionMode <> 0){ ; Connection with pen exists
    if (UsingMode <> lastInput) { ;Check the difference commands in flow
    if (UsingMode == PEN_BTN_HOVERING){ ;New code is "hovering + btn"
    sPen_RBtn := 1 ;Mark pressed button state
    ; MouseMove -100, -100, 0 ;Send to system cursor position of mouse/pen out of the screen (Krita and Chrome cheating)
    ; Click left
    MouseMove %mouseXpos%, %mouseYpos%, 0 ;Send to system cursor position of mouse/pen
    mouseXpos_Old := mouseXpos
    mouseYpos_Old := mouseYpos
    SendModifierKeys()
    Send {RButton Down} ;Right button pressed
    }else{
    if (lastInput == PEN_BTN_HOVERING){ ;Last code is "hovering + btn"
    ; RadiusMouseOffset(mouseXpos_Old, mouseXpos, mouseYpos_Old, mouseYpos)
    SendModifierKeys()
    Send {RButton Up} ;Right button is release
    }
    sPen_RBtn := 0 ;Mark button released state
    }
    lastInput := UsingMode ;Save new code for new loop
    }
    }else{ ; Lost connection with pen
    if (sPen_RBtn <> 0){ ;Last state of pen "Button is pressed"
    ; RadiusMouseOffset(mouseXpos_Old, mouseXpos, mouseYpos_Old, mouseYpos)
    SendModifierKeys()
    Send {RButton Up} ;Right button is release
    }
    }
    }
    }

    The instruction how to use is here:
    1 - Download AutoHotKey. I recommend portable version no need to install (download "AutoHotkey.zip" from official site https://autohotkey.com/)

    2 - Get the script. For this download the "ready to use" script file from this link:
    https://yadi.sk/d/mO4qYrFefpzdVw
    And Put the script to the same folder where your Autohotkey folder is

    3. - Download the library file "AHKHID.ahk" and put it in same folder where your Autohotkey folder is (download it from https://github.com/jleb/AHKHID/)

    4. - Now you have to run the script using Autohotkey app. To do that: right click on the script file you get on step 2 (script name "spen_by_Serega.ahk"). In context menu choose "properties" in next menu choose "Change" button where "Open with" is and in the next menu in the bottom choose"More apps" and then choose "Look for another app on this PC" and then you have to choose the folder "Autohotkey_1.1.30/00" and in this folder choose file "AutohotkeyU64.exe" then in the menu choose "apply" and "OK".

    4.1. - Just make double left clik on script file to run it. In right bottom corner of you screen you'll see the green Autohotkey icon that means that scripts works and now your S-pen button works the same way as right mouse button.

    5. Enjoy
     
    Last edited: Nov 9, 2018
    WillAdams, Telgar and LeoZappa like this.
  8. LeoZappa

    LeoZappa Pen Pal - Newbie

    Messages:
    39
    Likes Received:
    39
    Trophy Points:
    26

    Haven't even finished reading, but THANK YOU!!!!!!! Will test later today or tomorrow, this is G R E A T !


    ---EDIT: there is still some offset in UWP applications. Did you know that the Autohotkey function MouseClick allows to specify the X,Y coordinates where the click must be placed? I can't understand your script, but I suspect you wrote code to artificially move the mouse position, while I believe you could let Autohotkey do that for you. That might solve the offset in UWP apps... (Here is the documentation)
     
    Last edited: Nov 9, 2018
  9. Piton812

    Piton812 Pen Pal - Newbie

    Messages:
    16
    Likes Received:
    17
    Trophy Points:
    6
    About offset, I agree there was an error in code. It's fixed try new version of the S-pen script:

    https://yadi.sk/d/MFCgIcoHPiH_ww

    1 - Download AutoHotKey. I recommend portable version no need to install (download "AutoHotkey.zip" from official site https://autohotkey.com/)

    2 - Get the script. For this download the "ready to use" script file from this link:
    https://yadi.sk/d/MFCgIcoHPiH_ww
    And Put the script to the same folder where your Autohotkey folder is

    3. - Download the library file "AHKHID.ahk" and put it in same folder where your Autohotkey folder is (download it from https://github.com/jleb/AHKHID/)

    4. - Now you have to run the script using Autohotkey app. To do that: right click on the script file you get on step 2 (script name "spen_by_Serega.ahk"). In context menu choose "properties" in next menu choose "Change" button where "Open with" is and in the next menu in the bottom choose"More apps" and then choose "Look for another app on this PC" and then you have to choose the folder "Autohotkey_1.1.30/00" and in this folder choose file "AutohotkeyU64.exe" then in the menu choose "apply" and "OK".

    4.1. - Just make double left clik on script file to run it. In right bottom corner of you screen you'll see the green Autohotkey icon that means that scripts works and now your S-pen button works the same way as right mouse button.

    5. Enjoy

    Let me know please if it will not be work in some app (and tell me what the app exactly do you use where it's not working... I'll test it myself and try to find the solution).

    For those who whant to use this script on some another device (not Samsung Galaxy Book 12) pay attention please that the script by the link above "as it is" works correctly only on Samsung galaxy book 12 (becouse there is the settings (resolution and coordinates) of the device inside the script and for now there is Samsung Galaxy Book 12 settings).
    So if you whant to use this script with some another Samsung device (with Galaxy book 10 for example) you have to change relevant settings inside the script namely the Minimal and Maximal coordinates of the pen regarding the screen borders of your device. Also you can change those settings if you whant to get activity area of your device not for full screen but for part of it.
    How to get settings of your device I discribe in instruction bellow.


    If you use this script on Samsung galaxy book 12 you don't have to change anything, just run the script and everything will works well. But if you whant to use this script on another Samsung device (for example on Samsung galaxy book 10) you have to change the settings of device inside the script.
    To be able to get the settings of your NOT Samsung Galaxy Book 12 device I modify the script "Example 2" from https://autohotkey.com/board/topic/38015-ahkhid-an-ahk-implementation-of-the-hid-functions/
    so now it can display Minimal and Maximal coordinates of your pen and current coordinates of the mouse.

    So to get settings information of your device do the next steps:

    1. Download the modified version of the script "Example 2" script from link below:
    https://yadi.sk/d/Dfq_IrprVSy64g
    and put it inside your Autohotkey folder.

    2. Run the script example2_with_min_max_XY.ahk

    3. In the menu fill the fields:
    - UsagePage = 13
    - Usage = 2
    After that push the "Add" button and after that push "Call" button.

    4. Now you have to lead the tip of the pen around the perimeter of the screen (along the every edge (border) of the screen. Getting the Maximal and Minimal coordinates is completed when values of the coordinates (of X Y) will stop changes from pen movements. This values (which stop changes) is your Minimal and Maximal coordinates.

    5. After getting the Maximal and Minimal coordinates you have to change it in the script (it is the first couple strokes of the script). By the default it is Samsung Galaxy book 12 values:

    global Xmin := 0
    global Xmax := 25272
    global Ymin := 0
    global Ymax := 16848
    ; write the resolution of your display
    global screenXmax := 2160
    global screenYmax := 1440

    Change it to yours device values you get from "example2_with_min_max_XY.ahk" script. And write the resolution of your screen (by default it is 2160x1440).

    6. Now you should save changes of your script and run it.
     
    Last edited: Nov 15, 2018
  10. Piton812

    Piton812 Pen Pal - Newbie

    Messages:
    16
    Likes Received:
    17
    Trophy Points:
    6
    New version of the script works well in ClipStudio for changing the brush size. Link is in my previous post

    http://forum.tabletpcreview.com/thr...-discussion-thread.71795/page-370#post-528013
     
Loading...

Share This Page