Set/synchronize CAPSLOCK from X11

This commit is contained in:
Aaron Culliney 2014-01-01 11:13:22 -08:00
parent 8414a37025
commit 58041f5105
3 changed files with 7 additions and 6 deletions

View File

@ -52,7 +52,7 @@ extern int raw_js_y;
static int next_key = -1; static int next_key = -1;
static int last_scancode = -1; static int last_scancode = -1;
static char caps_lock = 1; /* is enabled */ bool caps_lock = false; /* is enabled */
static bool in_interface = false; static bool in_interface = false;
/* ---------------------------------------------------- /* ----------------------------------------------------
@ -165,11 +165,6 @@ void c_handle_input(int scancode, int pressed)
{ {
last_scancode = scancode; last_scancode = scancode;
if (key_pressed[ SCODE_CAPS ])
{
caps_lock = !caps_lock;
}
if ((key_pressed[ SCODE_L_SHIFT ] || key_pressed[ SCODE_R_SHIFT ]) && if ((key_pressed[ SCODE_L_SHIFT ] || key_pressed[ SCODE_R_SHIFT ]) &&
(key_pressed[ SCODE_L_CTRL ] || key_pressed[ SCODE_R_CTRL ])) (key_pressed[ SCODE_L_CTRL ] || key_pressed[ SCODE_R_CTRL ]))
{ {

View File

@ -137,6 +137,7 @@
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
extern pthread_mutex_t interface_mutex; extern pthread_mutex_t interface_mutex;
extern bool caps_lock;
#ifdef PC_JOYSTICK #ifdef PC_JOYSTICK
extern int js_fd; extern int js_fd;

View File

@ -556,6 +556,11 @@ void video_sync(int block) {
// also process other input events // also process other input events
post_image(); post_image();
// sync to the capslock state (which could be modified outside this app)
unsigned int caps_state = 0;
XkbGetIndicatorState(display, XkbUseCoreKbd, &caps_state);
caps_lock = (caps_state & 0x01);
bool keyevent = true; bool keyevent = true;
do { do {
if (doShm) if (doShm)