Number with gestures. Am I missing something?
Hi all, I was experimenting with the sample of gestures of https://github.com/blackberry/NDK-Samples/tree/ndk2/Gesture ... I wanted to do something when a tap gesture were found (some processing and registration for the file...)...
I noticed that after the treatment, the gestures would stop working...
I was able to recreate the problem simply by putting a 2 second delay in the section of the tap of the gestures of the Gesturs sample application standard callback function... I am pasting the main.c below...
I tried searching in the gesture API on delays documentation or any configuration of the time-out option, but could not find something... am I missing something? How can I recover when it arrives? (of course I could put the personalised treatment in another thread, but I don't need this way, and I don't see why it wouldn't work...). Anyone else having this problem?
This is the code:
/* * Copyright (c) 2011-2012 Research In Motion Limited. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include#include #include #include #include #include #include #include #include #include #include "input/screen_helpers.h" #include "gestures/double_tap.h" #include "gestures/pinch.h" #include "gestures/set.h" #include "gestures/swipe.h" #include "gestures/tap.h" #include "gestures/two_finger_pan.h" #define MIN_VIEWPORT_SIZE 128 #define MAX_VIEWPORT_SIZE 4096 screen_context_t screen_ctx; screen_window_t screen_win; static bool shutdown; struct gestures_set * set; const char* img_path = "app/native/wallpaper.jpg"; /* Relative path to image asset */ int viewport_pos[2] = { 0, 0 }; int viewport_size[2] = { 0, 0 }; int last_touch[2] = { 0, 0 }; /** * The callback invoked when a gesture is recognized or updated. */ void gesture_callback(gesture_base_t* gesture, mtouch_event_t* event, void* param, int async) { if (async) { fprintf(stderr,"[async] "); } switch (gesture->type) { case GESTURE_TWO_FINGER_PAN: { gesture_tfpan_t* tfpan = (gesture_tfpan_t*)gesture; fprintf(stderr,"Two finger pan: %d, %d", (tfpan->last_centroid.x - tfpan->centroid.x), (tfpan->last_centroid.y - tfpan->centroid.y)); if (tfpan->last_centroid.x && tfpan->last_centroid.y) { viewport_pos[0] += (tfpan->last_centroid.x - tfpan->centroid.x) >> 1; viewport_pos[1] += (tfpan->last_centroid.y - tfpan->centroid.y) >> 1; } break; } case GESTURE_PINCH: { gesture_pinch_t* pinch = (gesture_pinch_t*)gesture; fprintf(stderr,"Pinch %d, %d", (pinch->last_distance.x - pinch->distance.x), (pinch->last_distance.y - pinch->distance.y)); int dist_x = pinch->distance.x; int dist_y = pinch->distance.y; int last_dist_x = pinch->last_distance.x; int last_dist_y = pinch->last_distance.y; int reldist = sqrt((dist_x)*(dist_x) + (dist_y)*(dist_y)); int last_reldist = sqrt((last_dist_x)*(last_dist_x) + (last_dist_y)*(last_dist_y)); if (reldist && last_reldist) { viewport_size[0] += (last_reldist - reldist) >> 1; viewport_size[1] += (last_reldist - reldist) >> 1; /* Size restrictions */ if (viewport_size[0] < MIN_VIEWPORT_SIZE) { viewport_size[0] = MIN_VIEWPORT_SIZE; } else if (viewport_size[0] > MAX_VIEWPORT_SIZE) { viewport_size[0] = MAX_VIEWPORT_SIZE; } if (viewport_size[1] < MIN_VIEWPORT_SIZE) { viewport_size[1] = MIN_VIEWPORT_SIZE; } else if (viewport_size[1] > MAX_VIEWPORT_SIZE) { viewport_size[1] = MAX_VIEWPORT_SIZE; } /* Zoom into center of image */ if (viewport_size[0] > MIN_VIEWPORT_SIZE && viewport_size[1] > MIN_VIEWPORT_SIZE && viewport_size[0] < MAX_VIEWPORT_SIZE && viewport_size[1] < MAX_VIEWPORT_SIZE) { viewport_pos[0] -= (last_reldist - reldist) >> 2; viewport_pos[1] -= (last_reldist - reldist) >> 2; } } break; } case GESTURE_TAP: { gesture_tap_t* tap = (gesture_tap_t*)gesture; fprintf(stderr,"Tap x:%d y:%d delay 2000",tap->touch_coords.x,tap->touch_coords.y); // *** 2 sec delay to reproduce issue *** delay(2000); break; } case GESTURE_DOUBLE_TAP: { gesture_tap_t* d_tap = (gesture_tap_t*)gesture; fprintf(stderr,"Double tap x:%d y:%d", d_tap->touch_coords.x, d_tap->touch_coords.y); break; } default: { fprintf(stderr,"Unknown Gesture"); break; } } fprintf(stderr,"\n"); } /** * Initialize the gestures sets */ static void init_gestures() { gesture_tap_t* tap; gesture_double_tap_t* double_tap; set = gestures_set_alloc(); if (NULL != set) { tap = tap_gesture_alloc(NULL, gesture_callback, set); double_tap = double_tap_gesture_alloc(NULL, gesture_callback, set); tfpan_gesture_alloc(NULL, gesture_callback, set); pinch_gesture_alloc(NULL, gesture_callback, set); } else { fprintf(stderr, "Failed to allocate gestures set\n"); } } static void gestures_cleanup() { if (NULL != set) { gestures_set_free(set); set = NULL; } } static void handle_screen_event(bps_event_t *event) { int screen_val, rc; screen_event_t screen_event = screen_event_get_event(event); mtouch_event_t mtouch_event; rc = screen_get_event_property_iv(screen_event, SCREEN_PROPERTY_TYPE, &screen_val); if(screen_val == SCREEN_EVENT_MTOUCH_TOUCH || screen_val == SCREEN_EVENT_MTOUCH_MOVE || screen_val == SCREEN_EVENT_MTOUCH_RELEASE) { rc = screen_get_mtouch_event(screen_event, &mtouch_event, 0); if (rc) { fprintf(stderr, "Error: failed to get mtouch event\n"); } rc = gestures_set_process_event(set, &mtouch_event, NULL); /* No gesture detected, treat as pan. */ if (!rc) { if (mtouch_event.contact_id == 0) { if(last_touch[0] && last_touch[1]) { fprintf(stderr,"Pan %d %d\n",(last_touch[0] - mtouch_event.x),(last_touch[1] - mtouch_event.y)); viewport_pos[0] += (last_touch[0] - mtouch_event.x) >> 1; viewport_pos[1] += (last_touch[1] - mtouch_event.y) >> 1; } last_touch[0] = mtouch_event.x; last_touch[1] = mtouch_event.y; } } if (screen_val == SCREEN_EVENT_MTOUCH_RELEASE) { last_touch[0] = 0; last_touch[1] = 0; } } } static void handle_navigator_event(bps_event_t *event) { switch (bps_event_get_code(event)) { case NAVIGATOR_EXIT: shutdown = true; break; } } static void handle_events() { int rc, domain; bool has_events = true; while(has_events) { bps_event_t *event = NULL; rc = bps_get_event(&event, 50); assert(rc == BPS_SUCCESS); if (event) { domain = bps_event_get_domain(event); if (domain == navigator_get_domain()) { handle_navigator_event(event); } else if (domain == screen_get_domain()) { handle_screen_event(event); /* Re-draw the screen after a screen event */ screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_SOURCE_POSITION , viewport_pos); screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_SOURCE_SIZE , viewport_size); screen_flush_context(screen_ctx,0); } } else { has_events = false; } } } static int decode_setup(uintptr_t data, img_t *img, unsigned flags) { screen_window_t screen_win = (screen_window_t)data; screen_buffer_t screen_buf; int size[2]; size[0] = img->w; size[1] = img->h; screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size); screen_create_window_buffers(screen_win, 1); screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)&screen_buf); screen_get_buffer_property_pv(screen_buf, SCREEN_PROPERTY_POINTER, (void **)&img->access.direct.data); screen_get_buffer_property_iv(screen_buf, SCREEN_PROPERTY_STRIDE, (int *)&img->access.direct.stride); img->flags |= IMG_DIRECT; return IMG_ERR_OK; } static void decode_abort(uintptr_t data, img_t *img) { screen_window_t screen_win = (screen_window_t)data; screen_destroy_window_buffers(screen_win); } int load_image(screen_window_t screen_win, const char *path) { img_decode_callouts_t callouts; img_lib_t ilib = NULL; img_t img; int rc; rc = img_lib_attach(&ilib); if (rc != IMG_ERR_OK) { return -1; } memset(&img, 0, sizeof(img)); img.flags |= IMG_FORMAT; img.format = IMG_FMT_PKLE_XRGB8888; memset(&callouts, 0, sizeof(callouts)); callouts.setup_f = decode_setup; callouts.abort_f = decode_abort; callouts.data = (uintptr_t)screen_win; rc = img_load_file(ilib, path, &callouts, &img); img_lib_detach(ilib); return rc == IMG_ERR_OK ? 0 : -1; } int main(int argc, char **argv) { const int usage = SCREEN_USAGE_WRITE; screen_buffer_t screen_buf = NULL; int rect[4] = { 0, 0, 0, 0 }; /* Setup the window */ screen_create_context(&screen_ctx, 0); screen_create_window(&screen_win, screen_ctx); screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_USAGE, &usage); load_image(screen_win, img_path); screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_RENDER_BUFFERS, (void **)&screen_buf); screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, rect+2); viewport_size[0] = rect[2]; viewport_size[1] = rect[3]; screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_SOURCE_SIZE , viewport_size); screen_post_window(screen_win, screen_buf, 1, rect, 0); init_gestures(); /* Signal bps library that navigator and screen events will be requested */ bps_initialize(); screen_request_events(screen_ctx); navigator_request_events(0); while (!shutdown) { /* Handle user input */ handle_events(); } /* Clean up */ gestures_cleanup(); screen_stop_events(screen_ctx); bps_shutdown(); screen_destroy_window(screen_win); screen_destroy_context(screen_ctx); return 0; }
Yes, when I run the code above I get the same problem. It seems that the two finger gestures and pinching are fly events and not 'fault', so that it goes to the tap gesture. If I rearrange the gesture_allocs to this
_tfpan = tfpan_gesture_alloc (& tfparams, cb, _gest_set);
_pinch = pinch_gesture_alloc (& pinparams, cb, _gest_set);
_double_tap = double_tap_gesture_alloc (& dtparams, cb, _gest_set);
_tap = tap_gesture_alloc (& tparams, cb, _gest_set);
This works. But the double tap does not work, probably because it takes 2 pressures, and to know that you have only 1 tap must wait or get an idle screen event. In this case, I guess you could buffer events and use gestures_set_process_event_list with the functions in event_list.h
In addition, time of the event is the time of the real event, not when you have received the event with bps_get_event. Any delay should not affect the treatment of the gesture.
Tags: BlackBerry Developers
Similar Questions
-
Hello
I can't seem to open additional tabs with the +, the drop down menu, or T command? Is this a bug or am I missing something?I use Firefox 30.0 in OS 10.8.5 on a Mac Book Pro with the Intel Core i7 2.7 GHz and 1333 MHz DDR3 8 GB memory.
Thanks in advance,
PatYou have a "Community Toolbar" extension installed? Which has been reported by other users of Mac as affecting the new tab feature in Firefox 30.
-
I just bought 14 items and must have missed something because the order only gives me downloads for Windows and I'm on Mac. I have the serial number for Windows download. How to move to Mac downloads?
Hello
Please see a product for another language or version of trading platform
Kind regards
Sheena
-
I set up a 'user' for my son and use parental controls. I want to him to have access to Word for Mac, and it appears in the list of applications I can check to allow use for. However, when we opened a session under his username, these applications do not seem to be anywhere. When you configure new users, applications such as Word for Mac or the available Pages on users? I can't find any information to help in this regard. I don't know if I'm missing something under user put up, or parental controls, or both. Any help would be greatly appreciated!
These requests should be made available, provided you installed then in the folder/applications, not in a private folder ~/Applications for a specific user.
-
Trying to figure out why I get message ORA-06530 to a simple example below. I am trying to create a PL/SQL table of values to be stored and then used later in a PL/SQL procedure. But now get this message when you try to added values to the table. Have I missed something?
/*
type of projection Usage_Groups_for_coda_tab1;
type of projection Usage_Groups_for_coda_rec1;
CREATE TYPE Usage_Groups_for_coda_rec1 AS
object
(Usage_Group_ID NUMBER (10),)
Coda_comment VARCHAR2 (45).
Amount NUMBER,
Deduction_amount NUMBER)
/
CREATE TYPE Usage_Groups_for_coda_tab1 AS
THE Usage_Groups_for_coda_rec1 TABLE
/
*/
declare
p_usage_group_id USAGE_GROUP. USAGE_GROUP_ID % TYPE: = 10412.
p_coda_comment CODA_TRANSACTION. CODA_TRANSACTION_COMMENT % TYPE: = 046602001;
p_amount CODA_TRANSACTION. TOTAL_CREDIT_AMT % TYPE: = 100;
p_deduction_amount CODA_TRANSACTION. TOTAL_CREDIT_AMT % TYPE: = 0;
I have directory;
g_usage_groups_for_coda_tab Usage_Groups_for_coda_tab1;
BEGIN
dbms_output.put_line ('initialize table');
g_usage_groups_for_coda_tab: = Usage_Groups_for_coda_tab1();
dbms_output.put_line ('1 added to count of records in the table");
I: = g_usage_groups_for_coda_tab. COUNT + 1;
dbms_output.put_line (' extend: do 1 row of table to use ');
g_usage_groups_for_coda_tab.extend;
dbms_output.put_line ('values added to g_usage_groups_for_coda_tab');
g_usage_groups_for_coda_tab (i). Usage_Group_ID: = p_usage_group_id;
g_usage_groups_for_coda_tab (i). Coda_comment: = p_coda_comment;
g_usage_groups_for_coda_tab (i). Amount: = p_amount;
g_usage_groups_for_coda_tab (i). Deduction_amount: = p_deduction_amount;
dbms_output.put_line ('g_usage_groups_for_coda_tab (i).) Usage_Group_ID ' | g_usage_groups_for_coda_tab (i). Usage_Group_ID | ") ;
END;
You instantiate the collection, but you should also initialize the type of object for each row in the collection.
A compact way to do this is to use the constructor when you complete each row, e... g
g_usage_groups_for_coda_tab (i): =.
() Usage_Groups_for_coda_rec1
Usage_Group_ID-online p_usage_group_id,
Coda_comment-online p_coda_comment,
Amount-online p_amount,
Deduction_amount-online p_deduction_amount);
-
BufferedReader InputStream? I'm missing something...
Video lesson 3-4 deals with "Method 2" to get a BufferedReader using an InputStream created from UART.
The minute 04:38 mark slideshows:
InputStream is = Channels.newInputStream (uart);
BufferedReader reader = new BufferedReader (is);
The IDE nor any JavaDoc I find this a constructor for a BufferedReader with an InputStream as an argument.
Just curious to know if I'm missing something or there is an error?
It should be: Player BufferedReader in = new BufferedReader (new InputStreamReader (is));
Thank you
Brent SAs a result of my own question, I've implemented as follows, and it does not work (good or bad).
InputStream is = Channels.newInputStream (uart);
BufferedReader reader = new BufferedReader (new InputStreamReader (is));
Maybe a quick edit of the video he will make it clear if I'm right.
Enjoy!
Brent S
-
Are you sure that you're not open your files with the free player instead of using Acrobat? And please do not post the same question multiple times. Also, try to be more specific. "I am not able" can mean many different things.
-
Is this a bug or am I missing something?
Hello everyone
I was playing around with the CC 2015 first version and I noticed this. If I have, say, three or four clips on the other and I need to extract some of them, I score inside and out, I activate the tracks I want extract to apply to the and I touched the relative tone (default is the ' key but I put extract to X and Z elevator key because I also do a lot of work with Avid Media Composer "). What I've noticed, however, is that, even if, say, the song V2 and V3 are not activated, the elevator is also applied to these titles. The only way around this is to turn off synchronization on these securities locking and then the action of the extract happens as it should. What's weird, is that this is NOT the case with the command of the elevator, which only works on the slopes turned on, without having to turn off the synchronization lock option.
To give you a better idea what I'm talking about, I am attaching a video of my screen (please forgive me for the use of shortcuts X and Z, rather than the menu commands, the power of habbit, I guess... :-)
I missing something here or is this a bug that Adobe should be aware of? I think it's also the case with the CC 2014 version but I need to check. It is very uncomfortable because on Avid, it works very well, and despite the fact, there is so much more that I love on the first, it's really frustrating on my workflow.
Any ideas on this would be most welcome.
If you want it changed to behave differently, then you must file a feature request:
Feature request/Bug Report Form
MtD
-
None of the serial numbers on the product box build fields to enter in the window? Am I missing something?
Yes.
-
I recently bought and downloaded Lightroom 5.7 and Lightroom 3 was updated. In my module to develop, I have no settings hightlight and shadow sliders. Am I missing something?
Your photo does not process release 2012. Any photo with process version 2003 or 2010 will use the 'old' as shown below basic controls. You can update the process for 2012.
-
upsert xmltype data xpath - missing something obvious?
Version: 10.2.0 * 2 * EA
I'm doing a upsert (update / insert) of an xmltype for a given xpath.
The xml data is passed as an xmltype, xpath is a string (varchar2), the new value is a string, varchar2.
If the node specified by the xpath expression exists it is trivial using updatexml; of course if the node is not nothing happens. I can verify the existence of nodes using is node, but I just take off, trying to figure out how to insert the node.
All the APIs I can find who to insert XML (APPENDCHILDXML, INSERTXMLBEFORE, INSERTCHILDXML) do not take an xpath but require an xmltype. Which means that if I'm reading this right I have no other choice to the parse varchar2 string xpath to create an xmltype (ugh!).
I can't find any API that takes an xpath as a varchar2 and a value and gives me an xmltype. Ideally I want same, here an API that returns the XML updated which took the set xpath to update (or inserted if it did not exist) with the new value.
I'm not an XML expert but I'm pretty handy with SQL and PL/SQL. For me this seems incredibly heavy just to do something as mundane as an upsert, so I hope I'm missing something obvious!
Can soemone please put me everything right with a pointer or an example?
On top of the XML uses namespaces, but they are not registered, there is no record of current schema.Marco Gralike wrote:
Could not be done through XQuery, although the version of database doesn't really help...It would be possible with a dynamic, but 'painful' XQuery with a static expression expression because it would require parsing the XPath expression and rebuild the entire document of entry with the necessary adaptations.
I think XSLT would be more effective in this case.Perhaps, one day, when the database is XQuery Update Facility, we will be able to do:
copy $a := $doc/Address modify ( if ($a/zip) then replace value of node $a/zip with "12345" else insert node element zip {"12345"} into $a ) return $a
user12083137 wrote: for me, from a SQL background, I can't believe this simple case is simply not covered.
Perhaps not as simple as it sounds. :)
The feature can be simulated by an IF/THEN/ELSE logic, or a DELETE/INSERT sequence.
For example:case when existsNode(doc, xpath) = 1 then updateXML( doc , xpath || '/text()' , somevalue ) else appendchildxml( doc , substr(xpath, 1, instr(xpath, '/', -1)-1) , xmlelement( evalname(substr(xpath, instr(xpath, '/', -1)+1)) , somevalue ) ) end
or,
appendChildXML( deleteXML(doc, xpath) , substr(xpath, 1, instr(xpath, '/', -1)-1) , xmlelement( evalname(substr(xpath, instr(xpath, '/', -1)+1)) , somevalue ) )
-
On my MBP, 2011, in recovery mode menu bar offers only a single - switch language option. How do you get Terminal? Missing something?
You will need to choose your language first.
From there on, the Terminal will be on the menu drop-down utilities > Terminal
-
By clicking with the right button on something, I accidentally blocked the photos to a Web site - want their return but may not know how to do
This has happened
Don't know how many times
== I right click on the images of block a site or something like that.
Check the image exceptions: Tools > Options > content: Load Images: Exceptions - see the web content, pop-ups, fonts and language settings
A way to see what images are blocked is to click on the favicon (Site ID icon) on the left side of the address bar and click the button "additional information".
This will open the Security tab of the window of the Information Page (also accessible via Tools > Page Info).
Go to the Media of this Page Info window tab.
Select the first image and scroll though the list with the arrow pointing downwards.
If an image in the list is grayed out and there is a check mark in the box of block Images of... remove this brand in order to unlock the images from this area.See also the problems that cause to not show images and http://kb.mozillazine.org/Images_or_animations_do_not_load
-
Am I missing something? Where is the history of Web page?
I just install the proposed updates and it has upgraded me to Internet Explorer 8, which is no longer guard the track of what I've been to Web pages (or anywhere that I can see...). For example, I go to Google several times in one night. Before, I could pull down the drop down bar at the top of the screen and it show me the history of navigation, including all sites, I had visited since the last time I had deleted the history. Now, NONE of them are down down (in fact, it is not still drop more).
Surely I'm missing something?
Shortcut:
Open history
CTRL + H
Other shortcuts: http://windows.microsoft.com/en-CA/windows-vista/Internet-Explorer-8-keyboard-shortcuts
TaurArian [MVP] 2005-2010 - Update Services
-
When you use Excel or my Peachtree Accounting program, entered digital as "$152(32 in the accounting package or the same number with a square symbol as the decimal point in Excel.)". No idea what I should check first?
Thank you for visiting the website of Microsoft Windows Vista Community. The question you have posted is related to Office Excel and would be better suited to the office community. Please visit the link below to find a community that will support what ask you
http://www.Microsoft.com/Office/Community/en-us/default.mspx?d=1
Mike - Engineer Support Microsoft Answers
Visit our Microsoft answers feedback Forum and let us know what you think.
Maybe you are looking for
-
My Favorites don't show even if the bookmark link is turned on.
The favorites were not deleted. I tried to turn on/off the bookmark link. Unfortunately, it did not work.
-
Apple Hardware Test Error: 4BAT/6/40000005: 0x898fb90
Apple Hardware Test Error: 4BAT/6/40000005: 0x8984fb90 Anyone know what this code hardware error test means or is for? I just had to replace my trackpad again today because it was not moving. Now, my computer works fine. I did a test of material j
-
BlackBerry Z30 bought in the USA for use in Germany
I would buy the Z30 the USA and ship it to Germany to use it here. I am a customer of Telekom (Germany) and would like to buy the smartphone in the United States, because it's cheaper here. I would like to know if there are compatibility issues, if I
-
Update of Windows 8 poster 18 download complete (0 total Kb, 0%) update
I just upgraded to Windows 7 to Windows 8 Pro. When you have completed the installation, I got a message that "upgrades are available". I clicked on install updates and now get the message "downloading updates 18 (0 total Kb, 0% Complete). It worked
-
Photosmart 5514 print only accessory photo, not enamel
I got this printer from QVC, where they showed picture after printing of photo of people by sending them from all over the country. When I sent a picture of my phone it printed a page saying Android, then the image with the word Android on the photo