Samsung Galaxy Book discussion thread

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

  1. Piton812

    Piton812 Pen Pal - Newbie

    Messages:
    14
    Likes Received:
    14
    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.
  2. dstrauss

    dstrauss Comic Relief Senior Member

    Messages:
    8,215
    Likes Received:
    5,968
    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.
  3. Piton812

    Piton812 Pen Pal - Newbie

    Messages:
    14
    Likes Received:
    14
    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.
  4. LeoZappa

    LeoZappa Pen Pal - Newbie

    Messages:
    25
    Likes Received:
    24
    Trophy Points:
    6

    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
  5. Piton812

    Piton812 Pen Pal - Newbie

    Messages:
    14
    Likes Received:
    14
    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 at 3:25 AM
  6. Piton812

    Piton812 Pen Pal - Newbie

    Messages:
    14
    Likes Received:
    14
    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
     
  7. nnthemperor

    nnthemperor Scribbler - Standard Member Senior Member

    Messages:
    1,237
    Likes Received:
    268
    Trophy Points:
    101
    The battery on the GB10.6 is even wise than I thought. Had it charged up (85%, set it to that) and attended a 3-hr lecture. Just recording voice and taking notes in UWP OneNote app with Wi-Fi on sucked the juice down to 15% by the end of the lecture.
    I really love the device, why doesn't Sammy give us the version 2 of it? I'll take the WOS and pay a little more.

    Sent from my SM-N950F using Tapatalk
     
    WillAdams likes this.
  8. dstrauss

    dstrauss Comic Relief Senior Member

    Messages:
    8,215
    Likes Received:
    5,968
    Trophy Points:
    331
    Back to that floppy origami keyboard thingy...

    Yesterday at BB I finally saw the iPad Pro 12.9 in it keyboard folio, and it is a solid design like a laptop...as muttered "why the H can't Samsung do this," I then realized Apple cheated - or at least can cheat, BECAUSE THEY DON'T SUPPORT A TOUCHPAD/MOUSE. Because of that, the keyboard sits on the forward edge of the base, so the screen and back support can rest on the back of that plate.

    Another marvel of Apple engineering enabled by its limited feature set...

    SO my latest thought is to just get a good leather folio I like, reinforce one side with a stiff plat of some sort, then just set the GB12 on the folio for stability. I like carrying a small folio anyway, so this is a good "sour grapes" alternative to trying to find some way to attach support to the existing keyboard.
     
    Bishop and DRTigerlilly like this.
  9. DRTigerlilly

    DRTigerlilly Tablet Lead Mod (Retired) Super Moderator

    Messages:
    7,213
    Likes Received:
    489
    Trophy Points:
    271
    I was thinking about the Incipio case for the GB12 for you. I used something like that for the original SP1 b/c of the limited kickstand. Like you said it would need reinforcement though, b/c it will weaken over time.
     
    dstrauss likes this.
  10. Steve B

    Steve B Moderator Moderator

    Messages:
    3,236
    Likes Received:
    415
    Trophy Points:
    151
    Also worth saying that Apple recognizes the device is a touch screen first. As such, I would assume the goal is to get you close enough to the screen that doing touch input, for selection processes, scrolling, and such, is as easy and ergonomic as possible. Less gorilla arm. That's nice. It's a good design for a certain kind of input.

    All about individual needs. I'm sure there are people who wish Windows devices helped make touch better by making the screen closer.
     
Loading...

Share This Page