Welcome, Guest. Please login or register.

Author Topic: Direct input  (Read 2403 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline KarlosTopic starter

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Direct input
« on: February 19, 2003, 12:28:51 PM »
Hi all,

Does anybody know an OS friendly way to directly query the absolute mouse position/button states from C?

I need this feature for an input abstraction layer (direct version) I'm working on:

class Mouse {
//...
public:
   static int directReadX(); // get current absolute xPos
   static int directReadY(); // get current absolute yPos
//...
};

I have looked around the includes/autodocs/RKMs and don't seem to find anything with which to implement the above interface.

I already have a buffered version which works by processing normal input events and that works fine. It's just the above direct access that's holding me up.

Cheers for any advice,

K
int p; // A
 

Offline Steady

Re: Direct input
« Reply #1 on: February 20, 2003, 02:24:23 PM »
MouseX and MouseY in struct IntuitionBase contains the mouse co-ordinates relative to the View (that being the entire display, not just an individual screen).
You could use these as they are not defined within the 'private' part of the IntuitionBase structure.
Obviously, use LockIBase()/UnlockIBase() when reading and make it quick.
 

Offline KarlosTopic starter

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: Direct input
« Reply #2 on: February 20, 2003, 02:36:14 PM »
Thanks matey. I don't suppose the currently active mouse button states are anywhere in there too?

-edit-

Assuming I only want to read said variables, is locking intution *strictly* required? I realise the value you get may be slightly old, but I doubt it will be too many pixels out (unless your really zoom the mouse along!)
int p; // A
 

Offline Rogue

  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 566
    • Show only replies by Rogue
    • http://www.hyperion-entertainment.com
Re: Direct input
« Reply #3 on: February 20, 2003, 05:22:35 PM »
The only thing that you could do is install an input handler. It is generally a bad idea, however, to grab the mouse globally. A much better approach would really be to use IntuiMessages.

Mouse coordinates can also be obtained from the current screen.

But if you have a window, the best way is really to use IDCMP. That way you won't read mouse coordinates that are supposed to go to Workbench or other stuff that is running.
Look out, I\'ve got a gun
 

Offline KarlosTopic starter

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: Direct input
« Reply #4 on: February 21, 2003, 12:09:28 PM »
Hi Rouge,

Thanks for the suggestions. I am aware that global mouse reading looks a bit silly, but I only wanted to add the absolute position stuff to the Mouse class to complete the interface.

For normal input, I do have an 'InputFocus' class interface (that utilizes IDCMP under AmigaOS) and thats working just fine.

Ultimately the classes I'm writing are for a multiplatform 'system abstraction layer' project. The intention is to provide a set of application building blocks that can take advantage of the underlying OS's abilities whilst giving a consistent programming interface.

This is a project I've been working on for some time and recently aimed for an internal version bump so everything is getting re written.

int p; // A