Changeset 300 for trunk


Ignore:
Timestamp:
09/24/06 10:34:39 (18 years ago)
Author:
Nicholas Riley
Message:

HIDRemotemodule.m: Support for Logitech Music Anywhere USB headphones.

libHIDUtilities.a, HID_Utilities_External.h: built from <http://homepage.mac.com/geowar1/.Public/Sample%20Code/HID_Utilities.sit>

setup.py: Build HIDRemote module.

StreamVision.py: Support Bluetooth headphones; don't turn on/off the
stereo if we use the play/pause control on the headphones.

Location:
trunk/StreamVision
Files:
3 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/StreamVision/StreamVision.py

    r252 r300  
    33
    44from appscript import app, k, its, CommandError
    5 from AppKit import NSApplication, NSBeep, NSSystemDefined, NSURL, NSWorkspace
     5from AppKit import NSApplication, NSApplicationDefined, NSBeep, NSSystemDefined, NSURL, NSWorkspace
    66from Foundation import NSDistributedNotificationCenter
    77from PyObjCTools import AppHelper
     
    1010import struct
    1111import scrape
     12import HIDRemote
    1213import HotKey
    1314
     
    1819kEventHotKeyPressedSubtype = 6
    1920kEventHotKeyReleasedSubtype = 9
     21
     22kHIDUsage_Csmr_ScanNextTrack = 0xB5
     23kHIDUsage_Csmr_ScanPreviousTrack = 0xB6
     24kHIDUsage_Csmr_PlayOrPause = 0xCD
    2025
    2126growl = app('GrowlHelperApp')
     
    138143        iTunes.current_track.rating.set(rating)
    139144
    140     def playPause(self):
     145    def playPause(self, useStereo=True):
    141146        iTunes = iTunesApp()
    142147        was_playing = (iTunes.player_state.get() == k.playing)
     
    146151            iTunes.browser_windows[1].view.set(iTunes.user_playlists.filter(its.name=='Stations')[1].get())
    147152            iTunes.play()
    148         if HAVE_XTENSION:
     153        if HAVE_XTENSION and useStereo:
    149154            if iTunes.player_state.get() == k.playing:
    150155                XTensionApp().turnon('Stereo')
     
    190195        self.registerZoomWindowHotKey()
    191196        NSDistributedNotificationCenter.defaultCenter().addObserver_selector_name_object_(self, self.displayTrackInfo, 'com.apple.iTunes.playerInfo', None)
     197        try:
     198            HIDRemote.connect()
     199        except OSError, e:
     200            print "failed to connect to remote: ", e
    192201
    193202    def sendEvent_(self, theEvent):
    194         if theEvent.type() == NSSystemDefined and \
     203        eventType = theEvent.type()
     204        if eventType == NSSystemDefined and \
    195205               theEvent.subtype() == kEventHotKeyPressedSubtype:
    196206            self.hotKeyActions[theEvent.data1()]()
     207        elif eventType == NSApplicationDefined:
     208            key = theEvent.data1()
     209            if key == kHIDUsage_Csmr_ScanNextTrack:
     210                iTunesApp().next_track()
     211            elif key == kHIDUsage_Csmr_ScanPreviousTrack:
     212                iTunesApp().previous_track()
     213            elif key == kHIDUsage_Csmr_PlayOrPause:
     214                self.playPause(useStereo=False)
    197215        super(StreamVision, self).sendEvent_(theEvent)
    198216
    199217if __name__ == "__main__":
    200218    AppHelper.runEventLoop()
     219    HIDRemote.disconnect() # XXX do we get here?
  • trunk/StreamVision/setup.py

    r211 r300  
    1919    ext_modules=[Extension('HotKey',
    2020                           sources=['HotKeymodule.c'],
    21                            extra_link_args=['-framework', 'Carbon'])],
     21                           extra_link_args=['-framework', 'Carbon']),
     22                 Extension('HIDRemote',
     23                           sources=['HIDRemotemodule.m'],
     24                           extra_link_args=['-framework', 'Cocoa',
     25                                            '-framework', 'IOKit',
     26                                            'libHIDUtilities.a'])],
    2227    data_files=["English.lproj"],
    2328    options=dict(py2app=dict(plist=plist)),
Note: See TracChangeset for help on using the changeset viewer.