Author Topic: Not Support Samsung S-Pen Plugins?  (Read 11141 times)

acura

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Not Support Samsung S-Pen Plugins?
« on: January 05, 2014, 01:20:16 PM »
Hi, I Using NGUI Plugin,
It's Very Beautiful User Interface Tool!

Now, I made a game by Samsung Galaxy Note Series,
This device has S-Pen(Wacom Stylus)

Samsung Support a S-Pen SDK ( http://developer.samsung.com/s-pen-sdk/sdk/S-Pen-SDK-2-3 )
and Unity S-Pen Extension ( http://developer.samsung.com/s-pen-sdk/unity-extension )

Using S-Pen SDK/Extension
onGUI Available S-Pen Touch Event, But NGUI Not Available S-Pen Touch Event ;-(

Please NGUI Support S-Pen Touch Event

breakmachine

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 71
    • View Profile
Re: Not Support Samsung S-Pen Plugins?
« Reply #1 on: January 07, 2014, 06:05:09 AM »
Any plans to support Stylus?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Not Support Samsung S-Pen Plugins?
« Reply #2 on: January 07, 2014, 09:09:18 AM »
NGUI can't support third party extensions.

As for the stylus, I believe Unity treats it as a mouse device. UICamera.Awake force-disables the mouse on mobile devices. You can comment out that part if you like.

breakmachine

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 71
    • View Profile
Re: Not Support Samsung S-Pen Plugins?
« Reply #3 on: January 09, 2014, 04:18:17 AM »
I tried enabling useMouse on Start() but I get some issues regarding hover on UIImageButton. If I drag and release (using touch) it's as if I leave an invisible mouse pointer.

After that I tried enabling useMouse and disabling useTouch if Event.current.type==EventType.MouseDown and vice versa but it didn't help either.

Any ideas?
« Last Edit: January 09, 2014, 04:42:45 AM by breakmachine »

Shifty Geezer

  • Full Member
  • ***
  • Thank You
  • -Given: 7
  • -Receive: 9
  • Posts: 226
    • View Profile
Re: Not Support Samsung S-Pen Plugins?
« Reply #4 on: January 09, 2014, 08:30:00 AM »
How about using the standard S-Pen interface but calling...

target.SendMessage("OnPress", pressed, SendMessageOptions.DontRequireReceiver);

...and the like to the intended NGUI widget? There's a script UIForwardEvent that lists multiple different event options, so you should easily be able to capture S-Pen events like hover and button-press and call whatever event you want in response. You can get the UI control underneath using the UICamera, I think.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Not Support Samsung S-Pen Plugins?
« Reply #5 on: January 09, 2014, 06:59:34 PM »
Unity likely treats the stylus as two things at once -- creating both mouse and touch devices from a single event, which is why you are seeing oddities.

Also, if sending manual events, use UICamera.Notify function instead of SendMessage. It's cleaner. :)

breakmachine

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 71
    • View Profile
Re: Not Support Samsung S-Pen Plugins?
« Reply #6 on: January 10, 2014, 07:30:39 AM »
@ArenMook
I've tried running on a device that doesn't even have stylus. I get the oddities simply by enabling useMouse and using touch/finger.
We just got a tablet with stylus to the office so I'll research more with that.

@Shifty Geezer
Could be a workaround absolutely. Not sure if drag will work though.
« Last Edit: January 10, 2014, 07:39:36 AM by breakmachine »

breakmachine

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 71
    • View Profile
Re: Not Support Samsung S-Pen Plugins?
« Reply #7 on: January 10, 2014, 09:16:32 AM »
Btw... I'm using SendMessage("OnPress") when "clicking" the Android back button and I get an null reference error in UIButtonColor.cs because UICamera.currentTouch is null.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Not Support Samsung S-Pen Plugins?
« Reply #8 on: January 10, 2014, 05:29:40 PM »
Yes, you need to set UICamera.currentTouch = UICamera.controller (or UICamera.GetMouse(0) if you have an older version) prior to calling UICamera.Notify.

breakmachine

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 71
    • View Profile
Re: Not Support Samsung S-Pen Plugins?
« Reply #9 on: January 15, 2014, 09:33:47 AM »
Seems like Unity's support for stylus sends mouse-events. And so does touches.

This means, that if I wan't to enable stylus I have to set UICamera.useMouse = true. But then NGUI thinks I have a mouse and when I release/stop a touch it thinks there's a mouse pointer on buttons etc leaving them in hovered state.

Is there any way of stopping hover/drag or maybe moving the fake pointer to 0.0 on mouseUp?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Not Support Samsung S-Pen Plugins?
« Reply #10 on: January 15, 2014, 09:27:49 PM »
If Unity sends both mouse and touch events from the stylus, there is not much NGUI can do. One event causing two events is the same problem that occurs in Unity Remote as well, and is a stupid thing on Unity's side.

breakmachine

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 3
  • Posts: 71
    • View Profile
Re: Not Support Samsung S-Pen Plugins?
« Reply #11 on: January 16, 2014, 03:14:04 AM »
Sorry, Im not making myself understood. It's touching the screen with a finger that generate both mouse and touch events. Stylus only generates mouse events. So if I enable useMouse NGUI treats my finger as a mouse pointer since it's generating mouse events. Lifting the finger from the screen is as if I leave the mouse pointer there and buttons etc underneath are left in a hover state.

I can see two solutions:

1. I detect if I'm using stylus or not and then toggle useMouse. But this is quite tricky since I can't use the stylus sdk. I've tried using Input.simulateMouseWithTouches = false but that didn't do anything. I've also tried using Input.mousePresent but it seems to be set to true by finger touches aswell. The only way to tell a difference from touches and stylus is that stylus is not triggering touch events. Maybe if I have a timer or something I could switch to useMouse if there hasn't been any touchevents for x amount of time. But it seems like a pretty dirty solution.

2. Have useMouse set to true but still treat touch.end to stop hovering. This however I dont know if I could do without editing ngui classes which I'd prefer not to.

What do you think?

**update**
I ended up with a combination. Basically I detect if I'm using a stylus by detecting if the mousePosition has changed and touchCount==0. I also had to add a function in UICamera to stop OnHover. I've attached my solution.
« Last Edit: January 16, 2014, 11:00:35 AM by breakmachine »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Not Support Samsung S-Pen Plugins?
« Reply #12 on: January 17, 2014, 12:09:55 AM »
That's pretty clever.

tkok

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 16
    • View Profile
Re: Not Support Samsung S-Pen Plugins?
« Reply #13 on: February 12, 2014, 07:07:06 AM »
- -
**update**
I ended up with a combination. Basically I detect if I'm using a stylus by detecting if the mousePosition has changed and touchCount==0. I also had to add a function in UICamera to stop OnHover. I've attached my solution.

Thank you for your attachment. I had the same problem with the NGUI producing both events when I added mouse support to mobile devices.

Your code seems to fixed all of that. But there was line:
  1. if (mMouse[0]!=null) mMouse[0].last = null;
and my UICamera's MouseOrTouch class (type of mMouse[0]) has no "last" parameter. I just commented the line in code and it seems to work. Was there any real reason behind that line?

tkok

kennethljj

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 13
    • View Profile
Re: Not Support Samsung S-Pen Plugins?
« Reply #14 on: May 02, 2014, 01:39:54 AM »
I ended up with a combination. Basically I detect if I'm using a stylus by detecting if the mousePosition has changed and touchCount==0. I also had to add a function in UICamera to stop OnHover. I've attached my solution.

Hi,
Thanks for your attachment. May I know if I am supposed to attach the script to my camera object in every scene?