Guest User

g15daemon.patch

a guest
Jul 11th, 2014
610
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. diff -Nuar g15daemon-1.9.5.3.orig/g15daemon/utility_funcs.c g15daemon-1.9.5.3/g15daemon/utility_funcs.c
  2. --- g15daemon-1.9.5.3.orig/g15daemon/utility_funcs.c    2008-01-26 07:02:07.000000000 +0200
  3. +++ g15daemon-1.9.5.3/g15daemon/utility_funcs.c 2011-11-09 09:19:43.000000000 +0200
  4. @@ -356,7 +356,7 @@
  5.      config_items_t * item=NULL;
  6.      char line[1024];
  7.      
  8. -    config_fd = open(filename,O_CREAT|O_RDWR|O_TRUNC);
  9. +    config_fd = open(filename,O_CREAT|O_RDWR|O_TRUNC, 0644);
  10.      if(config_fd){
  11.      snprintf(line,1024,"# G15Daemon Configuration File\n# any items entered before a [section] header\n# will be in the Global config space\n# comments you wish to keep should start with a semicolon';'\n");
  12.      write(config_fd,line,strlen(line));
  13.  
  14. --- g15daemon-1.9.5.3.orig/libg15daemon_client/g15daemon_net.c
  15. +++ g15daemon-1.9.5.3/libg15daemon_client/g15daemon_net.c
  16. @@ -217,7 +217,7 @@
  17.      if(poll(pfd,1,100)>0){
  18.         if(pfd[0].revents & POLLPRI && !(pfd[0].revents & POLLERR || pfd[0].revents & POLLHUP || pfd[0].revents & POLLNVAL)) {
  19.               memset(packet,0,sizeof(packet));
  20. -             msgret = recv(sock, packet, 10 , MSG_OOB);
  21. +             msgret = recv(sock, packet, sizeof(packet) , MSG_OOB);
  22.               if (msgret < 1) {
  23.                    return -1;
  24.                }
  25. --- a/plugins/g15_plugin_uinput.c   2008-01-24 12:51:07.000000000 +0000
  26. +++ b/plugins/g15_plugin_uinput.c   2014-05-09 09:34:44.000000000 +0000
  27. @@ -46,6 +46,12 @@
  28.  static int uinp_fd = -1;
  29.  static config_section_t *uinput_cfg=NULL;
  30.  static int map_Lkeys = 0;
  31. +static int vol_state = 0;
  32. +static int mkey_state = 0;
  33. +static int mr_state = 0;
  34. +static unsigned int mled_state = G15_LED_M1;
  35. +/*mkey state 0,1 and 2 = M1, M2 and M3*/
  36. +
  37.  
  38.  #define GKEY_OFFSET 167
  39.  #define MKEY_OFFSET 185
  40. @@ -125,6 +129,16 @@
  41.      event.value = G15KEY_DOWN;
  42.      
  43.      write (uinp_fd, &event, sizeof(event));
  44. +
  45. +    /* Need to write sync event */
  46. +    memset(&event, 0, sizeof(event));
  47. +
  48. +    event.type = EV_SYN;
  49. +    event.code = SYN_REPORT;
  50. +    event.value = 0;
  51. +
  52. +    write(uinp_fd, &event, sizeof(event));
  53. +
  54.  }
  55.  
  56.  static void g15_uinput_keyup(unsigned char code)
  57. @@ -137,8 +151,17 @@
  58.      event.value = G15KEY_UP;
  59.      
  60.      write (uinp_fd, &event, sizeof(event));
  61. -}
  62.  
  63. +    /* Need to write sync event */
  64. +    memset(&event, 0, sizeof(event));
  65. +
  66. +    event.type = EV_SYN;
  67. +    event.code = SYN_REPORT;
  68. +    event.value = 0;
  69. +
  70. +    write(uinp_fd, &event, sizeof(event));
  71. +
  72. +}
  73.      void (*keyup)(unsigned char code) = &g15_uinput_keyup;
  74.      void (*keydown)(unsigned char code) = &g15_uinput_keydown;
  75.  #else
  76. @@ -147,151 +170,406 @@
  77.  #endif
  78.  #endif
  79.      
  80. +/*The layout of the 'G' keys is now hard-coded here below. See /usr/include/linux/input.h for details on the keys you can use*/
  81.  static void g15_process_keys(g15daemon_t *masterlist, unsigned int currentkeys, unsigned int lastkeys)
  82.  {
  83. -    /* 'G' keys */
  84. -    if((currentkeys & G15_KEY_G1) && !(lastkeys & G15_KEY_G1))
  85. -        keydown(GKEY_OFFSET);
  86. -    else if(!(currentkeys & G15_KEY_G1) && (lastkeys & G15_KEY_G1))
  87. -        keyup(GKEY_OFFSET);
  88. -
  89. -    if((currentkeys & G15_KEY_G2) && !(lastkeys & G15_KEY_G2))
  90. -        keydown(GKEY_OFFSET+1);
  91. -    else if(!(currentkeys & G15_KEY_G2) && (lastkeys & G15_KEY_G2))
  92. -        keyup(GKEY_OFFSET+1);
  93. -
  94. -    if((currentkeys & G15_KEY_G3) && !(lastkeys & G15_KEY_G3))
  95. -        keydown(GKEY_OFFSET+2);
  96. -    else if(!(currentkeys & G15_KEY_G3) && (lastkeys & G15_KEY_G3))
  97. -        keyup(GKEY_OFFSET+2);
  98. -
  99. -    if((currentkeys & G15_KEY_G4) && !(lastkeys & G15_KEY_G4))
  100. -        keydown(GKEY_OFFSET+3);
  101. -    else if(!(currentkeys & G15_KEY_G4) && (lastkeys & G15_KEY_G4))
  102. -        keyup(GKEY_OFFSET+3);
  103. -
  104. -    if((currentkeys & G15_KEY_G5) && !(lastkeys & G15_KEY_G5))
  105. -        keydown(GKEY_OFFSET+4);
  106. -    else if(!(currentkeys & G15_KEY_G5) && (lastkeys & G15_KEY_G5))
  107. -        keyup(GKEY_OFFSET+4);
  108. -
  109. -    if((currentkeys & G15_KEY_G6) && !(lastkeys & G15_KEY_G6))
  110. -        keydown(GKEY_OFFSET+5);
  111. -    else if(!(currentkeys & G15_KEY_G6) && (lastkeys & G15_KEY_G6))
  112. -        keyup(GKEY_OFFSET+5);
  113. -
  114. -    if((currentkeys & G15_KEY_G7) && !(lastkeys & G15_KEY_G7))
  115. -        keydown(GKEY_OFFSET+6);
  116. -    else if(!(currentkeys & G15_KEY_G7) && (lastkeys & G15_KEY_G7))
  117. -        keyup(GKEY_OFFSET+6);
  118. -
  119. -    if((currentkeys & G15_KEY_G8) && !(lastkeys & G15_KEY_G8))
  120. -        keydown(GKEY_OFFSET+7);
  121. -    else if(!(currentkeys & G15_KEY_G8) && (lastkeys & G15_KEY_G8))
  122. -        keyup(GKEY_OFFSET+7);
  123. -
  124. -    if((currentkeys & G15_KEY_G9) && !(lastkeys & G15_KEY_G9))
  125. -        keydown(GKEY_OFFSET+8);
  126. -    else if(!(currentkeys & G15_KEY_G9) && (lastkeys & G15_KEY_G9))
  127. -        keyup(GKEY_OFFSET+8);
  128. -
  129. -    if((currentkeys & G15_KEY_G10) && !(lastkeys & G15_KEY_G10))
  130. -        keydown(GKEY_OFFSET+9);
  131. -    else if(!(currentkeys & G15_KEY_G10) && (lastkeys & G15_KEY_G10))
  132. -        keyup(GKEY_OFFSET+9);
  133. -
  134. -    if((currentkeys & G15_KEY_G11) && !(lastkeys & G15_KEY_G11))
  135. -        keydown(GKEY_OFFSET+10);
  136. -    else if(!(currentkeys & G15_KEY_G11) && (lastkeys & G15_KEY_G11))
  137. -        keyup(GKEY_OFFSET+10);
  138. -
  139. -    if((currentkeys & G15_KEY_G12) && !(lastkeys & G15_KEY_G12))
  140. -        keydown(GKEY_OFFSET+11);
  141. -    else if(!(currentkeys & G15_KEY_G12) && (lastkeys & G15_KEY_G12))
  142. -        keyup(GKEY_OFFSET+11);
  143. -
  144. -    if((currentkeys & G15_KEY_G13) && !(lastkeys & G15_KEY_G13))
  145. -        keydown(GKEY_OFFSET+12);
  146. -    else if(!(currentkeys & G15_KEY_G13) && (lastkeys & G15_KEY_G13))
  147. -        keyup(GKEY_OFFSET+12);
  148. -
  149. -    if((currentkeys & G15_KEY_G14) && !(lastkeys & G15_KEY_G14))
  150. -        keydown(GKEY_OFFSET+13);
  151. -    else if(!(currentkeys & G15_KEY_G14) && (lastkeys & G15_KEY_G14))
  152. -        keyup(GKEY_OFFSET+13);
  153. -
  154. -    if((currentkeys & G15_KEY_G15) && !(lastkeys & G15_KEY_G15))
  155. -        keydown(GKEY_OFFSET+14);
  156. -    else if(!(currentkeys & G15_KEY_G15) && (lastkeys & G15_KEY_G15))
  157. -        keyup(GKEY_OFFSET+14);
  158. -
  159. -    if((currentkeys & G15_KEY_G16) && !(lastkeys & G15_KEY_G16))
  160. -        keydown(GKEY_OFFSET+15);
  161. -    else if(!(currentkeys & G15_KEY_G16) && (lastkeys & G15_KEY_G16))
  162. -        keyup(GKEY_OFFSET+15);
  163. -
  164. -    if((currentkeys & G15_KEY_G17) && !(lastkeys & G15_KEY_G17))
  165. -        keydown(GKEY_OFFSET+16);
  166. -    else if(!(currentkeys & G15_KEY_G17) && (lastkeys & G15_KEY_G17))
  167. -        keyup(GKEY_OFFSET+16);
  168. -
  169. -    if((currentkeys & G15_KEY_G18) && !(lastkeys & G15_KEY_G18))
  170. -        keydown(GKEY_OFFSET+17);
  171. -    else if(!(currentkeys & G15_KEY_G18) && (lastkeys & G15_KEY_G18))
  172. -        keyup(GKEY_OFFSET+17);
  173. -
  174. -    /* 'M' keys */
  175. -
  176. -    if((currentkeys & G15_KEY_M1) && !(lastkeys & G15_KEY_M1))
  177. -        keydown(MKEY_OFFSET);
  178. -    else if(!(currentkeys & G15_KEY_M1) && (lastkeys & G15_KEY_M1))
  179. -        keyup(MKEY_OFFSET);
  180. -
  181. -    if((currentkeys & G15_KEY_M2) && !(lastkeys & G15_KEY_M2))
  182. -        keydown(MKEY_OFFSET+1);
  183. -    else if(!(currentkeys & G15_KEY_M2) && (lastkeys & G15_KEY_M2))
  184. -        keyup(MKEY_OFFSET+1);
  185. -
  186. -    if((currentkeys & G15_KEY_M3) && !(lastkeys & G15_KEY_M3))
  187. -        keydown(MKEY_OFFSET+2);
  188. -    else if(!(currentkeys & G15_KEY_M3) && (lastkeys & G15_KEY_M3))
  189. -        keyup(MKEY_OFFSET+2);
  190. -
  191. -    if((currentkeys & G15_KEY_MR) && !(lastkeys & G15_KEY_MR))
  192. -        keydown(MKEY_OFFSET+3);
  193. -    else if(!(currentkeys & G15_KEY_MR) && (lastkeys & G15_KEY_MR))
  194. -        keyup(MKEY_OFFSET+3);
  195. -    
  196. -    if(map_Lkeys){
  197. -        /* 'L' keys...  */
  198. -        if((currentkeys & G15_KEY_L1) && !(lastkeys & G15_KEY_L1))
  199. -            keydown(LKEY_OFFSET);
  200. -        else if(!(currentkeys & G15_KEY_L1) && (lastkeys & G15_KEY_L1))
  201. -            keyup(LKEY_OFFSET);
  202. -
  203. -        if((currentkeys & G15_KEY_L2) && !(lastkeys & G15_KEY_L2))
  204. -            keydown(LKEY_OFFSET+1);
  205. -        else if(!(currentkeys & G15_KEY_L2) && (lastkeys & G15_KEY_L2))
  206. -            keyup(LKEY_OFFSET+1);
  207. -
  208. -        if((currentkeys & G15_KEY_L3) && !(lastkeys & G15_KEY_L3))
  209. -            keydown(LKEY_OFFSET+2);
  210. -        else if(!(currentkeys & G15_KEY_L3) && (lastkeys & G15_KEY_L3))
  211. -            keyup(LKEY_OFFSET+2);
  212. -
  213. -        if((currentkeys & G15_KEY_L4) && !(lastkeys & G15_KEY_L4))
  214. -            keydown(LKEY_OFFSET+3);
  215. -        else if(!(currentkeys & G15_KEY_L4) && (lastkeys & G15_KEY_L4))
  216. -            keyup(LKEY_OFFSET+3);
  217. -
  218. -        if((currentkeys & G15_KEY_L5) && !(lastkeys & G15_KEY_L5))
  219. -            keydown(LKEY_OFFSET+4);
  220. -        else if(!(currentkeys & G15_KEY_L5) && (lastkeys & G15_KEY_L5))
  221. -            keyup(LKEY_OFFSET+4);
  222. +    if(!(currentkeys & G15_KEY_LIGHT))
  223. +    {
  224. +    /*Note: ALL system(""); commands will be run as root as g15daemon needs to be activated by root. Use "su USERNAME -c command" to avoid it.
  225. +    also if a command is run from terminal that would post output into the terminal the ability to run commands will hang. to avoid that add "& disown" to command*/
  226. +    /*Note2: There's a bug with detecting key release; this means that sometimes if you use key-release function to release the keys, the key will be "stuck" down until you press it again
  227. +    that's why I only use the key-release functionality for macros where I need to be able to hold down the button (like tab-switching)*/
  228. +    switch(mkey_state)
  229. +    {
  230. +        //M1 and the default layout (This one i use for commands while in X.
  231. +        case 0:
  232. +        {
  233. +/*M1*/      /*G Keys 1-6 open folders i use all the time.*/
  234. +/*M1*/      if((currentkeys & G15_KEY_G1) && !(lastkeys & G15_KEY_G1))
  235. +/*M1*/          system("sudo -H -u '#1000' dbus-launch thunar /mnt/Storage/Anime & disown");
  236. +/*M1*/
  237. +/*M1*/      if((currentkeys & G15_KEY_G2) && !(lastkeys & G15_KEY_G2))
  238. +/*M1*/          system("sudo -H -u '#1000' dbus-launch thunar /mnt/Storage/Biomyndir & disown");
  239. +/*M1*/
  240. +/*M1*/      if((currentkeys & G15_KEY_G3) && !(lastkeys & G15_KEY_G3))
  241. +/*M1*/          system("sudo -H -u '#1000' dbus-launch thunar /mnt/Storage/Music & disown");
  242. +/*M1*/
  243. +/*M1*/      if((currentkeys & G15_KEY_G4) && !(lastkeys & G15_KEY_G4))
  244. +/*M1*/          system("sudo -H -u '#1000' dbus-launch thunar /mnt/Storage/Downloads & disown");
  245. +/*M1*/
  246. +/*M1*/      if((currentkeys & G15_KEY_G5) && !(lastkeys & G15_KEY_G5))
  247. +/*M1*/          system("sudo -H -u '#1000' dbus-launch thunar /mnt/Storage/Art & disown");
  248. +/*M1*/
  249. +/*M1*/      if((currentkeys & G15_KEY_G6) && !(lastkeys & G15_KEY_G6))
  250. +/*M1*/          system("sudo -H -u '#1000' dbus-launch thunar $HOME/ & disown");
  251. +/*M1*/
  252. +/*M1*/
  253. +/*M1*/          /*G Keys 7-12* Switch workspaces 1-6 with Win(META)+F1-F6 keys.*/
  254. +/*M1*/      if((currentkeys & G15_KEY_G7) && !(lastkeys & G15_KEY_G7))
  255. +/*M1*/          {keydown(KEY_LEFTMETA);keydown(KEY_F1);keyup(KEY_F1);keyup(KEY_LEFTMETA);}
  256. +/*M1*/      
  257. +/*M1*/      if((currentkeys & G15_KEY_G8) && !(lastkeys & G15_KEY_G8))
  258. +/*M1*/          {keydown(KEY_LEFTMETA);keydown(KEY_F2);keyup(KEY_F2);keyup(KEY_LEFTMETA);}
  259. +/*M1*/
  260. +/*M1*/      if((currentkeys & G15_KEY_G9) && !(lastkeys & G15_KEY_G9))
  261. +/*M1*/          {keydown(KEY_LEFTMETA);keydown(KEY_F3);keyup(KEY_F3);keyup(KEY_LEFTMETA);}
  262. +/*M1*/
  263. +/*M1*/      if((currentkeys & G15_KEY_G10) && !(lastkeys & G15_KEY_G10))
  264. +/*M1*/          {keydown(KEY_LEFTMETA);keydown(KEY_F4);keyup(KEY_F4);keyup(KEY_LEFTMETA);}
  265. +/*M1*/
  266. +/*M1*/      if((currentkeys & G15_KEY_G11) && !(lastkeys & G15_KEY_G11))
  267. +/*M1*/          {keydown(KEY_LEFTMETA);keydown(KEY_F5);keyup(KEY_F5);keyup(KEY_LEFTMETA);}
  268. +/*M1*/
  269. +/*M1*/      if((currentkeys & G15_KEY_G12) && !(lastkeys & G15_KEY_G12))
  270. +/*M1*/          {keydown(KEY_LEFTMETA);keydown(KEY_F6);keyup(KEY_F6);keyup(KEY_LEFTMETA);}
  271. +/*M1*/
  272. +/*M1*/
  273. +/*M1*/      /*G Keys 13-18 13(Close Tab) 16(Mouseclick(via terminal)) 14(Alt+F4) 17(Open Terminal) 15 and 18 (Next/Prev tab, Ctrl+PgUp/PgDn)*/
  274. +/*M1*/      if((currentkeys & G15_KEY_G13) && !(lastkeys & G15_KEY_G13))
  275. +/*M1*/          {keydown(KEY_LEFTCTRL);keydown(KEY_W);keyup(KEY_W);keyup(KEY_LEFTCTRL);}
  276. +/*M1*/      
  277. +/*M1*/      if((currentkeys & G15_KEY_G14) && !(lastkeys & G15_KEY_G14))
  278. +/*M1*/          {keydown(KEY_LEFTALT);keydown(KEY_F4);keyup(KEY_F4);keyup(KEY_LEFTALT);}
  279. +/*M1*/
  280. +/*M1*/      if((currentkeys & G15_KEY_G15) && !(lastkeys & G15_KEY_G15))
  281. +/*M1*/          {keydown(KEY_LEFTCTRL);keydown(KEY_PAGEUP);}
  282. +/*M1*/      else if(!(currentkeys & G15_KEY_G15) && (lastkeys & G15_KEY_G15))
  283. +/*M1*/          {keyup(KEY_PAGEUP);keyup(KEY_LEFTCTRL);}
  284. +/*M1*/
  285. +/*M1*/          /*Mouse Click Emulation requires xdotool installed*/
  286. +/*M1*/      if((currentkeys & G15_KEY_G16) && !(lastkeys & G15_KEY_G16))
  287. +/*M1*/          system("sudo -H -u '#1000' xdotool mousedown 1");
  288. +/*M1*/      else if(!(currentkeys & G15_KEY_G16) && (lastkeys & G15_KEY_G16))
  289. +/*M1*/          system("sudo -H -u '#1000' xdotool mouseup 1");
  290. +/*M1*/
  291. +/*M1*/      if((currentkeys & G15_KEY_G17) && !(lastkeys & G15_KEY_G17))
  292. +/*M1*/          system("sudo -H -u '#1000' terminator --working-directory=~$HOME & disown");
  293. +/*M1*/      
  294. +/*M1*/      if((currentkeys & G15_KEY_G18) && !(lastkeys & G15_KEY_G18))
  295. +/*M1*/          {keydown(KEY_LEFTCTRL);keydown(KEY_PAGEDOWN);}
  296. +/*M1*/      else if(!(currentkeys & G15_KEY_G18) && (lastkeys & G15_KEY_G18))
  297. +/*M1*/          {keyup(KEY_PAGEDOWN);keyup(KEY_LEFTCTRL);}
  298. +        /*M1 END*/
  299. +        
  300. +        break;
  301. +        }
  302. +
  303. +        //M2 layout, This one i use for terminal shortcuts
  304. +        case 1:
  305. +        {
  306. +        /*G Keys 1-6
  307. +        G1((?)) G2(Levels(CTRL+L)) G3(Color Selector(Shift+I))
  308. +        G4(?) G5(HSL/HSV(CTRL+U)) G6(Shade Selector (Shift+M))
  309. +        */
  310. +/*M2*/      if((currentkeys & G15_KEY_G1) && !(lastkeys & G15_KEY_G1))
  311. +/*M2*/          {keydown(KEY_LEFTCTRL); keydown(KEY_LEFTSHIFT); keydown(KEY_F);keyup(KEY_LEFTCTRL); keyup(KEY_LEFTSHIFT); keyup(KEY_F);}
  312. +/*M2*/      
  313. +/*M2*/      if((currentkeys & G15_KEY_G2) && !(lastkeys & G15_KEY_G2))
  314. +/*M2*/          {keydown(KEY_LEFTCTRL); keydown(KEY_L); keyup(KEY_LEFTCTRL); keyup(KEY_L);}
  315. +/*M2*/      
  316. +/*M2*/      if((currentkeys & G15_KEY_G3) && !(lastkeys & G15_KEY_G3))
  317. +/*M2*/          {keydown(KEY_LEFTSHIFT); keydown(KEY_I); keyup(KEY_LEFTSHIFT); keyup(KEY_I);}
  318. +/*M2*/      
  319. +/*M2*/      if((currentkeys & G15_KEY_G4) && !(lastkeys & G15_KEY_G4))
  320. +/*M2*/          {keydown(KEY_LEFTCTRL);keydown(KEY_K);}
  321. +/*M2*/      else if(!(currentkeys & G15_KEY_G4) && (lastkeys & G15_KEY_G4))
  322. +/*M2*/          {keyup(KEY_K);keyup(KEY_LEFTCTRL);}
  323. +/*M2*/      
  324. +/*M2*/      if((currentkeys & G15_KEY_G5) && !(lastkeys & G15_KEY_G5))
  325. +/*M2*/          {keydown(KEY_LEFTCTRL); keydown(KEY_U); keyup(KEY_LEFTCTRL); keyup(KEY_U);}
  326. +/*M2*/      
  327. +/*M2*/      if((currentkeys & G15_KEY_G6) && !(lastkeys & G15_KEY_G6))
  328. +/*M2*/          {keydown(KEY_LEFTSHIFT);keydown(KEY_M);keyup(KEY_M);keyup(KEY_LEFTSHIFT);}
  329. +/*M2*/
  330. +/*M2*/
  331. +/*M2*/          /*G Keys 7-12,
  332. +        G7 (Reset Rotation/Canvas View(CTRL+')) G8 (Flip Canvas Vert(Ctrl+M)) G9(Move Layer(T))
  333. +        G10 (Merge Down (Ctrl+E)) G11 (Flip Canvas Horizontally(M)) G12 (Transform Layer (CTRL+T))
  334. +        */
  335. +/*M2*/      if((currentkeys & G15_KEY_G7) && !(lastkeys & G15_KEY_G7))
  336. +/*M2*/          {keydown(KEY_LEFTCTRL);keydown(KEY_APOSTROPHE);keyup(KEY_LEFTCTRL);keyup(KEY_APOSTROPHE);}
  337. +/*M2*/      
  338. +/*M2*/      if((currentkeys & G15_KEY_G8) && !(lastkeys & G15_KEY_G8))
  339. +/*M2*/          {keydown(KEY_LEFTCTRL);keydown(KEY_M);keyup(KEY_M);keyup(KEY_LEFTCTRL);}
  340. +/*M2*/
  341. +/*M2*/      if((currentkeys & G15_KEY_G9) && !(lastkeys & G15_KEY_G9))
  342. +/*M2*/          {keydown(KEY_T);keyup(KEY_T);}
  343. +/*M2*/
  344. +/*M2*/      if((currentkeys & G15_KEY_G10) && !(lastkeys & G15_KEY_G10))
  345. +/*M2*/          {keydown(KEY_LEFTCTRL);keydown(KEY_E);keyup(KEY_E);keyup(KEY_LEFTCTRL);}
  346. +/*M2*/
  347. +/*M2*/      if((currentkeys & G15_KEY_G11) && !(lastkeys & G15_KEY_G11))
  348. +/*M2*/          {keydown(KEY_M);keyup(KEY_M);}
  349. +/*M2*/
  350. +/*M2*/      if((currentkeys & G15_KEY_G12) && !(lastkeys & G15_KEY_G12))
  351. +/*M2*/          {keydown(KEY_LEFTCTRL);keydown(KEY_T);keyup(KEY_T);keyup(KEY_LEFTCTRL);}
  352. +/*M2*/
  353. +/*M2*/
  354. +/*M2*/      /*G Keys 13-18,
  355. +        G13(Freehand Select (?)) G14(Increase Opacity of Brush(I)) G15(Darker Color(K))
  356. +        G16(Deselect (CTRL+D) G17(Decrease Opacity of Brush(O)) G18(Lighter color (L))
  357. +        */
  358. +/*M2*/      if((currentkeys & G15_KEY_G13) && !(lastkeys & G15_KEY_G13))
  359. +/*M2*/          {keydown(KEY_LEFTCTRL);keydown(KEY_LEFTSHIFT);keydown(KEY_F);keyup(KEY_F);keyup(KEY_LEFTSHIFT);keyup(KEY_LEFTCTRL);}
  360. +/*M2*/      
  361. +/*M2*/      if((currentkeys & G15_KEY_G14) && !(lastkeys & G15_KEY_G14))
  362. +/*M2*/          {keydown(KEY_I);}
  363. +/*M2*/      else if(!(currentkeys & G15_KEY_G14) && (lastkeys & G15_KEY_G14))
  364. +/*M2*/          {keyup(KEY_I);}
  365. +/*M2*/
  366. +/*M2*/      if((currentkeys & G15_KEY_G15) && !(lastkeys & G15_KEY_G15))
  367. +/*M2*/          {keydown(KEY_K);}
  368. +/*M2*/      else if(!(currentkeys & G15_KEY_G15) && (lastkeys & G15_KEY_G15))
  369. +/*M2*/          {keyup(KEY_K);}
  370. +/*M2*/      
  371. +/*M2*/      if((currentkeys & G15_KEY_G16) && !(lastkeys & G15_KEY_G16))
  372. +/*M2*/          {keydown(KEY_LEFTCTRL);keydown(KEY_D); keyup(KEY_LEFTCTRL); keyup(KEY_D);}
  373. +/*M2*/      
  374. +/*M2*/      if((currentkeys & G15_KEY_G17) && !(lastkeys & G15_KEY_G17))
  375. +/*M2*/          {keydown(KEY_O);}
  376. +/*M2*/      else if(!(currentkeys & G15_KEY_G17) && (lastkeys & G15_KEY_G17))
  377. +/*M2*/          {keyup(KEY_O);}
  378. +/*M2*/      
  379. +/*M2*/      if((currentkeys & G15_KEY_G18) && !(lastkeys & G15_KEY_G18))
  380. +/*M2*/          {keydown(KEY_L);}
  381. +/*M2*/      else if(!(currentkeys & G15_KEY_G18) && (lastkeys & G15_KEY_G18))
  382. +/*M2*/          {keyup(KEY_L);}
  383. +        /*M2 END*/
  384. +        break;
  385. +        }
  386. +        //M3 layout for terminal commands (Placeholder)
  387. +        case 2:
  388. +        {
  389. +        /*G Keys 1-6*/
  390. +        /*G keys 1-6 G1(EraseLineLeft) G2(EraseWordLeft) G3(WordLeft) G4(EraseLineRight) G5(EraseWordRight) G6(WordRight)*/
  391. +/*M3*/      if((currentkeys & G15_KEY_G1) && !(lastkeys & G15_KEY_G1))
  392. +/*M3*/          {keydown(KEY_LEFTCTRL); keydown(KEY_U);}
  393. +/*M3*/      else if(!(currentkeys & G15_KEY_G1) && (lastkeys & G15_KEY_G1))
  394. +/*M3*/          {keyup(KEY_U);keyup(KEY_LEFTCTRL);}
  395. +/*M3*/      
  396. +/*M3*/      if((currentkeys & G15_KEY_G2) && !(lastkeys & G15_KEY_G2))
  397. +/*M3*/          {keydown(KEY_LEFTCTRL);keydown(KEY_W);}
  398. +/*M3*/      else if(!(currentkeys & G15_KEY_G2) && (lastkeys & G15_KEY_G2))
  399. +/*M3*/          {keyup(KEY_W);keyup(KEY_LEFTCTRL);}
  400. +/*M3*/      
  401. +/*M3*/      if((currentkeys & G15_KEY_G3) && !(lastkeys & G15_KEY_G3))
  402. +/*M3*/          {keydown(KEY_LEFTALT);keydown(KEY_B);}
  403. +/*M3*/      else if(!(currentkeys & G15_KEY_G3) && (lastkeys & G15_KEY_G3))
  404. +/*M3*/          {keyup(KEY_B);keyup(KEY_LEFTALT);}
  405. +/*M3*/      
  406. +/*M3*/      if((currentkeys & G15_KEY_G4) && !(lastkeys & G15_KEY_G4))
  407. +/*M3*/          {keydown(KEY_LEFTCTRL);keydown(KEY_K);}
  408. +/*M3*/      else if(!(currentkeys & G15_KEY_G4) && (lastkeys & G15_KEY_G4))
  409. +/*M3*/          {keyup(KEY_K);keyup(KEY_LEFTCTRL);}
  410. +/*M3*/      
  411. +/*M3*/      if((currentkeys & G15_KEY_G5) && !(lastkeys & G15_KEY_G5))
  412. +/*M3*/          {keydown(KEY_LEFTALT);keydown(KEY_D);}
  413. +/*M3*/      else if(!(currentkeys & G15_KEY_G5) && (lastkeys & G15_KEY_G5))
  414. +/*M3*/          {keyup(KEY_D);keyup(KEY_LEFTALT);}
  415. +/*M3*/      
  416. +/*M3*/      if((currentkeys & G15_KEY_G6) && !(lastkeys & G15_KEY_G6))
  417. +/*M3*/          {keydown(KEY_LEFTALT);keydown(KEY_F);}
  418. +/*M3*/      else if(!(currentkeys & G15_KEY_G6) && (lastkeys & G15_KEY_G6))
  419. +/*M3*/          {keyup(KEY_F);keyup(KEY_LEFTALT);}
  420. +/*M3*/
  421. +/*M3*/
  422. +/*M3*/          /*G Keys 7-12, Switch between terms 1-6 with Ctrl+Alt+F1-F6*/
  423. +/*M3*/      if((currentkeys & G15_KEY_G7) && !(lastkeys & G15_KEY_G7))
  424. +/*M3*/          {keydown(KEY_LEFTCTRL);keydown(KEY_LEFTALT);keydown(KEY_F1);}
  425. +/*M3*/      else if(!(currentkeys & G15_KEY_G7) && (lastkeys & G15_KEY_G7))
  426. +/*M3*/          {keyup(KEY_F1);keyup(KEY_LEFTALT);keyup(KEY_LEFTCTRL);}
  427. +/*M3*/      
  428. +/*M3*/      if((currentkeys & G15_KEY_G8) && !(lastkeys & G15_KEY_G8))
  429. +/*M3*/          {keydown(KEY_LEFTCTRL);keydown(KEY_LEFTALT);keydown(KEY_F2);}
  430. +/*M3*/      else if(!(currentkeys & G15_KEY_G8) && (lastkeys & G15_KEY_G8))
  431. +/*M3*/          {keyup(KEY_F2);keyup(KEY_LEFTALT);keyup(KEY_LEFTCTRL);}
  432. +/*M3*/
  433. +/*M3*/      if((currentkeys & G15_KEY_G9) && !(lastkeys & G15_KEY_G9))
  434. +/*M3*/          {keydown(KEY_LEFTCTRL);keydown(KEY_LEFTALT);keydown(KEY_F3);}
  435. +/*M3*/      else if(!(currentkeys & G15_KEY_G9) && (lastkeys & G15_KEY_G9))
  436. +/*M3*/          {keyup(KEY_F3);keyup(KEY_LEFTALT);keyup(KEY_LEFTCTRL);}
  437. +/*M3*/
  438. +/*M3*/      if((currentkeys & G15_KEY_G10) && !(lastkeys & G15_KEY_G10))
  439. +/*M3*/          {keydown(KEY_LEFTCTRL);keydown(KEY_LEFTALT);keydown(KEY_F4);}
  440. +/*M3*/      else if(!(currentkeys & G15_KEY_G10) && (lastkeys & G15_KEY_G10))
  441. +/*M3*/          {keyup(KEY_F4);keyup(KEY_LEFTALT);keyup(KEY_LEFTCTRL);}
  442. +/*M3*/
  443. +/*M3*/      if((currentkeys & G15_KEY_G11) && !(lastkeys & G15_KEY_G11))
  444. +/*M3*/          {keydown(KEY_LEFTCTRL);keydown(KEY_LEFTALT);keydown(KEY_F5);}
  445. +/*M3*/      else if(!(currentkeys & G15_KEY_G11) && (lastkeys & G15_KEY_G11))
  446. +/*M3*/          {keyup(KEY_F5);keyup(KEY_LEFTALT);keyup(KEY_LEFTCTRL);}
  447. +/*M3*/
  448. +/*M3*/      if((currentkeys & G15_KEY_G12) && !(lastkeys & G15_KEY_G12))
  449. +/*M3*/          {keydown(KEY_LEFTCTRL);keydown(KEY_LEFTALT);keydown(KEY_F6);}
  450. +/*M3*/      else if(!(currentkeys & G15_KEY_G12) && (lastkeys & G15_KEY_G12))
  451. +/*M3*/          {keyup(KEY_F6);keyup(KEY_LEFTALT);keyup(KEY_LEFTCTRL);}
  452. +/*M3*/
  453. +/*M3*/
  454. +/*M3*/      /*G Keys 13-18 13(Switch to GUI) 16(Kill X11) 14(Ctrl+C) 17(Q+Enter) 15/18(Shift+PgUp/PgDn for Scroll Up/Dn)*/
  455. +/*M3*/      if((currentkeys & G15_KEY_G13) && !(lastkeys & G15_KEY_G13))
  456. +/*M3*/          {keydown(KEY_LEFTCTRL);keydown(KEY_LEFTALT);keydown(KEY_F7);}
  457. +/*M3*/      else if(!(currentkeys & G15_KEY_G13) && (lastkeys & G15_KEY_G13))
  458. +/*M3*/          {keyup(KEY_F7);keyup(KEY_LEFTALT);keyup(KEY_LEFTCTRL);}
  459. +/*M3*/      
  460. +/*M3*/      if((currentkeys & G15_KEY_G14) && !(lastkeys & G15_KEY_G14))
  461. +/*M3*/          {keydown(KEY_LEFTCTRL);keydown(KEY_C);}
  462. +/*M3*/      else if(!(currentkeys & G15_KEY_G14) && (lastkeys & G15_KEY_G14))
  463. +/*M3*/          {keyup(KEY_C);keyup(KEY_LEFTCTRL);}
  464. +/*M3*/
  465. +/*M3*/      if((currentkeys & G15_KEY_G15) && !(lastkeys & G15_KEY_G15))
  466. +/*M3*/          {keydown(KEY_LEFTSHIFT);keydown(KEY_PAGEUP);}
  467. +/*M3*/      else if(!(currentkeys & G15_KEY_G15) && (lastkeys & G15_KEY_G15))
  468. +/*M3*/          {keyup(KEY_PAGEUP);keyup(KEY_LEFTSHIFT);}
  469. +/*M3*/      
  470. +/*M3*/      if((currentkeys & G15_KEY_G16) && !(lastkeys & G15_KEY_G16))
  471. +/*M3*/          {keydown(KEY_LEFTCTRL);keydown(KEY_LEFTALT);keydown(KEY_BACKSPACE);}
  472. +/*M3*/      else if(!(currentkeys & G15_KEY_G16) && (lastkeys & G15_KEY_G16))
  473. +/*M3*/          {keyup(KEY_BACKSPACE);keyup(KEY_LEFTALT);keyup(KEY_LEFTCTRL);}
  474. +/*M3*/      
  475. +/*M3*/      if((currentkeys & G15_KEY_G17) && !(lastkeys & G15_KEY_G17))
  476. +/*M3*/          {keydown(KEY_Q);}
  477. +/*M3*/      else if(!(currentkeys & G15_KEY_G17) && (lastkeys & G15_KEY_G17))
  478. +/*M3*/          {keyup(KEY_Q);keydown(KEY_ENTER);keyup(KEY_ENTER);}
  479. +/*M3*/      
  480. +/*M3*/      if((currentkeys & G15_KEY_G18) && !(lastkeys & G15_KEY_G18))
  481. +/*M3*/          {keydown(KEY_LEFTSHIFT);keydown(KEY_PAGEDOWN);}
  482. +/*M3*/      else if(!(currentkeys & G15_KEY_G18) && (lastkeys & G15_KEY_G18))
  483. +/*M3*/          {keyup(KEY_PAGEDOWN);keyup(KEY_LEFTSHIFT);}
  484. +        /*M3 END*/
  485. +        break;
  486. +        }
  487.      }
  488. +    
  489. +        /* 'M' keys... */
  490. +    
  491. +        if((currentkeys & G15_KEY_M1) && !(lastkeys & G15_KEY_M1))
  492. +            //keydown(MKEY_OFFSET);
  493. +        mkey_state = 0;
  494. +        /*else if(!(currentkeys & G15_KEY_M1) && (lastkeys & G15_KEY_M1))
  495. +            keyup(MKEY_OFFSET);*/
  496. +    
  497. +        if((currentkeys & G15_KEY_M2) && !(lastkeys & G15_KEY_M2))
  498. +            //keydown(MKEY_OFFSET+1);
  499. +        mkey_state = 1;
  500. +        /*else if(!(currentkeys & G15_KEY_M2) && (lastkeys & G15_KEY_M2))
  501. +            keyup(MKEY_OFFSET+1);*/
  502. +    
  503. +        if((currentkeys & G15_KEY_M3) && !(lastkeys & G15_KEY_M3))
  504. +            //keydown(MKEY_OFFSET+2);
  505. +        mkey_state = 2;
  506. +        /*else if(!(currentkeys & G15_KEY_M3) && (lastkeys & G15_KEY_M3))
  507. +            keyup(MKEY_OFFSET+2);*/
  508. +    
  509. +    if((currentkeys & G15_KEY_MR) && !(lastkeys & G15_KEY_MR) && mr_state == 0){
  510. +        mr_state = 1;
  511. +    }
  512. +    else if(!(currentkeys & G15_KEY_MR) && (lastkeys & G15_KEY_MR) && mr_state == 1){
  513. +    /*Toggle function on first key release*/
  514. +    }
  515. +    else if((currentkeys & G15_KEY_MR) && !(lastkeys & G15_KEY_MR) && mr_state == 1){
  516. +        mr_state = 0;
  517. +    }
  518. +    else if(!(currentkeys & G15_KEY_MR) && (lastkeys & G15_KEY_MR) && mr_state == 0){
  519. +    /*Úntoggle function on second key release*/
  520. +    }
  521. +        
  522. +        if(map_Lkeys){
  523. +            /* 'L' keys...  */
  524. +            if((currentkeys & G15_KEY_L1) && !(lastkeys & G15_KEY_L1))
  525. +                keydown(LKEY_OFFSET);
  526. +            else if(!(currentkeys & G15_KEY_L1) && (lastkeys & G15_KEY_L1))
  527. +                keyup(LKEY_OFFSET);
  528. +    
  529. +            if((currentkeys & G15_KEY_L2) && !(lastkeys & G15_KEY_L2))
  530. +                keydown(LKEY_OFFSET+1);
  531. +            else if(!(currentkeys & G15_KEY_L2) && (lastkeys & G15_KEY_L2))
  532. +                keyup(LKEY_OFFSET+1);
  533. +    
  534. +            if((currentkeys & G15_KEY_L3) && !(lastkeys & G15_KEY_L3))
  535. +                keydown(LKEY_OFFSET+2);
  536. +            else if(!(currentkeys & G15_KEY_L3) && (lastkeys & G15_KEY_L3))
  537. +                keyup(LKEY_OFFSET+2);
  538. +    
  539. +            if((currentkeys & G15_KEY_L4) && !(lastkeys & G15_KEY_L4))
  540. +                keydown(LKEY_OFFSET+3);
  541. +            else if(!(currentkeys & G15_KEY_L4) && (lastkeys & G15_KEY_L4))
  542. +                keyup(LKEY_OFFSET+3);
  543. +    
  544. +            if((currentkeys & G15_KEY_L5) && !(lastkeys & G15_KEY_L5))
  545. +                keydown(LKEY_OFFSET+4);
  546. +            else if(!(currentkeys & G15_KEY_L5) && (lastkeys & G15_KEY_L5))
  547. +                keyup(LKEY_OFFSET+4);
  548. +        }
  549. +
  550. +    }
  551. +
  552. +
  553. +     else
  554. +     {
  555. +        // G15_KEY_LIGHT - Key modifier for Logitech G510 Media Keys implementation
  556. +
  557. +        // XF86AudioPlay
  558. +        if((currentkeys & G15_KEY_G1) && !(lastkeys & G15_KEY_G1))
  559. +            keydown(KEY_PLAYPAUSE);
  560. +        else if(!(currentkeys & G15_KEY_G1) && (lastkeys & G15_KEY_G1))
  561. +            keyup(KEY_PLAYPAUSE);
  562. +
  563. +        // XF86AudioStop
  564. +        if((currentkeys & G15_KEY_G2) && !(lastkeys & G15_KEY_G2))
  565. +            keydown(KEY_STOPCD);
  566. +        else if(!(currentkeys & G15_KEY_G2) && (lastkeys & G15_KEY_G2))
  567. +            keyup(KEY_STOPCD);
  568. +
  569. +        // XF86AudioPrev
  570. +        if((currentkeys & G15_KEY_G3) && !(lastkeys & G15_KEY_G3))
  571. +            keydown(KEY_PREVIOUSSONG);
  572. +        else if(!(currentkeys & G15_KEY_G3) && (lastkeys & G15_KEY_G3))
  573. +            keyup(KEY_PREVIOUSSONG);
  574. +
  575. +        // XF86AudioNext
  576. +        if((currentkeys & G15_KEY_G4) && !(lastkeys & G15_KEY_G4))
  577. +            keydown(KEY_NEXTSONG);
  578. +        else if(!(currentkeys & G15_KEY_G4) && (lastkeys & G15_KEY_G4))
  579. +            keyup(KEY_NEXTSONG);
  580. +
  581. +        // XF86AudioMute
  582. +        if((currentkeys & G15_KEY_G5) && !(lastkeys & G15_KEY_G5))
  583. +            keydown(KEY_MUTE);
  584. +        else if(!(currentkeys & G15_KEY_G5) && (lastkeys & G15_KEY_G5))
  585. +            keyup(KEY_MUTE);
  586. +
  587. +        // XF86AudioRaise/LowerVolume (this was a pain to figure out, i dropped it at one point while it was semi-functioning and fixed it later)
  588. +        if(((currentkeys & G15_KEY_G6) && !(lastkeys & G15_KEY_G6)) && (vol_state == 0 || vol_state == 1)){
  589. +        keydown(KEY_VOLUMEUP);
  590. +        vol_state = 1;
  591. +    }
  592. +        else if(((currentkeys & G15_KEY_G7) && !(lastkeys & G15_KEY_G7)) && (vol_state == 0 || vol_state == 2)){
  593. +        keydown(KEY_VOLUMEDOWN);
  594. +        vol_state = 2;
  595. +    }
  596. +    else if((!(currentkeys & G15_KEY_G6) || !(currentkeys & G15_KEY_G7)) && ((lastkeys & G15_KEY_G7) || (lastkeys & G15_KEY_G6))){
  597. +        keyup(KEY_VOLUMEUP);
  598. +            keyup(KEY_VOLUMEDOWN);
  599. +        vol_state = 0;  
  600. +        }
  601. +    }
  602. +/*Set led states per M key (Doing this in the switch was slow and didn't activate till after button release)*/
  603. +    if(mkey_state == 0)
  604. +    mled_state = G15_LED_M1;
  605. +    else if(mkey_state == 1)
  606. +    mled_state = G15_LED_M2;
  607. +    else if(mkey_state == 2)
  608. +    mled_state = G15_LED_M3;
  609. +
  610. +/*Set leds and toggle MR led depending on mr_state*/
  611. +    if(mr_state == 0)
  612. +    setLEDs(mled_state -0x20);
  613. +    else if(mr_state == 1)
  614. +    setLEDs(mled_state -0x20 | G15_LED_MR -0x20);
  615. +
  616.  }
  617.  
  618.  
  619.  static int keyevents(plugin_event_t *myevent) {
  620.      lcd_t *lcd = (lcd_t*) myevent->lcd;
  621.      static int lastkeys;
  622.  
  623. --- a/contrib/xmodmaprc 2008-01-24 12:51:08.000000000 +0000
  624. +++ b/contrib/xmodmaprc 2013-04-11 15:25:26.000000000 +0000
  625. @@ -3,7 +3,7 @@
  626.  keycode 130 = XF86Launch9
  627.  keycode 131 = XF86Launch2
  628.  keycode 132 = XF86Phone
  629. -keycode 133 = XF86Messenger
  630. +keycode 133 = Super_L
  631.  keycode 136 = XF86LaunchD
  632.  keycode 137 = XF86Support
  633.  keycode 138 = XF86Word
RAW Paste Data