|
@@ -28,7 +28,12 @@ static bool select_pokemon_input_callback(InputEvent* event, void* context) {
|
|
|
SelectPokemon* select_pokemon = (SelectPokemon*)context;
|
|
SelectPokemon* select_pokemon = (SelectPokemon*)context;
|
|
|
bool consumed = false;
|
|
bool consumed = false;
|
|
|
|
|
|
|
|
- if(event->type == InputTypePress && event->key == InputKeyOk) {
|
|
|
|
|
|
|
+ /* We only handle InputTypePress at the moment */
|
|
|
|
|
+ if(event->type != InputTypePress) return consumed;
|
|
|
|
|
+
|
|
|
|
|
+ switch(event->key) {
|
|
|
|
|
+ /* Advance to next view with the selected pokemon */
|
|
|
|
|
+ case InputKeyOk:
|
|
|
with_view_model_cpp(
|
|
with_view_model_cpp(
|
|
|
select_pokemon->view,
|
|
select_pokemon->view,
|
|
|
SelectPokemonModel*,
|
|
SelectPokemonModel*,
|
|
@@ -40,10 +45,16 @@ static bool select_pokemon_input_callback(InputEvent* event, void* context) {
|
|
|
false);
|
|
false);
|
|
|
view_dispatcher_switch_to_view(select_pokemon->app->view_dispatcher, AppViewTrade);
|
|
view_dispatcher_switch_to_view(select_pokemon->app->view_dispatcher, AppViewTrade);
|
|
|
consumed = true;
|
|
consumed = true;
|
|
|
- } else if(event->type == InputTypePress && event->key == InputKeyBack) {
|
|
|
|
|
|
|
+ break;
|
|
|
|
|
+
|
|
|
|
|
+ /* Return to the previous view */
|
|
|
|
|
+ case InputKeyBack:
|
|
|
view_dispatcher_switch_to_view(select_pokemon->app->view_dispatcher, VIEW_NONE);
|
|
view_dispatcher_switch_to_view(select_pokemon->app->view_dispatcher, VIEW_NONE);
|
|
|
consumed = true;
|
|
consumed = true;
|
|
|
- } else if(event->type == InputTypePress && event->key == InputKeyLeft) {
|
|
|
|
|
|
|
+ break;
|
|
|
|
|
+
|
|
|
|
|
+ /* Move back one through the pokedex listing */
|
|
|
|
|
+ case InputKeyLeft:
|
|
|
with_view_model_cpp(
|
|
with_view_model_cpp(
|
|
|
select_pokemon->view,
|
|
select_pokemon->view,
|
|
|
SelectPokemonModel*,
|
|
SelectPokemonModel*,
|
|
@@ -57,7 +68,12 @@ static bool select_pokemon_input_callback(InputEvent* event, void* context) {
|
|
|
},
|
|
},
|
|
|
true);
|
|
true);
|
|
|
consumed = true;
|
|
consumed = true;
|
|
|
- } else if(event->type == InputTypePress && event->key == InputKeyDown) {
|
|
|
|
|
|
|
+ break;
|
|
|
|
|
+
|
|
|
|
|
+ /* Move back ten through the pokemon listing, wrap to max pokemon on
|
|
|
|
|
+ * underflow.
|
|
|
|
|
+ */
|
|
|
|
|
+ case InputKeyDown:
|
|
|
with_view_model_cpp(
|
|
with_view_model_cpp(
|
|
|
select_pokemon->view,
|
|
select_pokemon->view,
|
|
|
SelectPokemonModel*,
|
|
SelectPokemonModel*,
|
|
@@ -71,7 +87,10 @@ static bool select_pokemon_input_callback(InputEvent* event, void* context) {
|
|
|
},
|
|
},
|
|
|
true);
|
|
true);
|
|
|
consumed = true;
|
|
consumed = true;
|
|
|
- } else if(event->type == InputTypePress && event->key == InputKeyRight) {
|
|
|
|
|
|
|
+ break;
|
|
|
|
|
+
|
|
|
|
|
+ /* Move forward one through the pokedex listing */
|
|
|
|
|
+ case InputKeyRight:
|
|
|
with_view_model_cpp(
|
|
with_view_model_cpp(
|
|
|
select_pokemon->view,
|
|
select_pokemon->view,
|
|
|
SelectPokemonModel*,
|
|
SelectPokemonModel*,
|
|
@@ -85,7 +104,12 @@ static bool select_pokemon_input_callback(InputEvent* event, void* context) {
|
|
|
},
|
|
},
|
|
|
true);
|
|
true);
|
|
|
consumed = true;
|
|
consumed = true;
|
|
|
- } else if(event->type == InputTypePress && event->key == InputKeyUp) {
|
|
|
|
|
|
|
+ break;
|
|
|
|
|
+
|
|
|
|
|
+ /* Move forward ten through the pokemon listing, wrap to min pokemon on
|
|
|
|
|
+ * overflow.
|
|
|
|
|
+ */
|
|
|
|
|
+ case InputKeyUp:
|
|
|
with_view_model_cpp(
|
|
with_view_model_cpp(
|
|
|
select_pokemon->view,
|
|
select_pokemon->view,
|
|
|
SelectPokemonModel*,
|
|
SelectPokemonModel*,
|
|
@@ -95,11 +119,15 @@ static bool select_pokemon_input_callback(InputEvent* event, void* context) {
|
|
|
model->current_pokemon += 10;
|
|
model->current_pokemon += 10;
|
|
|
} else {
|
|
} else {
|
|
|
model->current_pokemon = 0;
|
|
model->current_pokemon = 0;
|
|
|
- ;
|
|
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
true);
|
|
true);
|
|
|
consumed = true;
|
|
consumed = true;
|
|
|
|
|
+ break;
|
|
|
|
|
+
|
|
|
|
|
+ default:
|
|
|
|
|
+ // Do Nothing
|
|
|
|
|
+ break;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return consumed;
|
|
return consumed;
|