multi-mouse software with HaXe

130 views
Skip to first unread message

Mark

unread,
Sep 20, 2014, 11:53:15 AM9/20/14
to haxe...@googlegroups.com
hi Guys,

Looking at Mouse event handler (either [import] flash... or openfl... or nme...) it seems HaXe is not prepared to work with multiple mice. Is that right or do I miss something?

If I'm right (which now I suppose :P)
Is this possible HaXe can implement detecting multiple mice / mouse event sources? In other words, can HaXe see -and differentiate- the input devices and their delta motion/click/etc data (arriving from drivers), or sees only the OS-translated screen-based pointer movement?


Thank you for the help in advance.


Cheers,
Mark

Dan Korostelev

unread,
Sep 20, 2014, 3:55:55 PM9/20/14
to haxe...@googlegroups.com
It's not really correct to talk about what Haxe itself supports here. Are you talking about OpenFL? Native target?

суббота, 20 сентября 2014 г., 19:53:15 UTC+4 пользователь Mark написал:

Mark

unread,
Sep 21, 2014, 6:21:37 AM9/21/14
to haxe...@googlegroups.com
maybe I was not clear...

haxe is written in ocaml as far as I know. the question is (not knowing ocaml or haxe's code) how haxe handles hardware events, coming from drivers? mouse events now, to be more specific. i.e. is this possible to implement in haxe to handle more mice at the same time (doing different actions!) or not?

if I'm correct, this has nothing to do with openFL or other libraries (built on top of haxe...) as those are just wrappers of events coming from haxe (which events come from host OS, which come from drivers, which come from hardware interrupts).


an example for a better understand:
in windows, one can use "the standard approach" and attach to mouse events sent by the OS and care about pointer location & movement & stuff (e.g. click) only.
but there's also raw input API. in that, windows sends over completion port, and other information too. the down-side is one has to figure out what happened -and act accordingly- from the raw data, not fancy processed data.
so if I want to write a software handing multiple mice, first I have to implement raw input API mouse event handling, as otherwise, using the standard libraries I would get only "mouse pointer events" so I can't tell  mouse1 from mouse2 - as OS hides that from me.

following the analogy, if the core language (haxe in this case) does not support (in win. terms) "accessing raw input API", I will never be able to use two mice with independent actions, as haxe can't tell the difference between mouse1 and mouse2 - so neither openFL, or whatever library ever can.

Dan Korostelev

unread,
Sep 21, 2014, 6:49:15 AM9/21/14
to haxe...@googlegroups.com
That analogy is wrong in the haxe case. What haxe compiler does is translate hx code to target code which is c++/js/c#/etc which is then compiled using respective compilers to a binary. That means, if you target c++, for example, you can access its API using externs. And OpenFL/Lime does exactly that (iirc it uses SDL to provide low level stuff).

воскресенье, 21 сентября 2014 г., 14:21:37 UTC+4 пользователь Mark написал:

Mark

unread,
Sep 21, 2014, 7:00:08 AM9/21/14
to haxe...@googlegroups.com
here is a "theoretical example" for a better understand, highlighting the issue. I stay with 'windows' as that's my kung fu but don't mind it. Could be linux or mac too :)


Added extra mouse pointer to windows or only Haxe can figure out there are more mice, doesn't matter.
For windows desktop implementation (which looks a bit pointless, though) and for a better understand see https://www.dicolab.com/

Let's say I want to write an application in Haxe, let's say with using openFL library (doesn't matter, in fact).

I want to add event listener for mouse actions so what I do? This:
addEventListener(MouseEvent.MOUSE_MOVE, stage_onMouseMove);


You see? I'm stuck already. What I should be able to do is the following:

var foo = getArrayOfMice(); //a silly yet powerful call :)
if (foo.count != 2) {
   
PopError("Sorry dude, this is a dual wield game. Install exactly two mice!");
   
BlowUpEverythingAndSailToTheSunset();
   
return;
} else {
   mouseA
= foo.mice[0];
   mouseB
= foo.mice[1];
}
addEventListener
(mouseA.MouseEvent.MOUSE_MOVE, stage_onRightHandMouseMove);
addEventListener
(mouseB.MouseEvent.MOUSE_MOVE, stage_onLeftHandMouseMove);


Could be I don't see the "big picture" and the above is impossible but this is exactly what I'd like to know - is there any way to do this in/with Haxe?


Thank you again and sorry if I was not clear at the first time ;)

Mark

unread,
Sep 21, 2014, 7:07:39 AM9/21/14
to haxe...@googlegroups.com
Hm, I can see now what the issue is with the idea. Haxe is really just "translating" hx code to whatever target I chose.

Could you please advice "which way to go" -with externs, perhaps?- to implement what I want? (if it's possible at all).
I assume what I posted before seen your answer is not possible and won't ever be :/

Dan Korostelev

unread,
Sep 21, 2014, 7:31:25 AM9/21/14
to haxe...@googlegroups.com
Whether you use OpenFL or not actually matters. I may be wrong, but I think OpenFL (or Lime to be exact) uses SDL library on native targets which doesn't support multiple mouses, so with OpenFL you can't use that.
That means that unless someone already did that, you gonna need to write a c++ "binding" library that receives events from the OS and translates it to haxe/c++ somehow. If you want to use OpenFL, you may also want to integrate it into its main loop.
I haven't actually worked with C++ target or OpenFL, but I think this article is relevant: http://old.haxe.org/doc/cpp/ffi

воскресенье, 21 сентября 2014 г., 15:00:08 UTC+4 пользователь Mark написал:

Mark

unread,
Sep 21, 2014, 9:00:10 AM9/21/14
to haxe...@googlegroups.com
Just looked into it a little: SDL 1.3 supported multiple mice (and keyboard) but actual 2.0(.3) version does not anymore. Weird stuff.

Anyways. Thank you for the help -especially with FFI-, I'll try to figure out something but it seems it won't be easy (especially without locking myself to windows desktop).


I wait with completion/close to see if anyone else -some are more active on business days :)- have some additional hints.


Thanks again,
Mark

Hugh

unread,
Sep 22, 2014, 1:03:12 AM9/22/14
to haxe...@googlegroups.com
Yes, this is nothing to do with haxe, and all to do with the library.  For flash, this is maybe not so clear, since the library is the flash runtime (which only supports one mouse).

You (or someone on your behalf) is going to need to hack one on the c++ based projects (nme or lime) to expose the extra mice to the haxe code.  These are based on sdl, so the information is there, be hard to get at.

If you know of a library or driver, you may be able to "poll" the positions of the extra mice - this may be easier if you you can get it to work because it may only be one or two functions you need to glue in.

Hugh

Mark

unread,
Sep 22, 2014, 7:25:52 AM9/22/14
to haxe...@googlegroups.com
Thank you Hugh. Indeed you are also correct -as well as Dan-.

The thing is then, to sum it up, I have to grab a v1.3 SDL (which had dual-mouse implemented via raw input API), merge the code into the latest SDL (as for some reason it was removed in later versions - ???), then try to patch up some library to handle this; and don't forget I'm not platform independent anymore as I can't compile to flash, and probably need modifications for Mac and/or Linux releases (as raw input API is windows).


Thank you again guys! ;)

Tarwin Stroh-Spijer

unread,
Sep 22, 2014, 1:50:32 PM9/22/14
to haxe...@googlegroups.com
Just a quick question; why do you need two mouse inputs? If it's a multitouch display for example there is probably other options than "mouse".



Tarwin Stroh-Spijer
_______________________

phone: +1 650 842 0920

Developer at Fanplayr Inc. (Palo Alto)
Original at Touch My Pixel (touchmypixel.com)
_______________________

--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.

Mark

unread,
Sep 22, 2014, 3:07:36 PM9/22/14
to haxe...@googlegroups.com, tar...@touchmypixel.com
it's super-secret for a revolutionary game software. no (multi)touch display(s) involved
Reply all
Reply to author
Forward
0 new messages