History

Experimenting with ambidextrous sixense mouse input

barnold1953 committed 12 years ago

Commit d0b18801 parent 32a9eed3 files · +117 −87Browse files

Showing the changes to interface/src/ui/ApplicationOverlay.cpp (1 of 3 files). Show all

Unified · Split

interface/src/ui/ApplicationOverlay.cpp+54−48
@@ -45,70 +45,76 @@ void renderControllerPointer() { · 44 unmodified lines
4545
4646
4747 int palmIndex;
48− if (Menu::getInstance()->isOptionChecked(MenuOption::SixenseLeftHanded)) {
48+ /*if (Menu::getInstance()->isOptionChecked(MenuOption::SixenseLeftHanded)) {
4949 palmIndex = 2;
5050 } else {
5151 palmIndex = 3;
52− }
53− const PalmData* palmData = NULL;
52+ }*/
53+ for (palmIndex = 2; palmIndex < 4; palmIndex++) {
54+ const PalmData* palmData = NULL;
5455
55− if (palmIndex >= handData->getPalms().size()) {
56− return;
57− }
56+ if (palmIndex >= handData->getPalms().size()) {
57+ return;
58+ }
5859
59− if (handData->getPalms()[palmIndex].isActive()) {
60− palmData = &handData->getPalms()[palmIndex];
61− } else {
62− return;
63− }
64−
65− // Get directon relative to avatar orientation
66− glm::vec3 direction = glm::inverse(myAvatar->getOrientation()) * palmData->getFingerDirection();
60+ if (handData->getPalms()[palmIndex].isActive()) {
61+ palmData = &handData->getPalms()[palmIndex];
62+ } else {
63+ return;
64+ }
6765
68− // Get the angles, scaled between 0-1
69− float xAngle = (atan2(direction.z, direction.x) + M_PI_2) + 0.5f;
70− float yAngle = 1.0f - ((atan2(direction.z, direction.y) + M_PI_2) + 0.5f);
66+ // Get directon relative to avatar orientation
67+ glm::vec3 direction = glm::inverse(myAvatar->getOrientation()) * palmData->getFingerDirection();
7168
72− float cursorRange = glWidget->width();
69+ // Get the angles, scaled between 0-1
70+ float xAngle = (atan2(direction.z, direction.x) + M_PI_2) + 0.5f;
71+ float yAngle = 1.0f - ((atan2(direction.z, direction.y) + M_PI_2) + 0.5f);
7372
74− int mouseX = cursorRange * xAngle;
75− int mouseY = cursorRange * yAngle;
73+ float cursorRange = glWidget->width();
7674
77− if (mouseX < 0) {
78− mouseX = 0;
79− } else if (mouseX > glWidget->width()) {
80− mouseX = glWidget->width();
81− }
82− if (mouseY < 0) {
83− mouseY = 0;
84− } else if (mouseY > glWidget->width()) {
85− mouseY = glWidget->width();
86− }
75+ int mouseX = cursorRange * xAngle;
76+ int mouseY = cursorRange * yAngle;
8777
88− const float pointerWidth = 40;
89− const float pointerHeight = 40;
90− const float crossPad = 16;
78+ if (mouseX < 0) {
79+ //mouseX = 0;
80+ continue;
81+ } else if (mouseX > glWidget->width()) {
82+ //mouseX = glWidget->width();
83+ continue;
84+ }
85+ if (mouseY < 0) {
86+ //mouseY = 0;
87+ continue;
88+ } else if (mouseY > glWidget->width()) {
89+ //mouseY = glWidget->width();
90+ continue;
91+ }
9192
92− mouseX -= pointerWidth / 2.0f;
93− mouseY += pointerHeight / 2.0f;
93+ const float pointerWidth = 40;
94+ const float pointerHeight = 40;
95+ const float crossPad = 16;
9496
95− glBegin(GL_QUADS);
97+ mouseX -= pointerWidth / 2.0f;
98+ mouseY += pointerHeight / 2.0f;
9699
97− glColor3f(0, 0, 1);
100+ glBegin(GL_QUADS);
98101
99− //Horizontal crosshair
100− glVertex2i(mouseX, mouseY - crossPad);
101− glVertex2i(mouseX + pointerWidth, mouseY - crossPad);
102− glVertex2i(mouseX + pointerWidth, mouseY - pointerHeight + crossPad);
103− glVertex2i(mouseX, mouseY - pointerHeight + crossPad);
102+ glColor3f(0.0f, 0.0f, 1.0f);
104103
105− //Vertical crosshair
106− glVertex2i(mouseX + crossPad, mouseY);
107− glVertex2i(mouseX + pointerWidth - crossPad, mouseY);
108− glVertex2i(mouseX + pointerWidth - crossPad, mouseY - pointerHeight);
109− glVertex2i(mouseX + crossPad, mouseY - pointerHeight);
104+ //Horizontal crosshair
105+ glVertex2i(mouseX, mouseY - crossPad);
106+ glVertex2i(mouseX + pointerWidth, mouseY - crossPad);
107+ glVertex2i(mouseX + pointerWidth, mouseY - pointerHeight + crossPad);
108+ glVertex2i(mouseX, mouseY - pointerHeight + crossPad);
110109
111− glEnd();
110+ //Vertical crosshair
111+ glVertex2i(mouseX + crossPad, mouseY);
112+ glVertex2i(mouseX + pointerWidth - crossPad, mouseY);
113+ glVertex2i(mouseX + pointerWidth - crossPad, mouseY - pointerHeight);
114+ glVertex2i(mouseX + crossPad, mouseY - pointerHeight);
115+
116+ glEnd();
117+ }
112118 }
113119
114120 // Renders the overlays either to a texture or to the screen

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t