merges qt4 into trunk
git-svn-id: svn://svn.code.sf.net/p/qjoypad/code/trunk@94 c05e91a0-76c8-4ec0-b377-ef19ce7cc080
This commit is contained in:
committed by
virtuoussin13
parent
17ed926cdf
commit
c1ef3fa0b7
@ -1,30 +0,0 @@
|
||||
[Breakpoint 0]
|
||||
Enabled=true
|
||||
File=layout.cpp
|
||||
Line=263
|
||||
Temporary=false
|
||||
|
||||
[Breakpoint 1]
|
||||
Enabled=true
|
||||
File=moc_layout_edit.cpp
|
||||
Line=58
|
||||
Temporary=false
|
||||
|
||||
[Breakpoint 2]
|
||||
Enabled=true
|
||||
File=layout_edit.cpp
|
||||
Line=107
|
||||
Temporary=false
|
||||
|
||||
[General]
|
||||
DebuggerCmdStr=
|
||||
DriverName=GDB
|
||||
FileVersion=1
|
||||
OptionsSelected=
|
||||
ProgramArgs=
|
||||
TTYLevel=7
|
||||
WorkingDirectory=
|
||||
|
||||
[Memory]
|
||||
ColumnWidths=80,0
|
||||
NumExprs=0
|
721
src/Makefile
721
src/Makefile
@ -1,37 +1,34 @@
|
||||
#############################################################################
|
||||
# Makefile for building: qjoypad
|
||||
# Generated by qmake (1.07a) (Qt 3.3.6) on: Wed Nov 1 12:59:29 2006
|
||||
# Generated by qmake (2.01a) (Qt 4.5.1) on: Mon May 25 00:43:37 2009
|
||||
# Project: qjoypad.pro
|
||||
# Template: app
|
||||
# Command: $(QMAKE) "DEVDIR=/dev/input" "PREFIX=/usr" "DEFINES += " -o Makefile qjoypad.pro
|
||||
# Command: /usr/bin/qmake -unix -o Makefile qjoypad.pro
|
||||
#############################################################################
|
||||
|
||||
####### Compiler, tools and options
|
||||
|
||||
CC = gcc
|
||||
CXX = g++
|
||||
LEX = flex
|
||||
YACC = yacc
|
||||
CFLAGS = -pipe -Wall -W -O2 -D_REENTRANT -DDEVDIR='"/dev/input"' -DICON24='"/usr/share/pixmaps/qjoypad/icon24.png"' -DICON64='"/usr/share/pixmaps/qjoypad/icon64.png"' -DQT_NO_DEBUG -DQT_THREAD_SUPPORT -DQT_SHARED -DQT_TABLET_SUPPORT
|
||||
CXXFLAGS = -pipe -Wall -W -O2 -D_REENTRANT -DDEVDIR='"/dev/input"' -DICON24='"/usr/share/pixmaps/qjoypad/icon24.png"' -DICON64='"/usr/share/pixmaps/qjoypad/icon64.png"' -DQT_NO_DEBUG -DQT_THREAD_SUPPORT -DQT_SHARED -DQT_TABLET_SUPPORT
|
||||
LEXFLAGS =
|
||||
YACCFLAGS= -d
|
||||
INCPATH = -I/usr/share/qt3/mkspecs/default -I. -I. -Itrayicon -I/usr/include/qt3
|
||||
DEFINES = -DDEVDIR="\"/dev/input\"" -DICON24="\"/share/pixmaps/qjoypad/icon24.png\"" -DICON64="\"/share/pixmaps/qjoypad/icon64.png\"" -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
|
||||
CFLAGS = -pipe -march=i686 -mtune=generic -O2 -pipe -Wall -W -D_REENTRANT $(DEFINES)
|
||||
CXXFLAGS = -g -pipe -march=i686 -mtune=generic -O2 -pipe -Wall -W -D_REENTRANT $(DEFINES)
|
||||
INCPATH = -I/usr/share/qt/mkspecs/linux-g++ -I. -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include -I. -Itrayicon -I. -I.
|
||||
LINK = g++
|
||||
LFLAGS =
|
||||
LIBS = $(SUBLIBS) -L/usr/share/qt3/lib -L/usr/X11R6/lib -lXtst -lqt-mt -lXext -lX11 -lm -lpthread
|
||||
LFLAGS = -Wl,-O1 -Wl,-rpath,/usr/lib
|
||||
LIBS = $(SUBLIBS) -L/usr/lib -lXtst -lQtGui -L/usr/lib -L/usr/X11R6/lib -pthread -lpng -lfreetype -lgobject-2.0 -lSM -lICE -pthread -pthread -lXrender -lfontconfig -lXext -lX11 -lQtCore -lz -lm -pthread -lgthread-2.0 -lrt -lglib-2.0 -ldl -lpthread
|
||||
AR = ar cqs
|
||||
RANLIB =
|
||||
MOC = /usr/share/qt3/bin/moc
|
||||
UIC = /usr/share/qt3/bin/uic
|
||||
QMAKE = qmake
|
||||
QMAKE = /usr/bin/qmake
|
||||
TAR = tar -cf
|
||||
GZIP = gzip -9f
|
||||
COMPRESS = gzip -9f
|
||||
COPY = cp -f
|
||||
SED = sed
|
||||
COPY_FILE = $(COPY)
|
||||
COPY_DIR = $(COPY) -r
|
||||
INSTALL_FILE= $(COPY_FILE)
|
||||
INSTALL_FILE = install -m 644 -p
|
||||
INSTALL_DIR = $(COPY_DIR)
|
||||
INSTALL_PROGRAM = install -m 755 -p
|
||||
DEL_FILE = rm -f
|
||||
SYMLINK = ln -sf
|
||||
DEL_DIR = rmdir
|
||||
@ -45,29 +42,6 @@ OBJECTS_DIR = ./
|
||||
|
||||
####### Files
|
||||
|
||||
HEADERS = axis.h \
|
||||
axis_edit.h \
|
||||
axisw.h \
|
||||
button.h \
|
||||
button_edit.h \
|
||||
buttonw.h \
|
||||
component.h \
|
||||
constant.h \
|
||||
device.h \
|
||||
error.h \
|
||||
event.h \
|
||||
flash.h \
|
||||
icon.h \
|
||||
joypad.h \
|
||||
joypadw.h \
|
||||
joyslider.h \
|
||||
keycode.h \
|
||||
layout.h \
|
||||
layout_edit.h \
|
||||
loop.h \
|
||||
quickset.h \
|
||||
timer.h \
|
||||
trayicon/trayicon.h
|
||||
SOURCES = axis.cpp \
|
||||
axis_edit.cpp \
|
||||
axisw.cpp \
|
||||
@ -83,11 +57,22 @@ SOURCES = axis.cpp \
|
||||
keycode.cpp \
|
||||
layout.cpp \
|
||||
layout_edit.cpp \
|
||||
loop.cpp \
|
||||
main.cpp \
|
||||
quickset.cpp \
|
||||
getkey.cpp \
|
||||
trayicon/trayicon.cpp \
|
||||
trayicon/trayicon_x11.cpp
|
||||
trayicon/trayicon_x11.cpp moc_axis.cpp \
|
||||
moc_axis_edit.cpp \
|
||||
moc_button.cpp \
|
||||
moc_button_edit.cpp \
|
||||
moc_flash.cpp \
|
||||
moc_icon.cpp \
|
||||
moc_joypad.cpp \
|
||||
moc_joypadw.cpp \
|
||||
moc_keycode.cpp \
|
||||
moc_layout.cpp \
|
||||
moc_getkey.cpp \
|
||||
moc_trayicon.cpp
|
||||
OBJECTS = axis.o \
|
||||
axis_edit.o \
|
||||
axisw.o \
|
||||
@ -103,31 +88,43 @@ OBJECTS = axis.o \
|
||||
keycode.o \
|
||||
layout.o \
|
||||
layout_edit.o \
|
||||
loop.o \
|
||||
main.o \
|
||||
quickset.o \
|
||||
getkey.o \
|
||||
trayicon.o \
|
||||
trayicon_x11.o
|
||||
FORMS =
|
||||
UICDECLS =
|
||||
UICIMPLS =
|
||||
SRCMOC = moc_axis_edit.cpp \
|
||||
moc_button_edit.cpp \
|
||||
moc_flash.cpp \
|
||||
moc_icon.cpp \
|
||||
moc_joypadw.cpp \
|
||||
moc_keycode.cpp \
|
||||
moc_layout.cpp \
|
||||
trayicon/moc_trayicon.cpp
|
||||
OBJMOC = moc_axis_edit.o \
|
||||
trayicon_x11.o \
|
||||
moc_axis.o \
|
||||
moc_axis_edit.o \
|
||||
moc_button.o \
|
||||
moc_button_edit.o \
|
||||
moc_flash.o \
|
||||
moc_icon.o \
|
||||
moc_joypad.o \
|
||||
moc_joypadw.o \
|
||||
moc_keycode.o \
|
||||
moc_layout.o \
|
||||
moc_getkey.o \
|
||||
moc_trayicon.o
|
||||
DIST = qjoypad.pro
|
||||
DIST = /usr/share/qt/mkspecs/common/g++.conf \
|
||||
/usr/share/qt/mkspecs/common/unix.conf \
|
||||
/usr/share/qt/mkspecs/common/linux.conf \
|
||||
/usr/share/qt/mkspecs/qconfig.pri \
|
||||
/usr/share/qt/mkspecs/features/qt_functions.prf \
|
||||
/usr/share/qt/mkspecs/features/qt_config.prf \
|
||||
/usr/share/qt/mkspecs/features/exclusive_builds.prf \
|
||||
/usr/share/qt/mkspecs/features/default_pre.prf \
|
||||
/usr/share/qt/mkspecs/features/release.prf \
|
||||
/usr/share/qt/mkspecs/features/default_post.prf \
|
||||
/usr/share/qt/mkspecs/features/warn_on.prf \
|
||||
/usr/share/qt/mkspecs/features/qt.prf \
|
||||
/usr/share/qt/mkspecs/features/unix/thread.prf \
|
||||
/usr/share/qt/mkspecs/features/moc.prf \
|
||||
/usr/share/qt/mkspecs/features/resources.prf \
|
||||
/usr/share/qt/mkspecs/features/uic.prf \
|
||||
/usr/share/qt/mkspecs/features/yacc.prf \
|
||||
/usr/share/qt/mkspecs/features/lex.prf \
|
||||
/usr/share/qt/mkspecs/features/include_source_dir.prf \
|
||||
qjoypad.pro
|
||||
QMAKE_TARGET = qjoypad
|
||||
DESTDIR =
|
||||
TARGET = qjoypad
|
||||
@ -135,53 +132,82 @@ TARGET = qjoypad
|
||||
first: all
|
||||
####### Implicit rules
|
||||
|
||||
.SUFFIXES: .c .o .cpp .cc .cxx .C
|
||||
.SUFFIXES: .o .c .cpp .cc .cxx .C
|
||||
|
||||
.cpp.o:
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
|
||||
|
||||
.cc.o:
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
|
||||
|
||||
.cxx.o:
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
|
||||
|
||||
.C.o:
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(CFLAGS) $(INCPATH) -o $@ $<
|
||||
$(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
|
||||
|
||||
####### Build rules
|
||||
|
||||
all: Makefile $(TARGET)
|
||||
|
||||
$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC)
|
||||
$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJMOC) $(OBJCOMP) $(LIBS)
|
||||
$(TARGET): $(OBJECTS)
|
||||
$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
|
||||
|
||||
mocables: $(SRCMOC)
|
||||
uicables: $(UICDECLS) $(UICIMPLS)
|
||||
|
||||
$(MOC):
|
||||
( cd $(QTDIR)/src/moc && $(MAKE) )
|
||||
|
||||
Makefile: qjoypad.pro /usr/share/qt3/mkspecs/default/qmake.conf /usr/share/qt3/lib/libqt-mt.prl
|
||||
$(QMAKE) "DEVDIR=/dev/input" "PREFIX=/usr" "DEFINES += " -o Makefile qjoypad.pro
|
||||
qmake:
|
||||
@$(QMAKE) "DEVDIR=/dev/input" "PREFIX=/usr" "DEFINES += " -o Makefile qjoypad.pro
|
||||
Makefile: qjoypad.pro /usr/share/qt/mkspecs/linux-g++/qmake.conf /usr/share/qt/mkspecs/common/g++.conf \
|
||||
/usr/share/qt/mkspecs/common/unix.conf \
|
||||
/usr/share/qt/mkspecs/common/linux.conf \
|
||||
/usr/share/qt/mkspecs/qconfig.pri \
|
||||
/usr/share/qt/mkspecs/features/qt_functions.prf \
|
||||
/usr/share/qt/mkspecs/features/qt_config.prf \
|
||||
/usr/share/qt/mkspecs/features/exclusive_builds.prf \
|
||||
/usr/share/qt/mkspecs/features/default_pre.prf \
|
||||
/usr/share/qt/mkspecs/features/release.prf \
|
||||
/usr/share/qt/mkspecs/features/default_post.prf \
|
||||
/usr/share/qt/mkspecs/features/warn_on.prf \
|
||||
/usr/share/qt/mkspecs/features/qt.prf \
|
||||
/usr/share/qt/mkspecs/features/unix/thread.prf \
|
||||
/usr/share/qt/mkspecs/features/moc.prf \
|
||||
/usr/share/qt/mkspecs/features/resources.prf \
|
||||
/usr/share/qt/mkspecs/features/uic.prf \
|
||||
/usr/share/qt/mkspecs/features/yacc.prf \
|
||||
/usr/share/qt/mkspecs/features/lex.prf \
|
||||
/usr/share/qt/mkspecs/features/include_source_dir.prf \
|
||||
/usr/lib/libQtGui.prl \
|
||||
/usr/lib/libQtCore.prl
|
||||
$(QMAKE) -unix -o Makefile qjoypad.pro
|
||||
/usr/share/qt/mkspecs/common/g++.conf:
|
||||
/usr/share/qt/mkspecs/common/unix.conf:
|
||||
/usr/share/qt/mkspecs/common/linux.conf:
|
||||
/usr/share/qt/mkspecs/qconfig.pri:
|
||||
/usr/share/qt/mkspecs/features/qt_functions.prf:
|
||||
/usr/share/qt/mkspecs/features/qt_config.prf:
|
||||
/usr/share/qt/mkspecs/features/exclusive_builds.prf:
|
||||
/usr/share/qt/mkspecs/features/default_pre.prf:
|
||||
/usr/share/qt/mkspecs/features/release.prf:
|
||||
/usr/share/qt/mkspecs/features/default_post.prf:
|
||||
/usr/share/qt/mkspecs/features/warn_on.prf:
|
||||
/usr/share/qt/mkspecs/features/qt.prf:
|
||||
/usr/share/qt/mkspecs/features/unix/thread.prf:
|
||||
/usr/share/qt/mkspecs/features/moc.prf:
|
||||
/usr/share/qt/mkspecs/features/resources.prf:
|
||||
/usr/share/qt/mkspecs/features/uic.prf:
|
||||
/usr/share/qt/mkspecs/features/yacc.prf:
|
||||
/usr/share/qt/mkspecs/features/lex.prf:
|
||||
/usr/share/qt/mkspecs/features/include_source_dir.prf:
|
||||
/usr/lib/libQtGui.prl:
|
||||
/usr/lib/libQtCore.prl:
|
||||
qmake: FORCE
|
||||
@$(QMAKE) -unix -o Makefile qjoypad.pro
|
||||
|
||||
dist:
|
||||
@mkdir -p .tmp/qjoypad && $(COPY_FILE) --parents $(SOURCES) $(HEADERS) $(FORMS) $(DIST) .tmp/qjoypad/ && ( cd `dirname .tmp/qjoypad` && $(TAR) qjoypad.tar qjoypad && $(GZIP) qjoypad.tar ) && $(MOVE) `dirname .tmp/qjoypad`/qjoypad.tar.gz . && $(DEL_FILE) -r .tmp/qjoypad
|
||||
@$(CHK_DIR_EXISTS) .tmp/qjoypad1.0.0 || $(MKDIR) .tmp/qjoypad1.0.0
|
||||
$(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/qjoypad1.0.0/ && $(COPY_FILE) --parents axis.h axis_edit.h axisw.h button.h button_edit.h buttonw.h constant.h device.h error.h event.h flash.h icon.h joypad.h joypadw.h joyslider.h keycode.h layout.h getkey.h layout_edit.h quickset.h trayicon/trayicon.h .tmp/qjoypad1.0.0/ && $(COPY_FILE) --parents axis.cpp axis_edit.cpp axisw.cpp button.cpp button_edit.cpp buttonw.cpp event.cpp flash.cpp icon.cpp joypad.cpp joypadw.cpp joyslider.cpp keycode.cpp layout.cpp layout_edit.cpp main.cpp quickset.cpp getkey.cpp trayicon/trayicon.cpp trayicon/trayicon_x11.cpp .tmp/qjoypad1.0.0/ && (cd `dirname .tmp/qjoypad1.0.0` && $(TAR) qjoypad1.0.0.tar qjoypad1.0.0 && $(COMPRESS) qjoypad1.0.0.tar) && $(MOVE) `dirname .tmp/qjoypad1.0.0`/qjoypad1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/qjoypad1.0.0
|
||||
|
||||
mocclean:
|
||||
-$(DEL_FILE) $(OBJMOC)
|
||||
-$(DEL_FILE) $(SRCMOC)
|
||||
|
||||
uiclean:
|
||||
|
||||
yaccclean:
|
||||
lexclean:
|
||||
clean: mocclean
|
||||
clean:compiler_clean
|
||||
-$(DEL_FILE) $(OBJECTS)
|
||||
-$(DEL_FILE) *~ core *.core
|
||||
|
||||
@ -189,220 +215,308 @@ clean: mocclean
|
||||
####### Sub-libraries
|
||||
|
||||
distclean: clean
|
||||
-$(DEL_FILE) $(TARGET) $(TARGET)
|
||||
-$(DEL_FILE) $(TARGET)
|
||||
-$(DEL_FILE) Makefile
|
||||
|
||||
|
||||
FORCE:
|
||||
mocclean: compiler_moc_header_clean compiler_moc_source_clean
|
||||
|
||||
####### Compile
|
||||
mocables: compiler_moc_header_make_all compiler_moc_source_make_all
|
||||
|
||||
axis.o: axis.cpp axis.h \
|
||||
component.h \
|
||||
timer.h \
|
||||
event.h \
|
||||
constant.h
|
||||
compiler_moc_header_make_all: moc_axis.cpp moc_axis_edit.cpp moc_button.cpp moc_button_edit.cpp moc_flash.cpp moc_icon.cpp moc_joypad.cpp moc_joypadw.cpp moc_keycode.cpp moc_layout.cpp moc_getkey.cpp moc_trayicon.cpp
|
||||
compiler_moc_header_clean:
|
||||
-$(DEL_FILE) moc_axis.cpp moc_axis_edit.cpp moc_button.cpp moc_button_edit.cpp moc_flash.cpp moc_icon.cpp moc_joypad.cpp moc_joypadw.cpp moc_keycode.cpp moc_layout.cpp moc_getkey.cpp moc_trayicon.cpp
|
||||
moc_axis.cpp: constant.h \
|
||||
axis.h
|
||||
/usr/bin/moc $(DEFINES) $(INCPATH) axis.h -o moc_axis.cpp
|
||||
|
||||
axis_edit.o: axis_edit.cpp axis_edit.h \
|
||||
joyslider.h \
|
||||
keycode.h \
|
||||
axis.h \
|
||||
constant.h \
|
||||
component.h \
|
||||
timer.h \
|
||||
event.h
|
||||
|
||||
axisw.o: axisw.cpp axisw.h \
|
||||
axis.h \
|
||||
axis_edit.h \
|
||||
flash.h \
|
||||
component.h \
|
||||
timer.h \
|
||||
event.h \
|
||||
moc_axis_edit.cpp: axis.h \
|
||||
constant.h \
|
||||
joyslider.h \
|
||||
keycode.h
|
||||
|
||||
button.o: button.cpp button.h \
|
||||
component.h \
|
||||
timer.h \
|
||||
keycode.h \
|
||||
event.h \
|
||||
constant.h
|
||||
axis_edit.h
|
||||
/usr/bin/moc $(DEFINES) $(INCPATH) axis_edit.h -o moc_axis_edit.cpp
|
||||
|
||||
button_edit.o: button_edit.cpp button_edit.h \
|
||||
button.h \
|
||||
moc_button.cpp: keycode.h \
|
||||
constant.h \
|
||||
button.h
|
||||
/usr/bin/moc $(DEFINES) $(INCPATH) button.h -o moc_button.cpp
|
||||
|
||||
moc_button_edit.cpp: button.h \
|
||||
keycode.h \
|
||||
component.h \
|
||||
timer.h \
|
||||
event.h \
|
||||
constant.h
|
||||
constant.h \
|
||||
button_edit.h
|
||||
/usr/bin/moc $(DEFINES) $(INCPATH) button_edit.h -o moc_button_edit.cpp
|
||||
|
||||
buttonw.o: buttonw.cpp buttonw.h \
|
||||
button.h \
|
||||
button_edit.h \
|
||||
flash.h \
|
||||
component.h \
|
||||
timer.h \
|
||||
moc_flash.cpp: flash.h
|
||||
/usr/bin/moc $(DEFINES) $(INCPATH) flash.h -o moc_flash.cpp
|
||||
|
||||
moc_icon.cpp: constant.h \
|
||||
icon.h
|
||||
/usr/bin/moc $(DEFINES) $(INCPATH) icon.h -o moc_icon.cpp
|
||||
|
||||
moc_joypad.cpp: button.h \
|
||||
keycode.h \
|
||||
event.h \
|
||||
constant.h
|
||||
|
||||
event.o: event.cpp event.h
|
||||
|
||||
flash.o: flash.cpp flash.h
|
||||
|
||||
icon.o: icon.cpp icon.h \
|
||||
constant.h
|
||||
|
||||
joypad.o: joypad.cpp joypad.h \
|
||||
button.h \
|
||||
constant.h \
|
||||
axis.h \
|
||||
joypadw.h \
|
||||
error.h \
|
||||
component.h \
|
||||
timer.h \
|
||||
keycode.h \
|
||||
event.h \
|
||||
constant.h \
|
||||
axisw.h \
|
||||
buttonw.h \
|
||||
quickset.h \
|
||||
axis_edit.h \
|
||||
flash.h \
|
||||
axis_edit.h \
|
||||
joyslider.h \
|
||||
button_edit.h
|
||||
|
||||
joypadw.o: joypadw.cpp joypadw.h \
|
||||
joypad.h \
|
||||
axisw.h \
|
||||
error.h \
|
||||
buttonw.h \
|
||||
button_edit.h \
|
||||
quickset.h \
|
||||
button.h \
|
||||
joypad.h
|
||||
/usr/bin/moc $(DEFINES) $(INCPATH) joypad.h -o moc_joypad.cpp
|
||||
|
||||
moc_joypadw.cpp: axisw.h \
|
||||
axis.h \
|
||||
error.h \
|
||||
component.h \
|
||||
timer.h \
|
||||
keycode.h \
|
||||
event.h \
|
||||
constant.h \
|
||||
axis_edit.h \
|
||||
flash.h \
|
||||
axis_edit.h \
|
||||
joyslider.h \
|
||||
button_edit.h
|
||||
|
||||
joyslider.o: joyslider.cpp joyslider.h \
|
||||
constant.h
|
||||
|
||||
keycode.o: keycode.cpp keycode.h \
|
||||
constant.h
|
||||
|
||||
layout.o: layout.cpp layout.h \
|
||||
keycode.h \
|
||||
joypad.h \
|
||||
button.h \
|
||||
joypadw.h \
|
||||
buttonw.h \
|
||||
button_edit.h \
|
||||
quickset.h \
|
||||
error.h \
|
||||
joypadw.h
|
||||
/usr/bin/moc $(DEFINES) $(INCPATH) joypadw.h -o moc_joypadw.cpp
|
||||
|
||||
moc_keycode.cpp: constant.h \
|
||||
keycode.h
|
||||
/usr/bin/moc $(DEFINES) $(INCPATH) keycode.h -o moc_keycode.cpp
|
||||
|
||||
moc_layout.cpp: joypad.h \
|
||||
button.h \
|
||||
keycode.h \
|
||||
constant.h \
|
||||
axis.h \
|
||||
joypadw.h \
|
||||
axisw.h \
|
||||
flash.h \
|
||||
axis_edit.h \
|
||||
joyslider.h \
|
||||
buttonw.h \
|
||||
button_edit.h \
|
||||
quickset.h \
|
||||
error.h \
|
||||
device.h \
|
||||
trayicon/trayicon.h \
|
||||
icon.h \
|
||||
layout_edit.h \
|
||||
layout.h \
|
||||
layout.h
|
||||
/usr/bin/moc $(DEFINES) $(INCPATH) layout.h -o moc_layout.cpp
|
||||
|
||||
moc_getkey.cpp: constant.h \
|
||||
getkey.h
|
||||
/usr/bin/moc $(DEFINES) $(INCPATH) getkey.h -o moc_getkey.cpp
|
||||
|
||||
moc_trayicon.cpp: trayicon/trayicon.h
|
||||
/usr/bin/moc $(DEFINES) $(INCPATH) trayicon/trayicon.h -o moc_trayicon.cpp
|
||||
|
||||
compiler_rcc_make_all:
|
||||
compiler_rcc_clean:
|
||||
compiler_image_collection_make_all: qmake_image_collection.cpp
|
||||
compiler_image_collection_clean:
|
||||
-$(DEL_FILE) qmake_image_collection.cpp
|
||||
compiler_moc_source_make_all:
|
||||
compiler_moc_source_clean:
|
||||
compiler_uic_make_all:
|
||||
compiler_uic_clean:
|
||||
compiler_yacc_decl_make_all:
|
||||
compiler_yacc_decl_clean:
|
||||
compiler_yacc_impl_make_all:
|
||||
compiler_yacc_impl_clean:
|
||||
compiler_lex_make_all:
|
||||
compiler_lex_clean:
|
||||
compiler_clean: compiler_moc_header_clean
|
||||
|
||||
####### Compile
|
||||
|
||||
axis.o: axis.cpp axis.h \
|
||||
constant.h \
|
||||
event.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o axis.o axis.cpp
|
||||
|
||||
axis_edit.o: axis_edit.cpp axis_edit.h \
|
||||
axis.h \
|
||||
constant.h \
|
||||
joyslider.h \
|
||||
keycode.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o axis_edit.o axis_edit.cpp
|
||||
|
||||
axisw.o: axisw.cpp axisw.h \
|
||||
axis.h \
|
||||
constant.h \
|
||||
flash.h \
|
||||
axis_edit.h \
|
||||
joyslider.h \
|
||||
keycode.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o axisw.o axisw.cpp
|
||||
|
||||
button.o: button.cpp button.h \
|
||||
keycode.h \
|
||||
constant.h \
|
||||
event.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o button.o button.cpp
|
||||
|
||||
button_edit.o: button_edit.cpp button_edit.h \
|
||||
button.h \
|
||||
keycode.h \
|
||||
constant.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o button_edit.o button_edit.cpp
|
||||
|
||||
buttonw.o: buttonw.cpp buttonw.h \
|
||||
button.h \
|
||||
keycode.h \
|
||||
constant.h \
|
||||
button_edit.h \
|
||||
flash.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o buttonw.o buttonw.cpp
|
||||
|
||||
event.o: event.cpp event.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o event.o event.cpp
|
||||
|
||||
flash.o: flash.cpp flash.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o flash.o flash.cpp
|
||||
|
||||
icon.o: icon.cpp icon.h \
|
||||
constant.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o icon.o icon.cpp
|
||||
|
||||
joypad.o: joypad.cpp joypad.h \
|
||||
button.h \
|
||||
keycode.h \
|
||||
constant.h \
|
||||
axis.h \
|
||||
joypadw.h \
|
||||
component.h \
|
||||
timer.h \
|
||||
keycode.h \
|
||||
event.h \
|
||||
constant.h \
|
||||
axisw.h \
|
||||
buttonw.h \
|
||||
quickset.h \
|
||||
axis_edit.h \
|
||||
flash.h \
|
||||
axis_edit.h \
|
||||
joyslider.h \
|
||||
button_edit.h
|
||||
buttonw.h \
|
||||
button_edit.h \
|
||||
quickset.h \
|
||||
error.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o joypad.o joypad.cpp
|
||||
|
||||
joypadw.o: joypadw.cpp joypadw.h \
|
||||
axisw.h \
|
||||
axis.h \
|
||||
constant.h \
|
||||
flash.h \
|
||||
axis_edit.h \
|
||||
joyslider.h \
|
||||
keycode.h \
|
||||
joypad.h \
|
||||
button.h \
|
||||
error.h \
|
||||
buttonw.h \
|
||||
button_edit.h \
|
||||
quickset.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o joypadw.o joypadw.cpp
|
||||
|
||||
joyslider.o: joyslider.cpp joyslider.h \
|
||||
constant.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o joyslider.o joyslider.cpp
|
||||
|
||||
keycode.o: keycode.cpp keycode.h \
|
||||
constant.h \
|
||||
getkey.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o keycode.o keycode.cpp
|
||||
|
||||
layout.o: layout.cpp layout.h \
|
||||
joypad.h \
|
||||
button.h \
|
||||
keycode.h \
|
||||
constant.h \
|
||||
axis.h \
|
||||
joypadw.h \
|
||||
axisw.h \
|
||||
flash.h \
|
||||
axis_edit.h \
|
||||
joyslider.h \
|
||||
buttonw.h \
|
||||
button_edit.h \
|
||||
quickset.h \
|
||||
error.h \
|
||||
device.h \
|
||||
trayicon/trayicon.h \
|
||||
icon.h \
|
||||
layout_edit.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o layout.o layout.cpp
|
||||
|
||||
layout_edit.o: layout_edit.cpp layout_edit.h \
|
||||
flash.h \
|
||||
layout.h \
|
||||
device.h \
|
||||
joypadw.h \
|
||||
joypad.h \
|
||||
error.h \
|
||||
trayicon/trayicon.h \
|
||||
icon.h \
|
||||
button.h \
|
||||
axis.h \
|
||||
component.h \
|
||||
timer.h \
|
||||
keycode.h \
|
||||
event.h \
|
||||
constant.h \
|
||||
axisw.h \
|
||||
buttonw.h \
|
||||
quickset.h \
|
||||
axis_edit.h \
|
||||
joyslider.h \
|
||||
button_edit.h
|
||||
|
||||
loop.o: loop.cpp loop.h \
|
||||
joypad.h \
|
||||
device.h \
|
||||
button.h \
|
||||
axis.h \
|
||||
joypadw.h \
|
||||
error.h \
|
||||
component.h \
|
||||
timer.h \
|
||||
keycode.h \
|
||||
event.h \
|
||||
constant.h \
|
||||
axisw.h \
|
||||
buttonw.h \
|
||||
quickset.h \
|
||||
axis_edit.h \
|
||||
flash.h \
|
||||
joyslider.h \
|
||||
button_edit.h
|
||||
|
||||
main.o: main.cpp loop.h \
|
||||
layout.h \
|
||||
event.h \
|
||||
device.h \
|
||||
error.h \
|
||||
joypad.h \
|
||||
button.h \
|
||||
axis.h \
|
||||
joypadw.h \
|
||||
component.h \
|
||||
timer.h \
|
||||
keycode.h \
|
||||
constant.h \
|
||||
axis.h \
|
||||
joypadw.h \
|
||||
axisw.h \
|
||||
buttonw.h \
|
||||
quickset.h \
|
||||
axis_edit.h \
|
||||
flash.h \
|
||||
joyslider.h \
|
||||
buttonw.h \
|
||||
button_edit.h \
|
||||
quickset.h \
|
||||
error.h \
|
||||
device.h \
|
||||
trayicon/trayicon.h \
|
||||
icon.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o layout_edit.o layout_edit.cpp
|
||||
|
||||
main.o: main.cpp layout.h \
|
||||
joypad.h \
|
||||
button.h \
|
||||
keycode.h \
|
||||
constant.h \
|
||||
axis.h \
|
||||
joypadw.h \
|
||||
axisw.h \
|
||||
flash.h \
|
||||
axis_edit.h \
|
||||
joyslider.h \
|
||||
buttonw.h \
|
||||
button_edit.h \
|
||||
quickset.h \
|
||||
error.h \
|
||||
device.h \
|
||||
trayicon/trayicon.h \
|
||||
icon.h \
|
||||
layout_edit.h
|
||||
layout_edit.h \
|
||||
event.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp
|
||||
|
||||
quickset.o: quickset.cpp quickset.h \
|
||||
keycode.h \
|
||||
joypad.h \
|
||||
constant.h \
|
||||
button.h \
|
||||
keycode.h \
|
||||
constant.h \
|
||||
axis.h \
|
||||
joypadw.h \
|
||||
error.h \
|
||||
component.h \
|
||||
timer.h \
|
||||
event.h \
|
||||
axisw.h \
|
||||
buttonw.h \
|
||||
axis_edit.h \
|
||||
flash.h \
|
||||
axis_edit.h \
|
||||
joyslider.h \
|
||||
button_edit.h
|
||||
buttonw.h \
|
||||
button_edit.h \
|
||||
error.h \
|
||||
getkey.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o quickset.o quickset.cpp
|
||||
|
||||
getkey.o: getkey.cpp getkey.h \
|
||||
constant.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o getkey.o getkey.cpp
|
||||
|
||||
trayicon.o: trayicon/trayicon.cpp trayicon/trayicon.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o trayicon.o trayicon/trayicon.cpp
|
||||
@ -410,116 +524,67 @@ trayicon.o: trayicon/trayicon.cpp trayicon/trayicon.h
|
||||
trayicon_x11.o: trayicon/trayicon_x11.cpp trayicon/trayicon.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o trayicon_x11.o trayicon/trayicon_x11.cpp
|
||||
|
||||
moc_axis_edit.o: moc_axis_edit.cpp axis_edit.h joyslider.h \
|
||||
keycode.h \
|
||||
axis.h \
|
||||
constant.h \
|
||||
component.h \
|
||||
timer.h \
|
||||
event.h
|
||||
moc_axis.o: moc_axis.cpp
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_axis.o moc_axis.cpp
|
||||
|
||||
moc_button_edit.o: moc_button_edit.cpp button_edit.h button.h \
|
||||
keycode.h \
|
||||
component.h \
|
||||
timer.h \
|
||||
event.h \
|
||||
constant.h
|
||||
moc_axis_edit.o: moc_axis_edit.cpp
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_axis_edit.o moc_axis_edit.cpp
|
||||
|
||||
moc_flash.o: moc_flash.cpp flash.h
|
||||
moc_button.o: moc_button.cpp
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_button.o moc_button.cpp
|
||||
|
||||
moc_icon.o: moc_icon.cpp icon.h constant.h
|
||||
moc_button_edit.o: moc_button_edit.cpp
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_button_edit.o moc_button_edit.cpp
|
||||
|
||||
moc_joypadw.o: moc_joypadw.cpp joypadw.h joypad.h \
|
||||
axisw.h \
|
||||
buttonw.h \
|
||||
quickset.h \
|
||||
button.h \
|
||||
axis.h \
|
||||
error.h \
|
||||
component.h \
|
||||
timer.h \
|
||||
keycode.h \
|
||||
event.h \
|
||||
constant.h \
|
||||
axis_edit.h \
|
||||
flash.h \
|
||||
joyslider.h \
|
||||
button_edit.h
|
||||
moc_flash.o: moc_flash.cpp
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_flash.o moc_flash.cpp
|
||||
|
||||
moc_keycode.o: moc_keycode.cpp keycode.h constant.h
|
||||
moc_icon.o: moc_icon.cpp
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_icon.o moc_icon.cpp
|
||||
|
||||
moc_layout.o: moc_layout.cpp layout.h joypad.h \
|
||||
error.h \
|
||||
device.h \
|
||||
trayicon/trayicon.h \
|
||||
icon.h \
|
||||
layout_edit.h \
|
||||
button.h \
|
||||
axis.h \
|
||||
joypadw.h \
|
||||
component.h \
|
||||
timer.h \
|
||||
keycode.h \
|
||||
event.h \
|
||||
constant.h \
|
||||
axisw.h \
|
||||
buttonw.h \
|
||||
quickset.h \
|
||||
axis_edit.h \
|
||||
flash.h \
|
||||
joyslider.h \
|
||||
button_edit.h
|
||||
moc_joypad.o: moc_joypad.cpp
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_joypad.o moc_joypad.cpp
|
||||
|
||||
moc_trayicon.o: trayicon/moc_trayicon.cpp trayicon/trayicon.h
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_trayicon.o trayicon/moc_trayicon.cpp
|
||||
moc_joypadw.o: moc_joypadw.cpp
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_joypadw.o moc_joypadw.cpp
|
||||
|
||||
moc_axis_edit.cpp: $(MOC) axis_edit.h
|
||||
$(MOC) axis_edit.h -o moc_axis_edit.cpp
|
||||
moc_keycode.o: moc_keycode.cpp
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_keycode.o moc_keycode.cpp
|
||||
|
||||
moc_button_edit.cpp: $(MOC) button_edit.h
|
||||
$(MOC) button_edit.h -o moc_button_edit.cpp
|
||||
moc_layout.o: moc_layout.cpp
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_layout.o moc_layout.cpp
|
||||
|
||||
moc_flash.cpp: $(MOC) flash.h
|
||||
$(MOC) flash.h -o moc_flash.cpp
|
||||
moc_getkey.o: moc_getkey.cpp
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_getkey.o moc_getkey.cpp
|
||||
|
||||
moc_icon.cpp: $(MOC) icon.h
|
||||
$(MOC) icon.h -o moc_icon.cpp
|
||||
|
||||
moc_joypadw.cpp: $(MOC) joypadw.h
|
||||
$(MOC) joypadw.h -o moc_joypadw.cpp
|
||||
|
||||
moc_keycode.cpp: $(MOC) keycode.h
|
||||
$(MOC) keycode.h -o moc_keycode.cpp
|
||||
|
||||
moc_layout.cpp: $(MOC) layout.h
|
||||
$(MOC) layout.h -o moc_layout.cpp
|
||||
|
||||
trayicon/moc_trayicon.cpp: $(MOC) trayicon/trayicon.h
|
||||
$(MOC) trayicon/trayicon.h -o trayicon/moc_trayicon.cpp
|
||||
moc_trayicon.o: moc_trayicon.cpp
|
||||
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_trayicon.o moc_trayicon.cpp
|
||||
|
||||
####### Install
|
||||
|
||||
install_target: all
|
||||
@$(CHK_DIR_EXISTS) "$(INSTALL_ROOT)/usr/bin/" || $(MKDIR) "$(INSTALL_ROOT)/usr/bin/"
|
||||
-$(INSTALL_FILE) "$(QMAKE_TARGET)" "$(INSTALL_ROOT)/usr/bin/$(QMAKE_TARGET)"
|
||||
-strip "$(INSTALL_ROOT)/usr/bin/$(QMAKE_TARGET)"
|
||||
install_target: first FORCE
|
||||
@$(CHK_DIR_EXISTS) $(INSTALL_ROOT)/bin/ || $(MKDIR) $(INSTALL_ROOT)/bin/
|
||||
-$(INSTALL_PROGRAM) "$(QMAKE_TARGET)" "$(INSTALL_ROOT)/bin/$(QMAKE_TARGET)"
|
||||
-strip "$(INSTALL_ROOT)/bin/$(QMAKE_TARGET)"
|
||||
|
||||
uninstall_target:
|
||||
-$(DEL_FILE) "$(INSTALL_ROOT)/usr/bin/$(QMAKE_TARGET)"
|
||||
-$(DEL_DIR) "$(INSTALL_ROOT)/usr/bin/"
|
||||
uninstall_target: FORCE
|
||||
-$(DEL_FILE) "$(INSTALL_ROOT)/bin/$(QMAKE_TARGET)"
|
||||
-$(DEL_DIR) $(INSTALL_ROOT)/bin/
|
||||
|
||||
|
||||
install_icons: all
|
||||
@$(CHK_DIR_EXISTS) "$(INSTALL_ROOT)/usr/share/pixmaps/qjoypad/" || $(MKDIR) "$(INSTALL_ROOT)/usr/share/pixmaps/qjoypad/"
|
||||
cp ../icons/* /usr/share/pixmaps/qjoypad; cd /usr/share/pixmaps/qjoypad; ln -sf gamepad4-24x24.png icon24.png; ln -sf gamepad3-64x64.png icon64.png; chmod -R a+r /usr/share/pixmaps/qjoypad
|
||||
install_icons: first FORCE
|
||||
@$(CHK_DIR_EXISTS) $(INSTALL_ROOT)/share/pixmaps/qjoypad/ || $(MKDIR) $(INSTALL_ROOT)/share/pixmaps/qjoypad/
|
||||
cp ../icons/* /share/pixmaps/qjoypad; cd /share/pixmaps/qjoypad; ln -sf gamepad4-24x24.png icon24.png; ln -sf gamepad3-64x64.png icon64.png; chmod -R a+r /share/pixmaps/qjoypad
|
||||
|
||||
|
||||
install_doc: all
|
||||
@$(CHK_DIR_EXISTS) "$(INSTALL_ROOT)/usr/doc/qjoypad3/" || $(MKDIR) "$(INSTALL_ROOT)/usr/doc/qjoypad3/"
|
||||
cp ../README.txt ../LICENSE.txt /usr/doc/qjoypad3
|
||||
install_doc: first FORCE
|
||||
@$(CHK_DIR_EXISTS) $(INSTALL_ROOT)/doc/qjoypad3/ || $(MKDIR) $(INSTALL_ROOT)/doc/qjoypad3/
|
||||
cp ../README.txt ../LICENSE.txt /doc/qjoypad3
|
||||
|
||||
|
||||
install: install_target install_icons install_doc
|
||||
install: install_target install_icons install_doc FORCE
|
||||
|
||||
uninstall: uninstall_target
|
||||
uninstall: uninstall_target FORCE
|
||||
|
||||
FORCE:
|
||||
|
||||
|
47
src/axis.cpp
47
src/axis.cpp
@ -1,28 +1,36 @@
|
||||
#include "axis.h"
|
||||
|
||||
#include "event.h"
|
||||
#include "time.h"
|
||||
#define sqr(a) ((a)*(a))
|
||||
|
||||
|
||||
Axis::Axis( int i ) {
|
||||
index = i;
|
||||
isOn = false;
|
||||
//to keep toDefault from calling tossTimer without first calling takeTimer
|
||||
isDown = false;
|
||||
state = 0;
|
||||
gradient = false;
|
||||
toDefault();
|
||||
tick = 0;
|
||||
timer = new QTimer(this);
|
||||
a = 0;
|
||||
b = 0;
|
||||
c = 0;
|
||||
}
|
||||
|
||||
|
||||
Axis::~Axis() {
|
||||
release();
|
||||
delete timer;
|
||||
}
|
||||
|
||||
bool Axis::read( QTextStream* stream ) {
|
||||
// At this point, toDefault has just been called.
|
||||
|
||||
//read in a line from the stream, and split it up into individual words
|
||||
QString input = stream->readLine().lower();
|
||||
QString input = stream->readLine().toLower();
|
||||
QRegExp regex("[\\s,]+");
|
||||
QStringList words = QStringList::split(regex,input);
|
||||
QStringList words = input.split(regex);
|
||||
|
||||
//used to assure QString->int conversions worked
|
||||
bool ok;
|
||||
@ -76,7 +84,6 @@ bool Axis::read( QTextStream* stream ) {
|
||||
}
|
||||
//the rest of the options are keywords without integers
|
||||
else if (*it == "gradient") {
|
||||
if (!gradient) takeTimer( this );
|
||||
gradient = true;
|
||||
}
|
||||
else if (*it == "throttle+") {
|
||||
@ -110,6 +117,10 @@ bool Axis::read( QTextStream* stream ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void Axis::timerCalled() {
|
||||
timerTick(++tick);
|
||||
}
|
||||
|
||||
void Axis::write( QTextStream* stream ) {
|
||||
*stream << "\t" << getName() << ": ";
|
||||
if (gradient) *stream << "gradient, ";
|
||||
@ -152,17 +163,26 @@ void Axis::jsevent( int value ) {
|
||||
state = (value + JOYMIN) / 2;
|
||||
else
|
||||
state = (value + JOYMAX) / 2;
|
||||
|
||||
//set isOn, deal with state changing.
|
||||
//if was on but now should be off:
|
||||
if (isOn && abs(state) <= dZone) {
|
||||
isOn = false;
|
||||
if (gradient) release();
|
||||
if (gradient) {
|
||||
duration = 0;
|
||||
release();
|
||||
timer->stop();
|
||||
disconnect(timer, SIGNAL(timeout()), 0, 0);
|
||||
tick = 0;
|
||||
}
|
||||
}
|
||||
//if was off but now should be on:
|
||||
else if (!isOn && abs(state) >= dZone) {
|
||||
isOn = true;
|
||||
if (gradient) duration = (abs(state) * FREQ) / JOYMAX;
|
||||
if (gradient) {
|
||||
duration = (abs(state) * FREQ) / JOYMAX;
|
||||
connect(timer, SIGNAL(timeout()), this, SLOT(timerCalled()));
|
||||
timer->start(MSEC);
|
||||
}
|
||||
}
|
||||
//otherwise, state doesn't change! Don't touch it.
|
||||
else return;
|
||||
@ -176,12 +196,11 @@ void Axis::jsevent( int value ) {
|
||||
|
||||
void Axis::toDefault() {
|
||||
release();
|
||||
|
||||
if (gradient) tossTimer( this );
|
||||
gradient = false;
|
||||
throttle = 0;
|
||||
maxSpeed = 100;
|
||||
dZone = DZONE;
|
||||
tick = 0;
|
||||
xZone = XZONE;
|
||||
mode = keybd;
|
||||
pkeycode = 0;
|
||||
@ -231,11 +250,13 @@ void Axis::setKey(bool positive, int value) {
|
||||
nkeycode = value;
|
||||
}
|
||||
|
||||
void Axis::timer( int tick ) {
|
||||
void Axis::timerTick( int tick ) {
|
||||
if (isOn) {
|
||||
if (mode == keybd) {
|
||||
if (tick % FREQ == 0) {
|
||||
if (duration == FREQ) {
|
||||
if (tick % FREQ == 0)
|
||||
{
|
||||
if (duration == FREQ)
|
||||
{
|
||||
if (!isDown) move(true);
|
||||
duration = (abs(state) * FREQ) / JOYMAX;
|
||||
return;
|
||||
|
159
src/joypad.cpp
159
src/joypad.cpp
@ -1,12 +1,22 @@
|
||||
|
||||
#include "unistd.h"
|
||||
#include "joypad.h"
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <poll.h>
|
||||
#include <QApplication>
|
||||
JoyPad::JoyPad( int i, int dev ) {
|
||||
//remember the index,
|
||||
index = i;
|
||||
|
||||
//load data from the joystick device, if available.
|
||||
joydevFileHandle = NULL;
|
||||
if(dev > 0) {
|
||||
resetToDev(dev);
|
||||
|
||||
joydevFileHandle = new QSocketNotifier(dev, QSocketNotifier::Read, this);
|
||||
joydevFileException = new QSocketNotifier(dev, QSocketNotifier::Exception, this);
|
||||
connect(joydevFileHandle, SIGNAL(activated(int)), this, SLOT(handleJoyEvents(int)));
|
||||
connect(joydevFileException, SIGNAL(activated(int)), this, SLOT(errorRead(int)));
|
||||
}
|
||||
//there is no JoyPadWidget yet.
|
||||
jpw = NULL;
|
||||
}
|
||||
@ -33,26 +43,69 @@ void JoyPad::resetToDev(int dev ) {
|
||||
for (int i = 0; i < buttons; i++) {
|
||||
if (Buttons[i] == 0) Buttons.insert(i, new Button( i ));
|
||||
}
|
||||
struct pollfd read_struct;
|
||||
read_struct.fd = joydev;
|
||||
read_struct.events = POLLIN;
|
||||
char buf[10];
|
||||
while(poll(&read_struct, 1, 2)!=0) {
|
||||
printf("reading junk data\n");
|
||||
read(joydev, buf, 10);
|
||||
}
|
||||
setupJoyDeviceListener(dev);
|
||||
}
|
||||
|
||||
void JoyPad::setupJoyDeviceListener(int dev) {
|
||||
if(joydevFileHandle != NULL) {
|
||||
delete joydevFileHandle;
|
||||
}
|
||||
joydevFileHandle = new QSocketNotifier(dev, QSocketNotifier::Read, this);
|
||||
connect(joydevFileHandle, SIGNAL(activated(int)), this, SLOT(handleJoyEvents(int)));
|
||||
}
|
||||
|
||||
void JoyPad::toDefault() {
|
||||
//to reset the whole, reset all the parts.
|
||||
for ( QIntDictIterator<Axis> it( Axes ); it.current(); ++it )
|
||||
it.current()->toDefault();
|
||||
for ( QIntDictIterator<Button> it( Buttons ); it.current(); ++it )
|
||||
it.current()->toDefault();
|
||||
do
|
||||
{
|
||||
QHashIterator<int, Axis*> it( Axes );
|
||||
while (it.hasNext())
|
||||
{
|
||||
it.next();
|
||||
it.value()->toDefault();
|
||||
}
|
||||
} while (0);
|
||||
do
|
||||
{
|
||||
QHashIterator<int, Button*> it( Buttons );
|
||||
while (it.hasNext())
|
||||
{
|
||||
it.next();
|
||||
it.value()->toDefault();
|
||||
}
|
||||
} while (0);
|
||||
}
|
||||
|
||||
bool JoyPad::isDefault() {
|
||||
//if any of the parts are not at default, then the whole isn't either.
|
||||
for ( QIntDictIterator<Axis> it( Axes ); it.current(); ++it )
|
||||
if (!it.current()->isDefault()) return false;
|
||||
for ( QIntDictIterator<Button> it( Buttons ); it.current(); ++it )
|
||||
if (!it.current()->isDefault()) return false;
|
||||
do {
|
||||
QHashIterator<int, Axis*> it( Axes );
|
||||
while (it.hasNext())
|
||||
{
|
||||
it.next();
|
||||
if (!it.value()->isDefault()) return false;
|
||||
}
|
||||
} while (0);
|
||||
do {
|
||||
QHashIterator<int, Button*> it( Buttons );
|
||||
while (it.hasNext())
|
||||
{
|
||||
it.next();
|
||||
if (!it.value()->isDefault()) return false;
|
||||
}
|
||||
} while (0);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JoyPad::read( QTextStream* stream ) {
|
||||
bool JoyPad::readConfig( QTextStream* stream ) {
|
||||
toDefault();
|
||||
|
||||
QString word;
|
||||
@ -61,7 +114,7 @@ bool JoyPad::read( QTextStream* stream ) {
|
||||
|
||||
*stream >> word;
|
||||
while (word != NULL && word != "}") {
|
||||
word = word.lower();
|
||||
word = word.toLower();
|
||||
if (word == "button") {
|
||||
*stream >> num;
|
||||
if (num > 0) {
|
||||
@ -112,18 +165,23 @@ bool JoyPad::read( QTextStream* stream ) {
|
||||
void JoyPad::write( QTextStream* stream ) {
|
||||
int i = 0; //use to test if this is default or not.
|
||||
QString result;
|
||||
QTextStream* s = new QTextStream(&result, IO_WriteOnly);
|
||||
QTextStream* s = new QTextStream(&result, QIODevice::WriteOnly);
|
||||
*s << getName() << " {\n";
|
||||
for ( QIntDictIterator<Axis> it( Axes ); it.current(); ++it ) {
|
||||
//only write an axis if it is not at the default settings :)
|
||||
if (!it.current()->isDefault()) {
|
||||
it.current()->write( s );
|
||||
do {
|
||||
QHashIterator<int, Axis*> it( Axes );
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
if (!it.value()->isDefault()) {
|
||||
it.value()->write( s );
|
||||
++i;
|
||||
}
|
||||
}
|
||||
for ( QIntDictIterator<Button> it( Buttons ); it.current(); ++it ) {
|
||||
if (!it.current()->isDefault()) {
|
||||
it.current()->write( s );
|
||||
} while (0);
|
||||
QHashIterator<int, Button*> it( Buttons );
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
if (!it.value()->isDefault()) {
|
||||
it.value()->write( s );
|
||||
++i;
|
||||
}
|
||||
}
|
||||
@ -134,12 +192,20 @@ void JoyPad::write( QTextStream* stream ) {
|
||||
}
|
||||
|
||||
void JoyPad::release() {
|
||||
for ( QIntDictIterator<Axis> it( Axes ); it.current(); ++it ) {
|
||||
it.current()->release();
|
||||
do {
|
||||
QHashIterator<int, Axis*> it( Axes );
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
it.value()->release();
|
||||
}
|
||||
for ( QIntDictIterator<Button> it( Buttons ); it.current(); ++it ) {
|
||||
it.current()->release();
|
||||
} while (0);
|
||||
do {
|
||||
QHashIterator<int, Button*> it( Buttons );
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
it.value()->release();
|
||||
}
|
||||
} while (0);
|
||||
}
|
||||
|
||||
void JoyPad::jsevent( js_event msg ) {
|
||||
@ -148,6 +214,7 @@ void JoyPad::jsevent( js_event msg ) {
|
||||
//tell the dialog there was an event. It will use this to flash
|
||||
//the appropriate button, if necesary.
|
||||
jpw->jsevent(msg);
|
||||
return;
|
||||
}
|
||||
//if the dialog is open, stop here. We don't want to signal ourselves with
|
||||
//the input we generate.
|
||||
@ -156,9 +223,13 @@ void JoyPad::jsevent( js_event msg ) {
|
||||
//otherwise, lets create us a fake event! Pass on the event to whichever
|
||||
//Button or Axis was pressed and let them decide what to do with it.
|
||||
if (msg.type & JS_EVENT_AXIS) {
|
||||
printf("DEBUG: passing on an axis event\n");
|
||||
printf("DEBUG: %d %d\n", msg.number, msg.value);
|
||||
Axes[msg.number]->jsevent(msg.value);
|
||||
}
|
||||
else {
|
||||
printf("DEBUG: passing on a button event\n");
|
||||
printf("DEBUG: %d %d\n", msg.number, msg.value);
|
||||
Buttons[msg.number]->jsevent(msg.value);
|
||||
}
|
||||
}
|
||||
@ -169,7 +240,47 @@ JoyPadWidget* JoyPad::widget( QWidget* parent, int i) {
|
||||
return jpw;
|
||||
}
|
||||
|
||||
void JoyPad::handleJoyEvents(int fd) {
|
||||
js_event msg;
|
||||
int len;
|
||||
|
||||
len = read( joydev, &msg, sizeof(js_event));
|
||||
//if there was a real event waiting,
|
||||
if (len == (int) sizeof(js_event)) {
|
||||
//pass that event on to the joypad!
|
||||
jsevent(msg);
|
||||
}
|
||||
|
||||
//sleep for a moment. This is just to keep us from throwing all the
|
||||
//available processer power into madly checking for new events.
|
||||
//usleep(10000);
|
||||
}
|
||||
|
||||
void JoyPad::releaseWidget() {
|
||||
//this is how we know that there is no longer a JoyPadWidget around.
|
||||
jpw = NULL;
|
||||
}
|
||||
|
||||
void JoyPad::unsetDev() {
|
||||
close(joydev);
|
||||
joydev = -1;
|
||||
if(joydevFileHandle != NULL) {
|
||||
delete joydevFileHandle;
|
||||
}
|
||||
}
|
||||
|
||||
void JoyPad::errorRead(int fd) {
|
||||
joydevFileHandle->blockSignals(true);
|
||||
joydevFileHandle->setEnabled(false);
|
||||
close(joydev);
|
||||
if(disconnect(joydevFileHandle , 0, 0, 0)) {
|
||||
joydevFileHandle->deleteLater();
|
||||
joydevFileHandle = NULL;
|
||||
}
|
||||
if(disconnect(joydevFileException, 0, 0, 0)) {
|
||||
joydevFileException->setEnabled(false);
|
||||
joydevFileException->deleteLater();
|
||||
joydevFileException = NULL;
|
||||
}
|
||||
joydev = -1;
|
||||
}
|
||||
|
37
src/joypad.h
37
src/joypad.h
@ -1,19 +1,6 @@
|
||||
#ifndef JOYPAD_H
|
||||
#define JOYPAD_H
|
||||
|
||||
//to have dictionaries of buttons and axes
|
||||
#include <qintdict.h>
|
||||
//the parent of JoyPadWidget
|
||||
#include <qobject.h>
|
||||
|
||||
//for access to qApp so I can check if the application has active windows :)
|
||||
#include <qapplication.h>
|
||||
|
||||
//for actually interacting with the joystick devices
|
||||
#include <linux/joystick.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
//parts of the joypad
|
||||
#include "button.h"
|
||||
#include "axis.h"
|
||||
@ -24,16 +11,27 @@
|
||||
//for raising errors
|
||||
#include "error.h"
|
||||
|
||||
//for actually interacting with the joystick devices
|
||||
#include <linux/joystick.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <QTextStream>
|
||||
#include <QHash>
|
||||
#include <QSocketNotifier>
|
||||
|
||||
|
||||
class JoyPadWidget;
|
||||
|
||||
//represents an actual joystick device
|
||||
class JoyPad : public QObject{
|
||||
Q_OBJECT
|
||||
friend class JoyPadWidget;
|
||||
friend class QuickSet;
|
||||
public:
|
||||
void setupJoyDeviceListener(int dev);
|
||||
JoyPad( int i, int dev );
|
||||
//read from a stream
|
||||
bool read( QTextStream* stream );
|
||||
bool readConfig( QTextStream* stream );
|
||||
//write to a stream
|
||||
void write( QTextStream* stream );
|
||||
//release any pushed buttons and return to a neutral state
|
||||
@ -45,7 +43,7 @@ class JoyPad : public QObject{
|
||||
//true iff this is currently at default settings
|
||||
bool isDefault();
|
||||
//release the connection to the real joystick
|
||||
void unsetDev() {close(joydev); joydev = -1;};
|
||||
void unsetDev();
|
||||
//read the dimensions on the real joystick and use them
|
||||
void resetToDev( int dev );
|
||||
//generates a name ("Joystick 1")
|
||||
@ -66,14 +64,19 @@ class JoyPad : public QObject{
|
||||
//layouts with different numbers of axes/buttons than the current
|
||||
//devices. Note that with the current layout settings, the defined
|
||||
//buttons that don't actually exist on the device may not be contiguous.
|
||||
QIntDict<Axis> Axes;
|
||||
QIntDict<Button> Buttons;
|
||||
QHash<int, Axis*> Axes;
|
||||
QHash<int, Button*> Buttons;
|
||||
//the index of this device (devicenum)
|
||||
int index;
|
||||
|
||||
//the widget that edits this. Mainly I keep track of this to know if
|
||||
//the joypad is currently being edited.
|
||||
JoyPadWidget* jpw;
|
||||
QSocketNotifier *joydevFileHandle;
|
||||
QSocketNotifier *joydevFileException;
|
||||
public slots:
|
||||
void handleJoyEvents(int fd);
|
||||
void errorRead(int fd);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
161
src/layout.cpp
161
src/layout.cpp
@ -1,4 +1,5 @@
|
||||
#include "layout.h"
|
||||
#include <errno.h>
|
||||
|
||||
//initialize things and set up an icon :)
|
||||
LayoutManager::LayoutManager( bool useTrayIcon ) {
|
||||
@ -6,9 +7,9 @@ LayoutManager::LayoutManager( bool useTrayIcon ) {
|
||||
le = NULL;
|
||||
|
||||
//prepare the popup first.
|
||||
Popup = new QPopupMenu();
|
||||
Popup = new QMenu();
|
||||
fillPopup();
|
||||
connect(Popup,SIGNAL(activated(int)),this, SLOT(trayMenu(int)));
|
||||
connect(Popup,SIGNAL(triggered(QAction*)),this, SLOT(trayMenu(QAction*)));
|
||||
|
||||
//make a tray icon
|
||||
if (useTrayIcon) {
|
||||
@ -47,8 +48,8 @@ bool LayoutManager::load(const QString& name) {
|
||||
}
|
||||
|
||||
//if the file isn't readable,
|
||||
if (!file.open(IO_ReadOnly)) {
|
||||
error("Load error","Error reading from file " + file.name());
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
error("Load error","Error reading from file " + file.fileName());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -56,20 +57,22 @@ bool LayoutManager::load(const QString& name) {
|
||||
//note that we don't use available here, but joypads instead. This is so
|
||||
//if one layout has more joypads than this one does, this won't have the
|
||||
//extra settings left over after things are supposed to be "cleared"
|
||||
QIntDictIterator<JoyPad> it( joypads );
|
||||
for ( ; it.current(); ++it ) {
|
||||
it.current()->toDefault();
|
||||
QHashIterator<int, JoyPad*> it( joypads );
|
||||
while (it.hasNext())
|
||||
{
|
||||
it.next();
|
||||
it.value()->toDefault();
|
||||
}
|
||||
|
||||
//start reading joypads!
|
||||
QTextStream stream( &file );
|
||||
QString input = stream.readLine().lower();
|
||||
QString input = stream.readLine().toLower();
|
||||
QRegExp quoted("\"(.*)\"");
|
||||
bool okay;
|
||||
int num;
|
||||
|
||||
while (input != QString::null) {
|
||||
QStringList words = QStringList::split(" ",input);
|
||||
QStringList words = input.split(" ");
|
||||
//if this line is specifying a joystick
|
||||
if (words[0] == "joystick") {
|
||||
num = words[1].toInt(&okay);
|
||||
@ -85,7 +88,7 @@ bool LayoutManager::load(const QString& name) {
|
||||
joypads.insert(num-1, new JoyPad(num-1, 0));
|
||||
}
|
||||
//try to read the joypad, report error on fail.
|
||||
if (!joypads[num-1]->read(&stream)) {
|
||||
if (!joypads[num-1]->readConfig(&stream)) {
|
||||
error( "Load error", "Error reading definition for joystick " + QString::number(num-1));
|
||||
//if this was attempting to change to a new layout and it failed,
|
||||
//revert back to the old layout.
|
||||
@ -97,7 +100,7 @@ bool LayoutManager::load(const QString& name) {
|
||||
}
|
||||
}
|
||||
//read a new line.
|
||||
input = stream.readLine().lower();
|
||||
input = stream.readLine().toLower();
|
||||
}
|
||||
//if loading succeeded, this is our new layout.
|
||||
setLayoutName(name);
|
||||
@ -108,7 +111,7 @@ bool LayoutManager::load() {
|
||||
//try to load the file named "layout" to retrieve the last used layout name
|
||||
QFile file( settingsDir + "layout");
|
||||
QString name;
|
||||
if (file.open(IO_ReadOnly)) {
|
||||
if (file.open(QIODevice::ReadOnly)) {
|
||||
QTextStream stream(&file);
|
||||
name = stream.readLine();
|
||||
file.close();
|
||||
@ -130,8 +133,11 @@ bool LayoutManager::reload() {
|
||||
|
||||
void LayoutManager::clear() {
|
||||
//reset all the joypads...
|
||||
for (QIntDictIterator<JoyPad> it(joypads); it.current(); ++it) {
|
||||
it.current()->toDefault();
|
||||
QHashIterator<int, JoyPad*> it (joypads);
|
||||
while (it.hasNext())
|
||||
{
|
||||
it.next();
|
||||
it.value()->toDefault();
|
||||
}
|
||||
//and call our layout NL
|
||||
setLayoutName(NL);
|
||||
@ -147,11 +153,14 @@ void LayoutManager::save() {
|
||||
QString filename = getFileName( CurrentLayout );
|
||||
QFile file(filename);
|
||||
//if it's good, start writing the file
|
||||
if (file.open(IO_WriteOnly)) {
|
||||
if (file.open(QIODevice::WriteOnly)) {
|
||||
QTextStream stream( &file );
|
||||
stream << "# "NAME" Layout File\n\n";
|
||||
for (QIntDictIterator<JoyPad> it(joypads); it.current(); ++it) {
|
||||
it.current()->write( &stream );
|
||||
QHashIterator<int, JoyPad*> it (joypads);
|
||||
while (it.hasNext())
|
||||
{
|
||||
it.next();
|
||||
it.value()->write( &stream );
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
@ -160,11 +169,14 @@ void LayoutManager::save() {
|
||||
error("Save error", "Could not open file " + filename + ", layout not saved.");
|
||||
}
|
||||
|
||||
|
||||
void LayoutManager::saveAs() {
|
||||
bool ok;
|
||||
//request a new name!
|
||||
QString name = QInputDialog::getText(NAME" - Name new layout","Enter a name for the new layout:", QLineEdit::Normal, QString::null, &ok );
|
||||
if (!ok) return;
|
||||
QString name = QInputDialog::getText(0, NAME" - Name new layout","Enter a name for the new layout:", QLineEdit::Normal, QString::null, &ok );
|
||||
if (!ok) {
|
||||
return;
|
||||
}
|
||||
QFile file(settingsDir + name + ".lyt");
|
||||
//don't overwrite an existing layout.
|
||||
if (file.exists()) {
|
||||
@ -187,7 +199,7 @@ void LayoutManager::saveAs() {
|
||||
|
||||
void LayoutManager::saveDefault() {
|
||||
QFile file( settingsDir + "layout");
|
||||
if (file.open(IO_WriteOnly)) {
|
||||
if (file.open(QIODevice::WriteOnly)) {
|
||||
QTextStream stream(&file);
|
||||
stream << CurrentLayout;
|
||||
file.close();
|
||||
@ -211,7 +223,7 @@ void LayoutManager::remove() {
|
||||
|
||||
QStringList LayoutManager::getLayoutNames() {
|
||||
//goes through the list of .lyt files and removes the file extensions ;)
|
||||
QStringList result = QDir(settingsDir).entryList("*.lyt");
|
||||
QStringList result = QDir(settingsDir).entryList(QStringList("*.lyt"));
|
||||
|
||||
for ( QStringList::Iterator it = result.begin(); it != result.end(); ++it ) {
|
||||
*it = (*it).left((*it).length() - 4);
|
||||
@ -231,11 +243,6 @@ void LayoutManager::setLayoutName(QString name) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void LayoutManager::trayClick() {
|
||||
//don't show the dialog if there aren't any joystick devices plugged in
|
||||
if (available.count() == 0) {
|
||||
@ -255,11 +262,14 @@ void LayoutManager::trayClick() {
|
||||
le = NULL;
|
||||
}
|
||||
|
||||
void LayoutManager::trayMenu(int id) {
|
||||
void LayoutManager::trayMenu(QAction *menuItemAction) {
|
||||
//if they clicked on a Layout name, load it!
|
||||
//note that the other options are handled with their own special functions
|
||||
if (Popup->indexOf(id) > 4 && Popup->text(id) != "Quit") {
|
||||
load(Popup->text(id));
|
||||
printf("%s\n", qPrintable(menuItemAction->text()));
|
||||
if (Popup->actions().indexOf(menuItemAction) > 1 && menuItemAction->text() != "Quit" &&
|
||||
menuItemAction->text() != "Update lyaout list" &&
|
||||
menuItemAction->text() != "Update joystick devices") {
|
||||
load(menuItemAction->text());
|
||||
}
|
||||
}
|
||||
|
||||
@ -269,33 +279,100 @@ void LayoutManager::fillPopup() {
|
||||
|
||||
//make a list of joystick devices
|
||||
QString devs = "Joysticks: ";
|
||||
QIntDictIterator<JoyPad> it( available );
|
||||
for ( ; it.current(); ++it ) {
|
||||
devs += QString::number(it.currentKey() + 1) + " ";
|
||||
QHashIterator<int, JoyPad*> it( available );
|
||||
while (it.hasNext())
|
||||
{
|
||||
it.next();
|
||||
devs += QString::number(it.key() + 1) + " ";
|
||||
}
|
||||
Popup->insertItem(devs);
|
||||
Popup->insertSeparator();
|
||||
QAction *temp = Popup->addAction(devs);
|
||||
Popup->addSeparator(/*temp*/);
|
||||
|
||||
//add in the Update options
|
||||
Popup->insertItem("Update layout list", this, SLOT(fillPopup()));
|
||||
Popup->insertItem("Update joystick devices", this, SLOT(updateJoyDevs()));
|
||||
Popup->insertSeparator();
|
||||
QAction *tempAdd = new QAction("Update layout list", this);
|
||||
connect(tempAdd, SIGNAL(triggered(bool)), this, SLOT(fillPopup()));
|
||||
Popup->addAction(tempAdd);
|
||||
tempAdd = new QAction("Update joystick devices", this);
|
||||
connect(tempAdd, SIGNAL(triggered(bool)), this, SLOT(updateJoyDevs()));
|
||||
Popup->addAction(tempAdd);
|
||||
Popup->addSeparator(/*temp*/);
|
||||
|
||||
//then add all the layout names
|
||||
QStringList names = getLayoutNames();
|
||||
for ( QStringList::Iterator it = names.begin(); it != names.end(); ++it ) {
|
||||
int id = Popup->insertItem(*it);
|
||||
temp = Popup->addAction(*it);
|
||||
temp->setCheckable(true);
|
||||
//put a check by the current one ;)
|
||||
if (CurrentLayout == (*it)) Popup->setItemChecked(id,true);
|
||||
if (CurrentLayout == (*it)) {
|
||||
temp->setChecked(true);
|
||||
}
|
||||
Popup->insertSeparator();
|
||||
}
|
||||
Popup->addSeparator();
|
||||
|
||||
//and, at the end, quit!
|
||||
Popup->insertItem("Quit",qApp,SLOT(quit()));
|
||||
Popup->addAction("Quit",qApp,SLOT(quit()));
|
||||
}
|
||||
|
||||
void LayoutManager::updateJoyDevs() {
|
||||
QString devdir = DEVDIR;
|
||||
//reset all joydevs to sentinal value (-1)
|
||||
do {
|
||||
QHashIterator<int, JoyPad*> it( joypads );
|
||||
while (it.hasNext() ) {
|
||||
it.next();
|
||||
it.value()->unsetDev();
|
||||
}
|
||||
} while (0);
|
||||
|
||||
//clear out the list of previously available joysticks
|
||||
available.clear();
|
||||
|
||||
//set all joydevs anew (create new JoyPad's if necesary)
|
||||
QDir DeviceDir(devdir);
|
||||
QStringList devices = DeviceDir.entryList(QStringList("js*"), QDir::System );
|
||||
QRegExp devicename(".*\\js(\\d+)");
|
||||
int joydev;
|
||||
int index;
|
||||
//for every joystick device in the directory listing...
|
||||
//(note, with devfs, only available devices are listed)
|
||||
for (QStringList::Iterator it = devices.begin(); it != devices.end(); ++it) {
|
||||
//try opening the device.
|
||||
joydev = open( qPrintable(devdir + "/" + (*it)), O_RDONLY | O_NONBLOCK);
|
||||
//if it worked, then we have a live joystick! Make sure it's properly
|
||||
//setup.
|
||||
if (joydev > 0) {
|
||||
devicename.indexIn(*it);
|
||||
index = QString(devicename.cap(1)).toInt();
|
||||
JoyPad* joypad;
|
||||
//if we've never seen this device before, make a new one!
|
||||
if (joypads[index] == 0) {
|
||||
struct pollfd read_struct;
|
||||
read_struct.fd = joydev;
|
||||
read_struct.events = POLLIN;
|
||||
char buf[10];
|
||||
while(poll(&read_struct, 1, 5)!=0) {
|
||||
printf("reading junk data\n");
|
||||
read(joydev, buf, 10);
|
||||
}
|
||||
joypad = new JoyPad( index, joydev );
|
||||
joypads.insert(index,joypad);
|
||||
}
|
||||
else {
|
||||
joypad = joypads[index];
|
||||
joypad->resetToDev(joydev);
|
||||
}
|
||||
//make this joystick device available.
|
||||
available.insert(index,joypad);
|
||||
}
|
||||
else {
|
||||
int errsv = errno;
|
||||
printf("%s\n", strerror(errsv));
|
||||
}
|
||||
}
|
||||
//when it's all done, rebuild the popup menu so it displays the correct
|
||||
//information.
|
||||
fillPopup();
|
||||
//the actual update process is handled by main.cpp, we just need to signal
|
||||
//ourselves to do it.
|
||||
raise(SIGUSR1);
|
||||
//raise(SIGUSR1);
|
||||
}
|
||||
|
@ -1,21 +1,24 @@
|
||||
#include "layout_edit.h"
|
||||
|
||||
|
||||
//build the dialog
|
||||
LayoutEdit::LayoutEdit( LayoutManager* l ) {
|
||||
lm = l;
|
||||
|
||||
setCaption( NAME );
|
||||
setIcon(QPixmap(ICON24));
|
||||
setWindowTitle( NAME );
|
||||
setWindowIcon(QPixmap(ICON24));
|
||||
|
||||
LMain = new QVBoxLayout( this,5,5 );
|
||||
LMain = new QVBoxLayout( this);
|
||||
LMain->setSpacing(5);
|
||||
LMain->setMargin(5);
|
||||
|
||||
QFrame* frame = new QFrame(this);
|
||||
frame->setFrameStyle(QFrame::Box | QFrame::Sunken );
|
||||
QGridLayout* g = new QGridLayout(frame,2,1,5,5);
|
||||
QGridLayout* g = new QGridLayout(frame);
|
||||
g->setMargin(5);
|
||||
g->setSpacing(5);
|
||||
CLayouts = new QComboBox(frame);
|
||||
connect( CLayouts, SIGNAL(activated( const QString& )), lm, SLOT(load(const QString&)));
|
||||
g->addMultiCellWidget(CLayouts,0,0,0,3);
|
||||
g->addWidget(CLayouts,0,0,1,4);
|
||||
|
||||
//most of these buttons can link directly into slots in the LayoutManager
|
||||
BAdd = new QPushButton("Add", frame);
|
||||
@ -32,43 +35,56 @@ LayoutEdit::LayoutEdit( LayoutManager* l ) {
|
||||
g->addWidget(BRev,1,3);
|
||||
LMain->addWidget( frame );
|
||||
|
||||
//we have a WidgetStack to represent the multiple joypads
|
||||
PadStack = new QWidgetStack( this );
|
||||
PadStack->setFrameStyle(QFrame::Box | QFrame::Sunken );
|
||||
LMain->addWidget(PadStack);
|
||||
|
||||
//produce a list of names for the FlashRadioArray
|
||||
//this is only necesary since joystick devices need not always be
|
||||
//contiguous
|
||||
int padcount = available.count();
|
||||
QString names[padcount];
|
||||
int i = 0;
|
||||
QIntDictIterator<JoyPad> it( available );
|
||||
for ( ; it.current(); ++it ) {
|
||||
names[i] = it.current()->getName();
|
||||
do
|
||||
{
|
||||
QHashIterator<int, JoyPad*> it( available );
|
||||
while (it.hasNext())
|
||||
{
|
||||
it.next();
|
||||
names[i] = it.value()->getName();
|
||||
++i;
|
||||
}
|
||||
} while (0);
|
||||
|
||||
//flash radio array
|
||||
JoyButtons = new FlashRadioArray(padcount, names, true, this );
|
||||
LMain->insertWidget( 1, JoyButtons );
|
||||
LMain->addWidget( JoyButtons );
|
||||
|
||||
//we have a WidgetStack to represent the multiple joypads
|
||||
PadStack = new QStackedWidget( this );
|
||||
PadStack->setFrameStyle(QFrame::Box | QFrame::Sunken );
|
||||
LMain->addWidget(PadStack);
|
||||
|
||||
//go through each of the available joysticks
|
||||
i = 0; // i is the current index into PadStack
|
||||
for (it.toFirst() ; it.current(); ++it ) {
|
||||
do
|
||||
{
|
||||
QHashIterator<int, JoyPad*> it(available);
|
||||
while (it.hasNext())
|
||||
{
|
||||
it.next();
|
||||
//add a new JoyPadWidget to the stack
|
||||
PadStack->addWidget( it.current()->widget(PadStack,i),i );
|
||||
PadStack->insertWidget( i,it.value()->widget(PadStack,i) );
|
||||
//every time it "flashes", flash the associated tab.
|
||||
connect( PadStack->widget(i), SIGNAL( flashed( int ) ), JoyButtons, SLOT( flash( int )));
|
||||
++i;
|
||||
}
|
||||
} while (0);
|
||||
//whenever a new tab is selected, raise the appropriate JoyPadWidget
|
||||
connect( JoyButtons, SIGNAL( changed( int ) ), PadStack, SLOT( raiseWidget( int )));
|
||||
connect( JoyButtons, SIGNAL( changed( int ) ), PadStack, SLOT( setCurrentIndex( int )));
|
||||
|
||||
updateLayoutList();
|
||||
|
||||
//add the buttons at the bottom.
|
||||
QHBoxLayout* h = new QHBoxLayout(0,0,5);
|
||||
QHBoxLayout* h = new QHBoxLayout(0);
|
||||
h->setMargin(0);
|
||||
h->setSpacing(5);
|
||||
QPushButton* close = new QPushButton( "-- Close Dialog --", this );
|
||||
connect(close, SIGNAL(clicked()), this, SLOT(close()));
|
||||
h->addWidget(close);
|
||||
@ -80,7 +96,7 @@ LayoutEdit::LayoutEdit( LayoutManager* l ) {
|
||||
|
||||
void LayoutEdit::setLayout(QString layout) {
|
||||
//change the text,
|
||||
CLayouts->setCurrentText(layout);
|
||||
CLayouts->setItemText(CLayouts->currentIndex(), layout);
|
||||
//update all the JoyPadWidgets.
|
||||
for (uint i = 0; i < available.count(); i++) {
|
||||
((JoyPadWidget*)PadStack->widget(i))->update();
|
||||
@ -91,20 +107,20 @@ void LayoutEdit::updateLayoutList() {
|
||||
//blank the list, then load in new names from the LayoutManager.
|
||||
CLayouts->clear();
|
||||
QStringList layouts = lm->getLayoutNames();
|
||||
//For some reason, insertStringList doesn't want to work for me!
|
||||
for ( QStringList::Iterator it = layouts.begin(); it != layouts.end(); ++it ) {
|
||||
CLayouts->insertItem(*it);
|
||||
}
|
||||
CLayouts->setCurrentText(lm->CurrentLayout);
|
||||
CLayouts->insertItems(-1, layouts);
|
||||
CLayouts->setCurrentIndex(layouts.indexOf(lm->CurrentLayout));
|
||||
}
|
||||
|
||||
void LayoutEdit::windowActivationChange( bool oldActive ) {
|
||||
if (oldActive) return;
|
||||
|
||||
//whenever the window becomes active, release all pressed buttons! This way
|
||||
//you don't get any presses without releases to confuse things.
|
||||
QIntDictIterator<JoyPad> it( available );
|
||||
for ( ; it.current(); ++it ) {
|
||||
it.current()->release();
|
||||
QHashIterator<int, JoyPad*> it( available );
|
||||
while (it.hasNext())
|
||||
{
|
||||
printf("iterating and releasing\n");
|
||||
it.next();
|
||||
it.value()->release();
|
||||
}
|
||||
printf("done releasing!\n");
|
||||
}
|
||||
|
@ -1,11 +1,7 @@
|
||||
#ifndef LAYOUT_EDIT_H
|
||||
#define LAYOUT_EDIT_H
|
||||
|
||||
//needed to build the dialog
|
||||
#include <qdialog.h>
|
||||
#include <qlayout.h>
|
||||
#include <qcombobox.h>
|
||||
#include <qwidgetstack.h>
|
||||
#include <QStackedWidget>
|
||||
|
||||
//for the tab list of joypads
|
||||
#include "flash.h"
|
||||
@ -32,15 +28,12 @@ class LayoutEdit : public QDialog {
|
||||
|
||||
//find out when the window is activated.
|
||||
virtual void windowActivationChange( bool oldActive );
|
||||
|
||||
//parts of the dialog:
|
||||
QVBoxLayout *LMain;
|
||||
QWidgetStack *PadStack;
|
||||
QStackedWidget *PadStack;
|
||||
FlashRadioArray *JoyButtons;
|
||||
|
||||
QComboBox* CLayouts;
|
||||
QPushButton *BAdd, *BRem, *BUpd, *BRev;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
96
src/main.cpp
96
src/main.cpp
@ -1,22 +1,13 @@
|
||||
#define MAIN
|
||||
|
||||
//to create a qapplication
|
||||
#include <qapplication.h>
|
||||
//for basic file i/o and argument parsing
|
||||
#include <qstring.h>
|
||||
#include <qdir.h>
|
||||
#include <qfile.h>
|
||||
#include <qstringlist.h>
|
||||
#include <qregexp.h>
|
||||
|
||||
#include <QFile>
|
||||
//for ouput when there is no GUI going
|
||||
#include <stdio.h>
|
||||
|
||||
//to create and handle signals for various events
|
||||
#include <signal.h>
|
||||
|
||||
//for our custom-made event loop
|
||||
#include "loop.h"
|
||||
//to load layouts
|
||||
#include "layout.h"
|
||||
//to give event.h the current X11 display
|
||||
@ -25,77 +16,19 @@
|
||||
#include "device.h"
|
||||
//to produce errors!
|
||||
#include "error.h"
|
||||
#include <QX11Info>
|
||||
#include <poll.h>
|
||||
#include <cstdlib>
|
||||
|
||||
//for making universally available variables
|
||||
extern Display* display; //from event.h
|
||||
QIntDict<JoyPad> available; //to device.h
|
||||
QIntDict<JoyPad> joypads; //to device.h
|
||||
QPtrList<Component> timerList; //to timer.h
|
||||
|
||||
//to be made available in timer.h
|
||||
//they simply pass on the message to JoyLoop
|
||||
void takeTimer( Component* c ) {
|
||||
((JoyLoop*) qApp->eventLoop())->takeTimer( c );
|
||||
}
|
||||
void tossTimer( Component* c ) {
|
||||
((JoyLoop*) qApp->eventLoop())->tossTimer( c );
|
||||
}
|
||||
QHash<int, JoyPad*> available; //to device.h
|
||||
QHash<int, JoyPad*> joypads; //to device.h
|
||||
|
||||
//variables needed in various functions in this file
|
||||
LayoutManager* lm;
|
||||
QString devdir = DEVDIR;
|
||||
|
||||
|
||||
|
||||
//update the joystick devices!
|
||||
void buildJoyDevices() {
|
||||
//reset all joydevs to sentinal value (-1)
|
||||
QIntDictIterator<JoyPad> it( joypads );
|
||||
for ( ; it.current(); ++it ) {
|
||||
it.current()->unsetDev();
|
||||
}
|
||||
|
||||
//clear out the list of previously available joysticks
|
||||
available.clear();
|
||||
|
||||
//set all joydevs anew (create new JoyPad's if necesary)
|
||||
QDir DeviceDir(devdir);
|
||||
QStringList devices = DeviceDir.entryList("js*", QDir::System );
|
||||
QRegExp devicename(".*\\js(\\d+)");
|
||||
int joydev;
|
||||
int index;
|
||||
//for every joystick device in the directory listing...
|
||||
//(note, with devfs, only available devices are listed)
|
||||
for (QStringList::Iterator it = devices.begin(); it != devices.end(); ++it) {
|
||||
//try opening the device.
|
||||
joydev = open( devdir + "/" + (*it), O_RDONLY | O_NONBLOCK);
|
||||
//if it worked, then we have a live joystick! Make sure it's properly
|
||||
//setup.
|
||||
if (joydev > 0) {
|
||||
devicename.match(*it);
|
||||
index = QString(devicename.cap(1)).toInt();
|
||||
JoyPad* joypad;
|
||||
//if we've never seen this device before, make a new one!
|
||||
if (joypads[index] == 0) {
|
||||
joypad = new JoyPad( index, joydev );
|
||||
joypads.insert(index,joypad);
|
||||
}
|
||||
else {
|
||||
joypad = joypads[index];
|
||||
joypad->resetToDev(joydev);
|
||||
}
|
||||
//make this joystick device available.
|
||||
available.insert(index,joypad);
|
||||
}
|
||||
}
|
||||
|
||||
//when it's all done, rebuild the popup menu so it displays the correct
|
||||
//information.
|
||||
lm->fillPopup();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//signal handler for SIGIO
|
||||
//SIGIO means that a new layout should be loaded. It is saved in
|
||||
// ~/.qjoypad/layout, where the last used layout is put.
|
||||
@ -111,7 +44,8 @@ void catchSIGIO( int sig )
|
||||
//signal handler for SIGUSR1
|
||||
//SIGUSR1 means that we should update the available joystick device list.
|
||||
void catchSIGUSR1( int sig ) {
|
||||
buildJoyDevices();
|
||||
//buildJoyDevices();
|
||||
lm->updateJoyDevs();
|
||||
//remember to catch this signal again next time.
|
||||
signal( sig, catchSIGUSR1 );
|
||||
}
|
||||
@ -130,7 +64,6 @@ int main( int argc, char **argv )
|
||||
{
|
||||
//create a new event loop. This will be captured by the QApplication
|
||||
//when it gets created
|
||||
JoyLoop loop;
|
||||
QApplication a( argc, argv );
|
||||
|
||||
|
||||
@ -139,7 +72,7 @@ int main( int argc, char **argv )
|
||||
|
||||
//if there is no new directory and we can't make it, complain
|
||||
if (!dir.exists() && !dir.mkdir(settingsDir)) {
|
||||
printf("Couldn't create the QJoyPad save directory (" + settingsDir + ")!");
|
||||
printf("Couldn't create the QJoyPad save directory (%s)!", settingsDir.toStdString().c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -191,7 +124,7 @@ int main( int argc, char **argv )
|
||||
//then we try to store that layout in the last-used layout spot, to be
|
||||
//loaded by default.
|
||||
QFile file( settingsDir + "layout");
|
||||
if (file.open(IO_WriteOnly))
|
||||
if (file.open(QIODevice::WriteOnly))
|
||||
{
|
||||
QTextStream stream( &file );
|
||||
stream << layout;
|
||||
@ -209,7 +142,7 @@ int main( int argc, char **argv )
|
||||
if (pidFile.exists())
|
||||
{
|
||||
int pid;
|
||||
if (pidFile.open( IO_ReadOnly ));
|
||||
if (pidFile.open( QIODevice::ReadOnly ));
|
||||
{
|
||||
//try to get that pid...
|
||||
QTextStream( &pidFile ) >> pid;
|
||||
@ -234,7 +167,7 @@ int main( int argc, char **argv )
|
||||
}
|
||||
}
|
||||
//now we can try to create and write our pid to the lock file.
|
||||
if (pidFile.open( IO_WriteOnly ))
|
||||
if (pidFile.open( QIODevice::WriteOnly ))
|
||||
{
|
||||
QTextStream( &pidFile ) << getpid();
|
||||
pidFile.close();
|
||||
@ -252,14 +185,15 @@ int main( int argc, char **argv )
|
||||
|
||||
|
||||
//capture the current display for event.h
|
||||
display = QPaintDevice::x11AppDisplay();
|
||||
display = QX11Info::display();
|
||||
|
||||
//create a new LayoutManager with a tray icon / floating icon, depending
|
||||
//on the user's request
|
||||
lm = new LayoutManager(useTrayIcon);
|
||||
|
||||
//build the joystick device list for the first time,
|
||||
buildJoyDevices();
|
||||
//buildJoyDevices();
|
||||
lm->updateJoyDevs();
|
||||
|
||||
//load the last used layout (Or the one given as a command-line argument)
|
||||
lm->load();
|
||||
|
BIN
src/qjoypad
BIN
src/qjoypad
Binary file not shown.
@ -1,89 +0,0 @@
|
||||
########################################
|
||||
# #
|
||||
# QMake project file for QJoyPad #
|
||||
# #
|
||||
########################################
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
##### Setup Targets #####
|
||||
|
||||
target.path = $$PREFIX/bin
|
||||
|
||||
icons.path = $$PREFIX/share/pixmaps/qjoypad
|
||||
icons.extra = cp ../icons/* $${icons.path}; cd $${icons.path}; ln -sf gamepad4-24x24.png icon24.png; ln -sf gamepad3-64x64.png icon64.png; chmod -R a+r $${icons.path}
|
||||
|
||||
doc.path = $$PREFIX/doc/qjoypad3
|
||||
doc.extra = cp ../README.txt ../LICENSE.txt $${doc.path}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
##### Setup Compile #####
|
||||
|
||||
DEFINES += DEVDIR='"$$DEVDIR"'
|
||||
DEFINES += ICON24='"$${icons.path}/icon24.png"'
|
||||
DEFINES += ICON64='"$${icons.path}/icon64.png"'
|
||||
|
||||
TEMPLATE = app
|
||||
DEPENDPATH += trayicon
|
||||
INCLUDEPATH += . trayicon
|
||||
QMAKE_LIBS += -lXtst
|
||||
|
||||
# Input
|
||||
HEADERS += axis.h \
|
||||
axis_edit.h \
|
||||
axisw.h \
|
||||
button.h \
|
||||
button_edit.h \
|
||||
buttonw.h \
|
||||
component.h \
|
||||
constant.h \
|
||||
device.h \
|
||||
error.h \
|
||||
event.h \
|
||||
flash.h \
|
||||
icon.h \
|
||||
joypad.h \
|
||||
joypadw.h \
|
||||
joyslider.h \
|
||||
keycode.h \
|
||||
layout.h \
|
||||
layout_edit.h \
|
||||
loop.h \
|
||||
quickset.h \
|
||||
timer.h \
|
||||
trayicon/trayicon.h
|
||||
SOURCES += axis.cpp \
|
||||
axis_edit.cpp \
|
||||
axisw.cpp \
|
||||
button.cpp \
|
||||
button_edit.cpp \
|
||||
buttonw.cpp \
|
||||
event.cpp \
|
||||
flash.cpp \
|
||||
icon.cpp \
|
||||
joypad.cpp \
|
||||
joypadw.cpp \
|
||||
joyslider.cpp \
|
||||
keycode.cpp \
|
||||
layout.cpp \
|
||||
layout_edit.cpp \
|
||||
loop.cpp \
|
||||
main.cpp \
|
||||
quickset.cpp \
|
||||
trayicon/trayicon.cpp \
|
||||
trayicon/trayicon_x11.cpp
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
##### Install #####
|
||||
|
||||
INSTALLS += target icons doc
|
@ -1,16 +1,21 @@
|
||||
#include "quickset.h"
|
||||
#include "getkey.h"
|
||||
|
||||
//build the dialog
|
||||
QuickSet::QuickSet( JoyPad* jp)
|
||||
: QDialog() {
|
||||
setting = false;
|
||||
joypad = jp;
|
||||
setCaption("Quick set " + joypad->getName());
|
||||
QVBoxLayout* LMain = new QVBoxLayout(this,5,5);
|
||||
LMain->setAutoAdd(true);
|
||||
setWindowTitle("Set " + jp->getName());
|
||||
QVBoxLayout* LMain = new QVBoxLayout(this);
|
||||
LMain->setMargin(5);
|
||||
LMain->setSpacing(5);
|
||||
//LMain->setAutoAdd(true);
|
||||
|
||||
new QLabel("Press any button or axis and\nyou will be prompted for a key.",this);
|
||||
QLabel *temp = new QLabel("Press any button or axis and\nyou will be prompted for a key.",this);
|
||||
LMain->addWidget(temp);
|
||||
QPushButton* button = new QPushButton("Done",this);
|
||||
LMain->addWidget(button);
|
||||
connect( button, SIGNAL(clicked()), this, SLOT(accept()));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user