I am just getting re-started in Mac coding. Wrote the software for original
Dymo LabelWriter, and a Desk Accessory for FileMaker.
Have been reading about Carbon and Cocoa. It appears they will only pass me
events that occur in MY apps windows.
I need to write a reader for a barcode scanner, so I need access to all
that comes on the keyboard.
I used to use a product called KeyQuencer by Montalcini in Italy which
he said could never be converted to OS X and I suspect it is the event
police that cause the problem. It was somewhat like Automator.
Is there, in fact, a way to gain access to ALL events or even just keyboard
events? Is Carbon or Cocoa the only way to program for Mac?
Is there an asm compiler for OSX?
Thanks,
Ski
Reinder Verlinde - 25 May 2007 19:15 GMT
A:
> I need to write a reader for a barcode scanner,
B:
> so I need access to all that comes on the keyboard.
I do not see how B follows logically from A.
<http://developer.apple.com/referencelibrary/GettingStarted/GS_HardwareDr
ivers/index.html>
> I used to use a product called KeyQuencer by Montalcini in Italy which
> he said could never be converted to OS X and I suspect it is the event
> police that cause the problem. It was somewhat like Automator.
AFAIK, Automator does nothing that you could not also do on the system.
> Is there, in fact, a way to gain access to ALL events or even just keyboard
> events?
<http://developer.apple.com/documentation/Carbon/Reference/QuartzEventSer
vicesRef/index.html>
> Is Carbon or Cocoa the only way to program for Mac?
No. Other options include Java and wxWidgets, but there are many, many
more.
> Is there an asm compiler for OSX?
If you have installed the developer tools: /usr/bin/as.
From your question, it lt looks like you think you will need to use
assembler to do what you want. I doubt that.
Reinder
Chris Hanson - 28 May 2007 12:28 GMT
> I am just getting re-started in Mac coding. Wrote the software for original
> Dymo LabelWriter, and a Desk Accessory for FileMaker.
> Have been reading about Carbon and Cocoa. It appears they will only pass me
> events that occur in MY apps windows.
That's correct. Generally speaking, the only events your application
should be concerned with are those that occur when the user interacts
with it. This has some significant benefits. For example, application
code can become a lot simpler, since it only needs to deal with
situations it's affirmatively prepared for. Application code can also
block when it has nothing to do, freeing up CPU for other operations or
even (if the event load on the overall system is low enough) for the
CPU to be slowed or suspended by power management. No application on
Mac OS X should *ever* spin-wait for events.
> I need to write a reader for a barcode scanner, so I need access to all
> that comes on the keyboard.
The antecedent does not follow from the precedent. I worked on a suite
of applications that leveraged a barcode scanner that behaved as a USB
keyboard. All it required was using a custom subclass of NSApplication
and overriding -sendEvent: to observe keyboard events within my
application.
Sure, if the user pulled the trigger to scan something and the
application wasn't active, they got essentially random typing. For
this application - a custom line-of-business application - we could
just say "don't do that." Before making more work for yourself, see if
you can do the same thing.
If you *do* want to get lower-level access to the event stream, say
because you intend to filter it, there's pretty much only one way to
go: A Core Graphics event tap, described in the Quartz Event Services
Reference:
<http://developer.apple.com/documentation/Carbon/Reference/QuartzEventServicesRef
/Reference/reference.html>
Note
that due to the low level of the interface and the secure, multiuser
nature of Mac OS X, it won't be nearly as simple as (say) just
installing a jGNEFilter to monitor events. Also note that event taps
are only supported in Mac OS X 10.4 or later.
> I used to use a product called KeyQuencer by Montalcini in Italy which
> he said could never be converted to OS X and I suspect it is the event
> police that cause the problem. It was somewhat like Automator.
>
> Is there, in fact, a way to gain access to ALL events or even just keyboard
> events?
Event taps, as above.
> Is Carbon or Cocoa the only way to program for Mac?
> Is there an asm compiler for OSX?
Cocoa and Carbon are pretty much the only game in town for high-end
native applications. Java is also available and well-supported. If
you want to write command-line utilities only, you can of course use
the wealth of BSD-derived and POSIX APIs available on Mac OS X.
I would seriously question your priorities if you wanted to write
production code in assembly rather than leveraging high-level
frameworks like Cocoa. After all, if nothing else you'll have to write
your code twice, once for PowerPC-based Macs and once for Intel-based
Macs.
Assembly is great to use when you absolutely need it. But it should be
avoided at all costs when you don't. That's why you won't get very far
asking for an "asm compiler" for Mac OS X -- why would anyone bother
with anything like that standalone? -- but the Xcode suite does include
assemblers in addition to compilers.
-- Chris