Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
fengzch-das
OIS
Commits
dc461f60
Commit
dc461f60
authored
Aug 15, 2010
by
Phillip Castaneda
Browse files
Remove x11 auto repeat setting change. Try to detect repeated keys with other method
parent
63f8f424
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
50 deletions
+36
-50
demos/OISConsole.cpp
demos/OISConsole.cpp
+2
-1
includes/linux/LinuxInputManager.h
includes/linux/LinuxInputManager.h
+0
-3
includes/linux/LinuxKeyboard.h
includes/linux/LinuxKeyboard.h
+19
-5
src/linux/LinuxInputManager.cpp
src/linux/LinuxInputManager.cpp
+1
-7
src/linux/LinuxKeyboard.cpp
src/linux/LinuxKeyboard.cpp
+14
-34
No files found.
demos/OISConsole.cpp
View file @
dc461f60
...
...
@@ -77,7 +77,8 @@ public:
}
bool
keyReleased
(
const
KeyEvent
&
arg
)
{
if
(
arg
.
key
==
KC_ESCAPE
||
arg
.
key
==
KC_Q
)
appRunning
=
false
;
appRunning
=
false
;
std
::
cout
<<
"KeyReleased {"
<<
((
Keyboard
*
)(
arg
.
device
))
->
getAsString
(
arg
.
key
)
<<
"}
\n
"
;
return
true
;
}
bool
mouseMoved
(
const
MouseEvent
&
arg
)
{
...
...
includes/linux/LinuxInputManager.h
View file @
dc461f60
...
...
@@ -100,9 +100,6 @@ namespace OIS
bool
grabMouse
,
grabKeyboard
;
bool
mGrabs
;
bool
hideMouse
;
//! By default, keyboard disables XRepeatRate
bool
useXRepeat
;
};
}
#endif
includes/linux/LinuxKeyboard.h
View file @
dc461f60
...
...
@@ -33,7 +33,7 @@ namespace OIS
class
LinuxKeyboard
:
public
Keyboard
{
public:
LinuxKeyboard
(
InputManager
*
creator
,
bool
buffered
,
bool
grab
,
bool
useXRepeat
);
LinuxKeyboard
(
InputManager
*
creator
,
bool
buffered
,
bool
grab
);
virtual
~
LinuxKeyboard
();
/** @copydoc Keyboard::isKeyDown */
...
...
@@ -57,7 +57,24 @@ namespace OIS
/** @copydoc Object::_initialize */
virtual
void
_initialize
();
protected:
protected:
inline
bool
_isKeyRepeat
(
XEvent
&
event
)
{
//When a key is repeated, there will be two events: released, followed by another immediate pressed. So check to see if another pressed is present
if
(
!
XPending
(
display
))
return
false
;
XEvent
e
;
XPeekEvent
(
display
,
&
e
);
if
(
e
.
type
==
KeyPress
&&
e
.
xkey
.
keycode
==
event
.
xkey
.
keycode
&&
(
e
.
xkey
.
time
-
event
.
xkey
.
time
)
<
2
)
{
XNextEvent
(
display
,
&
e
);
return
true
;
}
return
false
;
}
bool
_injectKeyDown
(
KeySym
key
,
int
text
);
bool
_injectKeyUp
(
KeySym
key
);
...
...
@@ -74,9 +91,6 @@ namespace OIS
bool
grabKeyboard
;
bool
keyFocusLost
;
bool
xAutoRepeat
;
bool
oldXAutoRepeat
;
std
::
string
mGetString
;
};
}
...
...
src/linux/LinuxInputManager.cpp
View file @
dc461f60
...
...
@@ -39,7 +39,6 @@ LinuxInputManager::LinuxInputManager() : InputManager("X11InputManager")
grabKeyboard
=
true
;
hideMouse
=
true
;
mGrabs
=
true
;
useXRepeat
=
false
;
keyboardUsed
=
mouseUsed
=
false
;
//Setup our internal factories
...
...
@@ -73,11 +72,6 @@ void LinuxInputManager::_parseConfigSettings( ParamList ¶mList )
window
=
strtoul
(
i
->
second
.
c_str
(),
0
,
10
);
//--------- Keyboard Settings ------------//
i
=
paramList
.
find
(
"XAutoRepeatOn"
);
if
(
i
!=
paramList
.
end
()
)
if
(
i
->
second
==
"true"
)
useXRepeat
=
true
;
i
=
paramList
.
find
(
"x11_keyboard_grab"
);
if
(
i
!=
paramList
.
end
()
)
if
(
i
->
second
==
"false"
)
...
...
@@ -171,7 +165,7 @@ Object* LinuxInputManager::createObject(InputManager *creator, Type iType, bool
case
OISKeyboard
:
{
if
(
keyboardUsed
==
false
)
obj
=
new
LinuxKeyboard
(
this
,
bufferMode
,
grabKeyboard
,
useXRepeat
);
obj
=
new
LinuxKeyboard
(
this
,
bufferMode
,
grabKeyboard
);
break
;
}
case
OISMouse
:
...
...
src/linux/LinuxKeyboard.cpp
View file @
dc461f60
...
...
@@ -32,7 +32,7 @@ restrictions:
using
namespace
OIS
;
#include <iostream>
//-------------------------------------------------------------------//
LinuxKeyboard
::
LinuxKeyboard
(
InputManager
*
creator
,
bool
buffered
,
bool
grab
,
bool
useXRepeat
)
LinuxKeyboard
::
LinuxKeyboard
(
InputManager
*
creator
,
bool
buffered
,
bool
grab
)
:
Keyboard
(
creator
->
inputSystemName
(),
buffered
,
0
,
creator
)
{
setlocale
(
LC_CTYPE
,
""
);
//Set the locale to (hopefully) the users LANG UTF-8 Env var
...
...
@@ -43,9 +43,6 @@ LinuxKeyboard::LinuxKeyboard(InputManager* creator, bool buffered, bool grab, bo
grabKeyboard
=
grab
;
keyFocusLost
=
false
;
xAutoRepeat
=
useXRepeat
;
oldXAutoRepeat
=
false
;
//X Key Map to KeyCode
keyConversion
.
insert
(
XtoOIS_KeyMap
::
value_type
(
XK_1
,
KC_1
));
keyConversion
.
insert
(
XtoOIS_KeyMap
::
value_type
(
XK_2
,
KC_2
));
...
...
@@ -212,20 +209,6 @@ void LinuxKeyboard::_initialize()
XGrabKeyboard
(
display
,
window
,
True
,
GrabModeAsync
,
GrabModeAsync
,
CurrentTime
);
keyFocusLost
=
false
;
if
(
xAutoRepeat
==
false
)
{
//We do not want to blindly turn on autorepeat later when quiting if
//it was not on to begin with.. So, let us check and see first
XKeyboardState
old
;
XGetKeyboardControl
(
display
,
&
old
);
oldXAutoRepeat
=
false
;
if
(
old
.
global_auto_repeat
==
AutoRepeatModeOn
)
oldXAutoRepeat
=
true
;
XAutoRepeatOff
(
display
);
}
}
//-------------------------------------------------------------------//
...
...
@@ -233,9 +216,6 @@ LinuxKeyboard::~LinuxKeyboard()
{
if
(
display
)
{
if
(
oldXAutoRepeat
)
XAutoRepeatOn
(
display
);
if
(
grabKeyboard
)
XUngrabKeyboard
(
display
,
CurrentTime
);
...
...
@@ -302,14 +282,13 @@ void LinuxKeyboard::capture()
LinuxInputManager
*
linMan
=
static_cast
<
LinuxInputManager
*>
(
mCreator
);
while
(
XPending
(
display
)
>
0
)
{
{
XNextEvent
(
display
,
&
event
);
if
(
KeyPress
==
event
.
type
)
if
(
KeyPress
==
event
.
type
)
{
unsigned
int
character
=
0
;
if
(
mTextMode
!=
Off
)
if
(
mTextMode
!=
Off
)
{
unsigned
char
buffer
[
6
]
=
{
0
,
0
,
0
,
0
,
0
,
0
};
XLookupString
(
&
event
.
xkey
,
(
char
*
)
buffer
,
6
,
&
key
,
0
);
...
...
@@ -334,16 +313,17 @@ void LinuxKeyboard::capture()
//Check for Alt-Tab
if
(
event
.
xkey
.
state
&
Mod1Mask
&&
key
==
XK_Tab
)
linMan
->
_setGrabState
(
false
);
}
else
if
(
KeyRelease
==
event
.
type
)
{
//Mask out the modifier states X sets.. or we will get improper values
event
.
xkey
.
state
&=
~
ShiftMask
;
event
.
xkey
.
state
&=
~
LockMask
;
}
else
if
(
KeyRelease
==
event
.
type
)
{
if
(
!
_isKeyRepeat
(
event
))
{
//Mask out the modifier states X sets.. or we will get improper values
event
.
xkey
.
state
&=
~
ShiftMask
;
event
.
xkey
.
state
&=
~
LockMask
;
//Else, it is a valid key release
XLookupString
(
&
event
.
xkey
,
NULL
,
0
,
&
key
,
NULL
);
_injectKeyUp
(
key
);
XLookupString
(
&
event
.
xkey
,
NULL
,
0
,
&
key
,
NULL
);
_injectKeyUp
(
key
);
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment