#!/usr/bin/python2
# coding:utf-8

# ----------------------------------------------------------------------------
# joy2mouse - control your mouse with your joystick/joypad
# Copyright (c) 2011 Daniel Nögel
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------------


import gobject
import gtk
from optparse import OptionParser
import sys

import joy2mouselib

gtk.gdk.threads_init()

parser = OptionParser()
parser.add_option("-p", "--profile",
                  action="store", dest="profile", default=None,
                  help="Select a profile from .joy2mouse")

(options, args) = parser.parse_args()


try:
    app = joy2mouselib.App(options)
except IOError:
    print "Joystick device not found"
    sys.exit(1)

try:
    loop = gobject.MainLoop() 
    loop.run() 
except (KeyboardInterrupt):
    app.mousethread.running = False
