-rw-r--r-- | examples/opiecore/oinputsystemdemo/oinputsystemdemo.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/examples/opiecore/oinputsystemdemo/oinputsystemdemo.cpp b/examples/opiecore/oinputsystemdemo/oinputsystemdemo.cpp index a9c0fd2..6c95048 100644 --- a/examples/opiecore/oinputsystemdemo/oinputsystemdemo.cpp +++ b/examples/opiecore/oinputsystemdemo/oinputsystemdemo.cpp | |||
@@ -54,64 +54,74 @@ int main( int argc, char** argv ) | |||
54 | 54 | ||
55 | QString features; | 55 | QString features; |
56 | features += QString( "\nSynchronous: " ); | 56 | features += QString( "\nSynchronous: " ); |
57 | if ( dev->hasFeature( OInputDevice::Synchronous ) ) features += "[ x ]"; else features += "[ ]"; | 57 | if ( dev->hasFeature( OInputDevice::Synchronous ) ) features += "[ x ]"; else features += "[ ]"; |
58 | features += QString( "\nKeys or Buttons: " ); | 58 | features += QString( "\nKeys or Buttons: " ); |
59 | if ( dev->hasFeature( OInputDevice::Keys ) ) features += "[ x ]"; else features += "[ ]"; | 59 | if ( dev->hasFeature( OInputDevice::Keys ) ) features += "[ x ]"; else features += "[ ]"; |
60 | features += QString( "\nRelative Axes: " ); | 60 | features += QString( "\nRelative Axes: " ); |
61 | if ( dev->hasFeature( OInputDevice::Relative ) ) features += "[ x ]"; else features += "[ ]"; | 61 | if ( dev->hasFeature( OInputDevice::Relative ) ) features += "[ x ]"; else features += "[ ]"; |
62 | features += QString( "\nAbsolute Axes: " ); | 62 | features += QString( "\nAbsolute Axes: " ); |
63 | if ( dev->hasFeature( OInputDevice::Absolute ) ) features += "[ x ]"; else features += "[ ]"; | 63 | if ( dev->hasFeature( OInputDevice::Absolute ) ) features += "[ x ]"; else features += "[ ]"; |
64 | features += QString( "\nMiscellaneous: " ); | 64 | features += QString( "\nMiscellaneous: " ); |
65 | if ( dev->hasFeature( OInputDevice::Miscellaneous ) ) features += "[ x ]"; else features += "[ ]"; | 65 | if ( dev->hasFeature( OInputDevice::Miscellaneous ) ) features += "[ x ]"; else features += "[ ]"; |
66 | features += QString( "\nLeds: " ); | 66 | features += QString( "\nLeds: " ); |
67 | if ( dev->hasFeature( OInputDevice::Leds ) ) features += "[ x ]"; else features += "[ ]"; | 67 | if ( dev->hasFeature( OInputDevice::Leds ) ) features += "[ x ]"; else features += "[ ]"; |
68 | features += QString( "\nSound: " ); | 68 | features += QString( "\nSound: " ); |
69 | if ( dev->hasFeature( OInputDevice::Sound ) ) features += "[ x ]"; else features += "[ ]"; | 69 | if ( dev->hasFeature( OInputDevice::Sound ) ) features += "[ x ]"; else features += "[ ]"; |
70 | features += QString( "\nAutoRepeat " ); | 70 | features += QString( "\nAutoRepeat " ); |
71 | if ( dev->hasFeature( OInputDevice::AutoRepeat ) ) features += "[ x ]"; else features += "[ ]"; | 71 | if ( dev->hasFeature( OInputDevice::AutoRepeat ) ) features += "[ x ]"; else features += "[ ]"; |
72 | features += QString( "\nForceFeedback: " ); | 72 | features += QString( "\nForceFeedback: " ); |
73 | if ( dev->hasFeature( OInputDevice::ForceFeedback ) ) features += "[ x ]"; else features += "[ ]"; | 73 | if ( dev->hasFeature( OInputDevice::ForceFeedback ) ) features += "[ x ]"; else features += "[ ]"; |
74 | features += QString( "\nPowerManagement: " ); | 74 | features += QString( "\nPowerManagement: " ); |
75 | if ( dev->hasFeature( OInputDevice::PowerManagement ) ) features += "[ x ]"; else features += "[ ]"; | 75 | if ( dev->hasFeature( OInputDevice::PowerManagement ) ) features += "[ x ]"; else features += "[ ]"; |
76 | features += QString( "\nFeedbackStatus: " ); | 76 | features += QString( "\nFeedbackStatus: " ); |
77 | if ( dev->hasFeature( OInputDevice::ForceFeedbackStatus ) ) features += "[ x ]"; else features += "[ ]"; | 77 | if ( dev->hasFeature( OInputDevice::ForceFeedbackStatus ) ) features += "[ x ]"; else features += "[ ]"; |
78 | 78 | ||
79 | odebug << "========================================" | 79 | odebug << "========================================" |
80 | << "\nDevice: " << dev->name() | 80 | << "\nDevice: " << dev->name() |
81 | << "\nName: " << dev->identity() | 81 | << "\nName: " << dev->identity() |
82 | << "\nPath: " << dev->path() | 82 | << "\nPath: " << dev->path() |
83 | << "\nUniq: " << dev->uniq() | 83 | << "\nUniq: " << dev->uniq() |
84 | << features << "\n" | 84 | << features << "\n" |
85 | << oendl; | 85 | << oendl; |
86 | |||
87 | if ( dev->isHeld( OInputDevice::Key_LEFTSHIFT ) ) | ||
88 | odebug << "Left Shift is being held." << oendl; | ||
89 | else odebug << "Left Shift is _not_ being held." << oendl; | ||
90 | |||
91 | if ( dev->isHeld( OInputDevice::Button_LEFT ) ) | ||
92 | odebug << "Left Mouse Button is being held." << oendl; | ||
93 | else odebug << "Left Mouse Button is _not_ being held." << oendl; | ||
94 | |||
95 | odebug << "Global key mask: " << dev->globalKeyMask() << oendl; | ||
86 | 96 | ||
87 | ++it; | 97 | ++it; |
88 | } | 98 | } |
89 | } | 99 | } |
90 | 100 | ||
91 | #else | 101 | #else |
92 | 102 | ||
93 | #include <fcntl.h> | 103 | #include <fcntl.h> |
94 | #include <unistd.h> | 104 | #include <unistd.h> |
95 | #include <cstdlib> | 105 | #include <cstdlib> |
96 | #include <cstdio> | 106 | #include <cstdio> |
97 | #include <string> | 107 | #include <string> |
98 | 108 | ||
99 | #include <sys/types.h> | 109 | #include <sys/types.h> |
100 | #include <linux/input.h> | 110 | #include <linux/input.h> |
101 | 111 | ||
102 | using std::string; | 112 | using std::string; |
103 | 113 | ||
104 | const unsigned char BUT1 = 0x01; | 114 | const unsigned char BUT1 = 0x01; |
105 | const unsigned char BUT2 = 0x04; | 115 | const unsigned char BUT2 = 0x04; |
106 | const unsigned char BUT3 = 0x02; | 116 | const unsigned char BUT3 = 0x02; |
107 | const unsigned char BUT4 = 0x40; | 117 | const unsigned char BUT4 = 0x40; |
108 | const unsigned char BUT5 = 0x80; | 118 | const unsigned char BUT5 = 0x80; |
109 | 119 | ||
110 | #define BITMASK( name, numbits ) \ | 120 | #define BITMASK( name, numbits ) \ |
111 | unsigned short name[ ((numbits) - 1) / (sizeof( short ) * 8) + 1 ]; \ | 121 | unsigned short name[ ((numbits) - 1) / (sizeof( short ) * 8) + 1 ]; \ |
112 | memset( name, 0, sizeof( name ) ) | 122 | memset( name, 0, sizeof( name ) ) |
113 | 123 | ||
114 | #define TEST_BIT( bitmask, bit ) \ | 124 | #define TEST_BIT( bitmask, bit ) \ |
115 | ( bitmask[ (bit) / sizeof(short) / 8 ] & (1u << ( (bit) % (sizeof(short) * 8))) ) | 125 | ( bitmask[ (bit) / sizeof(short) / 8 ] & (1u << ( (bit) % (sizeof(short) * 8))) ) |
116 | 126 | ||
117 | int Open_cPad() | 127 | int Open_cPad() |