mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
list not really needed
This commit is contained in:
parent
79e3e153bd
commit
e88521f94e
@ -6,67 +6,6 @@ static char *NAME = ":0.0";
|
|||||||
static int REGISTERED = 0;
|
static int REGISTERED = 0;
|
||||||
static int DIRTY = 0;
|
static int DIRTY = 0;
|
||||||
|
|
||||||
struct linked_list
|
|
||||||
{
|
|
||||||
unsigned long number;
|
|
||||||
KeyCode keycode;
|
|
||||||
struct linked_list *next;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct linked_list node;
|
|
||||||
node *head = NULL, *last = NULL;
|
|
||||||
|
|
||||||
void insertAtLast(unsigned long value, KeyCode keycode) {
|
|
||||||
node *temp_node;
|
|
||||||
temp_node = (node *) malloc(sizeof(node));
|
|
||||||
|
|
||||||
temp_node->number = value;
|
|
||||||
temp_node->keycode = keycode;
|
|
||||||
temp_node->next = NULL;
|
|
||||||
|
|
||||||
//For the 1st element
|
|
||||||
if(!head) {
|
|
||||||
head = temp_node;
|
|
||||||
last = temp_node;
|
|
||||||
} else {
|
|
||||||
last->next = temp_node;
|
|
||||||
last = temp_node;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void deleteItem(unsigned long value) {
|
|
||||||
node *myNode = head, *previous = NULL;
|
|
||||||
|
|
||||||
while(myNode) {
|
|
||||||
if(myNode->number == value) {
|
|
||||||
if(!previous)
|
|
||||||
head = myNode->next;
|
|
||||||
else
|
|
||||||
previous->next = myNode->next;
|
|
||||||
|
|
||||||
free(myNode);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
previous = myNode;
|
|
||||||
myNode = myNode->next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
node *searchItemNode(unsigned long value) {
|
|
||||||
node *searchNode = head;
|
|
||||||
|
|
||||||
while(searchNode) {
|
|
||||||
if(searchNode->number == value) {
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
searchNode = searchNode->next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return searchNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
Display *getXDisplay(void) {
|
Display *getXDisplay(void) {
|
||||||
/* Close the display if displayName has changed */
|
/* Close the display if displayName has changed */
|
||||||
if (DIRTY) {
|
if (DIRTY) {
|
||||||
@ -190,55 +129,41 @@ KeyCode XkbKeysymToKeycode(KeySym keysym) {
|
|||||||
int XKey(unsigned long key, int down) {
|
int XKey(unsigned long key, int down) {
|
||||||
Display *display = getXDisplay();
|
Display *display = getXDisplay();
|
||||||
KeyCode code = -2;
|
KeyCode code = -2;
|
||||||
// node *compareNode;
|
|
||||||
// compareNode = searchItemNode(key);
|
|
||||||
|
|
||||||
if (down) {
|
if (down) {
|
||||||
// if (compareNode && compareNode != last) {
|
code = XkbKeysymToKeycode(key);
|
||||||
// code = compareNode->keycode;
|
if (!code) {
|
||||||
// } else {
|
int min, max, numcodes;
|
||||||
code = XkbKeysymToKeycode(key);
|
XDisplayKeycodes(display, &min, &max);
|
||||||
if (!code) {
|
XGetKeyboardMapping(display, min, max-min, &numcodes);
|
||||||
int min, max, numcodes;
|
|
||||||
XDisplayKeycodes(display, &min, &max);
|
|
||||||
XGetKeyboardMapping(display, min, max-min, &numcodes);
|
|
||||||
|
|
||||||
code = (max-min+1)*numcodes;
|
code = (max-min+1)*numcodes;
|
||||||
KeySym keysym_list[numcodes];
|
KeySym keysym_list[numcodes];
|
||||||
for(int i=0;i<numcodes;i++) keysym_list[i] = key;
|
for(int i=0;i<numcodes;i++) keysym_list[i] = key;
|
||||||
XChangeKeyboardMapping(display, code, numcodes, keysym_list, 1);
|
XChangeKeyboardMapping(display, code, numcodes, keysym_list, 1);
|
||||||
}
|
}
|
||||||
if (!code)
|
if (!code)
|
||||||
return -1;
|
return -1;
|
||||||
// }
|
|
||||||
// insertAtLast(key, code);
|
|
||||||
XTestFakeKeyEvent(display, code, down, CurrentTime);
|
XTestFakeKeyEvent(display, code, down, CurrentTime);
|
||||||
XSync(display, 0);
|
XSync(display, 0);
|
||||||
} else {
|
} else {
|
||||||
// if (compareNode) {
|
code = XkbKeysymToKeycode(key);
|
||||||
// code = compareNode->keycode;
|
if (!code) {
|
||||||
|
int min, max, numcodes;
|
||||||
|
XDisplayKeycodes(display, &min, &max);
|
||||||
|
XGetKeyboardMapping(display, min, max-min, &numcodes);
|
||||||
|
|
||||||
code = XkbKeysymToKeycode(key);
|
code = (max-min+1)*numcodes;
|
||||||
if (!code) {
|
KeySym keysym_list[numcodes];
|
||||||
int min, max, numcodes;
|
for(int i=0;i<numcodes;i++) keysym_list[i] = key;
|
||||||
XDisplayKeycodes(display, &min, &max);
|
XChangeKeyboardMapping(display, code, numcodes, keysym_list, 1);
|
||||||
XGetKeyboardMapping(display, min, max-min, &numcodes);
|
}
|
||||||
|
if (!code)
|
||||||
|
return -1;
|
||||||
|
|
||||||
code = (max-min+1)*numcodes;
|
XTestFakeKeyEvent(display, code, down, CurrentTime);
|
||||||
KeySym keysym_list[numcodes];
|
XSync(display, 0);
|
||||||
for(int i=0;i<numcodes;i++) keysym_list[i] = key;
|
|
||||||
XChangeKeyboardMapping(display, code, numcodes, keysym_list, 1);
|
|
||||||
}
|
|
||||||
if (!code)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
XTestFakeKeyEvent(display, code, down, CurrentTime);
|
|
||||||
XSync(display, 0);
|
|
||||||
// deleteItem(key);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// return code;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void XClipboardSet(char *src) {
|
void XClipboardSet(char *src) {
|
||||||
|
@ -73,12 +73,10 @@ func KeyDown(code uint64) error {
|
|||||||
return fmt.Errorf("debounced key %v", code)
|
return fmt.Errorf("debounced key %v", code)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("Code-Press %v", code)
|
|
||||||
debounce_key[code] = time.Now()
|
debounce_key[code] = time.Now()
|
||||||
|
|
||||||
t := C.XKey(C.ulong(code), C.int(1))
|
C.XKey(C.ulong(code), C.int(1))
|
||||||
|
|
||||||
fmt.Printf("X-Press %v", t)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,10 +104,8 @@ func KeyUp(code uint64) error {
|
|||||||
|
|
||||||
delete(debounce_key, code)
|
delete(debounce_key, code)
|
||||||
|
|
||||||
fmt.Printf("Code-Release %v", code)
|
C.XKey(C.ulong(code), C.int(0))
|
||||||
t := C.XKey(C.ulong(code), C.int(0))
|
|
||||||
|
|
||||||
fmt.Printf("X-Release %v", t)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user