Bugfix : properly show icon for joystick or keyboard

This commit is contained in:
Aaron Culliney 2015-07-29 21:18:25 -07:00
parent 7067d10949
commit abfa6e743b
7 changed files with 21 additions and 8 deletions

View File

@ -260,6 +260,7 @@ void c_joystick_reset(void)
bool (*joydriver_isTouchJoystickAvailable)(void) = NULL;
void (*joydriver_setTouchJoystickEnabled)(bool enabled) = NULL;
void (*joydriver_setTouchJoystickOwnsScreen)(bool pwnd) = NULL;
bool (*joydriver_ownsScreen)(void) = NULL;
void (*joydriver_setTouchButtonValues)(char button0Val, char button1Val) = NULL;
void (*joydriver_setTouchAxisType)(touchjoy_axis_type_t axisType) = NULL;
void (*joydriver_setTouchAxisValues)(char up, char left, char right, char down) = NULL;

View File

@ -45,9 +45,12 @@ extern bool (*joydriver_isTouchJoystickAvailable)(void);
// enable/disable touch joystick
extern void (*joydriver_setTouchJoystickEnabled)(bool enabled);
// grant/remove ownership of touch screeen
// grant/remove ownership of touch screen
extern void (*joydriver_setTouchJoystickOwnsScreen)(bool pwnd);
// query touch screen ownership
extern bool (*joydriver_ownsScreen)(void);
// set the joystick button parameters (7bit ASCII characters or MOUSETEXT values)
extern void (*joydriver_setTouchButtonValues)(char button0Val, char button1Val);

View File

@ -493,5 +493,6 @@ bool c_keys_is_interface_key(int key)
bool (*keydriver_isTouchKeyboardAvailable)(void) = NULL;
void (*keydriver_setTouchKeyboardEnabled)(bool enabled) = NULL;
void (*keydriver_setTouchKeyboardOwnsScreen)(bool pwnd) = NULL;
bool (*keydriver_ownsScreen)(void) = NULL;
#endif

View File

@ -155,8 +155,11 @@ extern bool (*keydriver_isTouchKeyboardAvailable)(void);
// enable/disable touch keyboard HUD element
extern void (*keydriver_setTouchKeyboardEnabled)(bool enabled);
// grant/remove ownership of touch screeen
// grant/remove ownership of touch screen
extern void (*keydriver_setTouchKeyboardOwnsScreen)(bool pwnd);
// query touch screen ownership
extern bool (*keydriver_ownsScreen)(void);
#endif
#endif

View File

@ -668,6 +668,10 @@ static void gltouchjoy_setTouchJoystickOwnsScreen(bool pwnd) {
}
}
static bool gltouchjoy_ownsScreen(void) {
return ownsScreen;
}
static void _animation_showTouchJoystick(void) {
if (!isAvailable) {
return;
@ -740,6 +744,7 @@ static void _init_gltouchjoy(void) {
joydriver_isTouchJoystickAvailable = &gltouchjoy_isTouchJoystickAvailable;
joydriver_setTouchJoystickEnabled = &gltouchjoy_setTouchJoystickEnabled;
joydriver_setTouchJoystickOwnsScreen = &gltouchjoy_setTouchJoystickOwnsScreen;
joydriver_ownsScreen = &gltouchjoy_ownsScreen;
joydriver_setTouchButtonValues = &gltouchjoy_setTouchButtonValues;
joydriver_setTouchAxisType = &gltouchjoy_setTouchAxisType;
joydriver_setTouchAxisValues = &gltouchjoy_setTouchAxisValues;

View File

@ -682,6 +682,10 @@ static void gltouchkbd_setTouchKeyboardOwnsScreen(bool pwnd) {
}
}
static bool gltouchkbd_ownsScreen(void) {
return ownsScreen;
}
static void _animation_showTouchKeyboard(void) {
if (!isAvailable) {
return;
@ -709,6 +713,7 @@ static void _init_gltouchkbd(void) {
keydriver_isTouchKeyboardAvailable = &gltouchkbd_isTouchKeyboardAvailable;
keydriver_setTouchKeyboardEnabled = &gltouchkbd_setTouchKeyboardEnabled;
keydriver_setTouchKeyboardOwnsScreen = &gltouchkbd_setTouchKeyboardOwnsScreen;
keydriver_ownsScreen = &gltouchkbd_ownsScreen;
kbd.selectedCol = -1;
kbd.selectedRow = -1;

View File

@ -73,7 +73,6 @@ static struct {
GLModel *model;
bool topLeftShowing;
bool topRightShowing;
char kbdOrJoy;
} menu = { 0 };
static struct timespec timingBegin = { 0 };
@ -97,7 +96,7 @@ static inline void _present_menu(GLModel *parent) {
static inline void _show_top_left(void) {
topMenuTemplate[0][0] = ICONTEXT_MENU_SPROUT;
topMenuTemplate[0][1] = MOUSETEXT_RIGHT;
topMenuTemplate[1][0] = menu.kbdOrJoy;
topMenuTemplate[1][0] = joydriver_ownsScreen() ? ICONTEXT_UPPERCASE : ICONTEXT_MENU_TOUCHJOY;
topMenuTemplate[1][1] = ICONTEXT_NONACTIONABLE;
menu.topLeftShowing = true;
_present_menu(menu.model);
@ -329,7 +328,6 @@ static inline bool _tap_menu_item(float x, float y) {
if (video_backend->animation_showTouchJoystick) {
video_backend->animation_showTouchJoystick();
}
menu.kbdOrJoy = ICONTEXT_UPPERCASE;
_hide_top_left();
break;
@ -343,7 +341,6 @@ static inline bool _tap_menu_item(float x, float y) {
if (video_backend->animation_showTouchKeyboard) {
video_backend->animation_showTouchKeyboard();
}
menu.kbdOrJoy = ICONTEXT_MENU_TOUCHJOY;
_hide_top_left();
break;
@ -597,8 +594,6 @@ static void _init_gltouchmenu(void) {
interface_setTouchMenuEnabled = &gltouchmenu_setTouchMenuEnabled;
interface_setTouchMenuVisibility = &gltouchmenu_setTouchMenuVisibility;
menu.kbdOrJoy = ICONTEXT_UPPERCASE;
glnode_registerNode(RENDER_TOP, (GLNode){
.setup = &gltouchmenu_setup,
.shutdown = &gltouchmenu_shutdown,