Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #58 from ablake/next

Updating the Gamepad sample
  • Loading branch information...
commit aacfd584152101d1f9e8b5ec3485a2bf64a528c9 2 parents 51da844 + f53aad2
@jhoffmannrim jhoffmannrim authored
Showing with 142 additions and 150 deletions.
  1. +141 −147 Gamepad/main.c
  2. +1 −3 Gamepad/readme.txt
View
288 Gamepad/main.c
@@ -46,34 +46,34 @@ static int rc;
if (rc) fprintf(stderr, "\n%s in %s: %d", y, __FUNCTION__, errno)
// Constants used when allocating memory for our graphical data.
-static const int QUAD_COUNT = 41;
-static const int VERTEX_COORD_COUNT = 328; // QUAD_COUNT * 4 vertices per image * 2 vertex coords per vertex.
-static const int INDEX_COUNT = 246; // QUAD_COUNT * 6 indices per quad.
-static const int TEXCOORD_COUNT = 328; // QUAD_COUNT * 8 UVs per quad.
+static const int QUAD_COUNT = 33;
+static const int VERTEX_COORD_COUNT = 264; // QUAD_COUNT * 4 vertices per image * 2 vertex coords per vertex.
+static const int INDEX_COUNT = 198; // QUAD_COUNT * 6 indices per quad.
+static const int TEXCOORD_COUNT = 264; // QUAD_COUNT * 8 UVs per quad.
// Size and positions of all the controls.
-static const float ANALOG0_X = 75.0f;
-static const float ANALOG1_X = 460.0f;
-static const float ANALOG_Y = 75.0f;
+static const float ANALOG0_X = 150.0f;
+static const float ANALOG1_X = 385.0f;
+static const float ANALOG_Y = 125.0f;
static const float ANALOG_SIZE = 100.0f;
static const float DPAD_X = 25.0f;
-static const float DPAD_Y = 275.0f;
+static const float DPAD_Y = 300.0f;
static const float DPAD_LONG = 112.5f;
static const float DPAD_SHORT = 75.0f;
static const float BUTTONS_X = 400.0f;
-static const float BUTTONS_Y = 275.0f;
+static const float BUTTONS_Y = 300.0f;
static const float BUTTON_SIZE = 75.0f;
static const float LEFT_TRIGGERS_X = 25.0f;
static const float RIGHT_TRIGGERS_X = 450.0f;
-static const float TRIGGERS_Y = 525.0f;
+static const float TRIGGERS_Y = 550.0f;
static const float TRIGGER_WIDTH = 175.0f;
static const float TRIGGER_HEIGHT = 50.0f;
static const float SELECT_X = 237.5f;
-static const float SELECT_Y = 450.0f;
+static const float SELECT_Y = 475.0f;
// Other constants.
static const int FONT_SIZE = 4;
@@ -140,12 +140,12 @@ static unsigned int _gamepadTexture;
static GLfloat* _vertices;
static GLushort* _indices;
static GLfloat* _textureCoords;
-static Quad _quads[41];
+static Quad _quads[33];
// Pointers to the quads and buttons we'll need to modify during frame updates.
static Quad* _analog0Inner[2];
static Quad* _analog1Inner[2];
-static Button _buttons[2][16];
+static Button _buttons[2][12];
// Tapping an on-screen button will make it 'active', and the next gamepad button-press will map that gamepad button to this on-screen button.
static Button* _activeButton[2];
@@ -157,6 +157,7 @@ typedef struct GameController_t {
// Static device info.
screen_device_t handle;
int type;
+ int analogCount;
int buttonCount;
char id[64];
char vendor[64];
@@ -168,8 +169,7 @@ typedef struct GameController_t {
int analog1[3];
// Text to display to the user about this controller.
- char deviceString0[256];
- char deviceString1[256]; // bbutil.c does not handle line-breaks
+ char deviceString[256];
char buttonsString[128];
char analog0String[128];
char analog1String[128];
@@ -177,7 +177,7 @@ typedef struct GameController_t {
// Controller information.
static int MAX_CONTROLLERS = 2;
-static int MAX_BUTTONS = 16;
+static int MAX_BUTTONS = 12;
static GameController _controllers[2];
static void initController(GameController* controller, int player)
@@ -185,11 +185,12 @@ static void initController(GameController* controller, int player)
// Initialize controller values.
controller->handle = 0;
controller->type = 0;
+ controller->analogCount = 0;
controller->buttonCount = 0;
controller->buttons = 0;
controller->analog0[0] = controller->analog0[1] = controller->analog0[2] = 0;
controller->analog1[0] = controller->analog1[1] = controller->analog1[2] = 0;
- sprintf(controller->deviceString0, "Player %d: No device detected.", player + 1);
+ sprintf(controller->deviceString, "Player %d: No device detected.", player + 1);
}
int init()
@@ -245,48 +246,20 @@ int init()
// Set the initial positions of all joysticks and buttons.
for (i = 0; i < MAX_CONTROLLERS; ++i) {
/**
- * Quads | Buttons
- *
- * 0-3 | Analog sticks.
- * 4-7 | D-Pad. Up, Down, Left, Right.
- * 8-11 | A, B, X, Y Buttons.
- * 12,13 | Analog stick triggers (L3, R3) -- represented as buttons below the sticks.
- * 14-17 | Triggers: L1, L2, R1, R2.
- * 18,19 | Select, Start.
+ * Quads | Buttons | Description
+ * =======|==========|=============
+ * 0-3 | | Analog sticks.
+ * 4-7 | 0-3 | D-Pad. Up, Down, Left, Right.
+ * 8-11 | 4-7 | A, B, X, Y Buttons.
+ * 12,13 | 8, 9 | L1, R1.
+ * 14, 15 | 10, 11 | Select, Start.
*/
- int controllerIndex = 20*i;
+ int controllerIndex = 16*i;
float xOffset = (_surfaceWidth * 0.5f)*i;
- Quad* analog0Outer = &_quads[0 + controllerIndex];
- analog0Outer->x = ANALOG0_X + xOffset;
- analog0Outer->y = ANALOG_Y;
- analog0Outer->width = analog0Outer->height = ANALOG_SIZE;
- analog0Outer->uvs = _outerUVs;
-
- _analog0Inner[i] = &_quads[1 + controllerIndex];
- _analog0Inner[i]->x = ANALOG0_X + xOffset;
- _analog0Inner[i]->y = ANALOG_Y;
- _analog0Inner[i]->width = _analog0Inner[i]->height = ANALOG_SIZE;
- _analog0Inner[i]->uvs = _innerUVs;
-
- Quad* analog1Outer = &_quads[2 + controllerIndex];
- analog1Outer->x = ANALOG1_X + xOffset;
- analog1Outer->y = ANALOG_Y;
- analog1Outer->width = analog1Outer->height = ANALOG_SIZE;
- analog1Outer->uvs = _outerUVs;
-
- _analog1Inner[i] = &_quads[3 + controllerIndex];
- _analog1Inner[i]->x = ANALOG1_X + xOffset;
- _analog1Inner[i]->y = ANALOG_Y;
- _analog1Inner[i]->width = _analog1Inner[i]->height = ANALOG_SIZE;
- _analog1Inner[i]->uvs = _innerUVs;
-
- // Common to all buttons.
int j;
- for (j = 0; j < 16; ++j) {
- // Default mappings.
- _buttons[i][j].mapping = _buttonMappings[j];
- // Assign quads.
+ // Assign quads to all buttons.
+ for (j = 0; j < 12; ++j) {
_buttons[i][j].quad = &_quads[j+4 + controllerIndex];
}
@@ -296,15 +269,15 @@ int init()
}
// Buttons.
- for (j = 4; j < 10; ++j) {
+ for (j = 4; j < 8; ++j) {
_buttons[i][j].type = BUTTON;
_buttons[i][j].quad->width = BUTTON_SIZE;
_buttons[i][j].quad->height = BUTTON_SIZE;
_buttons[i][j].quad->uvs = _buttonUpUVs;
}
- // Triggers
- for (j = 10; j < 16; ++j) {
+ // Triggers.
+ for (j = 8; j < 12; ++j) {
_buttons[i][j].type = TRIGGER;
_buttons[i][j].quad->width = TRIGGER_WIDTH;
_buttons[i][j].quad->height = TRIGGER_HEIGHT;
@@ -312,6 +285,33 @@ int init()
}
// Set quad positions and sizes.
+
+ // Right stick
+ Quad* analog1Outer = &_quads[0 + controllerIndex];
+ analog1Outer->x = ANALOG1_X + xOffset;
+ analog1Outer->y = ANALOG_Y;
+ analog1Outer->width = analog1Outer->height = ANALOG_SIZE;
+ analog1Outer->uvs = _outerUVs;
+
+ _analog1Inner[i] = &_quads[1 + controllerIndex];
+ _analog1Inner[i]->x = ANALOG1_X + xOffset;
+ _analog1Inner[i]->y = ANALOG_Y;
+ _analog1Inner[i]->width = _analog1Inner[i]->height = ANALOG_SIZE;
+ _analog1Inner[i]->uvs = _innerUVs;
+
+ // Left stick
+ Quad* analog0Outer = &_quads[2 + controllerIndex];
+ analog0Outer->x = ANALOG0_X + xOffset;
+ analog0Outer->y = ANALOG_Y;
+ analog0Outer->width = analog0Outer->height = ANALOG_SIZE;
+ analog0Outer->uvs = _outerUVs;
+
+ _analog0Inner[i] = &_quads[3 + controllerIndex];
+ _analog0Inner[i]->x = ANALOG0_X + xOffset;
+ _analog0Inner[i]->y = ANALOG_Y;
+ _analog0Inner[i]->width = _analog0Inner[i]->height = ANALOG_SIZE;
+ _analog0Inner[i]->uvs = _innerUVs;
+
// Up
_buttons[i][0].label = "U";
_buttons[i][0].quad->x = DPAD_X + DPAD_SHORT + xOffset;
@@ -369,56 +369,35 @@ int init()
_buttons[i][7].quad->y = BUTTONS_Y + 2*BUTTON_SIZE;
_buttons[i][7].mapping = SCREEN_Y_GAME_BUTTON;
- // L3, R3
- _buttons[i][8].label = "L3";
- _buttons[i][8].quad->x = ANALOG0_X + BUTTON_SIZE*2.0f + xOffset;
- _buttons[i][8].quad->y = ANALOG_Y + BUTTON_SIZE;
- _buttons[i][8].mapping = SCREEN_L3_GAME_BUTTON;
-
- _buttons[i][9].label = "R3";
- _buttons[i][9].quad->x = ANALOG1_X - BUTTON_SIZE*2.0f + xOffset;
- _buttons[i][9].quad->y = ANALOG_Y + BUTTON_SIZE;
- _buttons[i][9].mapping = SCREEN_R3_GAME_BUTTON;
-
- // Triggers: L1, L2, R1, R2
- _buttons[i][10].label = "L1";
- _buttons[i][10].quad->x = LEFT_TRIGGERS_X + xOffset;
- _buttons[i][10].quad->y = TRIGGERS_Y;
- _buttons[i][10].mapping = SCREEN_L1_GAME_BUTTON;
-
- _buttons[i][11].label = "L2";
- _buttons[i][11].quad->x = LEFT_TRIGGERS_X + xOffset;
- _buttons[i][11].quad->y = TRIGGERS_Y + TRIGGER_HEIGHT + 25.0f;
- _buttons[i][11].mapping = SCREEN_L2_GAME_BUTTON;
-
- _buttons[i][12].label = "R1";
- _buttons[i][12].quad->x = RIGHT_TRIGGERS_X + xOffset;
- _buttons[i][12].quad->y = TRIGGERS_Y;
- _buttons[i][12].mapping = SCREEN_R1_GAME_BUTTON;
-
- _buttons[i][13].label = "R2";
- _buttons[i][13].quad->x = RIGHT_TRIGGERS_X + xOffset;
- _buttons[i][13].quad->y = TRIGGERS_Y + TRIGGER_HEIGHT + 25.0f;
- _buttons[i][13].mapping = SCREEN_R2_GAME_BUTTON;
+ // Triggers: L1, R1.
+ _buttons[i][8].label = "L1";
+ _buttons[i][8].quad->x = LEFT_TRIGGERS_X + xOffset;
+ _buttons[i][8].quad->y = TRIGGERS_Y;
+ _buttons[i][8].mapping = SCREEN_L1_GAME_BUTTON;
+
+ _buttons[i][9].label = "R1";
+ _buttons[i][9].quad->x = RIGHT_TRIGGERS_X + xOffset;
+ _buttons[i][9].quad->y = TRIGGERS_Y;
+ _buttons[i][9].mapping = SCREEN_R1_GAME_BUTTON;
// Select, Start
- _buttons[i][14].label = "Select";
- _buttons[i][14].quad->x = SELECT_X + xOffset;
- _buttons[i][14].quad->y = SELECT_Y;
- _buttons[i][14].mapping = SCREEN_MENU1_GAME_BUTTON;
-
- _buttons[i][15].label = "Start";
- _buttons[i][15].quad->x = SELECT_X + xOffset;
- _buttons[i][15].quad->y = SELECT_Y + TRIGGER_HEIGHT + 25.0f;
- _buttons[i][15].mapping = SCREEN_MENU2_GAME_BUTTON;
+ _buttons[i][10].label = "Select";
+ _buttons[i][10].quad->x = SELECT_X + xOffset;
+ _buttons[i][10].quad->y = SELECT_Y;
+ _buttons[i][10].mapping = SCREEN_MENU1_GAME_BUTTON;
+
+ _buttons[i][11].label = "Start";
+ _buttons[i][11].quad->x = SELECT_X + xOffset;
+ _buttons[i][11].quad->y = SELECT_Y + TRIGGER_HEIGHT + 25.0f;
+ _buttons[i][11].mapping = SCREEN_MENU2_GAME_BUTTON;
}
// Finally, one last quad is used for the "polling" button.
- Quad* pollingQuad = &_quads[40];
+ Quad* pollingQuad = &_quads[32];
pollingQuad->x = (surface_width * 0.5f) - TRIGGER_WIDTH * 0.5f;
- pollingQuad->y = 5.0f;
+ pollingQuad->y = 25.0f;
pollingQuad->width = TRIGGER_WIDTH;
- pollingQuad->height = TRIGGER_HEIGHT;
+ pollingQuad->height = TRIGGER_HEIGHT + 20;
pollingQuad->uvs = _triggerUpUVs;
_pollingButton.quad = pollingQuad;
@@ -505,25 +484,22 @@ static void loadController(GameController* controller)
// Query libscreen for information about this device.
SCREEN_API(screen_get_device_property_iv(controller->handle, SCREEN_PROPERTY_TYPE, &controller->type), "SCREEN_PROPERTY_TYPE");
SCREEN_API(screen_get_device_property_cv(controller->handle, SCREEN_PROPERTY_ID_STRING, sizeof(controller->id), controller->id), "SCREEN_PROPERTY_ID_STRING");
- SCREEN_API(screen_get_device_property_cv(controller->handle, SCREEN_PROPERTY_VENDOR, sizeof(controller->vendor), controller->vendor), "SCREEN_PROPERTY_VENDOR");
- SCREEN_API(screen_get_device_property_cv(controller->handle, SCREEN_PROPERTY_PRODUCT, sizeof(controller->product), controller->product), "SCREEN_PROPERTY_PRODUCT");
SCREEN_API(screen_get_device_property_iv(controller->handle, SCREEN_PROPERTY_BUTTON_COUNT, &controller->buttonCount), "SCREEN_PROPERTY_BUTTON_COUNT");
- if (controller->type == SCREEN_EVENT_GAMEPAD) {
- sprintf(controller->deviceString0, "Gamepad device ID: %s", controller->id);
- } else {
- sprintf(controller->deviceString0, "Joystick device: %s", controller->id);
+ // Check for the existence of analog sticks.
+ if (!screen_get_device_property_iv(controller->handle, SCREEN_PROPERTY_ANALOG0, controller->analog0)) {
+ ++controller->analogCount;
}
- if (strcmp(controller->vendor, "") == 0) {
- strcat(controller->vendor, "Unknown");
+ if (!screen_get_device_property_iv(controller->handle, SCREEN_PROPERTY_ANALOG1, controller->analog0)) {
+ ++controller->analogCount;
}
- if (strcmp(controller->product, "") == 0) {
- strcat(controller->product, "Unknown");
+ if (controller->type == SCREEN_EVENT_GAMEPAD) {
+ sprintf(controller->deviceString, "Gamepad device ID: %s", controller->id);
+ } else {
+ sprintf(controller->deviceString, "Joystick device: %s", controller->id);
}
-
- sprintf(controller->deviceString1, "Vendor: %s, Product: %s, Button count: %d", controller->vendor, controller->product, controller->buttonCount);
}
static void pollDevices()
@@ -535,8 +511,14 @@ static void pollDevices()
if (controller->handle) {
// Get the current state of a gamepad device.
SCREEN_API(screen_get_device_property_iv(controller->handle, SCREEN_PROPERTY_BUTTONS, &controller->buttons), "SCREEN_PROPERTY_BUTTONS");
- SCREEN_API(screen_get_device_property_iv(controller->handle, SCREEN_PROPERTY_ANALOG0, controller->analog0), "SCREEN_PROPERTY_ANALOG0");
- SCREEN_API(screen_get_device_property_iv(controller->handle, SCREEN_PROPERTY_ANALOG1, controller->analog1), "SCREEN_PROPERTY_ANALOG1");
+
+ if (controller->analogCount > 0) {
+ SCREEN_API(screen_get_device_property_iv(controller->handle, SCREEN_PROPERTY_ANALOG0, controller->analog0), "SCREEN_PROPERTY_ANALOG0");
+ }
+
+ if (controller->analogCount == 2) {
+ SCREEN_API(screen_get_device_property_iv(controller->handle, SCREEN_PROPERTY_ANALOG1, controller->analog1), "SCREEN_PROPERTY_ANALOG1");
+ }
}
}
}
@@ -572,9 +554,12 @@ static void handleScreenEvent(bps_event_t *event)
// Store the controller's new state.
SCREEN_API(screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_BUTTONS, &controller->buttons), "SCREEN_PROPERTY_BUTTONS");
- SCREEN_API(screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_ANALOG0, controller->analog0), "SCREEN_PROPERTY_ANALOG0");
- if (controller->type == SCREEN_EVENT_GAMEPAD) {
+ if (controller->analogCount > 0) {
+ SCREEN_API(screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_ANALOG0, controller->analog0), "SCREEN_PROPERTY_ANALOG0");
+ }
+
+ if (controller->analogCount == 2) {
SCREEN_API(screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_ANALOG1, controller->analog1), "SCREEN_PROPERTY_ANALOG1");
}
}
@@ -759,7 +744,7 @@ void update()
if (controller->buttons & _buttonMappings[j]) {
// Erase old button mapping if one exists.
int k;
- for (k = 0; k < 16; ++k) {
+ for (k = 0; k < MAX_BUTTONS; ++k) {
Button* button = &_buttons[i][k];
if (_buttonMappings[j] & button->mapping) {
button->mapping = 0;
@@ -778,16 +763,26 @@ void update()
float xOffset = (_surfaceWidth * 0.5f)*i;
// Set the inner joystick positions.
- _analog0Inner[i]->x = ANALOG0_X + xOffset + (controller->analog0[0] >> 2);
- _analog0Inner[i]->y = ANALOG_Y - (controller->analog0[1] >> 2);
+ if (controller->analogCount > 0) {
+ _analog0Inner[i]->x = ANALOG0_X + xOffset + (controller->analog0[0] >> 2);
+ _analog0Inner[i]->y = ANALOG_Y - (controller->analog0[1] >> 2);
+ sprintf(controller->analog0String, "Analog 0: (%4d, %4d)", controller->analog0[0], controller->analog0[1]);
+ } else {
+ sprintf(controller->analog0String, "Analog 0: N/A");
+ }
- _analog1Inner[i]->x = ANALOG1_X + xOffset + (controller->analog1[0] >> 2);
- _analog1Inner[i]->y = ANALOG_Y - (controller->analog1[1] >> 2);
+ if (controller->analogCount == 2) {
+ _analog1Inner[i]->x = ANALOG1_X + xOffset + (controller->analog1[0] >> 2);
+ _analog1Inner[i]->y = ANALOG_Y - (controller->analog1[1] >> 2);
+ sprintf(controller->analog1String, "Analog 1: (%4d, %4d)", controller->analog1[0], controller->analog1[1]);
+ } else {
+ sprintf(controller->analog1String, "Analog 1: N/A");
+ }
// Set the button UVs to correspond to their states, as well as the button text.
sprintf(controller->buttonsString, "Buttons: ");
int j;
- for (j = 0; j < 16; ++j) {
+ for (j = 0; j < MAX_BUTTONS; ++j) {
Button* button = &_buttons[i][j];
if ((controller->buttons & button->mapping) || button == _activeButton[i]) {
@@ -844,15 +839,6 @@ void update()
strcat(controller->buttonsString, buttonString);
}
}
-
- // Set the rest of the text to display for this controller.
- sprintf(controller->analog0String, "Analog 0: (%4d, %4d)", controller->analog0[0], controller->analog0[1]);
-
- if (controller->type == SCREEN_EVENT_GAMEPAD) {
- sprintf(controller->analog1String, "Analog 1: (%4d, %4d)", controller->analog1[0], controller->analog1[1]);
- } else {
- controller->analog1String[0] = '\0';
- }
}
}
@@ -906,14 +892,24 @@ void render()
glTexCoordPointer(2, GL_FLOAT, 0, _textureCoords);
glBindTexture(GL_TEXTURE_2D, _gamepadTexture);
+ if (_controllers[0].handle || _controllers[1].handle) {
+ // Draw the polling button.
+ glDrawElements(GL_TRIANGLE_STRIP, 6, GL_UNSIGNED_SHORT, _indices + 192);
+ }
+
// Draw only connected controllers.
- if (_controllers[0].handle && _controllers[1].handle) {
- glDrawElements(GL_TRIANGLE_STRIP, INDEX_COUNT, GL_UNSIGNED_SHORT, _indices);
- } else if (_controllers[0].handle) {
- glDrawElements(GL_TRIANGLE_STRIP, 120, GL_UNSIGNED_SHORT, _indices);
- glDrawElements(GL_TRIANGLE_STRIP, 6, GL_UNSIGNED_SHORT, _indices + 240);
- } else if (_controllers[1].handle) {
- glDrawElements(GL_TRIANGLE_STRIP, 126, GL_UNSIGNED_SHORT, _indices + 120);
+ // Only draw the analog sticks if they're present.
+ for (i = 0; i < MAX_CONTROLLERS; ++i) {
+ GameController* controller = &_controllers[i];
+ if (controller->handle) {
+ if (controller->analogCount == 2) {
+ glDrawElements(GL_TRIANGLE_STRIP, 96, GL_UNSIGNED_SHORT, _indices + i*96);
+ } else if (controller->analogCount == 1) {
+ glDrawElements(GL_TRIANGLE_STRIP, 84, GL_UNSIGNED_SHORT, _indices + 12 + i*96);
+ } else {
+ glDrawElements(GL_TRIANGLE_STRIP, 72, GL_UNSIGNED_SHORT, _indices + 24 + i*96);
+ }
+ }
}
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
@@ -926,16 +922,15 @@ void render()
GameController* controller = &_controllers[i];
float xOffset = (_surfaceWidth * 0.5f)*i;
- bbutil_render_text(_font, controller->deviceString0, 5 + xOffset, _surfaceHeight - 20, 1.0f, 0.0f, 0.0f, 1.0f);
+ bbutil_render_text(_font, controller->deviceString, 5 + xOffset, _surfaceHeight - 20, 1.0f, 0.0f, 0.0f, 1.0f);
if (controller->handle) {
// Controller is connected; display info about its current state.
- bbutil_render_text(_font, controller->deviceString1, 5 + xOffset, _surfaceHeight - 40, 1.0f, 0.0f, 0.0f, 1.0f);
- bbutil_render_text(_font, controller->buttonsString, 5 + xOffset, _surfaceHeight - 60, 1.0f, 0.0f, 0.0f, 1.0f);
- bbutil_render_text(_font, controller->analog0String, 5 + xOffset, _surfaceHeight - 80, 1.0f, 0.0f, 0.0f, 1.0f);
- bbutil_render_text(_font, controller->analog1String, 5 + xOffset, _surfaceHeight - 100, 1.0f, 0.0f, 0.0f, 1.0f);
+ bbutil_render_text(_font, controller->buttonsString, 5 + xOffset, _surfaceHeight - 40, 1.0f, 0.0f, 0.0f, 1.0f);
+ bbutil_render_text(_font, controller->analog0String, 5 + xOffset, _surfaceHeight - 60, 1.0f, 0.0f, 0.0f, 1.0f);
+ bbutil_render_text(_font, controller->analog1String, 5 + xOffset, _surfaceHeight - 80, 1.0f, 0.0f, 0.0f, 1.0f);
- // Render button labels.
+ // Button labels.
int j;
for (j = 0; j < MAX_BUTTONS; ++j) {
Button* button = &_buttons[i][j];
@@ -945,8 +940,7 @@ void render()
bbutil_render_text(_font, button->label, button->quad->x + 30, button->quad->y + 70, 1.0f, 0.0f, 0.0f, 1.0f);
} else if (button->type == DPAD_RIGHT) {
bbutil_render_text(_font, button->label, button->quad->x + 70, button->quad->y + 30, 1.0f, 0.0f, 0.0f, 1.0f);
- }
- else {
+ } else {
bbutil_render_text(_font, button->label, button->quad->x + 30, button->quad->y + 30, 1.0f, 0.0f, 0.0f, 1.0f);
}
}
View
4 Gamepad/readme.txt
@@ -24,9 +24,7 @@ Feature summary:
Requirements:
- BlackBerry� 10 Native SDK
- - One of the following:
- - BlackBerry� 10 device
- - BlackBerry� 10 simulator
+ - BlackBerry� 10 device
========================================================================
Importing a project into the Native SDK:
Please sign in to comment.
Something went wrong with that request. Please try again.