示例#1
0
文件: pointer.c 项目: gyroninja/bspwm
void window_grab_button(xcb_window_t win, uint8_t button, uint16_t modifier)
{
#define GRAB(b, m) \
	xcb_grab_button(dpy, false, win, XCB_EVENT_MASK_BUTTON_PRESS, \
	                XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC, XCB_NONE, XCB_NONE, b, m)
		GRAB(button, modifier);
		if (num_lock != XCB_NO_SYMBOL && caps_lock != XCB_NO_SYMBOL && scroll_lock != XCB_NO_SYMBOL) {
			GRAB(button, modifier | num_lock | caps_lock | scroll_lock);
		}
		if (num_lock != XCB_NO_SYMBOL && caps_lock != XCB_NO_SYMBOL) {
			GRAB(button, modifier | num_lock | caps_lock);
		}
		if (caps_lock != XCB_NO_SYMBOL && scroll_lock != XCB_NO_SYMBOL) {
			GRAB(button, modifier | caps_lock | scroll_lock);
		}
		if (num_lock != XCB_NO_SYMBOL && scroll_lock != XCB_NO_SYMBOL) {
			GRAB(button, modifier | num_lock | scroll_lock);
		}
		if (num_lock != XCB_NO_SYMBOL) {
			GRAB(button, modifier | num_lock);
		}
		if (caps_lock != XCB_NO_SYMBOL) {
			GRAB(button, modifier | caps_lock);
		}
		if (scroll_lock != XCB_NO_SYMBOL) {
			GRAB(button, modifier | scroll_lock);
		}
#undef GRAB
}
示例#2
0
/* Stolen from xfwm4 and modified.
 * FALSE on error. Call initModifiers before this.
 */
static gboolean grabKey(MyKey *key)
{
	Window root;
	Display *dpy = GDK_DISPLAY();
	static gboolean need_init = TRUE;

	if (need_init)
	{
		need_init = FALSE;
		gdk_window_add_filter(gdk_get_default_root_window(),
				filter_keys, NULL);
	}

	gdk_error_trap_push();

	root = GDK_ROOT_WINDOW();

	GRAB(key, 0);

	/* Here we grab all combinations of well known modifiers */
	GRAB(key, ScrollLockMask);
	GRAB(key, NumLockMask);
	GRAB(key, CapsLockMask);
	GRAB(key, ScrollLockMask | NumLockMask);
	GRAB(key, ScrollLockMask | CapsLockMask);
	GRAB(key, CapsLockMask | NumLockMask);
	GRAB(key, ScrollLockMask | CapsLockMask | NumLockMask);

	gdk_flush();
	return gdk_error_trap_pop() == Success;
}
示例#3
0
#include <dlfcn.h>
#include <CoreFoundation/CFRunLoop.h>

#include "../../common/rarch_wrapper.h"

#define BUILDING_BTDYNAMIC
#include "btdynamic.h"

#define GRAB(A) {#A, (void**)&A##_ptr}
static struct
{
   const char* name;
   void** target;
}  grabbers[] =
{
   GRAB(bt_open),
   GRAB(bt_close),
   GRAB(bt_flip_addr),
   GRAB(bd_addr_to_str),
   GRAB(bt_register_packet_handler),
   GRAB(bt_send_cmd),
   GRAB(bt_send_l2cap),
   GRAB(run_loop_init),
   GRAB(run_loop_execute),

   GRAB(btstack_set_power_mode),
   GRAB(hci_delete_stored_link_key),
   GRAB(hci_disconnect),
   GRAB(hci_read_bd_addr),
   GRAB(hci_inquiry),
   GRAB(hci_inquiry_cancel),
示例#4
0
task main()
{
  bMotorFlippedMode[port6] = 1;
  bMotorFlippedMode[port1] = 1;
  wait1Msec(2000);

  SensorValue[LeftEncoder] = 0;
  SensorValue[RightEncoder] = 0;

  while(SensorValue[RightEncoder] > -1500 )
  {
  	if(SensorValue[RightEncoder] > -1490 )
  	{
  		GO(122);
  	}
  	else
  	{
  		GO(0);
  	}
  }
  SensorValue[LeftEncoder] = 0;
  SensorValue[RightEncoder] = 0;

  while(SensorValue[RightEncoder] > -355 )
  {
  	if(SensorValue[RightEncoder] > -350 )
  	{
  		TURNLEFT(127);
  	}
  	else
  	{
  		GO(0);
  	}
  }
  SensorValue[LeftEncoder] = 0;
  SensorValue[RightEncoder] = 0;

  while(SensorValue[Pot] > 460  )
  {
  	if(SensorValue[Pot] > 450 )
  	{
  		LIFTUP(127);
  	}
  }

  LIFTUP(0);
	wait1Msec(1000);


  while(SensorValue[RightEncoder] > -135 )
  {
  	if(SensorValue[RightEncoder] > -130 )
  	{
  		GO(71);
  	}
  	else
  	{
  		GO(0);
  	}
  }
  SensorValue[LeftEncoder] = 0;
  SensorValue[RightEncoder] = 0;

  LIFTUP(0);
	wait1Msec(1000);

  GRAB(127);
	wait1Msec(1000);

	GRAB(0);
	wait1Msec(2000);

	SensorValue[LeftEncoder] = 0;
	SensorValue[RightEncoder] = 0;

	while(SensorValue[RightEncoder] < 410 )
	{
		if(SensorValue[RightEncoder] < 405 )
		{
			BACK(87);
		}
		else
		{
			GO(0);
		}
	}

	while (SensorValue[Pot] < 625 )
	{
		if(SensorValue[Pot] < 620 )
		{
			LIFTDOWN(105);
		}
	}

	SensorValue[LeftEncoder] = 0;
	SensorValue[RightEncoder] = 0;

  while(SensorValue[RightEncoder] < 285 )
	{
		if(SensorValue[RightEncoder] < 280 )
		{
		  TURNRIGHT(57);
		}
		else
		{
			GO(0);
		}
	}
	SensorValue[LeftEncoder] = 0;
	SensorValue[RightEncoder] = 0;

	while (SensorValue[Pot] > 500 )
	{
		if(SensorValue[Pot] > 500 )
		{
			LIFTUP(103);
		}
	}

  {
	  LIFTDOWN(0);
	  wait1Msec(1000);
	}


	while(SensorValue[RightEncoder] > -435 )
	{
		if(SensorValue[RightEncoder] > -430 )
		{
			GO(58);
		}
		else
		{
			GO(0);
		}
	}
	SensorValue[LeftEncoder] = 0;
	SensorValue[RightEncoder] = 0;

	LIFTDOWN(0);
	wait1Msec(1000);

	GRAB(127);
	wait1Msec(1000);

	GRAB(0);
	wait1Msec(2000);

	while(SensorValue[RightEncoder] < 385 )
	{
		if(SensorValue[RightEncoder] < 380 )
		{
			BACK(127);
		}
		else
		{
			GO(0);
		}
	}
	SensorValue[LeftEncoder] = 0;
	SensorValue[RightEncoder] = 0;

	while(SensorValue[RightEncoder] < 405 )
	{
		if(SensorValue[RightEncoder] < 400 )
		{
			TURNRIGHT(127);
		}
		else
		{
			GO(0);
		}
	}
	SensorValue[LeftEncoder] = 0;
	SensorValue[RightEncoder] = 0;

	while(SensorValue[RightEncoder] > -1095 )
	{
		if(SensorValue[RightEncoder] > -1090 )
		{
			GO(127);
		}
		else
		{
			GO(0);
		}
	}
	SensorValue[LeftEncoder] = 0;
	SensorValue[RightEncoder] = 0;

	while(SensorValue[RightEncoder] > -300 )
  {
  	if(SensorValue[RightEncoder] > -295 )
  	{
  		TURNLEFT(127);
  	}
  	else
  	{
  		GO(0);
  	}
  }
  SensorValue[LeftEncoder] = 0;
  SensorValue[RightEncoder] = 0;

  while(SensorValue[RightEncoder] > -335 )
  {
  	if(SensorValue[RightEncoder] > -330 )
  	{
  		GO(58);
  	}
  	else
  	{
  		GO(0);
  	}
  }
  SensorValue[LeftEncoder] = 0;
  SensorValue[RightEncoder] = 0;

	bVexAutonomousMode = false;

	while(true)
	{
		motor[port1] = vexRT[Ch5];
		motor[port2] = vexRT[Ch1] + vexRT[Ch2];
		motor[port3] = vexRT[Ch1] - vexRT[Ch2];
		motor[port4] = vexRT[Ch3];
		motor[port5] = vexRT[Ch5];
		motor[port6] = vexRT[Ch3];
		motor[port7] = vexRT[Ch1] + vexRT[Ch2];
		motor[port8] = vexRT[Ch1] - vexRT[Ch2];
	}
}