mirror of
https://github.com/libretro/ppsspp.git
synced 2025-02-26 03:35:27 +00:00
Merge branch 'master' of github.com:hrydgard/native
This commit is contained in:
commit
b3ad7d4584
@ -29,6 +29,9 @@ static JNIEnv *jniEnvUI;
|
||||
std::string frameCommand;
|
||||
std::string frameCommandParam;
|
||||
|
||||
static uint32_t pad_buttons_async_set;
|
||||
static uint32_t pad_buttons_async_clear;
|
||||
|
||||
// Android implementation of callbacks to the Java part of the app
|
||||
void SystemToast(const char *text) {
|
||||
frameCommand = "toast";
|
||||
@ -107,6 +110,9 @@ extern "C" void Java_com_turboviking_libnative_NativeApp_init
|
||||
renderer_inited = false;
|
||||
first_lost = true;
|
||||
|
||||
pad_buttons_async_set = 0;
|
||||
pad_buttons_async_clear = 0;
|
||||
|
||||
std::string apkPath = GetJavaString(env, japkpath);
|
||||
ILOG("APK path: %s", apkPath.c_str());
|
||||
VFSRegister("", new ZipAssetReader(apkPath.c_str(), "assets/"));
|
||||
@ -202,9 +208,11 @@ extern "C" void Java_com_turboviking_libnative_NativeRenderer_displayResize(JNIE
|
||||
|
||||
extern "C" void Java_com_turboviking_libnative_NativeRenderer_displayRender(JNIEnv *env, jobject obj) {
|
||||
if (renderer_inited) {
|
||||
UpdateInputState(&input_state);
|
||||
{
|
||||
lock_guard guard(input_state.lock);
|
||||
input_state.pad_buttons |= pad_buttons_async_set;
|
||||
input_state.pad_buttons &= ~pad_buttons_async_clear;
|
||||
UpdateInputState(&input_state);
|
||||
NativeUpdate(input_state);
|
||||
EndInputState(&input_state);
|
||||
}
|
||||
@ -266,38 +274,36 @@ extern "C" void JNICALL Java_com_turboviking_libnative_NativeApp_touch
|
||||
input_state.mouse_valid = true;
|
||||
}
|
||||
|
||||
extern "C" void Java_com_turboviking_libnative_NativeApp_keyDown
|
||||
(JNIEnv *, jclass, jint key) {
|
||||
ILOG("Keydown %i", key);
|
||||
lock_guard guard(input_state.lock);
|
||||
// Need a mechanism to release these.
|
||||
extern "C" void Java_com_turboviking_libnative_NativeApp_keyDown(JNIEnv *, jclass, jint key) {
|
||||
switch (key) {
|
||||
case 1: // Back
|
||||
input_state.pad_buttons |= PAD_BUTTON_BACK;
|
||||
pad_buttons_async_set |= PAD_BUTTON_BACK;
|
||||
pad_buttons_async_clear &= ~PAD_BUTTON_BACK;
|
||||
break;
|
||||
case 2: // Menu
|
||||
input_state.pad_buttons |= PAD_BUTTON_MENU;
|
||||
pad_buttons_async_set |= PAD_BUTTON_MENU;
|
||||
pad_buttons_async_clear &= ~PAD_BUTTON_MENU;
|
||||
break;
|
||||
case 3: // Search
|
||||
input_state.pad_buttons |= PAD_BUTTON_A;
|
||||
pad_buttons_async_set |= PAD_BUTTON_A;
|
||||
pad_buttons_async_clear &= ~PAD_BUTTON_A;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void Java_com_turboviking_libnative_NativeApp_keyUp
|
||||
(JNIEnv *, jclass, jint key) {
|
||||
ILOG("Keyup %i", key);
|
||||
lock_guard guard(input_state.lock);
|
||||
// Need a mechanism to release these.
|
||||
extern "C" void Java_com_turboviking_libnative_NativeApp_keyUp(JNIEnv *, jclass, jint key) {
|
||||
switch (key) {
|
||||
case 1: // Back
|
||||
input_state.pad_buttons &= ~PAD_BUTTON_BACK;
|
||||
pad_buttons_async_set &= ~PAD_BUTTON_BACK;
|
||||
pad_buttons_async_clear |= PAD_BUTTON_BACK;
|
||||
break;
|
||||
case 2: // Menu
|
||||
input_state.pad_buttons &= ~PAD_BUTTON_MENU;
|
||||
pad_buttons_async_set &= ~PAD_BUTTON_MENU;
|
||||
pad_buttons_async_clear |= PAD_BUTTON_MENU;
|
||||
break;
|
||||
case 3: // Search
|
||||
input_state.pad_buttons &= ~PAD_BUTTON_A;
|
||||
pad_buttons_async_set &= ~PAD_BUTTON_A;
|
||||
pad_buttons_async_clear |= PAD_BUTTON_A;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
13
ui/ui.cpp
13
ui/ui.cpp
@ -140,7 +140,7 @@ int UIButton(int id, const LayoutManager &layout, float w, const char *text, int
|
||||
|
||||
// Render button
|
||||
|
||||
ui_draw2d.DrawImage2GridH(theme.buttonImage, x, y, x + w);
|
||||
ui_draw2d.DrawImage2GridH((txOffset && theme.buttonSelected) ? theme.buttonSelected : theme.buttonImage, x, y, x + w);
|
||||
ui_draw2d.DrawTextShadow(theme.uiFont, text, x + w/2, y + h/2 + txOffset, 0xFFFFFFFF, ALIGN_HCENTER | ALIGN_VCENTER);
|
||||
|
||||
uistate.lastwidget = id;
|
||||
@ -361,14 +361,15 @@ int UIList::Do(int id, int x, int y, int w, int h, UIListAdapter *adapter) {
|
||||
} else if (scrollY < 0.0f) {
|
||||
scrollY += 0.3f * -scrollY;
|
||||
}
|
||||
lastX = uistate.mousex[0];
|
||||
lastY = uistate.mousey[0];
|
||||
uistate.lastwidget = id;
|
||||
} else {
|
||||
scrollY = 0.0f;
|
||||
scrolling = false;
|
||||
inertiaY = 0.0f;
|
||||
}
|
||||
|
||||
lastX = uistate.mousex[0];
|
||||
lastY = uistate.mousey[0];
|
||||
uistate.lastwidget = id;
|
||||
|
||||
// Drawing and item hittesting
|
||||
|
||||
// render items
|
||||
@ -384,7 +385,7 @@ int UIList::Do(int id, int x, int y, int w, int h, UIListAdapter *adapter) {
|
||||
selected == -1 &&
|
||||
UIRegionHit(k, x, item_y, w, itemHeight, 0)) {
|
||||
selected = i;
|
||||
} else if (scrolling) {
|
||||
} else if (scrolling && canScroll) {
|
||||
selected = -1;
|
||||
}
|
||||
}
|
||||
|
1
ui/ui.h
1
ui/ui.h
@ -125,6 +125,7 @@ struct UITheme {
|
||||
int uiFontSmall;
|
||||
int uiFontSmaller;
|
||||
int buttonImage;
|
||||
int buttonSelected;
|
||||
int checkOn;
|
||||
int checkOff;
|
||||
};
|
||||
|
@ -29,17 +29,18 @@ void TouchButton::update(InputState &input_state)
|
||||
}
|
||||
}
|
||||
|
||||
void TouchButton::draw(DrawBuffer &db, uint32_t color)
|
||||
void TouchButton::draw(DrawBuffer &db, uint32_t color, uint32_t colorOverlay)
|
||||
{
|
||||
float scale = 1.0f;
|
||||
if (isDown_) {
|
||||
color |= 0xFF000000;
|
||||
colorOverlay |= 0xFF000000;
|
||||
scale = 2.0f;
|
||||
}
|
||||
// We only mirror background
|
||||
db.DrawImageRotated(imageIndex_, x_ + w_/2, y_ + h_/2, scale, rotationAngle_, color, mirror_h_);
|
||||
if (overlayImageIndex_ != -1)
|
||||
db.DrawImageRotated(overlayImageIndex_, x_ + w_/2, y_ + h_/2, scale, rotationAngle_, color);
|
||||
db.DrawImageRotated(overlayImageIndex_, x_ + w_/2, y_ + h_/2, scale, rotationAngle_, colorOverlay);
|
||||
}
|
||||
|
||||
TouchStick::TouchStick(const Atlas *atlas, int bgImageIndex, int stickImageIndex, int stick)
|
||||
|
@ -13,7 +13,7 @@ public:
|
||||
TouchButton(const Atlas *atlas, int imageIndex, int overlayImageIndex, int button, int rotationAngle = 0, bool mirror_h = false);
|
||||
|
||||
void update(InputState &input_state);
|
||||
void draw(DrawBuffer &db, uint32_t color);
|
||||
void draw(DrawBuffer &db, uint32_t color, uint32_t colorOverlay);
|
||||
|
||||
void setPos(float x, float y) {
|
||||
x_ = x - w_ / 2;
|
||||
|
Loading…
x
Reference in New Issue
Block a user